Skip to content

Commit

Permalink
Implement v2->v1 conversion for rules dictionary (#1228)
Browse files Browse the repository at this point in the history
  • Loading branch information
Larry Golding authored Jan 22, 2019
1 parent e61d654 commit 0f25460
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"results": [
{
"ruleId": "C2009",
"ruleId": "C2001",
"message": "Some testing occurred."
},
{
Expand Down Expand Up @@ -45,10 +45,16 @@
"defaultLevel": "error",
"helpUri": "http://www.domain.com/rules/c2002.html"
},
"C2003": {
"id": "C2003",
"name": "Rule C2003 for C#",
"shortDescription": "C# rules were meant to be broken.",
"fullDescription": "Rent internal rebellion competence biography photograph."
},
"C2003-1": {
"id": "C2003",
"name": "Rule C2003",
"shortDescription": "Rules were meant to be broken.",
"name": "Rule C2003 for VB",
"shortDescription": "VB rules were meant to be broken.",
"fullDescription": "Rent internal rebellion competence biography photograph."
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
"language": "en-US"
},
"logicalLocations": {
"collections::list::add": {
"name": "add",
"parentKey": "collections::list",
"kind": "function"
"collections": {
"kind": "namespace"
},
"collections::list": {
"name": "list",
"parentKey": "collections",
"kind": "type"
},
"collections": {
"kind": "namespace"
"collections::list::add": {
"name": "add",
"parentKey": "collections::list",
"kind": "function"
}
},
"results": [
Expand Down Expand Up @@ -101,14 +101,14 @@
}
],
"rules": {
"WEB1079.AttributeValueIsNotQuoted": {
"WEB1079": {
"id": "WEB1079",
"shortDescription": "The attribute value is not quoted.",
"messageFormats": {
"default": "The value of the '{0}' attribute is not quoted. Wrap the attribute value in single or double quotes."
}
},
"WEB1066.TagNameIsNotLowercase": {
"WEB1066": {
"id": "WEB1066",
"shortDescription": "The tag name is not lowercase.",
"messageFormats": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@
}
],
"rules": {
"WEB1079.AttributeValueIsNotQuoted": {
"WEB1079": {
"id": "WEB1079",
"shortDescription": "The attribute value is not quoted.",
"messageFormats": {
"default": "The value of the '{0}' attribute is not quoted. Wrap the attribute value in single or double quotes."
}
},
"WEB1066.TagNameIsNotLowercase": {
"WEB1066": {
"id": "WEB1066",
"shortDescription": "The tag name is not lowercase.",
"messageFormats": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,29 @@
},
"results": [
{
"ruleId": "C2009",
"ruleId": "C2001",
"ruleIndex": 0,
"message": { "text": "Some testing occurred." }
},
{
"ruleId": "C2002",
"ruleIndex": 1,
"message": { "text": "Some testing occurred." }
},
{
"ruleId": "C2003",
"ruleIndex": 2,
"message": { "text": "Some testing occurred." }
},
{
"ruleId": "C2003-1",
"ruleId": "C2003",
"ruleIndex": 3,
"message": { "text": "Some testing occurred." }
}
],
"resources": {
"rules": {
"C2001": {
"rules": [
{
"id": "C2001",
"shortDescription": {
"text": "A variable was used without being initialized."
Expand All @@ -39,7 +43,7 @@
"some_key": "FoxForceFive"
}
},
"C2002": {
{
"id": "C2002",
"fullDescription": {
"text": "Catfish season continuous hen lamb include dose copy grant."
Expand All @@ -50,19 +54,31 @@
},
"helpUri": "http://www.domain.com/rules/c2002.html"
},
"C2003-1": {
{
"id": "C2003",
"name": {
"text": "Rule C2003"
"text": "Rule C2003 for C#"
},
"shortDescription": {
"text": "Rules were meant to be broken."
"text": "C# rules were meant to be broken."
},
"fullDescription": {
"text": "Rent internal rebellion competence biography photograph."
}
},
{
"id": "C2003",
"name": {
"text": "Rule C2003 for VB"
},
"shortDescription": {
"text": "VB rules were meant to be broken."
},
"fullDescription": {
"text": "Rent internal rebellion competence biography photograph."
}
}
}
]
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,21 @@ protected override string ConstructTestOutputFromInputResource(string inputResou
[Fact]
public void SarifTransformerTests_ToVersionOne_OneRunWithFiles() => RunTest("OneRunWithFiles.sarif");

#if TRANSFORM_CODE_AUTHORED
[Fact]
public void SarifTransformerTests_ToVersionOne_OneRunWithRules() => RunTest("OneRunWithRules.sarif");
#endif

[Fact]
public void SarifTransformerTests_ToVersionOne_OneRunWithBasicInvocation() => RunTest("OneRunWithBasicInvocation.sarif");

[Fact]
public void SarifTransformerTests_ToVersionOne_NotificationExceptionWithStack() => RunTest("NotificationExceptionWithStack.sarif");

#if TRANSFORM_CODE_AUTHORED
[Fact]
public void SarifTransformerTests_ToVersionOne_ResultLocations() => RunTest("ResultLocations.sarif");

[Fact]
public void SarifTransformerTests_ToVersionOne_TwoResultsWithFixes() => RunTest("TwoResultsWithFixes.sarif");
#endif

[Fact]
public void SarifTransformerTests_ToVersionOne_Regions() => RunTest("Regions.sarif");
}
Expand Down
15 changes: 11 additions & 4 deletions src/Sarif/Schemata/sarif-schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Static Analysis Results Format (SARIF) Version 2.0.0-csd.2.beta.2018-10-10 JSON Schema",
"title": "Static Analysis Results Format (SARIF) Version 2.0.0-csd.2.beta.2018-11-28 JSON Schema",
"description": "Static Analysis Results Format (SARIF) Version 2.0.0-csd.2.beta-2018-11-28 JSON Schema: a standard format for the output of static analysis tools.",
"additionalProperties": false,
"type": "object",
Expand Down Expand Up @@ -347,7 +347,7 @@
"description": "An array of external property files containing run.results arrays to be merged with the root log file.",
"type": "array",
"minItems": 1,
"uniqueItems": true,
"uniqueItems": false,
"items": {
"$ref": "#/definitions/externalPropertyFile"
}
Expand Down Expand Up @@ -1002,10 +1002,17 @@
},

"ruleId": {
"description": "The stable, unique identifier of the rule (if any) to which this notification is relevant. This member can be used to retrieve rule metadata from the rules dictionary, if it exists.",
"description": "The stable, unique identifier of the rule, if any, to which this notification is relevant.",
"type": "string"
},

"ruleIndex": {
"description": "The index within the run resources array of the rule object, if any, associated with this notification.",
"type": "integer",
"default": -1,
"minimum": -1
},

"physicalLocation": {
"description": "The file and region relevant to this notification.",
"$ref": "#/definitions/physicalLocation"
Expand Down Expand Up @@ -1274,7 +1281,7 @@
"properties": {

"ruleId": {
"description": "The stable, unique identifier of the rule (if any) to which this notification is relevant. This member can be used to retrieve rule metadata from the rules dictionary, if it exists.",
"description": "The stable, unique identifier of the rule, if any, to which this notification is relevant. This member can be used to retrieve rule metadata from the rules dictionary, if it exists.",
"type": "string"
},

Expand Down
Loading

0 comments on commit 0f25460

Please sign in to comment.