Skip to content

Stop guessing the SCM host from the Socket diff URL - #454

Open
lelia wants to merge 2 commits into
mainfrom
lelia/codeql-scm-url-detection
Open

lelia wants to merge 2 commits into
mainfrom
lelia/codeql-scm-url-detection

Conversation

@lelia

@lelia lelia commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Messages.get_manifest_file_url fell back to substring-matching diff.diff_url for github / gitlab / bitbucket when the config had no scm. That guess never affected a link: CliConfig always sets scm (default api), and without a config there is no repository_url to build a link from. diff_url also points at the Socket dashboard, not the SCM, as the comment just below the branch already says. This PR removes the branch so only config picks the SCM.

This clears CodeQL alert #8 (incomplete URL substring sanitization). There's no behavior change for CLI users.

Other open CodeQL alerts

These are being dismissed in the UI rather than changed in code:

  • #3–#6, cache poisoning in pr-preview.yml: the workflow writes no cache (no actions/cache, no setup-python cache). It runs only when a maintainer labels a PR or dispatches the workflow, only for same-repo branches, and with a contents: read token.
  • #7, clear-text logging in output.py: the --json output is meant to go to stdout. The report takes only repo, branch, commit_sha and the legal flag from config (FOSSA format: repo and branch), so no secrets reach it.

Testing

  • Added a unit test that a GitHub-looking diff_url without an explicit scm falls back to the Socket report link.
  • pytest tests/unit: 606 passed.

get_manifest_file_url fell back to substring-matching diff.diff_url for
"github"/"gitlab"/"bitbucket" when config had no scm. CliConfig always
sets scm, and without a config there is no repository_url to use, so the
guess never affected a link. diff_url also points at Socket rather than
the SCM. Remove the branch so only config picks the SCM, which clears
the CodeQL incomplete-URL-substring-sanitization alert.
@lelia
lelia requested a review from a team as a code owner November 14, 2026 06:06
@cursor

cursor Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Small URL-building refactor in manifest linking with a test; no auth or data-path changes, and CLI configs already supply scm.

Overview
Manifest file links no longer infer SCM type from diff.diff_url in Messages.get_manifest_file_url. SCM is taken only from config.scm (default api), matching the fact that diff_url is a Socket dashboard URL, not the host repo.

When SCM is not explicitly GitHub/GitLab/Bitbucket, links fall back to the Socket report ?tab=files&file=… view. A unit test locks in that a GitHub-shaped diff_url without scm does not produce a blob URL.

This removes dead substring-matching logic and addresses a CodeQL incomplete URL substring sanitization finding, with no expected change for CLI flows that always set scm.

Reviewed by Cursor Bugbot for commit ca0e80b. Configure here.

@lelia

lelia commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit ca0e80b. Configure here.

@lelia
lelia deployed to socket-firewall November 14, 2026 06:10 — with GitHub Actions Active

This branch was successfully deployed

1 active deployment
socket-firewall — 554c354a Deployed Nov 14, 2026 by lelia via python-sfw-smoke-enterprise #605
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