Add file-based inclusion filter for static analysis issues - #3273
Add file-based inclusion filter for static analysis issues#3273panicking wants to merge 1 commit into
Conversation
0eebb6a to
da19b89
Compare
|
So I am back on duty now. The idea behind the PR looks reasonable. I wonder if a simpler approach would work as well: create the instances for the existing file filter dynamically. So we do not need to change the filtering, just the creation of the filters? What do you think? That should make the change less intrusive. |
This is the way I create the list: git -C firmware diff --name-only ${GIT_COMMIT_firmware}..${GIT_REMOTE_firmware}/${GIT_BRANCH_firmware} > includeFiles.txtAnd this is the way how I use it recordIssues(sourceCodeRetention: 'MODIFIED',
tool: valgrind(pattern: "out/test/memcheck.xml"),
filesFilter: 'includeFiles.txt',
qualityGates: [[threshold: 1, type: 'TOTAL', criticality: 'FAILURE', unstable: false]])Can you provide an example in what you are look for? Before I have implemented I was thinking several way and I come out with some synthax simpler that can used without so much limit. You have more experience then me so I'm open to rework it |
| private AnnotatedReport scanWithTool(final Run<?, ?> run, final FilePath workspace, final TaskListener listener, | ||
| final Tool tool) throws IOException, InterruptedException { | ||
| var issuesScanner = new IssuesScanner(tool, getFilters(), getSourceCodeCharset(), | ||
| var issuesScanner = new IssuesScanner(tool, getFilters(), getFilesFilter(), getSourceCodeCharset(), |
There was a problem hiding this comment.
Wouldn't it be much simpler if we do not add a new parameter and simply change the existing parameter filters to getFilters() + createFiltersFromFile().
And in the new method createFiltersFromFile() you create additional Exclude/Include FileFilter instances by reading the file and creating a new filter? Or would that not work?
There was a problem hiding this comment.
@uhafner can you review the new approach if make sense for you?
8d71ca2 to
4470dd9
Compare
4470dd9 to
986b232
Compare
b1e4b59 to
907cee8
Compare
☀️ Quality MonitorTests Coverage for New Code 〰️ Line Coverage: 60.34% — 23 missed lines Coverage for Whole Project 〰️ Line Coverage: 80.54% Style Bugs Vulnerabilities 🛡️ OWASP Dependency Check: 229 vulnerabilities Software Metrics 🌀 Cyclomatic Complexity: 2663 (total) 📌 Reference ResultsDelta reports computed against the reference results of 9c38669 in workflow run 27501886918. 🚦 Quality GatesOverall Status: ❌ FAILURE✅ Passed Gates
❌ Failed Gates
Created by Quality Monitor v4.15.0 (#82d77af). More details are shown in the GitHub Checks Result. |
8982345 to
d2be40f
Compare
Introduce a `FileInclusionFilter` configuration that allows users to provide a path to a text file containing a list of filenames (one per line). Static analysis issues are filtered using an "ends-with" match strategy, ensuring that only issues originating from files specified in the inclusion list are reported. This mechanism acts as a viable alternative to traditional regex filters, avoiding the character limit constraints encountered when processing large patches or diffs in distributed CI environments. Key changes: - Created FileInclusionFilter, FileNameFilter, and FilterConfig to bundle and execute file-matching logic against issue paths. - Updated IssuesScanner and its internal ReportPostProcessor to read and apply the new filter during scanning and post-processing. - Added the 'filesFilter' parameter and data-bound setters to IssuesRecorder, RecordIssuesStep, and ScanForIssuesStep. - Integrated the configuration field into the Jenkins UI via Jelly templates and localization properties. Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
d2be40f to
5622a4c
Compare
This change introduces a
FileInclusionFilterthat allows users to provide a path to a text file containing a list of filenames (one per line). Only issues found in files that end with a path listed in this file will be reported.Key changes:
This functionality helps avoid character limit constraints of traditional regex filters when dealing with large patches in distributed environments.
Testing done
Deployed in the infrastructure and change the pipeline to test it
Submitter checklist