Skip to content

SONARPY-4533 Ignore startswith protocol literals - #2298

Closed
erwan-leforestier-sonarsource wants to merge 1 commit into
masterfrom
fix/sonarpy-4533-ignore-startswith-literals
Closed

SONARPY-4533 Ignore startswith protocol literals#2298
erwan-leforestier-sonarsource wants to merge 1 commit into
masterfrom
fix/sonarpy-4533-ignore-startswith-literals

Conversation

@erwan-leforestier-sonarsource

Copy link
Copy Markdown

Summary

Stops S5332 from reporting clear-text protocols used only as str.startswith comparison values, while preserving reports for actual endpoints.

Changes

  • Recognize direct literal and tuple arguments to str.startswith
  • Require a resolved str owner, keeping custom startswith calls in scope
  • Cover retained reporting for urllib.request.urlopen

Functional Validation

Artifact: SONARPY-4533-fv.zip

Once the file is attached to the PR description, unzip and run:
./run.sh

Expected output:

******************* MASTER *******************
Analyzing "sample.py"...
Results:
    - Rule "S5332" -> L.5
    - Rule "S5332" -> L.7
    - Rule "S5332" -> L.7
    - Rule "S5332" -> L.12

****** Branch "fix/sonarpy-4533-ignore-startswith-literals" ******
Analyzing "sample.py"...
Results:
    - Rule "S5332" -> L.12

⚠️⚠️ This is not ready for review ⚠️⚠️

@gitar-bot

gitar-bot Bot commented Aug 17, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Updates rule S5332 to ignore clear-text protocols used exclusively in str.startswith comparisons while retaining reports for actual endpoints. No issues found.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@erwan-leforestier-sonarsource

Copy link
Copy Markdown
Author

Closing: changes for SONARPY-4533 should go through the private sonar-python-enterprise repository, which is auto-mirrored to this public repo via copybara. Superseded by the corresponding PR opened there.

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.

1 participant