Repository navigation
security: remove old implementation of gitleaks and add all scanners - #7804
Conversation
…scanners *gitleaks *bandit *zizmor *trivy
✅ All Checks Passed — Ready for Review
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
Pre-commit check failed⛔ pre-commit failed Please run locally:
This repo uses |
ScottTodd
left a comment
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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:
- good findings for how to improve the security of our github actions workflows
- https://docs.zizmor.sh/audits/#template-injection looks easy to implement across our workflows (replacing
${{withenv:) - https://docs.zizmor.sh/audits/#artipacked also easy, add
persist-credentials: falsetoactions/checkoutcalls - https://docs.zizmor.sh/audits/#excessive-permissions case by case
- https://docs.zizmor.sh/audits/#secrets-inherit case by case
bandit:
- analysis of python scripts... the signal to noise ratio is particularly poor here
- untrusted input with
subprocesscalls 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
There was a problem hiding this comment.
Before we enable on all
pull_requestruns, 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.
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?
There was a problem hiding this comment.
I've started preparing some commits/PRs for the zizmor findings, fyi.
| exclude_dirs: | ||
| - .git | ||
| - .venv | ||
| - venv |
There was a problem hiding this comment.
We might want to exclude test directories, there were many false positives for tests.
There was a problem hiding this comment.
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:
- https://github.com/ROCm/TheRock/tree/main/build_tools/scan_tools (which this PR deletes)
security_tools/new directory.github/security_tools/if these are limited to only running on github actions - it does look like they support running locally though
There was a problem hiding this comment.
sure, I've added a parameter for each and moved them.
There was a problem hiding this comment.
Same comment about file location, https://trivy.dev/docs/latest/references/configuration/config-file/ supports custom locations with --config
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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/ |
There was a problem hiding this comment.
This can be a follow-up, but let's document these security tools, including how to run them locally.
Docs which could be updated:
- https://github.com/ROCm/TheRock/blob/main/SECURITY.md (what existing scanning / reporting we have, how individual reports fit into that story)
- https://github.com/ROCm/TheRock/blob/main/CONTRIBUTING.md (how to run the scanners)
- https://github.com/ROCm/TheRock/blob/main/TESTING.md (add details for how we test the security of our code, not just the correctness)
|
🎉 All checks passed! This PR is ready for review. |
…scanners # Conflicts: # .github/workflows/gitleaks.yml
|
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:
For more information about GitHub Code Scanning, check out the documentation. |
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.
There was a problem hiding this comment.
This seems unrelated. Something broken here?
There was a problem hiding this comment.
I'm not seeing changes to that file in the full diff. Was that just from a merge commit in the middle?
There was a problem hiding this comment.
Also not seeing this in the diff.
| rebuild_artifacts: | ||
| description: "Comma-separated artifact names to build (granular reuse). Empty = build all artifacts in stage." | ||
| type: string | ||
| default: "" |
There was a problem hiding this comment.
Feels like you branched of the wrong or an outdated branch and this would re-introduce old changes.
There was a problem hiding this comment.
Ok, I'll sync this to the head of main
There was a problem hiding this comment.
@marbre let me know if you can still see those files.
marbre
left a comment
There was a problem hiding this comment.
Not seeing the diff race whatever that was :)
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