Repository navigation
ci(secu): speed up dependency and gitleaks scans - #74
Merged
Merged
Conversation
The blocklist scan spawned one grep per IOC and per lockfile (1679 IOC x 30 lockfiles on centreon-modules), taking 60-120s per run. A single fixed-string grep per lockfile gives the same matches in under a second.
gitleaks-action only scans the pull request commits, but the checkout fetched the whole history (40-50s on centreon-modules for a 4s scan). Pull requests now fetch their commits plus the merge and base commits; other events keep the full history. Refs: MON-211442
gitleaks-action lists pull request commits without pagination, so only the first 30 commits were scanned (gitleaks/gitleaks-action#187). Pull requests now run a checksum-pinned gitleaks 8.24.3 on the full first^..head range; other events keep using gitleaks-action. Refs: MON-211442
Pull requests keep fetch-depth 0 but fetch the history without file contents and only check out the gitleaks config files; the contents of the scanned changes are fetched in one batch before the scan (63 MB instead of 1.3 GiB on centreon-modules). Refs: MON-211442
Drop the direct gitleaks run: gitleaks-action scans the pull request again, after a step that batch-fetches the file contents of the pull request changes into the blobless checkout. Refs: MON-211442
Go back to a PR-sized fetch-depth with file contents (about 60 MB on centreon-modules) instead of the blobless full-history checkout, which needed an extra authenticated fetch step for the same size. Refs: MON-211442
Under bash -eo pipefail, grep -v exits 1 when every blocklist line is a comment, which failed the step where the previous loop scanned nothing. Refs: MON-211442
sc979
reviewed
Oct 7, 2026
| pull-requests: read | ||
|
|
||
| steps: | ||
| # Pull requests only scan their own commits: fetch them plus the merge and base commits, full history otherwise |
sc979
approved these changes
Oct 7, 2026
sc979
added a commit
that referenced
this pull request
Oct 7, 2026
Bring in #74 (shallow PR checkout with a computed fetch depth, faster blocklist scan). The gitleaks conflict keeps the pull_request_target guard as the first step, then the fetch-depth step, and keeps the job token scoped to contents: read.
sc979
added a commit
that referenced
this pull request
Oct 7, 2026
Since #74 the PR checkout is shallow (fetch-depth = PR commits + 2). When the base branch moved further than that since the PR forked, the merge-base was unreachable: the scan concluded "no shared history" and ran a full scan of the shallow clone, where gitleaks reads boundary commits as roots and reports every pre-existing secret in the tree. A clean PR then failed on secrets already on the base branch. The scan now deepens the PR history (32 to 1024 commits, doubling) until the fork point is reachable from both sides, unshallows as a last resort, and never scans a range holding a shallow boundary commit. "No shared history" is only concluded on a complete clone. Deepening goes through the authenticated fetch and stops when a fetch brings nothing, so the existing retry loop takes over. Also shorten the pull_request_target error message. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Assisted-by: Claude Code (claude-opus-5-5)
sc979
added a commit
that referenced
this pull request
Oct 12, 2026
Since #74 the PR checkout is shallow (fetch-depth = PR commits + 2). When the base branch moved further than that since the PR forked, the merge-base was unreachable: the scan concluded "no shared history" and ran a full scan of the shallow clone, where gitleaks reads boundary commits as roots and reports every pre-existing secret in the tree. A clean PR then failed on secrets already on the base branch. The scan now deepens the PR history (32 to 1024 commits, doubling) until the fork point is reachable from both sides, unshallows as a last resort, and never scans a range holding a shallow boundary commit. "No shared history" is only concluded on a complete clone. Deepening goes through the authenticated fetch and stops when a fetch brings nothing, so the existing retry loop takes over. Also shorten the pull_request_target error message. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Assisted-by: Claude Code (claude-opus-5-5)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
What are your needs or what are you planning to do in this PR?
Fixes: MON-211442
Before / after on centreon-modules
dependency-analysisgitleaks-analysis(pull requests)gitleaksnetwork"Before" figures come from the 523 scan jobs run on centreon-modules from 2026-10-01 to 2026-10-06; "after" durations from the test PR centreon-modules#9507; network sizes from clones of the same refs. The 5-day "after" totals apply the new per-run figures to the same number of runs.
dependency-analysis.ymlgrepper IOC and per lockfile (1679 IOC x 30 lockfiles = ~50,000 processes, 64-118 s per run).name@versionpattern file once and runs a singlegrep -oF -fper lockfile: 96 s -> 0.24 s on the centreon-modules tree.main) and new steps run side by side withbash -eo pipefailon the centreon-modules tree: samefail_the_buildand exit code for clean, infected (40 IOC), overlapping IOC, lockfile compliance findings (before and after the enforcement date),OVERRIDE_DEPENDENCY_SCAN=trueand an empty blocklist. Only difference: when an IOC is contained in another one (e.g.ngx-bootstrap@19.0.4in@rxap/ngx-bootstrap@19.0.4), the old loop also reported the shorter, false-positive name.gitleaks-analysis.ymlgitleaks-actiononly scansfirst_pr_commit^..headon pull requests, but the checkout fetched the whole history (1.3 GiB, 38-48 s on centreon-modules for a 4 s scan).fetch-depthis now the PR commit count + 2 (merge and base commits). Push, schedule and workflow_dispatch keepfetch-depth: 0.Verification