feat(kyberforge): execute the plugin→APM conversion #95
@@ -87,14 +87,14 @@ for fpath in find_agents_md(repo_root):
|
|||||||
with open(fpath, encoding="utf-8", errors="replace") as f:
|
with open(fpath, encoding="utf-8", errors="replace") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
for i, line in enumerate(lines, start=1):
|
for i, line in enumerate(lines, start=1):
|
||||||
if PLACEHOLDER_RE.search(line):
|
|
||||||
continue
|
|
||||||
for label, pattern in PATTERNS:
|
for label, pattern in PATTERNS:
|
||||||
m = pattern.search(line)
|
m = pattern.search(line)
|
||||||
if not m:
|
if not m:
|
||||||
continue
|
continue
|
||||||
# Re-check placeholder allowlist against just the matched value, in case
|
# Scope the placeholder allowlist to the matched secret-candidate
|
||||||
# the placeholder marker sits outside the regex's own match span.
|
# substring only. Checking the whole line would let an unrelated
|
||||||
|
# placeholder-looking token elsewhere on the line (e.g. in a
|
||||||
|
# trailing comment) suppress detection of a real credential.
|
||||||
value = m.group(0)
|
value = m.group(0)
|
||||||
if PLACEHOLDER_RE.search(value):
|
if PLACEHOLDER_RE.search(value):
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -52,6 +52,19 @@ EOF
|
|||||||
assert_output --partial "connection string"
|
assert_output --partial "connection string"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "still catches a real secret when a placeholder token sits elsewhere on the same line" {
|
||||||
|
cat > "$TMPDIR/AGENTS.md" <<'EOF'
|
||||||
|
# AGENTS.md
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
- AWS_ACCESS_KEY_ID=AKIAABCDEFGHIJKLMNOP # see your-token-here for an example, gitleaks:allow (synthetic fixture — this test verifies the placeholder allowlist is scoped to the matched value, not the whole line)
|
||||||
|
EOF
|
||||||
|
run bash "$SCRIPT" "$TMPDIR"
|
||||||
|
assert_failure
|
||||||
|
assert_output --partial "AWS access key ID"
|
||||||
|
assert_output --partial "AGENTS.md:4"
|
||||||
|
}
|
||||||
|
|
||||||
@test "detects secrets in a nested AGENTS.md, not just root" {
|
@test "detects secrets in a nested AGENTS.md, not just root" {
|
||||||
mkdir -p "$TMPDIR/packages/api"
|
mkdir -p "$TMPDIR/packages/api"
|
||||||
cat > "$TMPDIR/AGENTS.md" <<'EOF'
|
cat > "$TMPDIR/AGENTS.md" <<'EOF'
|
||||||
|
|||||||
@@ -87,14 +87,14 @@ for fpath in find_agents_md(repo_root):
|
|||||||
with open(fpath, encoding="utf-8", errors="replace") as f:
|
with open(fpath, encoding="utf-8", errors="replace") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
for i, line in enumerate(lines, start=1):
|
for i, line in enumerate(lines, start=1):
|
||||||
if PLACEHOLDER_RE.search(line):
|
|
||||||
continue
|
|
||||||
for label, pattern in PATTERNS:
|
for label, pattern in PATTERNS:
|
||||||
m = pattern.search(line)
|
m = pattern.search(line)
|
||||||
if not m:
|
if not m:
|
||||||
continue
|
continue
|
||||||
# Re-check placeholder allowlist against just the matched value, in case
|
# Scope the placeholder allowlist to the matched secret-candidate
|
||||||
# the placeholder marker sits outside the regex's own match span.
|
# substring only. Checking the whole line would let an unrelated
|
||||||
|
# placeholder-looking token elsewhere on the line (e.g. in a
|
||||||
|
# trailing comment) suppress detection of a real credential.
|
||||||
value = m.group(0)
|
value = m.group(0)
|
||||||
if PLACEHOLDER_RE.search(value):
|
if PLACEHOLDER_RE.search(value):
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user