Skip to content

Fix first instance rule being used as rule description for all violations of that rule and other SARIF improvements#7640

Merged
chrchr-github merged 86 commits intodanmar:mainfrom
Nettozx:main
Oct 24, 2025
Merged

Fix first instance rule being used as rule description for all violations of that rule and other SARIF improvements#7640
chrchr-github merged 86 commits intodanmar:mainfrom
Nettozx:main

Conversation

@Nettozx
Copy link
Copy Markdown
Contributor

@Nettozx Nettozx commented Jul 2, 2025

  • Fixed issue where the first instance of a rule violation short description would get used for all subsequent rule violations, found that if you make all the rule name and descriptions empty strings, github will default to the instance descriptions
  • Added setting for problem.severity
  • Changed defaultConfiguration.level to use problem.severity instead of security-severity
  • Added more levels for security-severity
  • Added reporting of cwe ID
  • Fixed issue with uncrustify version detection
  • Added unit tests for sarif output

Before:
cppcheck_original_problem

After:
image

Comment thread cli/cppcheckexecutor.cpp Outdated
@firewave
Copy link
Copy Markdown
Collaborator

firewave commented Jul 2, 2025

Thanks for you contribution.

I added a remark on how to keep this in sync for future changes. Possibly not something which should addressed before/in this PR.

Also something like --errorlist-sarif might make sense.

Copy link
Copy Markdown
Owner

@danmar danmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!!

I believe we'll need to rethink that getRuleDescription somehow but unfortunately I don't see a quick/simple method..

Comment thread cli/cppcheckexecutor.cpp Outdated
Comment thread cli/cppcheckexecutor.cpp Outdated
Comment thread cli/cppcheckexecutor.cpp Outdated
Comment thread cli/cppcheckexecutor.cpp Outdated
@Nettozx Nettozx requested review from danmar and firewave July 3, 2025 00:54
@Nettozx
Copy link
Copy Markdown
Contributor Author

Nettozx commented Jul 3, 2025

@firewave @danmar I have implemented a generic approach that will not require ruleID maintenance, but like @firewave said the security related ruleID list should get moved to --errorlist-sarif or something in the future

Comment thread cli/cppcheckexecutor.cpp Outdated
Comment thread cli/cppcheckexecutor.cpp Outdated
Comment thread cli/cppcheckexecutor.cpp Outdated
Comment thread cli/cppcheckexecutor.cpp Outdated
Comment thread cli/cppcheckexecutor.cpp Outdated
@danmar
Copy link
Copy Markdown
Owner

danmar commented Jul 11, 2025

In the future.. if I don't respond for couple of days.. feel free to ping me.
It happens that I loose track of PRs.

@Nettozx Nettozx marked this pull request as draft July 15, 2025 17:09
@Nettozx Nettozx marked this pull request as ready for review July 15, 2025 22:47
@Nettozx
Copy link
Copy Markdown
Contributor Author

Nettozx commented Jul 15, 2025

@danmar I have simplified the approach significantly. I added genericMessage output for ErrorMessage class like you recommended and have reduced the regex to a minimum. I also removed the security violation list of errors and now I just add security tag if a CWE ID exists.

@Nettozx
Copy link
Copy Markdown
Contributor Author

Nettozx commented Jul 16, 2025

Actually I just made a discovery. If I make all the descriptions for the rules blank strings, github will default to the instance specific description for each and this solves the problem. So this should greatly simplify the addition.

Comment thread lib/errorlogger.cpp Fixed
@Nettozx Nettozx requested a review from danmar July 17, 2025 03:27
@Nettozx
Copy link
Copy Markdown
Contributor Author

Nettozx commented Jul 17, 2025

@danmar @firewave I updated the description of this PR with latest results and changes. This is ready for review now.

@danmar
Copy link
Copy Markdown
Owner

danmar commented Jul 17, 2025

Actually I just made a discovery. If I make all the descriptions for the rules blank strings, github will default to the instance specific description for each and this solves the problem. So this should greatly simplify the addition.

That is so much better 👍

Sounds like it will both simplify our job and make the user experience better.

Comment thread cli/cppcheckexecutor.cpp Outdated
Comment thread cli/cppcheckexecutor.cpp Outdated
Comment thread cli/cppcheckexecutor.cpp Outdated
Comment thread test/cli/helloworld_test.py Outdated
Comment thread test/testerrorlogger.cpp Outdated
@Nettozx Nettozx requested a review from danmar July 17, 2025 21:48
@Nettozx
Copy link
Copy Markdown
Contributor Author

Nettozx commented Jul 18, 2025

Actually I just made a discovery. If I make all the descriptions for the rules blank strings, github will default to the instance specific description for each and this solves the problem. So this should greatly simplify the addition.

That is so much better 👍

Sounds like it will both simplify our job and make the user experience better.

@danmar this is ready for review again

@danmar
Copy link
Copy Markdown
Owner

danmar commented Jul 20, 2025

Merge remote-tracking branch 'refs/remotes/origin/main'

for your information I prefer if people use git rebase .. instead of git merge .. because it makes the PRs cleaner. I guess it should not matter in the end though because I will squash this PR.

@danmar
Copy link
Copy Markdown
Owner

danmar commented Jul 20, 2025

CI: I think you can fix the "dmake" failures by just running make run-dmake in the cppcheck project folder.

@danmar
Copy link
Copy Markdown
Owner

danmar commented Jul 20, 2025

I have released 2.18.0 but if you fix this I think a 2.18.1 can be released with this fix.

@Nettozx
Copy link
Copy Markdown
Contributor Author

Nettozx commented Jul 20, 2025

CI: I think you can fix the "dmake" failures by just running make run-dmake in the cppcheck project folder.

@danmar I fixed the dmake issue.

@Nettozx
Copy link
Copy Markdown
Contributor Author

Nettozx commented Jul 24, 2025

@danmar this is ready for review

@danmar
Copy link
Copy Markdown
Owner

danmar commented Jul 31, 2025

@Nettozx there are 5 failing tests in the CI have you looked at those?

@Nettozx
Copy link
Copy Markdown
Contributor Author

Nettozx commented Jul 31, 2025

@Nettozx there are 5 failing tests in the CI have you looked at those?

I made an update to move sarif reporter out to its own header because it was in an anonymous class so it couldn't be used for unit test originally. Now that I moved it, I updated the tests so it no longer relies on cppcheck executable and it can use internal libraries.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Aug 1, 2025

@Nettozx
Copy link
Copy Markdown
Contributor Author

Nettozx commented Aug 4, 2025

@Nettozx there are 5 failing tests in the CI have you looked at those?

@danmar its all passing now

Comment thread test/testsarif.cpp Outdated
Comment thread test/testsarif.cpp Outdated
Comment thread runformat Outdated
Comment thread lib/sarifreport.cpp Outdated
@danmar
Copy link
Copy Markdown
Owner

danmar commented Aug 22, 2025

I am very sorry it took so long to review. Please feel free to ping me if it takes more than 3-4 days to get a review.

@Nettozx Nettozx requested a review from danmar September 30, 2025 04:12
@Nettozx
Copy link
Copy Markdown
Contributor Author

Nettozx commented Sep 30, 2025

@danmar This should be ready for review again now

@Nettozx
Copy link
Copy Markdown
Contributor Author

Nettozx commented Oct 1, 2025

@danmar the one windows failure is a github action timeout not related to PR, i think you may have to just re-run that test.

Comment thread cli/cppcheckexecutor.cpp Outdated
@sonarqubecloud
Copy link
Copy Markdown

@chrchr-github chrchr-github merged commit 92fffee into danmar:main Oct 24, 2025
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants