@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.
Files changed (90) hide show
  1. package/adapters/gate-8.sh +115 -73
  2. package/adapters/java.sh +373 -27
  3. package/adapters/powershell.sh +60 -5
  4. package/adapters/python.sh +38 -4
  5. package/build-integrity/__tests__/import-resolver.test.ts +59 -0
  6. package/build-integrity/gate-10.ts +17 -2
  7. package/gate-3.sh +51 -3
  8. package/gate-4.sh +32 -1
  9. package/gate-8.sh +115 -73
  10. package/hooks/gate-3.sh +51 -3
  11. package/hooks/gate-4.sh +32 -1
  12. package/hooks/gate-8.sh +115 -73
  13. package/hooks/pre-commit +404 -62
  14. package/lib/__tests__/doctor-spawn-capability.test.js +116 -0
  15. package/lib/__tests__/doctor-tui-skill-freshness.test.js +49 -10
  16. package/lib/doctor-tui.js +21 -3
  17. package/lib/doctor.js +111 -8
  18. package/lib/gate-audit.ts +3 -0
  19. package/lib/mattpocock-license-verdict.json +1 -1
  20. package/mock-policy/AGENTS.md +4 -4
  21. package/mutation/AGENTS.md +4 -4
  22. package/package.json +2 -2
  23. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  24. package/plugins/claude-code/skills/admin-template-guidelines/SKILL.md +1 -0
  25. package/plugins/claude-code/skills/batch-grill-me/SKILL.md +1 -0
  26. package/plugins/claude-code/skills/clipboard-vision/SKILL.md +1 -0
  27. package/plugins/claude-code/skills/delphi-review/AGENTS.md +4 -4
  28. package/plugins/claude-code/skills/domain-modeling/SKILL.md +1 -0
  29. package/plugins/claude-code/skills/grill-with-docs/SKILL.md +1 -0
  30. package/plugins/claude-code/skills/grilling/SKILL.md +1 -0
  31. package/plugins/claude-code/skills/improve-codebase-architecture/SKILL.md +1 -0
  32. package/plugins/claude-code/skills/ralph-loop/SKILL.md +1 -0
  33. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +4 -4
  34. package/plugins/claude-code/skills/test-driven-development/SKILL.md +1 -0
  35. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +4 -4
  36. package/plugins/claude-code/skills/test-specification-alignment/SKILL.md +1 -0
  37. package/plugins/claude-code/skills/to-issues/SKILL.md +1 -0
  38. package/plugins/dsh/package.json +1 -1
  39. package/plugins/dsh/skills/admin-template-guidelines/SKILL.md +1 -0
  40. package/plugins/dsh/skills/batch-grill-me/SKILL.md +1 -0
  41. package/plugins/dsh/skills/clipboard-vision/SKILL.md +1 -0
  42. package/plugins/dsh/skills/delphi-review/AGENTS.md +4 -4
  43. package/plugins/dsh/skills/domain-modeling/SKILL.md +1 -0
  44. package/plugins/dsh/skills/grill-with-docs/SKILL.md +1 -0
  45. package/plugins/dsh/skills/grilling/SKILL.md +1 -0
  46. package/plugins/dsh/skills/improve-codebase-architecture/SKILL.md +1 -0
  47. package/plugins/dsh/skills/ralph-loop/SKILL.md +1 -0
  48. package/plugins/dsh/skills/sprint-flow/AGENTS.md +4 -4
  49. package/plugins/dsh/skills/test-driven-development/SKILL.md +1 -0
  50. package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +4 -4
  51. package/plugins/dsh/skills/test-specification-alignment/SKILL.md +1 -0
  52. package/plugins/dsh/skills/to-issues/SKILL.md +1 -0
  53. package/plugins/opencode/package.json +1 -1
  54. package/plugins/opencode/skills/admin-template-guidelines/SKILL.md +1 -0
  55. package/plugins/opencode/skills/batch-grill-me/SKILL.md +1 -0
  56. package/plugins/opencode/skills/clipboard-vision/SKILL.md +1 -0
  57. package/plugins/opencode/skills/delphi-review/AGENTS.md +4 -4
  58. package/plugins/opencode/skills/domain-modeling/SKILL.md +1 -0
  59. package/plugins/opencode/skills/grill-with-docs/SKILL.md +1 -0
  60. package/plugins/opencode/skills/grilling/SKILL.md +1 -0
  61. package/plugins/opencode/skills/improve-codebase-architecture/SKILL.md +1 -0
  62. package/plugins/opencode/skills/ralph-loop/SKILL.md +1 -0
  63. package/plugins/opencode/skills/sprint-flow/AGENTS.md +4 -4
  64. package/plugins/opencode/skills/test-driven-development/SKILL.md +1 -0
  65. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +4 -4
  66. package/plugins/opencode/skills/test-specification-alignment/SKILL.md +1 -0
  67. package/plugins/opencode/skills/to-issues/SKILL.md +1 -0
  68. package/plugins/qoder/plugin.json +1 -1
  69. package/plugins/qoder/skills/delphi-review/AGENTS.md +4 -4
  70. package/plugins/qoder/skills/sprint-flow/AGENTS.md +4 -4
  71. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +4 -4
  72. package/principles/AGENTS.md +4 -4
  73. package/principles/adapters/__tests__/java.test.ts +317 -0
  74. package/principles/adapters/java.ts +325 -13
  75. package/principles/boy-scout.ts +36 -6
  76. package/scripts/sync-package-content.js +13 -6
  77. package/skills/admin-template-guidelines/SKILL.md +1 -0
  78. package/skills/batch-grill-me/SKILL.md +1 -0
  79. package/skills/clipboard-vision/SKILL.md +1 -0
  80. package/skills/delphi-review/AGENTS.md +4 -4
  81. package/skills/domain-modeling/SKILL.md +1 -0
  82. package/skills/grill-with-docs/SKILL.md +1 -0
  83. package/skills/grilling/SKILL.md +1 -0
  84. package/skills/improve-codebase-architecture/SKILL.md +1 -0
  85. package/skills/ralph-loop/SKILL.md +1 -0
  86. package/skills/sprint-flow/AGENTS.md +4 -4
  87. package/skills/test-driven-development/SKILL.md +1 -0
  88. package/skills/test-specification-alignment/AGENTS.md +4 -4
  89. package/skills/test-specification-alignment/SKILL.md +1 -0
  90. package/skills/to-issues/SKILL.md +1 -0
