Skip to content

ci: fix zizmor/CodeQL/Trivy/Bandit findings in workflows, Dockerfiles and examples - #556

Merged
zichguan-amd merged 3 commits into
amd-stagingfrom
zichguan/harden-workflows
Oct 26, 2026
Merged

zichguan-amd merged 3 commits into
amd-stagingfrom
zichguan/harden-workflows

Conversation

@zichguan-amd

@zichguan-amd zichguan-amd commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Fix the code-scanning alerts reported by the weekly security scan (CodeQL, zizmor, Trivy and Bandit) in the CI workflows, Dockerfiles and Python examples.

Technical Details

  • permissions: contents: read on 17 build workflows + linting.yml (CodeQL actions/missing-workflow-permissions, zizmor excessive-permissions).
  • persist-credentials: false on all checkouts; promotion.yml explicitly sets true for its git push (zizmor artipacked).
  • Expressions in run: moved to step env: in the VS/portable-solution workflows, build_docker.yml, build_libraries.yml, build-rocm-examples-reusable.yml and quartz_test.yml (zizmor template-injection).
  • Removed secrets: inherit from ci_nightly.yml, ci_therock.yml and quartz_test.yml. build-rocm-examples-reusable.yml has never referenced a secret, and the called workflow still gets its own GITHUB_TOKEN (zizmor secrets-inherit).
  • Dependabot cooldown: default-days: 7 (zizmor dependabot-cooldown).
  • Not changed: zizmor self-repository (3). The $/ syntax it asks for is rejected by actionlint v1.7.12 (Support the new $/ self-repository uses: syntax rhysd/actionlint#711, Support "$/" in uses: (reusable workflow and action at the running workflow's own repository and commit) rhysd/actionlint#760).
  • CodeQL Add gfx1151 support and add rules to generate asm files #242 (actions/unpinned-tag, rocm-docs-core@develop) was dismissed as intentional.
  • Replaced RUN cd with WORKDIR in the FFmpeg (AlmaLinux 8, SLES 15.7) and elfutils (SLES 15.7) source builds (Trivy DS-0013).
  • bandit.yml: skip only B101 (assert_used) for code adapted from upstream (Libraries/ComposableKernel/attention/fmha, from ROCm/composable_kernel example/ck_tile/01_fmha; Libraries/hipThreads/llama3c, from jameswdelancey/llama3.c), so it doesn't diverge from its sources. All other Bandit checks still run there.
  • AI/MIGraphX/gpu_resident_yolo26_pipeline/main.py: GPU-residency assert replaced with an explicit raise RuntimeError, so the check survives python -O (Bandit B101).

Test Plan

  • zizmor 1.30.0 run locally with the security-baseline config.
  • pre-commit run on the changed files (actionlint).
  • Trivy 0.70.0 config scan of Dockerfiles/.
  • Built the AlmaLinux 8 and SLES 15.7 images locally.
  • Bandit 1.9.4 with the repository bandit.yml, run the same way as the security baseline.
  • shellcheck output compared before and after.
  • CI on this PR.

Test Result

  • zizmor: 97 → 3 findings (only self-repository remains).
  • pre-commit: passes.
  • shellcheck: no new warnings.
  • Trivy: DS-0013 3 → 0, no new findings. Both images build; inside them elfutils 0.186 is installed, libavcodec.so.58 is in the ldconfig cache, /tmp is empty, and the working directory is still /workspace.
  • Bandit: 56 → 5 findings (remaining: llama3c export.py B614/B615, Scripts/VisualStudio/check_vs_files.py B405/B314). main.py compiles; the YOLO26 example itself was not run.

Added/Updated documentation?

  • Yes
  • No, does not apply to this PR.

Included Visual Studio files?

  • Yes
  • No, does not apply to this PR.

Submission Checklist

🤖 Generated with Claude Code

zichguan-amd and others added 3 commits October 20, 2026 11:41
- Add workflow-level `permissions: contents: read` to the build and
  linting workflows that had none.
- Set `persist-credentials: false` on all checkouts; promotion.yml keeps
  credentials explicitly since it pushes.
- Move `${{ }}` expressions out of run scripts into step `env:` to avoid
  template injection.
- Drop `secrets: inherit` from the reusable-workflow callers; the
  reusable workflow uses no secrets.
- Add a 7-day Dependabot cooldown for github-actions updates.

Co-Authored-By: Claude <noreply@anthropic.com>
Trivy DS-0013 flags `RUN cd ...` in the FFmpeg (AlmaLinux 8, SLES 15.7)
and elfutils (SLES 15.7) source builds. Switch to WORKDIR with
`tar --strip-components=1` and reset WORKDIR afterwards.

Co-Authored-By: Claude <noreply@anthropic.com>
Bandit B101 (assert_used) flags 50 asserts in code adapted from upstream
(CK tile fmha codegen, llama3.c); skip only that check for those
directories so they don't diverge from their sources. In the YOLO26
example, replace the GPU-residency assert with an explicit raise so the
check survives `python -O`.

Co-Authored-By: Claude <noreply@anthropic.com>
@zichguan-amd zichguan-amd changed the title ci: harden workflows against zizmor/CodeQL findings ci: fix zizmor/CodeQL/Trivy/Bandit findings in workflows, Dockerfiles and examples Oct 21, 2026
@zichguan-amd
zichguan-amd marked this pull request as ready for review October 26, 2026 16:05
@zichguan-amd
zichguan-amd requested a review from a team as a code owner October 26, 2026 16:05
@zichguan-amd
zichguan-amd merged commit 8d7f52f into amd-staging Oct 26, 2026
60 of 62 checks passed
@zichguan-amd
zichguan-amd deleted the zichguan/harden-workflows branch October 26, 2026 16:06
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