microsoft / DevSkim

DevSkim is a set of IDE plugins, language analyzers, and rules that provide security "linting" capabilities.
MIT License
910 stars 116 forks source link

How to supress a warning in the next line #625

Open josecelano opened 3 months ago

josecelano commented 3 months ago

Relates to: https://github.com/microsoft/DevSkim/issues/114

I don't see in the docs how to suppress a warning in the next line:

https://github.com/microsoft/DevSkim/wiki/Suppressions

gfs commented 3 months ago

Hi @josecelano,

Thanks for the feedback. I don't think this is a feature we support currently. The 2019 version of the extension is quite different to the most recent version where findings and suppressions are generated with the C# library.

This seems like a reasonable request for a feature add, I think with the refactor its relatively easy to integrate this, though I don't have an estimate right now when we can get to it.

As a note for future implementor, I think this just requires modifying the protected ParseLine method in the Suppression.cs class or the constructor of Suppression to check the line previous to the particular line as well as the line itself. It also requires check for a suppression comment with a slightly different style, perhaps DevSkim: ignore-next-line instead of DevSkim: ignore, to distinguish when the suppression is intended for a subsequent line instead of the current line. As well as new suppression test cases and new documentation.