Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toolComponent change #1277

Merged
merged 9 commits into from
Feb 12, 2019
Merged

toolComponent change #1277

merged 9 commits into from
Feb 12, 2019

Conversation

michaelcfanning
Copy link
Member

@lgolding can you sanity check the schema change for the new toolComponent object?

in re: oasis-tcs/sarif-spec#179

"extensionIndex": {
"description": "The index within the run.tool.extensions array of the tool component object which describes the plug-in or tool extension that produced the result.",
"type": "integer",
"minimum": -1
Copy link

@ghost ghost Feb 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimum [](start = 11, length = 7)

and: "default": -1 #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, did some clean up for minimum/default, please take a look at update.


In reply to: 255688316 [](ancestors = 255688316)

},

"extensions": {
"description": "Tool extensions that contributed to or reconfigured the analysis tool run.",
Copy link

@ghost ghost Feb 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run [](start = 96, length = 3)

"run" => "that was run" (for parallelism with description of "driver", and also I think it's clearer). #Closed

"properties": {

"name": {
"description": "The name of the tool.",
"description": "The name of the tool driver or extension.",
Copy link

@ghost ghost Feb 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

driver or extension [](start = 47, length = 19)

How about "component" since that's what you use in the rest of the properties below. #Resolved

}
},

"required": [ "driver" ]
Copy link

@ghost ghost Feb 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"required": [ "driver" ] [](start = 6, length = 24)

Yes. #Closed

}
},


Copy link

@ghost ghost Feb 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra blank line. #Closed

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@ghost
Copy link

ghost commented Feb 11, 2019

Looks fine. I agree you should add result.toolComponentIndex, default -1 (meaning it came from the driver, not an additional component). #Closed

@ghost
Copy link

ghost commented Feb 11, 2019

Michael, didn't we talk about linking from a toolComponent to a file object, so we could have information like file hashes? (So: toolComponent.fileIndex). Less important, but I still would like it: an additional role value of toolComponent. #Closed

@michaelcfanning
Copy link
Member Author

i put this in resultProvenance.extensionIndex. You don't populate this at all in cases where it came from the driver. Seems simpler for happy path production. ?


In reply to: 462492896 [](ancestors = 462492896)

@michaelcfanning
Copy link
Member Author

yes! on it. ok, role, yes.


In reply to: 462493928 [](ancestors = 462493928)

@ghost
Copy link

ghost commented Feb 11, 2019

  • Re: The default value: This is one of those cases where we need the default to be -1 for the sake of the serializer, because 0 is a valid value. If 0 were the default, the serializer would not emit 0, and it would like like it was absent. The serializer will refrain from emitting -1, so it will indeed be absent.
  • Re: location of extensionIndex: I think it belongs in result. Otherwise, if your tool has rule plug-ins, you have to instantiate a provenance object just to hold the extension index -- even if you would otherwise not have had to bother.

In reply to: 462495693 [](ancestors = 462495693,462492896)

@@ -518,7 +520,7 @@
"uriBaseId": {
"description": "A string which indirectly specifies the absolute URI with respect to which a relative URI in the \"uri\" property is interpreted.",
"type": "string"
},
},`
Copy link

@ghost ghost Feb 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

` [](start = 10, length = 1)

typo #Closed

@michaelcfanning
Copy link
Member Author

the default is -1, do you see a problem i need to fix?
yes, you need to instantiate the provenance object, just as you have to if you specify invocationIndex. Can you explain why extensionIndex would be on result but invocationIndex would not? in general, we introduced the provenance object to provide option, unusual origin data for results. associating a specific result with a custom plug-in qualifies, in my opinion.

do you have a different set of standards for what belongs in provenance?


In reply to: 462497387 [](ancestors = 462497387,462495693,462492896)

@ghost
Copy link

ghost commented Feb 11, 2019

No problem on the default. I misunderstood you.


In reply to: 462498159 [](ancestors = 462498159,462497387,462495693,462492896)

@michaelcfanning michaelcfanning changed the title Preliminary schema change for toolComponent change toolComponent change Feb 12, 2019
{
return this.NotificationsMetadata.HasAtLeastOneNonNullValue();
var toolComponent = new ToolComponent();
Copy link

@ghost ghost Feb 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ToolComponent [](start = 36, length = 13)

Can you create a property bag directly? Do you need a toolComponent to hold it? #Closed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is cumbersome to instantiate IDictionary<string, SerializedPropertyInfo> directly (I do it elsewhere in this change). This is the easier mechanism because you can use the SetProperty helper. Do you have other advice on creation? This specific changes retains the previous code pattern...


In reply to: 256107576 [](ancestors = 256107576)

@@ -177,7 +177,7 @@ public override Message VisitMessage(Message node)
}

