Repository navigation
ci(security): Trivy correctness fixes and a complete-coverage report #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
cd7214d
b156a3b
7f73828
cb86614
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,3 +124,79 @@ jobs: | |
| out.close() | ||
| sys.exit(1) | ||
| PY | ||
|
|
||
| # The git scan above only reaches commits that some ref still points at. Two classes of leak | ||
| # sit outside it, and only the GitHub API can see them: objects orphaned by a force push or a | ||
| # deleted branch, which remain fetchable by SHA, and secrets pasted into pull request or issue | ||
| # comments, where they arrive more often than in code. On this repository the API source reads | ||
| # ~8600 chunks against the git scan's ~6900, and takes about ten seconds. | ||
| # | ||
| # Report-only, and off pull requests: it depends on API availability and rate limits, so a | ||
| # transient failure must not block a merge. The blocking gate stays the git-based diff scan. | ||
| secrets-api: | ||
| name: secrets (GitHub API) | ||
| if: github.event_name != 'pull_request' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
| steps: | ||
| - name: TruffleHog scan (GitHub API — comments, wikis, unreachable objects) | ||
| env: | ||
| # The auto-injected token is enough for a public repository's commits and comments. | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| set -euo pipefail | ||
| docker run --rm \ | ||
| -e GITHUB_TOKEN \ | ||
| trufflesecurity/trufflehog:3.96.0@sha256:aa821cf4ace8861c7d096d83818cdf7bb9719028a52d37a52eaad44086a52577 \ | ||
| github \ | ||
| --repo "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" \ | ||
| --issue-comments \ | ||
| --pr-comments \ | ||
| --include-wikis \ | ||
| --json \ | ||
| --no-update \ | ||
| --results=verified,unknown,unverified,filtered_unverified \ | ||
| > trufflehog-api-findings.jsonl | ||
|
Comment on lines
+143
to
+160
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
IMAGE='trufflesecurity/trufflehog:3.96.0@sha256:aa821cf4ace8861c7d096d83818cdf7bb9719028a52d37a52eaad44086a52577'
docker run --rm "$IMAGE" github --help
docker run --rm "$IMAGE" github-experimental --helpRepository: constructorfabric/insight-front Length of output: 213 🌐 Web query:
💡 Result: The github-experimental object-discovery module in TruffleHog is an alpha feature designed to identify Cross Fork Object References, allowing users to discover and scan hidden or deleted commits in GitHub repositories [1][2][3]. As of TruffleHog version 3.96.0, which was released on July 24, 2026 [4][5], this feature remains available via the following command structure: trufflehog github-experimental --repo https://github.com//.git --object-discovery Key details for using this feature include: Authentication: You must provide a valid GitHub Access Token, either by setting the GITHUB_TOKEN environment variable or by passing it via the --token flag [3]. Operational Behavior: When executed, TruffleHog creates two files in a $HOME/.trufflehog directory: valid_hidden.txt and invalid.txt [1][6]. The former contains a list of all discovered hidden and deleted commits [1][3]. Users can include the --delete-cached-data flag if they wish to have these files automatically removed after the scan is complete [1][2]. Performance: The enumeration process can be time-intensive, potentially taking from 20 minutes to several hours depending on the repository size, as it involves querying GitHub's services for commit hashes [1][3]. Configuration: The command supports a --collision-threshold flag (defaulting to 1), which allows users to manage the trade-off between scan speed and potential hash collisions [7][3][8]. For more context on the security implications of Cross Fork Object References, refer to the official Truffle Security blog [3][9]. Citations:
🌐 Web query:
💡 Result: In TruffleHog, object discovery is an experimental sub-module within the github-experimental command designed to identify and scan hidden, deleted, or cross-fork commits in a GitHub repository [1]. To run this feature, use the command: trufflehog github-experimental --repo https://github.com//.git --object-discovery Key details about this experimental feature include: Data Outputs: When the --object-discovery flag is used, TruffleHog creates a $HOME/.trufflehog directory containing two files: valid_hidden.txt and invalid.txt [1]. These files track the state of commit enumeration and provide a list of all identified hidden and deleted commits [1]. Cleanup: To automatically remove these cached files after the scan completes, you can add the --delete-cached-data flag [1]. Performance: Enumerating all commits on a repository using this method can take between 20 minutes to several hours, depending on the repository size [1]. While enumeration takes time, the subsequent secret scanning phase is designed to run very quickly [1]. This functionality is categorized as an alpha release feature [1]. Citations: 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'Workflow file info:\n'
wc -l .github/workflows/trufflehog.yml 2>/dev/null || true
sed -n '1,230p' .github/workflows/trufflehog.yml 2>/dev/null | nl -ba
printf '\nSearch for object discovery/github-experimental references:\n'
rg -n "github-experimental|object-discovery|object discovery|orphaned|unreachable|orphan|hidden" .github/workflows/trufflehog.yml . 2>/dev/null | head -120Repository: constructorfabric/insight-front Length of output: 266 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'Workflow lines 1-230:\n'
python3 - <<'PY'
from pathlib import Path
p = Path('.github/workflows/trufflehog.yml')
lines = p.read_text().splitlines()
for i, line in enumerate(lines, 1):
print(f"{i:4}: {line}")
PY
printf '\nSearch results:\n'
python3 - <<'PY'
import re
from pathlib import Path
terms = ('github-experimental', 'object-discovery', 'object discovery', 'orphaned', 'unreachable', 'orphan', 'hidden')
for path in sorted(Path('.').rglob('*')):
if path.is_file() and '.git' not in path.parts:
try:
txt = path.read_text(errors='ignore').splitlines()
except Exception:
continue
for idx, line in enumerate(txt, 1):
if any(term in line for term in terms):
print(f"{path}:{idx}:{line}")
PYRepository: constructorfabric/insight-front Length of output: 50388 🏁 Script executed: #!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
p = Path('.github/workflows/trufflehog.yml')
text = p.read_text()
lines = text.splitlines()
for i, line in enumerate(lines, 1):
if 1 <= i <= 80 or 130 <= i <= 210:
print(f"{i:4}: {line}")
PYRepository: constructorfabric/insight-front Length of output: 8675 Align the GitHub API scan with TruffleHog execution realities. The workflow notes unreachable objects live on the remote and need 📍 Affects 1 file
🤖 Prompt for AI Agents |
||
|
|
||
| - name: Summarize (redacted) — report only | ||
| if: always() | ||
| run: | | ||
| [ -f trufflehog-api-findings.jsonl ] || exit 0 | ||
| python3 - trufflehog-api-findings.jsonl "${GITHUB_STEP_SUMMARY:-/dev/null}" <<'PY' | ||
| import json, sys, collections | ||
| rows = [] | ||
| with open(sys.argv[1], encoding="utf-8") as fh: | ||
| for line in fh: | ||
| line = line.strip() | ||
| if not line: | ||
| continue | ||
| d = json.loads(line) | ||
| meta = (d.get("SourceMetadata") or {}).get("Data", {}) | ||
| # The GitHub source reports under Github for commits and comments alike. | ||
| loc = meta.get("Github") or meta.get("Git") or {} | ||
| rows.append({ | ||
| "detector": d.get("DetectorName", "?"), | ||
| "verified": bool(d.get("Verified")), | ||
| # A comment hit carries a link instead of a path. | ||
| "where": loc.get("file") or loc.get("link") or "?", | ||
| }) | ||
| out = open(sys.argv[2], "a", encoding="utf-8") | ||
| w = out.write | ||
| w("## TruffleHog — GitHub API source (report-only)\n\n") | ||
| if not rows: | ||
| w("No secrets detected in commits, pull request and issue comments, or wikis " | ||
| "(all result kinds enabled).\n") | ||
| sys.exit(0) | ||
| ver = sum(1 for r in rows if r["verified"]) | ||
| w(f"**{len(rows)}** finding(s) — {ver} live-verified, {len(rows) - ver} unverified. " | ||
| "Values are redacted; open the linked location to read them.\n\n") | ||
| w("| Detector | Verified | Where |\n|---|---|---|\n") | ||
| for r in sorted(rows, key=lambda r: (not r["verified"], r["detector"])): | ||
| w(f"| `{r['detector']}` | {'yes' if r['verified'] else 'no'} | `{r['where']}` |\n") | ||
| by_det = collections.Counter(r["detector"] for r in rows) | ||
| w(f"\nBy detector: {', '.join(f'{k} x{v}' for k, v in by_det.most_common())}\n") | ||
| w("\nA hit here that the git scan did not report means the value lives outside the " | ||
| "current refs — an orphaned commit or a comment. **Rotate it; deleting the comment " | ||
| "does not.**\n") | ||
| out.close() | ||
| PY | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: constructorfabric/insight-front
Length of output: 306
🏁 Script executed:
Repository: constructorfabric/insight-front
Length of output: 5971
🌐 Web query:
Trivy --severity UNKNOWN documentation💡 Result:
In Trivy, the UNKNOWN severity signifies that a vulnerability's severity rating could not be determined from the available data sources [1][2]. Key aspects regarding the UNKNOWN severity include: Severity Assignment Logic: Trivy automatically aggregates severity data from multiple sources (such as NVD, GHSA, and OS-specific vendors) to provide the most accurate assessment [1][3]. If no configured vendor or data source provides a severity rating for a vulnerability, Trivy defaults to UNKNOWN [1][2]. Customizing Severity Sources: Users can control how severities are determined using the --vuln-severity-source flag [1][4]. This allows you to specify a priority list of data sources [4]. Trivy will check these sources in the order provided; if none of the specified sources contain a severity, it will fall back to UNKNOWN [1][4]. For example: --vuln-severity-source nvd,ghsa: Trivy checks NVD first, then GHSA, and returns UNKNOWN if neither provides a severity [4]. Reasons for UNKNOWN Severity: - Data Delay: Some vendors (like NVD) may delay severity analysis for new vulnerabilities, while others may provide it more quickly [1][5]. - Missing Detail: Vulnerabilities detected via OS advisories (e.g., Alpine secdb) may lack severity information in the underlying vulnerability database if the detail entry has not yet been populated [6]. - Light Database Mode: Using the --light option may result in UNKNOWN severities because the lightweight database lacks detailed vulnerability information (such as CVSS scores) often used to calculate severity [7]. Trivy Severity Mapping: In Trivy's internal classification, UNKNOWN is mapped to the value 0, while others are assigned as follows [1][2]: 0: Unknown 1: Low 2: Medium 3: High 4: Critical
Citations:
--vuln-severity-sourceflag to customize vulnerability severity selection aquasecurity/trivy#8180nvdandsourcedon't have severity for vulnerability aquasecurity/trivy#6714🌐 Web query:
Trivy UNKNOWN severity documentation💡 Result:
In Trivy, the "UNKNOWN" severity indicates that a vulnerability's severity level could not be determined from any of the available data sources (such as NVD, GHSA, or vendor-specific databases) [1][2][3]. Key points regarding the UNKNOWN severity: Determination Logic: Trivy automatically attempts to assign a severity based on a prioritized list of sources [1][2][4]. If no vendor or data source provides a specific severity rating, and it cannot be calculated via a CVSS score, Trivy assigns it the UNKNOWN severity [1][3]. Avoiding UNKNOWNs: To minimize the occurrence of UNKNOWN severities, Trivy is designed to use severity ratings from various vendors as fallbacks. For example, even if an NVD severity is not yet available, Trivy may use severity data from other vendors (like Red Hat) to provide a more actionable assessment [1][3][5]. Customization: Users can influence how severity is determined using the --vuln-severity-source flag [1][2][6]. This allows you to define a custom order of priority for severity sources. If you specify a sequence of sources, Trivy will check them in that order; if none of the specified sources contain a severity, Trivy will result in an UNKNOWN severity [1][2][6]. Reporting: In the context of reporting, UNKNOWN is considered a severity level (mapped to numerical value 0), distinct from other levels like Low, Medium, High, and Critical [1][2][3]. It is also important to distinguish this from vulnerability "status" (e.g., "unknown" status), which refers to whether a package is affected by a vulnerability on a specific platform [7]. For technical verification, you can check the SeveritySource field in Trivy's JSON output to identify exactly which source provided the severity (or if it was unable to be determined) for a specific vulnerability [2][3].
Citations:
nvdandsourcedon't have severity for vulnerability aquasecurity/trivy#6714--vuln-severity-sourceflag to customize vulnerability severity selection aquasecurity/trivy#8180Include Trivy’s
UNKNOWNseverity end to end.--severity CRITICAL,HIGH,MEDIUM,LOWfilters outUNKNOWNfindings, while the summary later says it reports every severity. AddUNKNOWNto the scan and include it in the summary counts/ranking so vulnerabilities without a determined severity are not silently omitted.🤖 Prompt for AI Agents
Source: MCP tools