Skip to content

security: remove old implementation of gitleaks and add all scanners - #7804

Merged
cgoea merged 15 commits into
mainfrom
users/cgoea/security_scanners
Sep 18, 2026
Merged

cgoea merged 15 commits into
mainfrom
users/cgoea/security_scanners

Conversation

@cgoea

@cgoea cgoea commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Add single entry point for all the security scanners:
*gitleaks
*bandit
*zizmor
*trivy
*codeql

and their specific config files

JIRA ID: ROCM-28051

Technical Details

Security governance is maintained from https://github.com/ROCm/rocm-security-gh

Submission Checklist

@therock-pr-bot

therock-pr-bot Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

✅ All Checks Passed — Ready for Review

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ✅ Pass —
🔎 pre-commit ✅ Pass —
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —
🤖 therock-pr-bot ✅ Pass —

🎉 All checks passed! This PR is ready for review.

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

@therock-pr-bot

therock-pr-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

Pre-commit check failed

⛔ pre-commit failed

Please run locally:

  • python -m pip install pre-commit
  • pre-commit install
  • pre-commit run --all-files --show-diff-on-failure

This repo uses .pre-commit-config.yaml.

@ScottTodd ScottTodd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice, this looks quite useful. Let's figure out how to get the checks to appear "passing" before we enable on all pull requests though.

Comment thread .github/workflows/security_scan_pr.yml Outdated
Comment on lines +12 to +23
on:
pull_request:

permissions:
contents: read

jobs:
security:
name: Security scan
uses: ROCm/rocm-security-gh/.github/workflows/security-baseline.yml@4b25e6bc1cb0b9bbc3c278b2f1c70d8f2f406e20 # v1.0.0
with:
report_formats: human No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This has failures: https://github.com/ROCm/TheRock/actions/runs/33512746901?pr=7804

Before we enable on all pull_request runs, let's fix / allow-list / suppress preexisting failures so open PRs will only show new findings, with a path to either fix or add to those allow-lists.


Looking through the findings...

zizmor:

