Repository navigation
SONARJAVA-7030 S4684 should support rule parameters declaring annotations/types resolved from server-side context - #6515
Conversation
…ions/types resolved from server-side context Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
| } | ||
|
|
||
| @GetMapping("/b") | ||
| public void typed(Other other, UserDetail userDetail) { // Noncompliant |
There was a problem hiding this comment.
Maybe this sample method should be split in two samples, one with a parameter of type Other that is non-compliant, and another with a UserDetail that is compliant. I was initially surprised to see that an issue should be raised on this line even though UserDetail is added as an excluded type in the rule parameters, until I realized the issue is on other.
…iant methods Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Code Review ✅ Approved 🟡 Medium risk 1 closed / 1 findingsConfigurable S4684 annotation/type exclusions could leave unsafe entity request parameters unflagged if project assertions do not match actual argument resolution. Adds opt-in ✅ 1 closed✅ Performance: Rule parameters re-parsed for every parameter of every endpoint
Verification Rules 2/2 met Repos 5 inspected · PRs 1 inspectedFunctional validation No results Rules 2 passed 2 not applicable
Broader impact Repos 5 inspected PRs 1 inspectedCross-repo 5 repositories inspected 0 open impacts
Cross-PR 1 PR inspected 0 open impacts
Auto-approval Not enabledFor more verification details, comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
aurelien-coet-sonarsource
left a comment
There was a problem hiding this comment.
LGTM !
|




Adds two opt-in rule parameters to S4684,
excludedAnnotationsandexcludedTypes(comma-separated fully qualified names, default empty). A request-mapping parameter carrying a declared annotation or of a declared type is not reported. Declaring one is an assertion by the project about its own argument resolver; the analyzer does not verify it. Default behaviour is unchanged.Related RSPEC PR documents the parameters : https://github.com/SonarSource/rspec/pull/8485.
Tests:
PersistentEntityUsedAsRequestParameterCheckTest(3 tests),JavaRulesDefinitionTestandGeneratedCheckListTestpass locally. Ruling ITs not run locally.🤖 Generated with Claude Code