Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
FxCop XML `Message` elements whose `Status` attribute is `"Active"` contain an `Issue` sub-element whose inner text provides the SARIF `result.message.text`. But `Message` elements whose `Status` attribute is `ExcludedInSource` (and possibly other values; I don't know) do not contain an `Issue` sub-element. For those FxCop `Message` elements, the `FxCopConverter` produces a SARIF `result` object whose `message` property is an empty object `{}`. This is invalid SARIF because a `message` object requires a `text` property. Each FxCop `Message` element contains a `CheckId` attribute whose value points to a `Rule` element, which in turn contains a `Resolution` element from which `result.message.text` might seemingly be constructed. But in general, the FxCop XML file does not contain enough information to reconstruct the message. For example, this `Message`: ``` <Member Name="#RemoveIf`1(!!0[]&,System.Func`2<!!0,System.Boolean>)" Kind="Method" Static="True" Accessibility="Public" ExternallyVisible="True"> <Messages> <Message Id="0#" TypeName="DoNotPassTypesByReference" Category="Microsoft.Design" CheckId="CA1045" Status="ExcludedInSource" Created="2018-08-23 13:07:11Z" FixCategory="Breaking" LastSeen="0001-01-01 00:00:00Z" /> ... </Messages> </Member> ``` points to this `Rule`: ``` <Rule TypeName="DoNotPassTypesByReference" Category="Microsoft.Design" CheckId="CA1045"> <Name>Do not pass types by reference</Name> <Description>...</Description> <Resolution Name="Default">Consider a design that does not require that {0} be a reference parameter.</Resolution> ... </Rule> ``` The sequence `{0}` should be replaced by the name of the first parameter to `RemoveIf`, which happens to be `array`. But "`array`" does not appear in the XML file. And even if all the necessary information were present, there would be no way for the converter to know which piece of information from the XML file would go into which replacement sequence in the `Resolution` string. Finally, some `Rule`s have more than one `Resolution` string, and the converter has no way to know which one to use. That's all a long way of saying that there's no way to synthesize a valid `result.message.text` string for FxCop `Message`s that don't provide one. And the converter can't just omit `result.message`, because it's required. The best we can do is to provide a canned message: `"FxCop does not provide messages for suppressed results."` Also: - Upgrade SarifSdkTest.xml.sarif (which had been generated by a pre-release version of the SDK) to the final version of the SARIF 2.1.0 format. This is necessary because if this file is down-level, the `FxCopConverter`'s call to the `PrereleaseCompatibilityTransformer` produces valid SARIF, masking the bug in the converter.
- Loading branch information