@boyingliu01/xp-gate 0.20.0 → 0.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/adapters/gate-8.sh +115 -73
- package/adapters/java.sh +373 -27
- package/adapters/powershell.sh +60 -5
- package/adapters/python.sh +38 -4
- package/build-integrity/__tests__/import-resolver.test.ts +59 -0
- package/build-integrity/gate-10.ts +17 -2
- package/gate-3.sh +51 -3
- package/gate-4.sh +32 -1
- package/gate-8.sh +115 -73
- package/hooks/gate-3.sh +51 -3
- package/hooks/gate-4.sh +32 -1
- package/hooks/gate-8.sh +115 -73
- package/hooks/pre-commit +404 -62
- package/lib/__tests__/doctor-spawn-capability.test.js +116 -0
- package/lib/__tests__/doctor-tui-skill-freshness.test.js +49 -10
- package/lib/doctor-tui.js +21 -3
- package/lib/doctor.js +111 -8
- package/lib/gate-audit.ts +3 -0
- package/lib/mattpocock-license-verdict.json +1 -1
- package/mock-policy/AGENTS.md +4 -4
- package/mutation/AGENTS.md +4 -4
- package/package.json +2 -2
- package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code/skills/admin-template-guidelines/SKILL.md +1 -0
- package/plugins/claude-code/skills/batch-grill-me/SKILL.md +1 -0
- package/plugins/claude-code/skills/clipboard-vision/SKILL.md +1 -0
- package/plugins/claude-code/skills/delphi-review/AGENTS.md +4 -4
- package/plugins/claude-code/skills/domain-modeling/SKILL.md +1 -0
- package/plugins/claude-code/skills/grill-with-docs/SKILL.md +1 -0
- package/plugins/claude-code/skills/grilling/SKILL.md +1 -0
- package/plugins/claude-code/skills/improve-codebase-architecture/SKILL.md +1 -0
- package/plugins/claude-code/skills/ralph-loop/SKILL.md +1 -0
- package/plugins/claude-code/skills/sprint-flow/AGENTS.md +4 -4
- package/plugins/claude-code/skills/test-driven-development/SKILL.md +1 -0
- package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +4 -4
- package/plugins/claude-code/skills/test-specification-alignment/SKILL.md +1 -0
- package/plugins/claude-code/skills/to-issues/SKILL.md +1 -0
- package/plugins/dsh/package.json +1 -1
- package/plugins/dsh/skills/admin-template-guidelines/SKILL.md +1 -0
- package/plugins/dsh/skills/batch-grill-me/SKILL.md +1 -0
- package/plugins/dsh/skills/clipboard-vision/SKILL.md +1 -0
- package/plugins/dsh/skills/delphi-review/AGENTS.md +4 -4
- package/plugins/dsh/skills/domain-modeling/SKILL.md +1 -0
- package/plugins/dsh/skills/grill-with-docs/SKILL.md +1 -0
- package/plugins/dsh/skills/grilling/SKILL.md +1 -0
- package/plugins/dsh/skills/improve-codebase-architecture/SKILL.md +1 -0
- package/plugins/dsh/skills/ralph-loop/SKILL.md +1 -0
- package/plugins/dsh/skills/sprint-flow/AGENTS.md +4 -4
- package/plugins/dsh/skills/test-driven-development/SKILL.md +1 -0
- package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +4 -4
- package/plugins/dsh/skills/test-specification-alignment/SKILL.md +1 -0
- package/plugins/dsh/skills/to-issues/SKILL.md +1 -0
- package/plugins/opencode/package.json +1 -1
- package/plugins/opencode/skills/admin-template-guidelines/SKILL.md +1 -0
- package/plugins/opencode/skills/batch-grill-me/SKILL.md +1 -0
- package/plugins/opencode/skills/clipboard-vision/SKILL.md +1 -0
- package/plugins/opencode/skills/delphi-review/AGENTS.md +4 -4
- package/plugins/opencode/skills/domain-modeling/SKILL.md +1 -0
- package/plugins/opencode/skills/grill-with-docs/SKILL.md +1 -0
- package/plugins/opencode/skills/grilling/SKILL.md +1 -0
- package/plugins/opencode/skills/improve-codebase-architecture/SKILL.md +1 -0
- package/plugins/opencode/skills/ralph-loop/SKILL.md +1 -0
- package/plugins/opencode/skills/sprint-flow/AGENTS.md +4 -4
- package/plugins/opencode/skills/test-driven-development/SKILL.md +1 -0
- package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +4 -4
- package/plugins/opencode/skills/test-specification-alignment/SKILL.md +1 -0
- package/plugins/opencode/skills/to-issues/SKILL.md +1 -0
- package/plugins/qoder/plugin.json +1 -1
- package/plugins/qoder/skills/delphi-review/AGENTS.md +4 -4
- package/plugins/qoder/skills/sprint-flow/AGENTS.md +4 -4
- package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +4 -4
- package/principles/AGENTS.md +4 -4
- package/principles/adapters/__tests__/java.test.ts +317 -0
- package/principles/adapters/java.ts +325 -13
- package/principles/boy-scout.ts +36 -6
- package/scripts/sync-package-content.js +13 -6
- package/skills/admin-template-guidelines/SKILL.md +1 -0
- package/skills/batch-grill-me/SKILL.md +1 -0
- package/skills/clipboard-vision/SKILL.md +1 -0
- package/skills/delphi-review/AGENTS.md +4 -4
- package/skills/domain-modeling/SKILL.md +1 -0
- package/skills/grill-with-docs/SKILL.md +1 -0
- package/skills/grilling/SKILL.md +1 -0
- package/skills/improve-codebase-architecture/SKILL.md +1 -0
- package/skills/ralph-loop/SKILL.md +1 -0
- package/skills/sprint-flow/AGENTS.md +4 -4
- package/skills/test-driven-development/SKILL.md +1 -0
- package/skills/test-specification-alignment/AGENTS.md +4 -4
- package/skills/test-specification-alignment/SKILL.md +1 -0
- package/skills/to-issues/SKILL.md +1 -0
package/adapters/gate-8.sh
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
# ============================================================================
|
|
2
|
-
# GATE 8: Secret Scanning (gitleaks)
|
|
3
|
-
# Detects secrets (API keys, passwords, tokens) in staged files
|
|
4
|
-
#
|
|
2
|
+
# GATE 8: Secret Scanning (gitleaks + detect-secrets)
|
|
3
|
+
# Detects secrets (API keys, passwords, tokens) in staged files.
|
|
4
|
+
# Tools:
|
|
5
|
+
# gitleaks -- primary, fail-closed (missing or non-0/1 exit => BLOCK, #499)
|
|
6
|
+
# detect-secrets -- secondary, baseline-diff: only blocks on secrets NOT in
|
|
7
|
+
# .secrets.baseline; silently does nothing when unavailable
|
|
5
8
|
# ============================================================================
|
|
6
9
|
|
|
7
10
|
2>&1 echo ""
|
|
8
|
-
2>&1 echo "→ Gate 8: Secret scanning (gitleaks)..."
|
|
11
|
+
2>&1 echo "→ Gate 8: Secret scanning (gitleaks + detect-secrets)..."
|
|
9
12
|
GATE_8_START=$(gate_start_ms)
|
|
10
13
|
|
|
11
14
|
# Gitleaks availability check
|
|
@@ -16,85 +19,124 @@ elif [ -f "$HOME/.local/bin/gitleaks" ]; then
|
|
|
16
19
|
GITLEAKS_CMD="$HOME/.local/bin/gitleaks"
|
|
17
20
|
fi
|
|
18
21
|
|
|
19
|
-
if [ -
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
if [ -z "$GITLEAKS_CMD" ]; then
|
|
23
|
+
# fail-closed (#499): an uninstalled gitleaks used to SKIP the gate, so any
|
|
24
|
+
# contributor without it shipped commits with zero secret protection and no
|
|
25
|
+
# signal. A security gate that cannot run must not report success.
|
|
26
|
+
echo " ❌ BLOCKED - gitleaks not installed (fail-closed, #499)."
|
|
27
|
+
echo " Secret scanning is mandatory before commit. Install gitleaks then retry:"
|
|
28
|
+
echo " macOS: brew install gitleaks"
|
|
29
|
+
echo " Windows: winget install gitleaks"
|
|
30
|
+
echo " Linux: scripts/install-gitleaks.sh (or https://github.com/gitleaks/gitleaks)"
|
|
31
|
+
exit 1
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
GITLEAKS_CONFIG=""
|
|
35
|
+
if [ -f ".gitleaks.toml" ]; then
|
|
36
|
+
# gitleaks is a native binary and may not understand MSYS paths, so pass an
|
|
37
|
+
# absolute path in the host's own format when we can derive one (#449).
|
|
38
|
+
if command -v cygpath >/dev/null 2>&1; then
|
|
39
|
+
GITLEAKS_CONFIG="--config=$(cygpath -w "$(pwd)/.gitleaks.toml")"
|
|
40
|
+
else
|
|
41
|
+
GITLEAKS_CONFIG="--config=$(pwd)/.gitleaks.toml"
|
|
29
42
|
fi
|
|
43
|
+
fi
|
|
30
44
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
45
|
+
# Scan the INDEX, not history. gitleaks 8.x `git --pre-commit` walks committed
|
|
46
|
+
# revisions and reports "0 commits scanned" on a pre-commit run -- so a staged
|
|
47
|
+
# secret was never seen and Gate 8 always passed. `git --staged` scans
|
|
48
|
+
# `git diff --cached`, which is exactly the pre-commit payload (#449).
|
|
49
|
+
GITLEAKS_REPORT="${TMPDIR:-/tmp}/gitleaks-report.json"
|
|
50
|
+
rm -f "$GITLEAKS_REPORT"
|
|
51
|
+
GITLEAKS_OUTPUT=$($GITLEAKS_CMD git --staged --redact --no-banner $GITLEAKS_CONFIG --report-format=json --report-path="$GITLEAKS_REPORT" 2>&1)
|
|
52
|
+
GITLEAKS_EXIT=$?
|
|
39
53
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
fi
|
|
54
|
+
if [ "$GITLEAKS_EXIT" -eq 0 ]; then
|
|
55
|
+
# Decide SKIP from the REPORT ARTIFACT, not from log wording. Parsing stdout
|
|
56
|
+
# meant a gitleaks message change would silently turn a no-evidence run into
|
|
57
|
+
# a PASS -- the same fail-open class this gate just fixed (#449).
|
|
58
|
+
# The report exists and is a JSON array of findings; `[]` == clean scan.
|
|
59
|
+
GITLEAKS_FINDINGS="?"
|
|
60
|
+
if [ -f "$GITLEAKS_REPORT" ]; then
|
|
61
|
+
# A report that is not shaped like a JSON array is no evidence: leave the
|
|
62
|
+
# '?' sentinel so the gate reports SKIP, never a PASS it cannot support
|
|
63
|
+
# (the fail-closed-on-the-claim rule #449 established).
|
|
64
|
+
if grep -q '^\[' "$GITLEAKS_REPORT" 2>/dev/null; then
|
|
65
|
+
# Count occurrences, not matching lines: `grep -c` prints its own zero AND
|
|
66
|
+
# exits 1 on a clean report, so the old `|| echo 0` handed the verdict table
|
|
67
|
+
# $'0\n0' -- no branch matched and a clean scan was BLOCKED as if it leaked
|
|
68
|
+
# (#493). wc -l emits exactly one value, and `|| true` keeps the assignment
|
|
69
|
+
# errexit/pipefail-safe (#489).
|
|
70
|
+
GITLEAKS_FINDINGS=$(grep -o '"RuleID"' "$GITLEAKS_REPORT" 2>/dev/null | wc -l | tr -d '[:space:]') || true
|
|
58
71
|
fi
|
|
72
|
+
fi
|
|
59
73
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
echo "$GITLEAKS_OUTPUT"
|
|
72
|
-
echo ""
|
|
73
|
-
echo "Remediation: remove the secret, or allowlist a false positive in .gitleaks.toml."
|
|
74
|
-
exit 1
|
|
75
|
-
fi
|
|
76
|
-
elif [ "$GITLEAKS_EXIT" -eq 1 ]; then
|
|
77
|
-
# Secrets found — output details
|
|
74
|
+
if [ "$GITLEAKS_FINDINGS" = "0" ]; then
|
|
75
|
+
echo " ✅ PASSED - No secrets detected."
|
|
76
|
+
GATE_8_STATUS="PASS"
|
|
77
|
+
elif [ "$GITLEAKS_FINDINGS" = "?" ]; then
|
|
78
|
+
# Exit 0 but no readable report: we have no evidence the scan happened.
|
|
79
|
+
# Fail closed on the *claim*: report SKIP, never PASS.
|
|
80
|
+
echo " ⚠️ gitleaks exited 0 but produced no readable report"
|
|
81
|
+
echo " ⏭️ SKIPPED - secret scanning produced no evidence (not a pass)"
|
|
82
|
+
GATE_8_STATUS="SKIP"
|
|
83
|
+
else
|
|
84
|
+
echo " ❌ BLOCKED - gitleaks reported $GITLEAKS_FINDINGS finding(s)"
|
|
78
85
|
echo "$GITLEAKS_OUTPUT"
|
|
79
86
|
echo ""
|
|
80
|
-
echo "
|
|
81
|
-
echo ""
|
|
82
|
-
echo "Remediation options:"
|
|
83
|
-
echo " 1. Remove the secret and use environment variables instead"
|
|
84
|
-
echo " 2. Add a false positive to .gitleaks.toml allowlist"
|
|
85
|
-
echo " 3. Use git secret or vault for sensitive data"
|
|
86
|
-
echo ""
|
|
87
|
-
echo "See: https://github.com/gitleaks/gitleaks"
|
|
87
|
+
echo "Remediation: remove the secret, or allowlist a false positive in .gitleaks.toml."
|
|
88
88
|
exit 1
|
|
89
|
+
fi
|
|
90
|
+
elif [ "$GITLEAKS_EXIT" -eq 1 ]; then
|
|
91
|
+
# Secrets found — output details
|
|
92
|
+
echo "$GITLEAKS_OUTPUT"
|
|
93
|
+
echo ""
|
|
94
|
+
echo " ❌ BLOCKED - Secrets detected in staged files."
|
|
95
|
+
echo ""
|
|
96
|
+
echo "Remediation options:"
|
|
97
|
+
echo " 1. Remove the secret and use environment variables instead"
|
|
98
|
+
echo " 2. Add a false positive to .gitleaks.toml allowlist"
|
|
99
|
+
echo " 3. Use git secret or vault for sensitive data"
|
|
100
|
+
echo ""
|
|
101
|
+
echo "See: https://github.com/gitleaks/gitleaks"
|
|
102
|
+
exit 1
|
|
103
|
+
else
|
|
104
|
+
# fail-closed (#499): a non-0/1 exit (config error, crash) used to SKIP, which
|
|
105
|
+
# let a broken scanner wave every commit through without any scan.
|
|
106
|
+
echo " ❌ BLOCKED - gitleaks exited with code $GITLEAKS_EXIT (fail-closed, #499)."
|
|
107
|
+
echo "$GITLEAKS_OUTPUT"
|
|
108
|
+
echo " Secret scanning could not complete; fix the gitleaks error above and retry."
|
|
109
|
+
exit 1
|
|
110
|
+
fi
|
|
111
|
+
|
|
112
|
+
# ---- detect-secrets(次要防线,基线比对)----
|
|
113
|
+
# detect-secrets-hook comes from the project's Python dev extra; it blocks only
|
|
114
|
+
# on secrets NOT yet registered in .secrets.baseline, so test-fixture dummy keys
|
|
115
|
+
# recorded in the baseline never trip it.
|
|
116
|
+
#
|
|
117
|
+
# The file list is piped NUL-delimited STRAIGHT into xargs -0 — never through a
|
|
118
|
+
# command substitution. `var=$(cmd -z)` strips every NUL byte (bash cannot hold
|
|
119
|
+
# NULs in a variable), which concatenated all filenames into one giant
|
|
120
|
+
# nonexistent path and would have BLOCKED every commit once a project shipped
|
|
121
|
+
# both detect-secrets-hook and .secrets.baseline. The pipeline lives inside an
|
|
122
|
+
# if-condition (errexit-exempt); a non-zero hook exit lands in the else branch.
|
|
123
|
+
if command -v detect-secrets-hook >/dev/null 2>&1 && [ -f ".secrets.baseline" ]; then
|
|
124
|
+
DS_TMP="$(dirname "$(mktemp -u)")/ds-output.$$"
|
|
125
|
+
if git diff --cached --name-only --diff-filter=ACM -z \
|
|
126
|
+
| xargs -0 detect-secrets-hook --baseline .secrets.baseline > "$DS_TMP" 2>&1; then
|
|
127
|
+
echo " ✅ detect-secrets PASSED - no new secrets beyond baseline."
|
|
89
128
|
else
|
|
90
|
-
|
|
91
|
-
echo "
|
|
92
|
-
|
|
129
|
+
cat "$DS_TMP"
|
|
130
|
+
echo ""
|
|
131
|
+
echo " ❌ BLOCKED - detect-secrets found secrets not in .secrets.baseline."
|
|
132
|
+
echo " If these are false positives, regenerate the baseline (cross-platform):"
|
|
133
|
+
echo " detect-secrets scan --update .secrets.baseline && git add .secrets.baseline"
|
|
134
|
+
rm -f "$DS_TMP"
|
|
135
|
+
exit 1
|
|
93
136
|
fi
|
|
137
|
+
rm -f "$DS_TMP"
|
|
94
138
|
else
|
|
95
|
-
echo "
|
|
96
|
-
echo " Install: brew install gitleaks (macOS) | winget install gitleaks (Windows) | scripts/install-gitleaks.sh (Linux)"
|
|
97
|
-
echo " ⏭️ SKIPPED - Secret scanning (gitleaks not installed)"
|
|
98
|
-
GATE_8_STATUS="SKIP"
|
|
139
|
+
echo " ⚠️ detect-secrets-hook unavailable (install: pip install -e \".[dev]\") — gitleaks only."
|
|
99
140
|
fi
|
|
141
|
+
|
|
100
142
|
record_gate_audit "gate-8" "secret-scanning" "$GATE_8_STATUS" "0" "$GATE_8_START"
|