-
Notifications
You must be signed in to change notification settings - Fork 94
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
Provide necessary support for SpotBugs SARIF #1952
Comments
Biggest problem is that our descriptor is written in HTML like this so we cannot provide it in TEXT and MD. It's also nice if we can generate necessary classes/interfaces from JSON schema. |
I remember that markdown can contain HTML elements, I'll directly put our descriptors into |
You can find the When you find problems, please come spotbugs/spotbugs#1185 to comment, or mention me at here. Thanks! |
I want to confirm this really work or not. However, even when I put Here is viewers' screenshot from my local: Here is the JSON data in {"messageStrings":{"default":{"text":"{0} is Serializable; consider declaring a serialVersionUID"}},"id":"SE_NO_SERIALVERSIONID","shortDescription":{"text":"Class is Serializable, but doesn't define serialVersionUID"},"fullDescription":{"markdown":"\n\n <p> This class implements the <code>Serializable<\/code> interface, but does\n not define a <code>serialVersionUID<\/code> field. \n A change as simple as adding a reference to a .class object\n will add synthetic fields to the class,\n which will unfortunately change the implicit\n serialVersionUID (e.g., adding a reference to <code>String.class<\/code>\n will generate a static field <code>class$java$lang$String<\/code>).\n Also, different source code to bytecode compilers may use different\n naming conventions for synthetic variables generated for\n references to class objects or inner classes.\n To ensure interoperability of Serializable across versions,\n consider adding an explicit serialVersionUID.<\/p>\n\n "},"helpUri":"https://spotbugs.readthedocs.io/en/latest/bugDescriptions.html#SE_NO_SERIALVERSIONID","properties":{"tags":["BAD_PRACTICE"]}} Or you may check the while main.sarif.txt. |
What is the difference between {
"version":"2.1.0",
"$schema":"https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.4.json",
"runs":[
{
"tool":{
"driver":{
"name":"SpotBugs",
"version":"Development",
"language":"en",
"notifications":[
{
"level":"error",
"descriptor":{
"id":"spotbugs-missing-classes"
},
"message":{
"text":"Classes needed for analysis were missing: [com.github.spotbugs.MissingClass]"
}
}
]
}
}
}
]
} |
|
OK thanks. I'm still not sure when I need to use |
When you want to report an actual notification that occurred to a user, such as when classes are missing, use @lgolding, you are an effective explainer of the standard, want to jump in here? :) |
@KengoTODA, @michaelcfanning is correct (except that, looking at your file, I see that you have The SARIF Tutorials has a section on Notifications that might help. Here is an example (which I will add to the tutorial):
Now, the SARIF The property |
@KengoTODA I added a Notifications sample to the SARIF Tutorials. I hope you find it helpful. I'm going through your sample SARIF output in detail and will provide more feedback later today. Thank you for doing this! |
Thanks. This is the latest example spotbugs.sarif, that was made for this PR. At least it passed the SARIF validator. I will check your comments carefully, to try to understand which property I should use for this case. |
Kengo, thank you for the latest spotbugs.sarif. It saved me a lot of work :-) This file is almost valid according to the schema. The only error is that the The spec (§3.28.4) explains the reason for this:
After I fixed that, the latest version of the SARIF validator tool (which we will publish very soon) finds only two problems:
I will now look by hand to see if I can make any more recommendations. |
Hi @KengoTODA, here are some more comments on the SpotBugs SARIF output. NOTE: Many of the things that I mention here, we will enhance our validator to report automatically.
|
@KengoTODA, I want to say a little more about SARIF "opaque" rule ids. When the spec says that a rule id must be "opaque", it does not mean that it must be incomprehensible to human readers, like "SPOT1001". It just means that a generic SARIF consumer -- that is, a consumer with no special knowledge of the tool -- is not allowed to assume anything about the internal structure of the identifier. For example, a generic SARIF consumer is not allowed to assume that because the rule id starts with "EI_", it has to do with "exposing internal representation" (as I see from the documentation of EI_EXPOSE_REP, EI_EXPOSE_REP2, etc.) SARIF opaque rule identifiers should be short (to take up less UI space) and search-engine-friendly (to make it easy for users to learn more about the rule). Your strings like EI_EXPOSE_REP are fine in those regards. I should not have encouraged you to invent additional "purely symbolic" identifiers like "SPOT1001". If your rules have additional, human-readable names, you could put them in the rule's
@michaelcfanning FYI |
@KengoTODA, we have now published the latest SARIF validator, which you can use to assess your SARIF output. To use the validator:
The SARIF validator checks for:
We continue to add new rules to the validator and to refine existing rules. To get the latest version:
Hope this helps! |
Thanks, I've tried it. It seems that it needs not SDK 3.1 but SDK 2.1, so I installed it from https://dotnet.microsoft.com/download/dotnet-core/2.1 Here is the log which was reported when I run
|
* fix: fix JSON1005 reported by SARIF validator error JSON1005: at "runs[0].results[0].locations[0].logicalLocation": The schema does not define a property named "logicalLocation", and the schema does not permit additional properties. * fix: fix SARIF1011 reported by SARIF validator $schema: The property value https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.4.json does not refer to the final version of the SARIF 2.1.0 schema. If you are using an earlier version of the SARIF format, consider upgrading your analysis tool to produce the final version. If this file does in fact conform to the final version of the schema, upgrade the tool to populate the property with a URL that refers to the final version of the schema. * refactor: extract the logic to decide exit code, to reuse from the SARIF reporter * docs: note that the SARIF support is experimental * fix: move notifications from tool.driver to invocations microsoft/sarif-sdk#1952 (comment)
Sorry for my lazy reply, I'll check your comments one by one.
Issued as spotbugs/spotbugs#1241
It should exist even in the current version (SpotBugs 4.1.1). I need to improve the sample output to cover features in the format. |
Trying to generate POJO from JSON schema. It marks fields in Still not sure where this problem comes from. |
@michaelcfanning , i think we can close this, since we were able to solve the issues in the sarif version from spotbugs. What do you think? |
@eddynaka in my case, in which project I should make an issue? is it https://github.com/oasis-tcs/sarif-spec/ ? |
@KengoTODA I thought this was the issue that we closed in spotbugs |
e.g., can we help provide a schema-driven Java OM?
spotbugs/discuss#95
The text was updated successfully, but these errors were encountered: