chore(stravapipe): enable ruff S (flake8-bandit) security lints - #990
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #990 +/- ##
=======================================
Coverage 82.69% 82.69%
=======================================
Files 313 313
Lines 15809 15809
Branches 3383 3382 -1
=======================================
Hits 13074 13074
Misses 2541 2541
Partials 194 194
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Adds the `S` (flake8-bandit) ruleset to stravapipe's ruff config, closing the Python SAST gap (gosec and govulncheck already cover the Go side). No behaviour change — lint config plus per-line suppressions with justifications. Every one of the 14 src findings was triaged individually rather than blanket-suppressed, so the rule keeps catching new code: - S608 (SQL injection) x7 — all safe: each interpolates only identifiers (table/column names from Final constants, or hardcoded purge() args) while every data value is a bound parameter (@activity_ids, :id, @user_id). Per-line noqa with a reason, so a new query that interpolates a value still trips it. - S105 x2 — name-collision false positives (_SECRET_PATH is a mount path, token_url is a public URL). - S311 x2 — retry-backoff jitter; non-cryptographic by design. - S101 x3 — type-narrowing asserts, not untrusted-input validation (the _bq_writer ones are reached only behind a caller's `is not None` guard; the protobuf one holds by TYPE_MESSAGE contract). Tests are exempted, not the codebase: `just py-lint` runs `ruff check .`, and tests carry 1200+ idiomatic S findings (asserts, fake fixture secrets). S101, S105, S106 and S608 are added to the three test per-file-ignore patterns, mirroring bandit's own skip-tests default, so src/ stays gated without the noise. py-lint, py-typecheck (125 files) and py-test (670 passed) all green with S enforced; verified the gate bites by seeding a fake token and observing S105.
…urface Enabling ruff S in packages/stravapipe/pyproject.toml also gates scripts/ops, local-dev/containers and schemas/bigquery, because pants points ruff at that one config for every Python target (pants.toml [ruff] config). The initial commit only ran the stravapipe-scoped `just py-lint`, so five S findings in the other roots slipped through and failed CI's `pants lint`. All five are legitimate: - S104 — cloudevent_adapter binds 0.0.0.0; a local-dev container must, to be reachable from the host. Per-line noqa. - S310 x3 — offline ops tooling (check-strava-sports, load_census_regions) opening known https URLs; one already carried a nosemgrep note for the same concern. Per-line noqa. - S603 — a CLI test runs the tool under test via subprocess with sys.executable and a fixed script path. Added to the test per-file-ignores alongside the other test-idiomatic S rules, since it is a test_*.py. Verified with the exact CI command: `pants lint packages/stravapipe:: schemas/bigquery:: scripts/ops:: local-dev/containers::` — all checks passed.
andy-esch
force-pushed
the
chore/ruff-s-stravapipe
branch
from
September 1, 2026 11:18
928f25d to
e0800f9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the
S(flake8-bandit) ruleset to stravapipe's ruff config, closing the Python SAST gap (gosec and govulncheck already cover the Go side). No behaviour change — lint config plus per-line suppressions with justifications.Every one of the 14 src findings was triaged individually rather than blanket-suppressed, so the rule keeps catching new code:
is not Noneguard; the protobuf one holds by TYPE_MESSAGE contract).Tests are exempted, not the codebase:
just py-lintrunsruff check ., and tests carry 1200+ idiomatic S findings (asserts, fake fixture secrets). S101, S105, S106 and S608 are added to the three test per-file-ignore patterns, mirroring bandit's own skip-tests default, so src/ stays gated without the noise.py-lint, py-typecheck (125 files) and py-test (670 passed) all green with S enforced; verified the gate bites by seeding a fake token and observing S105.