if (node.Text == null &&
_run.Tool?.GlobalMessageStrings?.TryGetValue(node.MessageId, out formatString) == true)
_run.Tool.Driver.GlobalMessageStrings?.TryGetValue(node.MessageId, out formatString) == true)
Copy link

@ghost ghost Feb 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

. [](start = 29, length = 1)

Why did you remove the null conditional operator? #Closed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check line 168, where it didn't exist. Tool.Driver is a required object. we could put an arg check at the top of the method


In reply to: 256108174 [](ancestors = 256108174)

@@ -36,6 +36,8 @@ private enum FieldIndex
private CsvParser _parser;
private List<Notification> _toolNotifications;

public override string ToolName { get { return "Semmle QL"; } }

Copy link

@ghost ghost Feb 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In all the other converters you just wrote

public override string ToolName => "Semmle QL";
``` #Closed

@@ -20,6 +20,8 @@ public CppCheckConverter()
_strings = new CppCheckStrings(_nameTable);
}

public override string ToolName => ToolFormat.CppCheck;
Copy link

@ghost ghost Feb 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CppCheck [](start = 54, length = 8)

I know we discussed, and I think we agreed, not to assume that the ToolFormat would also make a good tool name. In most of the other converters, you're just hard-coding a string here ("CppCheck"). #WontFix

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in fact, most converters still use ToolFormat. I'm not going to invest more here, I spent hours on this change DRYing out test code, removing embedded literals. We can revisit this in the future if need be.


In reply to: 256111009 [](ancestors = 256111009)

@@ -43,5 +44,36 @@ public SarifLog RunTestCase(string inputData, string expectedResult, bool pretty

return log;
}

private static SarifLog BuildToolSpecificEmptyLog()
Copy link

@ghost ghost Feb 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. #Closed

int intPropertyValue = 42;

string stringPropertyName = nameof(stringPropertyName);
string stringPropetyValue = "'\"\\'";
Copy link

@ghost ghost Feb 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stringPropetyValue [](start = 19, length = 18)

Propety => Property #Closed

{
string expected = CreateCurrentV2SarifLogText(
resultCount: 1,
(log) => {
Copy link

@ghost ghost Feb 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log [](start = 17, length = 3)

I absolutely love this pattern. #Closed

"properties": {
"tags": [
"singleTag"
],
Copy link

@ghost ghost Feb 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting. #Closed

"tags": [ "singleTag" ],
"propertyKey": "propertyValue"
},
"globalMessageStrings": {
Copy link

@ghost ghost Feb 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

globalMessageStrings [](start = 9, length = 20)

In 11-28, these three properties didn't yet live in tool, right? Global message strings and rules metadata lived in run.resources, and notification metadata didn't yet exist. #Resolved

{
new Invocation
{
ConfigurationNotifications = new List<Notification>(s_notifications)
Copy link

@ghost ghost Feb 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s_notifications [](start = 80, length = 15)

Hah. Really nice. #Closed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the pieces were here. :)


In reply to: 256121795 [](ancestors = 256121795)

@ghost
Copy link

ghost commented Feb 12, 2019

        string version = forceUpdate ? "2.0.0" : (string)sarifLog["version"];

Why is this no longer needed? If it's not needed, the comment is obsolete. #Pending


Refers to: src/Sarif/Writers/PrereleaseCompatibilityTransformer.cs:42 in 2dc4f02. [](commit_id = 2dc4f02, deletion_comment = True)

@michaelcfanning michaelcfanning merged commit 1b04ab5 into master Feb 12, 2019
@michaelcfanning michaelcfanning deleted the tool-components branch February 12, 2019 21:11
@michaelcfanning
Copy link
Member Author

        string version = forceUpdate ? "2.0.0" : (string)sarifLog["version"];

This force argument always existed because some tests lie about their version: i.e., the profess to have a format that they don't. I cleaned that up and removed this arg. I'll remove the dead comment in the next PR. also, please note: the modified log arg can go away now. at this point, any transformation of a prerelease format entails a change (because a required property, tool, has been updated).


In reply to: 462935363 [](ancestors = 462935363)


Refers to: src/Sarif/Writers/PrereleaseCompatibilityTransformer.cs:42 in 2dc4f02. [](commit_id = 2dc4f02, deletion_comment = True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant