Skip to content

chore(build): add gitleaks secret scanning workflow#137

Open
sklarsa wants to merge 4 commits into
mainfrom
add-gitleaks-workflow
Open

chore(build): add gitleaks secret scanning workflow#137
sklarsa wants to merge 4 commits into
mainfrom
add-gitleaks-workflow

Conversation

@sklarsa

@sklarsa sklarsa commented Mar 10, 2026

Copy link
Copy Markdown

Summary

  • Adds a Gitleaks GitHub Actions workflow to scan for secrets on pull requests and pushes to the default branch
  • Uses gitleaks/gitleaks-action@v2 with GITLEAKS_LICENSE secret

Reference: questdb/questdb#6863

Summary by CodeRabbit

  • Chores
    • Added an automated secret-scanning workflow to CI that runs on pull requests and pushes to main. The scan runs on hosted runners, checks the repository history, and is executed only when a license token is configured, supplying necessary runtime tokens securely via environment variables.

@coderabbitai

coderabbitai Bot commented Mar 10, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@sklarsa has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 28 minutes and 32 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 28 minutes and 32 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: eb8a3e07-2062-4a81-ad81-5d340a26dbe3

📥 Commits

Reviewing files that changed from the base of the PR and between fe0f3a1 and 33b40cf.

📒 Files selected for processing (1)
  • .github/workflows/gitleaks.yml
📝 Walkthrough

Walkthrough

Adds a new GitHub Actions workflow .github/workflows/gitleaks.yml that runs on pull_request and push to main, checks out the repo with full history (fetch-depth: 0), and conditionally runs gitleaks/gitleaks-action pinned to a commit, passing GITHUB_TOKEN and GITLEAKS_LICENSE via environment variables when the license secret is set.

Changes

Cohort / File(s) Summary
GitHub Actions Workflow
.github/workflows/gitleaks.yml
Adds a Gitleaks workflow triggered on pull_request and push to main; checks out full history and runs gitleaks/gitleaks-action (pinned to a commit). Action execution is conditional on secrets.GITLEAKS_LICENSE and receives secrets.GITHUB_TOKEN and secrets.GITLEAKS_LICENSE as env vars.

Sequence Diagram(s)

sequenceDiagram
    participant GitHub as GitHub Events
    participant Runner as Actions Runner
    participant Checkout as actions/checkout
    participant Gitleaks as gitleaks/gitleaks-action

    GitHub->>Runner: push to main / pull_request
    Runner->>Checkout: checkout repository (fetch-depth: 0)
    Runner->>Gitleaks: run action (pinned commit) with env: GITHUB_TOKEN, GITLEAKS_LICENSE
    Gitleaks->>Runner: scan repository for secrets
    Gitleaks-->>GitHub: report results (action outcome)
Loading

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 I hopped in quiet, nose to the code,
Scanning each branch down every road,
With a license tucked safe and a token in paw,
No secret escapes my careful law. 🔎✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the main change: adding a gitleaks secret scanning workflow as a new GitHub Actions workflow file.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-gitleaks-workflow

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sklarsa sklarsa changed the title Add Gitleaks secret scanning workflow chore(build): add gitleaks secret scanning workflow Mar 10, 2026

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/gitleaks.yml:
- Around line 4-5: The workflow runs on pull_request and unconditionally sets
the GITLEAKS_LICENSE env for gitleaks-action@v2, causing forked PRs to fail
because secrets aren't available; update the workflow to detect external PRs
(use github.event.pull_request.head.repo.fork or github.actor !=
repository_owner) and conditionally run the licensed gitleaks step only when the
secret is present/PR is internal, otherwise run an alternative non-secret scan
or skip the licensed step; reference the GITLEAKS_LICENSE environment entry and
the gitleaks-action@v2 step when adding the if: condition and a fallback step.
- Around line 13-16: The workflow uses movable tags for actions/checkout@v4 and
gitleaks/gitleaks-action@v2; replace those tag refs with the corresponding full
commit SHAs (the immutable full-length commit IDs) for both "uses" entries so
the workflow pins exact action commits (locate the actions/checkout and
gitleaks/gitleaks-action references in the YAML and substitute the tag@<sha>
form), then verify the workflow still passes and that secrets consumed by
gitleaks remain scoped as before.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c7667065-1566-4a91-8528-40d46606bdbc

📥 Commits

Reviewing files that changed from the base of the PR and between 914f625 and 409a6dc.

📒 Files selected for processing (1)
  • .github/workflows/gitleaks.yml

Comment thread .github/workflows/gitleaks.yml
Comment thread .github/workflows/gitleaks.yml Outdated
Comment on lines +13 to +16
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gitleaks/gitleaks-action@v2

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n .github/workflows/gitleaks.yml

Repository: questdb/c-questdb-client