@@ -1,11 +1,14 @@
1
1
  # ============================================================================
2
- # GATE 8: Secret Scanning (gitleaks)
3
- # Detects secrets (API keys, passwords, tokens) in staged files
4
- # Tool: gitleaks -- https://github.com/gitleaks/gitleaks
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 [ -n "$GITLEAKS_CMD" ]; then
20
- GITLEAKS_CONFIG=""
21
- if [ -f ".gitleaks.toml" ]; then
22
- # gitleaks is a native binary and may not understand MSYS paths, so pass an
23
- # absolute path in the host's own format when we can derive one (#449).
24
- if command -v cygpath >/dev/null 2>&1; then
25
- GITLEAKS_CONFIG="--config=$(cygpath -w "$(pwd)/.gitleaks.toml")"
26
- else
27
- GITLEAKS_CONFIG="--config=$(pwd)/.gitleaks.toml"
28
- fi
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
- # Scan the INDEX, not history. gitleaks 8.x `git --pre-commit` walks committed
32
- # revisions and reports "0 commits scanned" on a pre-commit run -- so a staged
33
- # secret was never seen and Gate 8 always passed. `git --staged` scans
34
- # `git diff --cached`, which is exactly the pre-commit payload (#449).
35
- GITLEAKS_REPORT="${TMPDIR:-/tmp}/gitleaks-report.json"
36
- rm -f "$GITLEAKS_REPORT"
37
- GITLEAKS_OUTPUT=$($GITLEAKS_CMD git --staged --redact --no-banner $GITLEAKS_CONFIG --report-format=json --report-path="$GITLEAKS_REPORT" 2>&1)
38
- GITLEAKS_EXIT=$?
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
- if [ "$GITLEAKS_EXIT" -eq 0 ]; then
41
- # Decide SKIP from the REPORT ARTIFACT, not from log wording. Parsing stdout
42
- # meant a gitleaks message change would silently turn a no-evidence run into
43
- # a PASS -- the same fail-open class this gate just fixed (#449).
44
- # The report exists and is a JSON array of findings; `[]` == clean scan.
45
- GITLEAKS_FINDINGS="?"
46
- if [ -f "$GITLEAKS_REPORT" ]; then
47
- # A report that is not shaped like a JSON array is no evidence: leave the
48
- # '?' sentinel so the gate reports SKIP, never a PASS it cannot support
49
- # (the fail-closed-on-the-claim rule #449 established).
50
- if grep -q '^\[' "$GITLEAKS_REPORT" 2>/dev/null; then
51
- # Count occurrences, not matching lines: `grep -c` prints its own zero AND
52
- # exits 1 on a clean report, so the old `|| echo 0` handed the verdict table
53
- # $'0\n0' -- no branch matched and a clean scan was BLOCKED as if it leaked
54
- # (#493). wc -l emits exactly one value, and `|| true` keeps the assignment
55
- # errexit/pipefail-safe (#489).
56
- GITLEAKS_FINDINGS=$(grep -o '"RuleID"' "$GITLEAKS_REPORT" 2>/dev/null | wc -l | tr -d '[:space:]') || true
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
- if [ "$GITLEAKS_FINDINGS" = "0" ]; then
61
- echo " ✅ PASSED - No secrets detected."
62
- GATE_8_STATUS="PASS"
63
- elif [ "$GITLEAKS_FINDINGS" = "?" ]; then
64
- # Exit 0 but no readable report: we have no evidence the scan happened.
65
- # Fail closed on the *claim*: report SKIP, never PASS.
66
- echo " ⚠️ gitleaks exited 0 but produced no readable report"
67
- echo " ⏭️ SKIPPED - secret scanning produced no evidence (not a pass)"
68
- GATE_8_STATUS="SKIP"
69
- else
70
- echo " ❌ BLOCKED - gitleaks reported $GITLEAKS_FINDINGS finding(s)"
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 "❌ BLOCKED - Secrets detected in staged files."
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
- echo " ⚠️ gitleaks exited with code $GITLEAKS_EXIT - skipping gate"
91
- echo " ✅ Secret Scanning (SKIP, gitleaks error)"
92
- GATE_8_STATUS="SKIP"
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 " ℹ️ gitleaks not installed — secret scanning unavailable"
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"