feat(secrets): Betterleaks instead of gitleaks, findings carry over (#516)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 11m59s

- The agent image ships Betterleaks 1.9.0 (MIT, gitleaks' successor by its
  author; pinned with checksum) instead of gitleaks 8.21.2. It reads our
  rules/gitleaks.toml unchanged, incl. the #464/#482 allowlists; `git .`
  replaces `detect --source .`, `dir .` stays. Live validation (which sends
  secrets to their providers) is never passed and a test pins that; the
  scan runs without network.
- The findings keep the scanner name `gitleaks` (finding_store::
  SECRET_SCANNER), so fingerprints (#491) and tracker issues carry over.
- RunFindings::adopt_renamed_secrets: a secret now reported under another
  rule (Betterleaks' composite aws-access-token reports a lone key id as
  generic-api-key; renamed vendor rules) takes over the stored row of the
  same target, file and match whose old rule no longer reports it: same id,
  status, triage and issue, with the new rule, title and severity.
- Compared on every fixture tree: identical results, except two planted
  hard-coded passwords Betterleaks finds in the C firmware fixture
  (generic-password), added to its nightly baseline.
- Docs (tools, guides), test plan check 33.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
This commit is contained in:
Sharang ParnerkarandClaude Opus 5.5 committed 2026-10-06 17:46:20 +02:00
1 parent 908e6b8449
commit ee30ecfddb
10 files changed
+375 -45

No files matched your search

+13 -11
View File
@@ -5,8 +5,8 @@ ARG RUST_VERSION=1.98.1
ARG CARGO_AUDIT_VERSION=0.22.2
ARG SYFT_VERSION=1.52.0
ARG SYFT_SHA256=caeedb81fb0491615f1ebd1761e4145d41ee86dd2cc7bf80669f9f5ad9d6133d
ARG GITLEAKS_VERSION=8.21.2
ARG GITLEAKS_SHA256=5bc41815076e6ed6ef8fbecc9d9b75bcae31f39029ceb55da08086315316e3ba
ARG BETTERLEAKS_VERSION=1.9.0
ARG BETTERLEAKS_SHA256=f8b185a39ffcece2a1ca82bf3a4e7435cd81963ffd16b7a9128daf75f35f6de7
# SBOM quality score (Interlynk, Apache-2.0), #496. The checksum is the one
# in the release's checksums.txt.
ARG SBOMQS_VERSION=2.1.2
@@ -56,8 +56,8 @@ ARG RUST_VERSION
ARG CARGO_AUDIT_VERSION
ARG SYFT_VERSION
ARG SYFT_SHA256
ARG GITLEAKS_VERSION
ARG GITLEAKS_SHA256
ARG BETTERLEAKS_VERSION
ARG BETTERLEAKS_SHA256
ARG SBOMQS_VERSION
ARG SBOMQS_SHA256
ARG SEMGREP_VERSION
@@ -90,11 +90,13 @@ RUN curl -sSfL -o /tmp/syft.tar.gz \
&& tar -xzf /tmp/syft.tar.gz -C /usr/local/bin syft \
&& rm /tmp/syft.tar.gz
RUN curl -sSfL -o /tmp/gitleaks.tar.gz \
"https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" \
&& echo "${GITLEAKS_SHA256} /tmp/gitleaks.tar.gz" | sha256sum -c - \
&& tar -xzf /tmp/gitleaks.tar.gz -C /usr/local/bin gitleaks \
&& rm /tmp/gitleaks.tar.gz
# Betterleaks (MIT), gitleaks' successor by its author (#516): reads our
# gitleaks.toml. Its live validation is never switched on.
RUN curl -sSfL -o /tmp/betterleaks.tar.gz \
"https://github.com/betterleaks/betterleaks/releases/download/v${BETTERLEAKS_VERSION}/betterleaks_${BETTERLEAKS_VERSION}_linux_x64.tar.gz" \
&& echo "${BETTERLEAKS_SHA256} /tmp/betterleaks.tar.gz" | sha256sum -c - \
&& tar -xzf /tmp/betterleaks.tar.gz -C /usr/local/bin betterleaks \
&& rm /tmp/betterleaks.tar.gz
RUN curl -sSfL -o /tmp/sbomqs.tar.gz \
"https://github.com/interlynk-io/sbomqs/releases/download/v${SBOMQS_VERSION}/sbomqs_${SBOMQS_VERSION}_Linux_x86_64.tar.gz" \
@@ -137,8 +139,8 @@ RUN curl -sSfL -o /tmp/dotnet.tar.gz \
COPY --chmod=0755 docker/devskim.sh /usr/local/bin/devskim
RUN mkdir -p /opt/pruefwerk \
&& printf '{"rust":"%s","cargo-audit":"%s","syft":"%s","gitleaks":"%s","semgrep":"%s","ruff":"%s","cppcheck":"%s","mobsfscan":"%s","sbomqs":"%s","devskim":"%s","dotnet-runtime":"%s"}\n' \
"${RUST_VERSION}" "${CARGO_AUDIT_VERSION}" "${SYFT_VERSION}" "${GITLEAKS_VERSION}" \
&& printf '{"rust":"%s","cargo-audit":"%s","syft":"%s","betterleaks":"%s","semgrep":"%s","ruff":"%s","cppcheck":"%s","mobsfscan":"%s","sbomqs":"%s","devskim":"%s","dotnet-runtime":"%s"}\n' \
"${RUST_VERSION}" "${CARGO_AUDIT_VERSION}" "${SYFT_VERSION}" "${BETTERLEAKS_VERSION}" \
"${SEMGREP_VERSION}" "${RUFF_VERSION}" "$(cppcheck --version | cut -d' ' -f2)" \
"${MOBSFSCAN_VERSION}" "${SBOMQS_VERSION}" "${DEVSKIM_VERSION}" "${DOTNET_RUNTIME_VERSION}" \
> /opt/pruefwerk/tool-versions.json
@@ -157,6 +157,10 @@ impl RunFindings {
self.adopt_legacy_rows(db, findings, &unknown, &stored_rows)
.await?,
);
stored_rows.extend(
self.adopt_renamed_secrets(db, findings, &unknown, &stored_rows)
.await?,
);
self.update_moved(db, findings, &stored_rows).await?;
let stored: HashSet<String> = stored_rows
.iter()
@@ -307,6 +311,119 @@ impl RunFindings {
Ok(adopted)
}
/// Give a secret the row an earlier run stored for it under another rule
/// (#516): the secret scanner's rules change between versions (gitleaks
/// to Betterleaks: a composite AWS rule, renamed vendor rules), and the
/// rule is part of the fingerprint. A row of [`SECRET_SCANNER`] with the
/// same target, file and match (`code_snippet`) under another rule, which
/// this run did not find again, is the same secret: it takes the new
/// fingerprint, rule, title, description and severity, and keeps its id,
/// status, triage and tracker issue.
///
/// # Returns
///
/// The adopted rows, as [`Self::adopt_legacy_rows`].
///
/// # Errors
///
/// A database error.
async fn adopt_renamed_secrets(
&mut self,
db: &Database,
findings: &[Finding],
unknown: &HashSet<String>,
stored_rows: &[Document],
) -> Result<Vec<Document>, AgentError> {
let known: HashSet<&str> = stored_rows
.iter()
.filter_map(|d| d.get_str("fingerprint").ok())
.collect();
let candidates: Vec<&Finding> = findings
.iter()
.filter(|f| f.scanner == SECRET_SCANNER)
.filter(|f| unknown.contains(&f.fingerprint) && !known.contains(f.fingerprint.as_str()))
.filter(|f| f.file_path.is_some() && f.code_snippet.is_some())
.collect();
if candidates.is_empty() {
return Ok(Vec::new());
}
// Rows this run found again are not another rule's.
let current: Vec<&str> = findings.iter().map(|f| f.fingerprint.as_str()).collect();
let places: Vec<Document> = candidates
.iter()
.map(|f| {
doc! {
"repo_id": &f.repo_id,
"file_path": f.file_path.as_deref(),
"code_snippet": f.code_snippet.as_deref(),
}
})
.collect();
let rows: Vec<Document> = db
.findings()
.clone_with_type::<Document>()
.find(doc! {
"scanner": SECRET_SCANNER,
"fingerprint": { "$nin": current },
"$or": places,
})
.projection(doc! {
"fingerprint": 1, "status": 1, "scanner": 1, "line_number": 1,
"repo_id": 1, "file_path": 1, "code_snippet": 1, "rule_id": 1,
})
.await?
.try_collect()
.await?;
let mut adopted = Vec::new();
let mut taken: HashSet<ObjectId> = HashSet::new();
for finding in candidates {
let row = rows.iter().find(|row| {
row.get_object_id("_id")
.is_ok_and(|id| !taken.contains(&id))
&& row.get_str("repo_id") == Ok(finding.repo_id.as_str())
&& row.get_str("file_path").ok() == finding.file_path.as_deref()
&& row.get_str("code_snippet").ok() == finding.code_snippet.as_deref()
&& row.get_str("rule_id").ok() != finding.rule_id.as_deref()
});
let Some(row) = row else { continue };
let (Ok(id), Ok(old)) = (row.get_object_id("_id"), row.get_str("fingerprint")) else {
continue;
};
taken.insert(id);
let severity = to_bson(&finding.severity)
.map_err(|e| AgentError::Other(format!("encode severity: {e}")))?;
db.findings()
.update_one(
doc! { "_id": id },
doc! {
"$set": {
"fingerprint": &finding.fingerprint,
"rule_id": finding.rule_id.as_deref(),
"title": &finding.title,
"description": &finding.description,
"severity": severity,
"line_number": finding.line_number,
"updated_at": mongodb::bson::DateTime::now(),
},
"$addToSet": { "legacy_fingerprints": old },
},
)
.await?;
let mut row = row.clone();
row.insert("fingerprint", finding.fingerprint.clone());
row.insert("line_number", finding.line_number);
adopted.push(row);
}
if !adopted.is_empty() {
tracing::info!(
scan_run_id = %self.scan_run_id,
adopted = adopted.len(),
"secrets stored under another rule of the secret scanner kept their findings"
);
}
Ok(adopted)
}
/// Move the stored rows of findings whose code moved (same content
/// fingerprint, another line) to the line this run found them at.
///
@@ -694,6 +811,10 @@ fn unanimous<'a>(
decisions.all(|d| d == Some(first)).then(|| first.clone())
}
/// The secret scanner's name on its findings. It stays `gitleaks` with
/// Betterleaks (#516), so fingerprints and issues carry over.
pub(crate) const SECRET_SCANNER: &str = "gitleaks";
/// The version tag in every content fingerprint, so a later change of what
/// it hashes can tell its own fingerprints apart.
const CONTENT_FINGERPRINT: &str = "content-v1";
+45 -23
View File
@@ -5,9 +5,21 @@ use compliance_core::traits::{ScanOutput, Scanner};
use compliance_core::CoreError;
use crate::pipeline::dedup;
use crate::pipeline::finding_store::SECRET_SCANNER;
/// Secret detection with Betterleaks (#516), the successor of gitleaks by its
/// author (MIT), which reads gitleaks' configuration and reports in its JSON
/// format. Its findings keep the scanner name `gitleaks`, so their
/// fingerprints and tracker issues carry over; a secret whose rule changed
/// keeps its finding too (see `RunFindings::adopt_renamed_secrets`).
///
/// Betterleaks can validate secrets against the providers' live APIs; that
/// sends them out and is never switched on (only `--validation` would).
pub struct GitleaksScanner;
/// The secret scanner's binary.
const BINARY: &str = "betterleaks";
/// gitleaks' own rules plus ours (Android signing passwords, Firebase API
/// keys), passed with `--config` on every run.
const RULES: &str = include_str!("../../rules/gitleaks.toml");
@@ -70,21 +82,32 @@ impl Drop for RunConfig {
}
}
/// How to point gitleaks at a tree. `detect` walks a git checkout's history;
/// on a directory that is not a checkout it scans **nothing** and reports no
/// leaks — a silent miss — so a plain tree (an uploaded source archive) is
/// scanned with `dir` instead.
/// How to point the scanner at a tree. `git` walks a checkout's history; a
/// plain tree (an uploaded source archive) has none, so it is scanned with
/// `dir`.
fn source_args(repo_path: &Path) -> &'static [&'static str] {
if repo_path.join(".git").exists() {
&["detect", "--source", "."]
&["git", "."]
} else {
&["dir", "."]
}
}
/// The arguments after the source and the configuration: JSON on stdout, no
/// banner, success whether or not secrets are found. No `--validation`.
const REPORT_ARGS: [&str; 7] = [
"--report-format",
"json",
"--report-path",
"-",
"--no-banner",
"--exit-code",
"0",
];
impl Scanner for GitleaksScanner {
fn name(&self) -> &str {
"gitleaks"
SECRET_SCANNER
}
fn scan_type(&self) -> ScanType {
@@ -97,34 +120,26 @@ impl Scanner for GitleaksScanner {
// `.gitleaks.toml` from the scanned repository, which could switch
// rules off.
let config = RunConfig::write().map_err(|e| CoreError::Scanner {
scanner: "gitleaks".to_string(),
scanner: SECRET_SCANNER.to_string(),
source: Box::new(e),
})?;
let output = tokio::time::timeout(
std::time::Duration::from_secs(300),
crate::pipeline::tool_cmd::tool("gitleaks", &[])
crate::pipeline::tool_cmd::tool(BINARY, &[])
.args(source_args(repo_path))
.arg("--config")
.arg(config.file())
.args([
"--report-format",
"json",
"--report-path",
"/dev/stdout",
"--no-banner",
"--exit-code",
"0",
])
.args(REPORT_ARGS)
.current_dir(repo_path)
.output(),
)
.await
.map_err(|_| CoreError::Scanner {
scanner: "gitleaks".to_string(),
scanner: SECRET_SCANNER.to_string(),
source: "timed out after 5 minutes".into(),
})?
.map_err(|e| CoreError::Scanner {
scanner: "gitleaks".to_string(),
scanner: SECRET_SCANNER.to_string(),
source: Box::new(e),
})?;
@@ -179,7 +194,7 @@ impl Scanner for GitleaksScanner {
let mut finding = Finding::new(
repo_id.to_string(),
fingerprint,
"gitleaks".to_string(),
SECRET_SCANNER.to_string(),
ScanType::SecretDetection,
title,
description,
@@ -319,12 +334,12 @@ mod tests {
/// by gitleaks whatever it is told, like an inline `gitleaks:allow`.)
#[tokio::test]
async fn mobile_secrets_are_found_whatever_the_repository_configures() {
if std::process::Command::new("gitleaks")
if std::process::Command::new(BINARY)
.arg("version")
.output()
.is_err()
{
eprintln!("SKIP: gitleaks not installed");
eprintln!("SKIP: betterleaks not installed");
return;
}
let dir = std::env::temp_dir().join(format!("cs-leaks-{}", uuid::Uuid::new_v4()));
@@ -340,6 +355,7 @@ mod tests {
),
// A repository trying to switch everything off.
(".gitleaks.toml", "[allowlist]\npaths = [\".*\"]\n"),
(".betterleaks.toml", "[allowlist]\npaths = [\".*\"]\n"),
];
for (path, content) in files {
let full = dir.join(path);
@@ -464,6 +480,12 @@ mod tests {
assert_eq!(results[0].rule_id, "generic-secret");
}
#[test]
fn secrets_are_never_validated_against_live_apis() {
// Validation sends the secrets to their providers (#516).
assert!(REPORT_ARGS.iter().all(|a| !a.starts_with("--validation")));
}
#[test]
fn a_plain_tree_is_scanned_as_a_directory() {
let dir = std::env::temp_dir().join(format!("cs-gitleaks-{}", uuid::Uuid::new_v4()));
@@ -471,7 +493,7 @@ mod tests {
// An uploaded archive is not a checkout: `detect` would scan nothing there.
assert_eq!(source_args(&dir), ["dir", "."]);
std::fs::create_dir_all(dir.join(".git")).expect("mkdir .git");
assert_eq!(source_args(&dir), ["detect", "--source", "."]);
assert_eq!(source_args(&dir), ["git", "."]);
std::fs::remove_dir_all(&dir).ok();
}
+139
View File
@@ -0,0 +1,139 @@
//! #516: the secret scanner's rules change between versions (gitleaks to
//! Betterleaks: a lone AWS key id is now `generic-api-key`), and the rule is
//! part of the fingerprint. A secret reported under another rule keeps its
//! finding: same row (so the same tracker issue), status and triage, with the
//! new rule. A row whose rule still reports it is left alone. Runs against a
//! live Mongo (`TEST_MONGODB_URI`) and skips cleanly without one.
#![allow(clippy::expect_used, clippy::unwrap_used)]
use compliance_agent::database::{Database, DatabasePool};
use compliance_agent::pipeline::finding_store::RunFindings;
use compliance_core::models::{Finding, FindingStatus, ScanType, Severity};
use mongodb::bson::doc;
const TARGET: &str = "target-1";
/// A secret scanner finding of `rule` for `secret` at `file:line`, as the
/// scanner reports it.
fn secret(rule: &str, file: &str, line: u32, secret: &str) -> Finding {
let mut f = Finding::new(
TARGET.into(),
format!("{rule}-{file}-{line}"),
"gitleaks".into(),
ScanType::SecretDetection,
format!("Secret detected: {rule}"),
format!("Potential secret ({rule}) found in {file}:{line}. Match: {secret}"),
Severity::High,
);
f.rule_id = Some(rule.into());
f.file_path = Some(file.into());
f.line_number = Some(line);
f.fingerprint_content = Some(secret.into());
f.code_snippet = Some(secret.into());
f
}
/// One scan of `tree` reporting `findings`, as the pipeline saves it.
async fn scan(db: &Database, tree: &std::path::Path, mut findings: Vec<Finding>) -> RunFindings {
let mut run = RunFindings::new("run").with_tree(tree.to_path_buf());
run.completed("gitleaks");
run.label(&mut findings);
run.save_new(db, &mut findings).await.unwrap();
run.write_back(db, &mut findings).await.unwrap();
run.resolve_missing(db, TARGET, &[]).await.unwrap();
run
}
async fn rows(db: &Database, file: &str) -> Vec<Finding> {
use futures_util::TryStreamExt;
let mut rows: Vec<Finding> = db
.findings()
.find(doc! { "repo_id": TARGET, "file_path": file })
.await
.unwrap()
.try_collect()
.await
.unwrap();
rows.sort_by(|a, b| a.rule_id.cmp(&b.rule_id));
rows
}
#[tokio::test]
async fn a_secret_keeps_its_finding_when_its_rule_changes() {
let uri = std::env::var("TEST_MONGODB_URI")
.unwrap_or_else(|_| "mongodb://root:example@localhost:27017/?authSource=admin".into());
let prefix = format!(
"secretrules_{}",
&uuid::Uuid::new_v4().simple().to_string()[..10]
);
let Ok(pool) = DatabasePool::connect(&uri, &prefix).await else {
eprintln!("SKIP secret_rules: no MongoDB reachable at {uri}");
return;
};
let tenant = "secret-rules";
let Ok(db) = pool.for_tenant_id(tenant).await else {
eprintln!("SKIP secret_rules: MongoDB at {uri} not usable");
return;
};
let tree = std::env::temp_dir().join(format!("cs-secretrules-{}", uuid::Uuid::new_v4()));
std::fs::create_dir_all(&tree).unwrap();
let key = "aws_key = \"AKIAZ3MSJH5K4QV7XWRT\"";
let token = "token: ghp_0123456789abcdefghijABCDEFGHIJ012345";
std::fs::write(tree.join("cfg.py"), format!("{key}\n")).unwrap();
std::fs::write(tree.join("ci.yml"), format!("{token}\n")).unwrap();
// Arrange: gitleaks found the key and a token; a person accepted the
// risk of the key.
scan(
&db,
&tree,
vec![
secret("aws-access-token", "cfg.py", 1, key),
secret("github-pat", "ci.yml", 1, token),
],
)
.await;
let before = rows(&db, "cfg.py").await;
assert_eq!(before.len(), 1);
db.findings()
.update_one(
doc! { "_id": before[0].id },
doc! { "$set": { "status": "accepted_risk" } },
)
.await
.unwrap();
// Act: Betterleaks reports the key under another rule; the token under
// its rule and, newly, a second one.
let run = scan(
&db,
&tree,
vec![
secret("generic-api-key", "cfg.py", 1, key),
secret("github-pat", "ci.yml", 1, token),
secret("generic-api-key", "ci.yml", 1, token),
],
)
.await;
// Assert: the key's row is the same, with its decision, under the new
// rule; nothing was closed or reopened.
let after = rows(&db, "cfg.py").await;
assert_eq!(after.len(), 1, "no new row for the key");
assert_eq!(after[0].id, before[0].id);
assert_eq!(after[0].status, FindingStatus::AcceptedRisk);
assert_eq!(after[0].rule_id.as_deref(), Some("generic-api-key"));
assert!(after[0]
.legacy_fingerprints
.contains(&before[0].fingerprint));
assert!(run.status_changed().is_empty(), "no close/reopen churn");
// The token is still reported under its rule: that row stays, and the
// new rule's finding is a finding of its own.
let token_rows = rows(&db, "ci.yml").await;
assert_eq!(token_rows.len(), 2);
assert_eq!(run.new_count(), 1);
let _ = std::fs::remove_dir_all(&tree);
pool.drop_tenant(tenant).await.ok();
}
+1 -1
View File
@@ -110,7 +110,7 @@ The most common types in a scan of source code:
| Type | Source |
|------|--------|
| **Codeanalyse (SAST)** | Semgrep; for C and C++ also cppcheck |
| **Zugangsdaten im Code** (Secrets) | gitleaks |
| **Zugangsdaten im Code** (Secrets) | Betterleaks |
| **Bekannte Schwachstelle (CVE)** | Components of the SBOM matched against OSV.dev and NVD |
| **Datenschutz** (Privacy / GDPR) | Prüfwerk's own pattern rules |
| **OAuth** | Prüfwerk's own pattern rules |
+1 -1
View File
@@ -10,7 +10,7 @@ in the sidebar switches it to English.
## What a scan covers
- **Static analysis (SAST)** -- Semgrep, and cppcheck for C and C++
- **Secrets** -- credentials committed to the code (gitleaks)
- **Secrets** -- credentials committed to the code (Betterleaks)
- **SBOM** -- the components, their versions and licenses, including libraries
copied into a firmware tree and the libraries of a CODESYS project
- **Known vulnerabilities (CVE)** -- the components matched against OSV.dev and NVD
+2 -2
View File
@@ -31,7 +31,7 @@ names while the scan runs.
are matched against OSV.dev; the firmware libraries against NVD by CPE.
5. **Privacy patterns** (*Datenschutz-Muster*) -- Prüfwerk's own GDPR and OAuth
pattern rules.
6. **Secrets in the code** (*Zugangsdaten im Code*) -- gitleaks.
6. **Secrets in the code** (*Zugangsdaten im Code*) -- Betterleaks.
7. **Code quality** (*Code-Qualität*) -- linters; those that have to run the
project's own code only where the deployment allows it (see
[What the scanner runs on your code](#what-the-scanner-runs-on-your-code)).
@@ -188,7 +188,7 @@ platform's own services.
## What the scanner runs on your code
Nearly every stage only *reads* your code: Semgrep, gitleaks, Syft, Ruff and the
Nearly every stage only *reads* your code: Semgrep, Betterleaks, Syft, Ruff and the
PLC parser parse files and never execute them, and they connect nowhere your
repository chooses. Two kinds of stage are different. Four have to run the
project to do their job:
+29 -7
View File
@@ -264,14 +264,36 @@ A scanner focused on data protection compliance, detecting:
- Unencrypted PII storage
- Cross-border data transfer issues
## gitleaks -- Secrets
## Betterleaks -- Secrets
[gitleaks](https://github.com/gitleaks/gitleaks) finds hardcoded secrets and
credentials: API keys, tokens, private keys, passwords. On a git checkout it
runs `gitleaks detect`, which also looks through the repository's history; on an
uploaded archive, which has no history, it scans the files with `gitleaks dir`.
Its findings have the type **Zugangsdaten im Code** (Secrets); the dashboard
shows the secret shortened.
[Betterleaks](https://github.com/betterleaks/betterleaks) (MIT, 1.9.0), the
successor of gitleaks by its author, finds hardcoded secrets and credentials:
API keys, tokens, private keys, passwords. It reads gitleaks' configuration:
Prüfwerk always passes its own `rules/gitleaks.toml` (gitleaks' rules plus ours
for Android signing passwords and Firebase keys), so a `.gitleaks.toml` or
`.betterleaks.toml` in a scanned repository cannot switch rules off. On a git
checkout it runs `betterleaks git`, which also looks through the repository's
history; on an uploaded archive, which has no history, it scans the files with
`betterleaks dir`. Its findings have the type **Zugangsdaten im Code**
(Secrets); the dashboard shows the secret shortened.
**Since #516 (replacing gitleaks 8.21.2):**
- The findings keep the scanner name `gitleaks`, so their fingerprints and
tracker issues carry over.
- Betterleaks has about 270 more rules, and on the nightly fixtures it also
finds hard-coded passwords in C/C++ sources (`generic-password`). Four
gitleaks rules have no exact counterpart (`datadog-access-token`,
`etsy-access-token`, `jfrog-api-key`, `jfrog-identity-token`), and a lone
AWS access key id is reported as `generic-api-key`, because Betterleaks'
`aws-access-token` pairs the key id with its secret key.
- A secret reported under another rule than before keeps its finding (same
row, status, triage and issue, now with the new rule), as long as the old
rule does not report it any more.
- **No live validation.** Betterleaks can check a secret against its
provider's API; that sends the secret out, needs DPA wording first, and is
never switched on (only the `--validation` flag would). The scan opens no
network connection.
## PLC Control-Logic Analyser
@@ -32,6 +32,7 @@ together on stage in one pass before the next prod promotion.
| #508 (B2) | Component creator (project URL) in the SBOM |
| #498 (4/4) | Draft ENISA notifications (CRA Art. 14) for actively exploited vulnerabilities |
| #498 (follow-up) | ENISA deadlines evaluated by the agent; one notification per CVE |
| #516 | Secret scanning with Betterleaks instead of gitleaks |
**Customer-visible on the next prod rescan** is marked **[visible]**: these
change what a customer sees on their existing targets, without them doing
@@ -702,6 +703,27 @@ Use the log4j target of check 31.
- **[visible]** deadlines as "fällig in"/"überfällig seit"; one draft per
vulnerability.
### 33. #516 Betterleaks instead of gitleaks
- **Do:** check the agent image: `betterleaks version` gives 1.9.0, no
`gitleaks` binary; `/opt/pruefwerk/tool-versions.json` lists
`betterleaks`.
- **Do:** rescan a target that had secret findings before (e.g. the Android
target with signing passwords, `fixtures/nightly/archive`). **Expect:** the
same findings (same ids and statuses, no close/reopen), scanner name still
`gitleaks`; tracker issues unchanged.
- **Do:** upload `fixtures/nightly/firmware/c-sensor-node`. **Expect:** two
new **Zugangsdaten im Code** findings, `generic-password` in `cli.cpp:8`
and `comms.c:9` (the planted passwords gitleaks missed).
- **Do:** a git target with a lone AWS key id `AKIA…` that had an
`aws-access-token` finding, which you mark "Risiko akzeptiert"; rescan.
**Expect:** the same finding, still accepted, now `generic-api-key`. Log:
`secrets stored under another rule of the secret scanner kept their
findings`.
- **Expect:** no outbound connection from the secret stage (no validation).
- **[visible]** more secret findings on some targets (new Betterleaks
rules); a few existing ones show another rule name.
## After the pass
- The nightly job on `main` is green with the new mobile targets.
@@ -12,6 +12,8 @@
"cppcheck:arrayIndexOutOfBounds sensors.c:15",
"cppcheck:memleak sensors.c:32",
"cppcheck:uninitvar sensors.c:19",
"gitleaks:generic-password cli.cpp:8",
"gitleaks:generic-password comms.c:9",
"semgrep:0xdea-raptor-insecure-api-rand-srand comms.c:35",
"semgrep:0xdea-raptor-insecure-api-sprintf-vsprintf comms.c:25",
"semgrep:0xdea-raptor-insecure-api-strcpy-strcat comms.c:20",