Length of output: 568


🌐 Web query:

GitHub Actions security hardening full commit SHA pin action references best practice

💡 Result:

Best practice: pin GitHub Actions to a full commit SHA

  • Pin all third‑party actions to an immutable ref—preferably a full, 40‑char commit SHA (not a branch like main/master, and not a mutable tag like v1). GitHub explicitly calls SHA pinning “the only way to use an action as an immutable release,” and recommends it to reduce supply‑chain risk (tags can be moved). [1]
  • Choose the SHA that corresponds to a tagged release, and add a comment with the human version to keep updates manageable (and friendlier for update tooling). Example: [2]
    - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  • Verify the SHA comes from the action’s official repository (not a fork) before pinning. [1]
  • Enforce SHA pinning via policy (enterprise/org/repo). GitHub supports requiring actions to be pinned to full-length SHAs, and this can be enforced in Actions policies (and via API fields like sha_pinning_required). [3][4]
  • Also consider pinning reusable workflow references, and/or restrict which actions/workflows are allowed to run using “allowed actions and reusable workflows” policy controls. [4][5]

Why this is recommended

GitHub recommends SHA pinning to proactively limit the impact of a compromised dependency in workflows. [5]

Sources
[1] GitHub Docs — Security hardening for GitHub Actions (Pin actions to a full length commit SHA) (docs.github.com)
[2] GitHub Well-Architected — Securing GitHub Actions Workflows (example of SHA pin + version comment) (wellarchitected.github.com)
[3] GitHub Enterprise Cloud Docs — Enforcing policies for GitHub Actions in your enterprise (require full-length SHA option) (docs.github.com)
[4] GitHub Docs — Disabling or limiting GitHub Actions for your organization (allow-list syntax; tag-or-SHA) (docs.github.com)
[5] GitHub Changelog — Actions policy now supports blocking and SHA pinning actions (recommends pinning to specific commit SHA) (github.blog)

Citations:


Pin action refs to full commit SHAs.

Both steps are using movable tags, and the gitleaks step receives repository secrets. GitHub's secure-use guidance recommends full-length commit SHAs because that is the only immutable way to reference an action release and it reduces tag-retargeting risk. (docs.github.com)

🔒 Suggested hardening
-      - uses: actions/checkout@v4
+      - uses: actions/checkout@<verified-full-length-commit-sha> # v4
         with:
           fetch-depth: 0
-      - uses: gitleaks/gitleaks-action@v2
+      - uses: gitleaks/gitleaks-action@<verified-full-length-commit-sha> # v2
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
           GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/gitleaks.yml around lines 13 - 16, The workflow uses
movable tags for actions/checkout@v4 and gitleaks/gitleaks-action@v2; replace
those tag refs with the corresponding full commit SHAs (the immutable
full-length commit IDs) for both "uses" entries so the workflow pins exact
action commits (locate the actions/checkout and gitleaks/gitleaks-action
references in the YAML and substitute the tag@<sha> form), then verify the
workflow still passes and that secrets consumed by gitleaks remain scoped as
before.

@coderabbitai coderabbitai Bot 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.

♻️ Duplicate comments (1)
.github/workflows/gitleaks.yml (1)

13-13: ⚠️ Potential issue | 🟠 Major

Pin actions/checkout to a full commit SHA.

The gitleaks action was correctly pinned (line 16), but actions/checkout@v4 still uses a movable tag. For supply-chain security, both actions should be pinned to immutable commit SHAs.

🔒 Suggested fix
-      - uses: actions/checkout@v4
+      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
         with:
           fetch-depth: 0
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/gitleaks.yml at line 13, The workflow uses a movable tag
for the checkout action ("actions/checkout@v4"); replace that tag with the full
immutable commit SHA to pin the action (same approach already used for the
gitleaks action). Locate the job step that references "actions/checkout@v4" and
update it to the corresponding full commit SHA from the actions/checkout
repository (get the SHA from the official GitHub repo/releases or the specific
release tag), ensuring the checkout step now uses that SHA string instead of
"@v4".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In @.github/workflows/gitleaks.yml:
- Line 13: The workflow uses a movable tag for the checkout action
("actions/checkout@v4"); replace that tag with the full immutable commit SHA to
pin the action (same approach already used for the gitleaks action). Locate the
job step that references "actions/checkout@v4" and update it to the
corresponding full commit SHA from the actions/checkout repository (get the SHA
from the official GitHub repo/releases or the specific release tag), ensuring
the checkout step now uses that SHA string instead of "@v4".

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 77a1674c-8da0-4bc0-b7e9-38285ed64f3d

📥 Commits

Reviewing files that changed from the base of the PR and between 409a6dc and fe0f3a1.

📒 Files selected for processing (1)
  • .github/workflows/gitleaks.yml

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