-
Notifications
You must be signed in to change notification settings - Fork 356
Add exclusion patterns and snippet choice support to SCANOSS scanner #10270
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
Add exclusion patterns and snippet choice support to SCANOSS scanner #10270
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #10270 +/- ##
=========================================
Coverage 56.43% 56.43%
Complexity 1604 1604
=========================================
Files 331 331
Lines 12243 12243
Branches 1135 1135
=========================================
Hits 6909 6909
Misses 4887 4887
Partials 447 447
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
53042f4 to
2c695dc
Compare
93ad889 to
9761e69
Compare
plugins/scanners/scanoss/src/test/assets/exclusionTest/server.go
Outdated
Show resolved
Hide resolved
d51e6aa to
ee1c81e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some final nits / questions.
|
|
||
| // Set line range only if both `sourceLocation.startLine` and `sourceLocation.endLine` are positive numbers. | ||
| // If either line is zero or negative, the rule will apply to the entire file. | ||
| if (choice.given.sourceLocation.startLine > 0 && choice.given.sourceLocation.endLine > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the TextLocation constructor limits valid line numbers, see
ort/model/src/main/kotlin/TextLocation.kt
Lines 58 to 60 in 6e68575
| require(startLine in 1..endLine || (startLine == UNKNOWN_LINE && endLine == UNKNOWN_LINE)) { | |
| "Invalid start or end line values." | |
| } |
I believe this check can be simplified to just choice.given.sourceLocation.startLine != TextLocation.UNKNOWN_LINE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that if changing the code, the comment should be slightly adjusted as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced hardcoded choice.given.sourceLocation.startLine > 0 checks with UNKNOWN_LINE constants for better semantics.
I kept both checks for readability, but I'm happy to simplify to a single check if you prefer that approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept both checks for readability, but I'm happy to simplify to a single check if you prefer that approach
I wasn't super happy with the single check either, as it reads a bit odd if don't know the internals. I was also thinking about introducing this. How about that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking also to introduce a method like you did on #10280. Is that PR going to be merge today?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that PR going to be merge today?
I'm confident at it will.
ee1c81e to
bfd7a6d
Compare
| // A sample purl in the results. | ||
| private const val PURL_1 = "pkg:github/fakeuser/[email protected]" | ||
|
|
||
| class ScanOssTest : WordSpec({ |
Check warning
Code scanning / QDJVMC
Unused symbol
This commit replaces test files containing OSS source code with randomly generated data to prevent false positives during code scanning. Signed-off-by: Agustin Isasmendi <[email protected]>
Implement exclusion filtering to respect path patterns specified in the configuration. The scanner now properly excludes files matching the patterns during the scan process. Signed-off-by: Agustin Isasmendi <[email protected]>
|
Please remember to rebase instead of merge to catch-up with latest |
Ignore please the latest merge. I'll remove it from the history |
Implement snippet choice processing functionality. It handles findings according to two different scenarios: - Original findings that should be included - Non-relevant findings that should be removed The implementation converts ORT's SnippetChoices into SCANOSS-specific rule types. Signed-off-by: Agustin Isasmendi <[email protected]>
ec7a4d7 to
792f5de
Compare
This PR enhances SCANOSS scanner by implementing:
This builds on top of the SCANOSS SDK migration completed in the previous PR #10265