ci: fix the three red crosses (lint, trivy pin, Pages) - #13
Merged
Conversation
All 12 unit-test jobs were already green; three jobs were failing for three
unrelated reasons.
1. SAST + lint - ruff found 7 pre-existing F401 unused imports in bus.py,
hunt.py, store.py, worker.py and tests/test_store.py. Removed them. 255
tests still pass, so nothing was re-exported through those imports.
ROOT CAUSE: the linters were installed unpinned, so a newer ruff widened
F401 and broke CI with no code change. Pinned ruff==0.16.1 and
bandit[toml]==1.9.4 - selecting rules in ruff.toml does not help when a
release changes what an existing rule detects.
2. SAST + lint (second, hidden failure) - bandit also exited 1 with 10 Medium
findings. It never ran in CI because the lint step failed first, so fixing
ruff alone would only have moved the cross. Reviewed all 10; every one is a
false positive or a deliberate control, so each carries a per-line
'# nosec <rule> - <reason>' rather than lowering the -ll threshold:
* 7x B608 - the SQL is concatenated from STATIC predicate fragments while
every user value is bound through a ? placeholder (and worker.py builds
its IN list as a join of '?'). Properly parameterised.
* 1x B608 - the schema-migration insert; executescript takes no params,
version is int()-cast and name is ''-escaped.
* 2x B104 - config.py:181 is the guard that REFUSES to bind 0.0.0.0 in
prod, i.e. bandit flagged the security control itself; space_server
binds all interfaces by design for the container/Space console.
* 1x B310 - urlopen against a hardcoded http://127.0.0.1 loopback upstream.
3. image build + filesystem scan - 'Unable to resolve action
aquasecurity/trivy-action@0.36.0'. The action publishes v-PREFIXED tags, so
the bare 0.36.0 does not exist and the job died in 'Set up job' before any
step ran. Now v0.36.0. This is the same mistake the previous fix made with
0.24.0, so the comment records how to verify a tag.
4. pages / build console - 'Create Pages site failed: Resource not accessible
by integration'. configure-pages@v5 with enablement:true cannot create a
Pages site with GITHUB_TOKEN: pages:write permits deploying, not creating.
Enabled Pages once on the repo with build_type=workflow; the workflow is
unchanged and enablement:true is now a no-op that keeps working for clones.
Verified locally: ruff exit 0, bandit exit 0, 255 passed + 7 subtests, and both
workflow YAMLs parse.
With the trivy action reference fixed, the 'image build + filesystem scan' job got far enough to reveal a real second failure: FileNotFoundError: [Errno 2] No such file or directory: '/app/docs/openapi.json' test_openapi_parity.TestCommittedSpec.test_the_committed_file_is_current The Dockerfile copies sentinelai/, tests/, requirements.txt and README.md, then runs the whole suite inside the image - but never copied docs/. So this test passed on the runner and failed only inside the build, which is why it was invisible until now. Copied the single 27 KB file the test needs rather than weakening the test or skipping it inside the image: the Dockerfile's own comment says the image is only published if its suite passes, so silently skipping a test there would hollow out that guarantee. Dockerfile.space is unaffected - it does not run the suite. Verified: the committed spec equals the generated one (5 parity tests pass), so the missing file was the only fault. The image build itself could not be run locally - the Docker daemon is not running on this machine - so CI is the proof.
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.
All 12 unit-test jobs were already green (py3.11–3.14 across ubuntu/macos/windows). Three jobs were failing for three unrelated reasons — plus a fourth that was hidden behind one of them.
1.
SAST + lint— 7 unused importsruff reported 7
F401unused imports inbus.py,hunt.py,store.py,worker.py,tests/test_store.py. Removed. 255 tests still pass, so nothing was being re-exported through them.Root cause: the linters were installed unpinned, so a newer ruff widened
F401and broke CI with no code change. Nowruff==0.16.1andbandit[toml]==1.9.4. Selecting rules inruff.tomldoes not protect you when a release changes what an existing rule detects — which is exactly what happened.2.
SAST + lint— a second failure hiding behind the firstBandit also exited 1, with 10 Medium findings. It never ran in CI because the lint step failed first, so fixing ruff alone would only have moved the cross one step to the right.
I reviewed all 10. Every one is a false positive or a deliberate control, so each gets a per-line
# nosec <rule> - <reason>instead of lowering the-llthreshold:B608?placeholder.worker.pybuilds itsINlist as a join of?. Properly parameterised.B608executescripttakes no params; version isint()-cast, name is''-escaped.B104config.py:181is the guard that refuses to bind0.0.0.0in prod — bandit flagged the security control itself.space_serverbinds all interfaces by design for the container/Space console.B310urlopenagainst a hardcodedhttp://127.0.0.1loopback upstream.3.
image build + filesystem scan— unresolvable actionThe action publishes v-prefixed tags, so bare
0.36.0doesn't exist and the job died in Set up job before any step ran. Nowv0.36.0.This is the same mistake the previous fix made with
0.24.0, so the comment now records how to check:4.
pages / build console— Pages site could not be createdconfigure-pages@v5withenablement: truecannot create a Pages site usingGITHUB_TOKEN:pages: writepermits deploying, not creating. The workflow's intent (no undocumented click) was right but isn't achievable with that token.Fixed outside the code by enabling Pages once on the repo with
build_type=workflow→ https://tusharbeckham.github.io/SentinelAI/. No workflow change needed —enablement: trueis now a harmless no-op that still helps anyone who clones this.Verification (local)