Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/secret-scan-pulse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# CI secret-scan enforcement via NVIDIA/security-workflows (Pulse).
# Runs on Linux nv-gha-runners (Pulse Docker image + OIDC/Vault) — Linux-only by design.
# The local secret-scan-trufflehog pre-commit hook is cross-platform (Linux/macOS/Windows via Git Bash).
# Pinned to a reviewed commit SHA; bump when NVIDIA/security-workflows consolidates.

name: Secret Scan (Pulse)

on:
push:
branches:
- main
- ctk-next
# copy-pr-bot mirror branches — trusted PR execution context
- "pull-request/[0-9]+"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-on-${{ github.event_name }}-from-${{ github.ref_name }}
cancel-in-progress: true

# Caller must grant at least every permission the reusable workflow declares
# (a reusable workflow requesting more than the caller allows fails at load time).
permissions:
contents: read
id-token: write # OIDC -> Vault -> nvcr.io image pull
security-events: write # publish redacted SARIF to code scanning

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

NVIDIA/cuda-python is public. GitHub documents actions: read as required by upload-sarif only for private repositories; this workflow otherwise needs contents: read, id-token: write, and security-events: write. Could we drop actions: read here to keep the caller token at the minimum scope?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Correction to my earlier "done" — I reverted this; actions: read is required here after all, though not for the private-repo reason.

The mechanism is reusable-workflow permission validation, not an intersection. The called workflow (NVIDIA/security-workflows/.github/workflows/secret-scan-pulse.yml, SHA-pinned) declares actions: read in its own permissions: block, and GitHub requires the caller to grant at least every permission the reusable workflow declares. With actions: read removed, the caller offered actions: none and the run failed at load time:

Error calling workflow '…/secret-scan-pulse.yml@69032f64…'. The workflow is requesting 'actions: read', but is only allowed 'actions: none'.

Dropping it from the caller would only be valid if we also dropped it from the reusable definition — but that workflow is generic and also consumed by private repos, where upload-sarif genuinely needs actions: read. So the reusable correctly keeps declaring it, and public callers grant it (harmless on public). Restored in 94851cd.

actions: read # reusable workflow declares actions: read (upload-sarif)

jobs:
secret-scan:
name: Secret Scan
# Pulse needs nv-gha-runners + Vault/nvcr vars; skip on forks.
if: github.repository == 'NVIDIA/cuda-python'
uses: NVIDIA/security-workflows/.github/workflows/secret-scan-pulse.yml@69032f641c3c34e0c0b46f636b54ed2b101b7aa4
with:
runs-on: linux-amd64-cpu4
# Set failure_policy explicitly so enforcement can't drift with upstream defaults.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is the Linux-only execution context intentional? The called workflow relies on POSIX shell syntax, docker, and python3, while the local pre-commit hook is also Bash-only and documents no Windows installation path. If Windows developers are expected to use this hook, please add a supported Windows implementation/instructions; otherwise, please document that this control is Linux/macOS-only.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

  • Local pre-commit hook: now cross-platform (Linux/macOS/Windows via Git Bash) as of v0.2.0.
  • CI reusable workflow (Pulse): intentionally Linux. It runs the NVIDIA-licensed Pulse scanner as a Docker container on nv-gha-runners with OIDC→Vault, so it's a server-side control on Linux CI runners — OS-independent from the contributor's side (a Windows dev's PR is still scanned in CI). I'll add a note that the CI control runs on Linux runners by design, while the developer hook is cross-platform.

# unverified — fail on verified/live secrets (183); warn on unverified (185) [default]
# strict — fail on any finding (verified or unverified)
# all — warn only; never fail the job on findings
failure_policy: unverified
10 changes: 9 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ ci:
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: quarterly
skip: [lychee, check-precommit-installed]
skip: [lychee, check-precommit-installed, secret-scan-trufflehog]
submodules: false

# Please update the rev: SHAs below with this command:
# pre-commit autoupdate --freeze
repos:
# Runs first so a leaked credential blocks the commit before any formatter runs.
# Self-installing: the hook downloads a pinned, checksum-verified trufflehog on
# first use (no manual install). Skipped on pre-commit.ci; Pulse CI enforces server-side.
- repo: https://github.com/NVIDIA/security-workflows
rev: v0.2.0
hooks:
- id: secret-scan-trufflehog

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: c60c980e561ed3e73101667fe8365c609d19a438 # frozen: v0.15.9
hooks:
Expand Down
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ If the hook isn't installed, `pre-commit run` (and CI) will print a visible
warning reminding you to run `pre-commit install`.


## Secret Scanning

Two complementary controls prevent accidental credential leakage:

- **Local pre-commit** (`secret-scan-trufflehog`, via `.pre-commit-config.yaml`): catches credentials before commit. Self-installing — no manual setup beyond `pre-commit install`; the hook downloads a pinned, checksum-verified `trufflehog` on first use. Never commit a flagged secret; check with maintainers on false positives, and only use `git commit --no-verify` in exceptional, agreed cases.
- **Server-side enforcement** (Pulse reusable workflow from `NVIDIA/security-workflows`, pinned by SHA): runs on `main`, `ctk-next`, and trusted copy-pr-bot branches on Linux runners, and blocks merges on verified secrets.

The local hook is skipped on hosted pre-commit.ci (no `trufflehog` binary there); Pulse remains the authoritative CI enforcement. On **Windows**, run the hook from a Git Bash / MSYS shell (bundled with Git for Windows), which the hook requires; the CI (Pulse) control is Linux-runner-only by design.


## Signing Your Work

Contributions to files licensed under Apache 2.0 must be certified under the
Expand Down
Loading