bandit:

  • analysis of python scripts... the signal to noise ratio is particularly poor here
  • untrusted input with subprocess calls is very broad and flagged many cases. Needs a triage pass to prioritize. Issue: [B404:blacklist] Consider possible security implications associated with the subprocess module. is quite strict.
  • many false positives like
    >> Issue: [B105:hardcoded_password_string] Possible hardcoded password: 'systems'
       Severity: Low   Confidence: Medium
       CWE: CWE-259 (https://cwe.mitre.org/data/definitions/259.html)
       More Info: https://bandit.readthedocs.io/en/1.9.4/plugins/b105_hardcoded_password_string.html
       Location: .scan-target/build_tools/github_actions/bump_automation.py:40:8
    39	        "updater": "ref",
    40	        "token_key": "systems",
    
    >> Issue: [B105:hardcoded_password_string] Possible hardcoded password: 'test-token-12345'
       Severity: Low   Confidence: Medium
       CWE: CWE-259 (https://cwe.mitre.org/data/definitions/259.html)
       More Info: https://bandit.readthedocs.io/en/1.9.4/plugins/b105_hardcoded_password_string.html
       Location: .scan-target/build_tools/github_actions/tests/github_actions_api_test.py:110:19
    109	        """GITHUB_TOKEN should be used when available, even if gh CLI is present."""
    110	        os.environ["GITHUB_TOKEN"] = "test-token-12345"
    111
    
    >> Issue: [B101:assert_used] Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
       Severity: Low   Confidence: High
       CWE: CWE-703 (https://cwe.mitre.org/data/definitions/703.html)
       More Info: https://bandit.readthedocs.io/en/1.9.4/plugins/b101_assert_used.html
       Location: .scan-target/build_tools/github_actions/tests/workflow_summary_test.py:68:8
    67	        assert len(jobs) == 3
    68	        assert all(j.result == "success" for j in jobs)
    69	        assert all(not j.continue_on_error for j in jobs)
    

trivy:

  • reasonable suggestions here for how to improve our dockerfiles

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Before we enable on all pull_request runs, let's fix / allow-list / suppress preexisting failures so open PRs will only show new findings, with a path to either fix or add to those allow-lists.

https://github.com/ROCm/TheRock/actions/runs/34583395292/job/103211993919?pr=7804#step:6:22

INFO Changed config (build_tools/scan_tools/trivy.yml) applies to every file, so this run scans the whole tree instead of the changed files alone

Looks like this is already going to decide to filter to just new code on most pull requests... or, at least that's what it advertises, but https://github.com/ROCm/rocm-security-gh/blob/main/security_scanners/github_actions/trivy.py says

- Derive change sets from the GitHub event for changed/all scans; in
  'changed' mode short-circuit to a no-op unless a dependency
  manifest / IaC / container file changed under `--source-dir` (trivy's
  filesystem scanner needs the whole subtree to resolve transitive
  deps and cross-file IaC references, so -- unlike bandit/zizmor --
  individual changed files are never fed to it directly: we either
  scan the whole subtree or nothing).

So "changed" doesn't work there, and PRs would show preexisting failures.

Could you run some tests showing what to expect for output on some typical PRs?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've started preparing some commits/PRs for the zizmor findings, fyi.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

#8275 for zizmor template-injection findings

Comment on lines +9 to +12
exclude_dirs:
- .git
- .venv
- venv

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We might want to exclude test directories, there were many false positives for tests.

Comment thread bandit.yaml Resolved
Comment thread trivy.yaml Resolved
Comment thread zizmor.yaml Resolved

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this file need to be in the repository root? Can we add to a subdirectory instead? Or use a dotfile at least? I want to limit how many files we put at the top level whenever possible.

Looks like https://bandit.readthedocs.io/en/latest/config.html supports .bandit in the root or a *.yaml file anywhere, together with the -c option (which we could forward to the security scan workflow(s))

Suggestions:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sure, I've added a parameter for each and moved them.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same comment about file location, https://trivy.dev/docs/latest/references/configuration/config-file/ supports custom locations with --config

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was my initial idea, but got some pushback regarding configs being anywhere else other than the root of the repo. I could make them configurable though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same comment about file location, https://docs.zizmor.sh/configuration/ supports custom locations with --config

# trivy configuration for Quartz, picked up by the rocm-security-gh
# reusable scanner (.github/workflows/security_scan_pr.yml and
# security_scan_weekly.yml) in place of its own org-wide default.
# Reference: https://trivy.dev/latest/docs/references/configuration/config-file/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This can be a follow-up, but let's document these security tools, including how to run them locally.

Docs which could be updated:

@therock-pr-bot

therock-pr-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown

🎉 All checks passed! This PR is ready for review.

@cgoea
cgoea requested a review from ScottTodd September 9, 2026 11:49
…scanners

# Conflicts:
#	.github/workflows/gitleaks.yml
@cgoea cgoea added the ci:skip Skip all CI builds/tests for this PR label Sep 9, 2026
@github-advanced-security

Copy link
Copy Markdown
Contributor

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

cgoea added a commit to ROCm/Quartz that referenced this pull request Sep 10, 2026
Mirrors ROCm/TheRock#7804's docs enhancement: add an "Automated security
scanning" section to SECURITY.md (what each scanner looks for, and how
the PR-time vs weekly workflows differ) and a "Security scanners"
section to CONTRIBUTING.md (local run commands against the same config
CI uses). Answers HereThereBeDragons' review comment asking for more
detail on how often the scanners run and on what.

@marbre marbre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Something is off here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems unrelated. Something broken here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not seeing changes to that file in the full diff. Was that just from a merge commit in the middle?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Also not seeing this in the diff.

Comment on lines +72 to +75
rebuild_artifacts:
description: "Comma-separated artifact names to build (granular reuse). Empty = build all artifacts in stage."
type: string
default: ""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Feels like you branched of the wrong or an outdated branch and this would re-introduce old changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll sync this to the head of main

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@marbre let me know if you can still see those files.

@haribabug haribabug 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.

LGTM

@ScottTodd ScottTodd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, LGTM. After merge let's monitor pull requests for false positives and and follow-up on the preexisting scanner findings as part of #8272.

@marbre marbre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not seeing the diff race whatever that was :)

@cgoea
cgoea merged commit f606a02 into main Sep 18, 2026
21 of 24 checks passed
@cgoea
cgoea deleted the users/cgoea/security_scanners branch September 18, 2026 14:13
@github-project-automation github-project-automation Bot moved this from TODO to Done in TheRock Triage Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:skip Skip all CI builds/tests for this PR

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants