@codyswann/lisa 6.0.9 → 6.0.10

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 (78) hide show
  1. package/all/copy-overwrite/scripts/lisa-hooks/sonar-secrets.sh +130 -47
  2. package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
  3. package/dist/core/lisa-owned-hash-ledger.js +2 -0
  4. package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
  5. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  6. package/dist/core/nightly-e2e-guard-behavior-certificate.js.map +1 -1
  7. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  8. package/dist/core/upstream-evidence-manifest.js +3 -2
  9. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  10. package/package.json +4 -4
  11. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  12. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  13. package/plugins/lisa/hooks/sonar-secrets.sh +130 -47
  14. package/plugins/lisa-agy/plugin.json +1 -1
  15. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  16. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  17. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  18. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  19. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  20. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  21. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  22. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  23. package/plugins/lisa-copilot/hooks/sonar-secrets.sh +130 -47
  24. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  25. package/plugins/lisa-cursor/hooks/sonar-secrets.sh +130 -47
  26. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  27. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  28. package/plugins/lisa-devin/hooks/sonar-secrets.sh +130 -47
  29. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  30. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  31. package/plugins/lisa-expo-agy/plugin.json +1 -1
  32. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  33. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  34. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  35. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  36. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  37. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  38. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  39. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  40. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  41. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  42. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  43. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  44. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  45. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  46. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  47. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  48. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  49. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  50. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  51. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  52. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  53. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  54. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  55. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  56. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  57. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  58. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  59. package/plugins/lisa-rails-agy/plugin.json +1 -1
  60. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  61. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  62. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  63. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  64. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  65. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  66. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  67. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  68. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  69. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  70. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  71. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  72. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  73. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  74. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  75. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  76. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  77. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  78. package/plugins/src/base/hooks/sonar-secrets.sh +130 -47
@@ -62,8 +62,38 @@ set -uo pipefail
62
62
  # the drain at exactly the moment this wrapper is proving `sonar` is absent
63
63
  # (CodySwannGT/lisa#3308). An empty delimiter means "read through NUL or EOF";
64
64
  # hook envelopes contain no NUL, so the non-zero EOF result is expected.
65
+ #
66
+ # Every wait in this file has a ceiling (CodySwannGT/lisa#5038). This one waited
67
+ # for EOF with none, so a caller that gave up on the hook without closing its end
68
+ # of the pipe left the hook blocked in `read` forever: four were found on one
69
+ # workstation, orphaned to PID 1 with no children, 2h, 2h, 5h and 146h old. A
70
+ # real caller writes the whole envelope at once (a 1MB payload drains in ~0.6s
71
+ # at a load average of 20), so the ceiling only ever ends a wait nobody is going
72
+ # to finish. When EOF arrives in time nothing changes: every exit below still
73
+ # follows it. When it does not, the hook stops waiting and steps aside — Bash
74
+ # discards a partial read on timeout, so there is no complete payload to scan.
75
+ #
76
+ # `read -t` cannot tell its caller which happened (Bash 3.2 returns 1 for both
77
+ # EOF and a timeout), so the clock decides: a read that lasted the whole ceiling
78
+ # timed out. A value that is not a positive whole number falls back to the
79
+ # shipped ten seconds rather than to `read -t 0`, which would skip the drain.
80
+ bound_s() {
81
+ case "$1" in
82
+ '' | *[!0-9]* | 0*) printf '10' ;;
83
+ *) printf '%s' "$1" ;;
84
+ esac
85
+ }
86
+
65
87
  payload=""
66
- IFS= read -r -d '' payload || true
88
+ stdin_bound="$(bound_s "${LISA_SONAR_STDIN_TIMEOUT_S:-}")"
89
+ stdin_started=$SECONDS
90
+ IFS= read -r -d '' -t "$stdin_bound" payload || true
91
+ if (( SECONDS - stdin_started >= stdin_bound )); then
92
+ echo "sonar: the hook's input did not finish arriving within ${stdin_bound}s;" >&2
93
+ echo " skipping the local secret scan. Commit-time and CI secret scanning" >&2
94
+ echo " still gate this repository." >&2
95
+ exit 0
96
+ fi
67
97
 
68
98
  event="${1:-}"
69
99
  [[ -n "$event" ]] || exit 0
@@ -81,8 +111,94 @@ command -v sonar >/dev/null 2>&1 || exit 0
81
111
  # exit code carries no information and the reason text is the only channel.
82
112
  inactive_marker='secret scanning is inactive'
83
113
 
114
+ # Run one command with a ceiling and capture its stdout into `captured`.
115
+ #
116
+ # Usage: capture_bounded <seconds> <delimiter> <label> <stdin> <command...>
117
+ # Returns 0 when the command answered in time, 1 when the ceiling expired (and
118
+ # `captured` is then empty), and 2 when the private FIFO could not be made.
119
+ #
120
+ # `read -t` supplies the ceiling. `timeout` is absent on a stock macOS and
121
+ # `coproc` needs Bash 4 (the hooks run under /bin/bash 3.2 there), so this is the
122
+ # portable form. Stopping the wait is not stopping the work, so when the read
123
+ # returns the command is killed and reaped; that requires its PID, which is why
124
+ # the command is backgrounded explicitly and its output goes through a FIFO.
125
+ # On /bin/bash 3.2, `$!` after `< <(cmd)` is the SHELL'S OWN PID, not the
126
+ # substitution's child (verified: the child's PPID is the shell, and `$!` equals
127
+ # the shell), so `kill -9 "$!"` there would tell the hook to kill itself. For a
128
+ # background pipeline `$!` is its last command, so the kill lands on the command
129
+ # itself; its stdin writer then dies on the closed pipe.
130
+ #
131
+ # The FIFO's OPEN is bounded too, not only the read (CodySwannGT/lisa#5038). A
132
+ # read-only open of a FIFO blocks until a writer opens the other end, and a
133
+ # writer that dies first would leave it blocked for good with `read -t` never
134
+ # reached. So the hook opens the FIFO read-write first, which never blocks, and
135
+ # the command inherits that end at fork instead of opening the path later. The
136
+ # read-only end is then opened while a writer is guaranteed to exist, and the
137
+ # hook's own write end is closed, so EOF arrives exactly when the command (and
138
+ # anything it handed its stdout to) is done.
139
+ #
140
+ # The FIFO is a rendezvous, not storage: a named pipe holds no data at rest, so a
141
+ # value carried through it never lands on disk (CWE-922) and a kill at any point
142
+ # leaves an empty pipe behind rather than a readable token. The directory is
143
+ # `mktemp -d`, which is 0700. Its explicit Lisa prefix makes an interrupted run
144
+ # attributable to the owning scratch lifecycle instead of anonymous `tmp.*`.
145
+ # Descriptors 3 and 4 are used for nothing else in this file.
146
+ captured=""
147
+ capture_bounded() {
148
+ local seconds="$1" delim="$2" label="$3" feed="$4" dir="" fifo="" child=""
149
+ local started=0 status=0
150
+ shift 4
151
+ captured=""
152
+ dir="$(mktemp -d "${TMPDIR:-/tmp}/lisa-sonar-${label}.XXXXXXXX")" || return 2
153
+ fifo="$dir/$label"
154
+ if ! mkfifo -m 600 "$fifo" 2>/dev/null; then
155
+ rm -rf "$dir"
156
+ return 2
157
+ fi
158
+ exec 3<>"$fifo"
159
+ { printf '%s' "$feed"; } 3>&- | "$@" >&3 3>&- 2>/dev/null &
160
+ child=$!
161
+ exec 4<"$fifo"
162
+ exec 3>&-
163
+ started=$SECONDS
164
+ IFS= read -r -d "$delim" -t "$seconds" captured <&4
165
+ exec 4<&-
166
+ # The clock decides, as for stdin above: Bash 3.2 returns 1 for EOF and for a
167
+ # timeout alike, and Bash 4+ keeps a timed-out partial read, which must never
168
+ # pass for a verdict or a token.
169
+ if (( SECONDS - started >= seconds )); then
170
+ captured=""
171
+ status=1
172
+ fi
173
+ kill -9 "$child" 2>/dev/null
174
+ wait "$child" 2>/dev/null
175
+ rm -rf "$dir"
176
+ return "$status"
177
+ }
178
+
179
+ # `sonar hook` is a call with no ceiling of its own, in front of every prompt and
180
+ # every file read (CodySwannGT/lisa#5038). Ten seconds by default, like the
181
+ # resolver below; `LISA_SONAR_SCAN_TIMEOUT_S` lets a caller that is not a session
182
+ # say otherwise. A scanner that does not answer is a degraded layer, not a
183
+ # finding, so the hook warns and steps aside.
184
+ scan_bound="$(bound_s "${LISA_SONAR_SCAN_TIMEOUT_S:-}")"
84
185
  run_scanner() {
85
- printf '%s' "$payload" | sonar hook "$event" 2>/dev/null
186
+ capture_bounded "$scan_bound" '' scan "$payload" sonar hook "$event"
187
+ case $? in
188
+ 0) out="$captured" ;;
189
+ 1)
190
+ echo "sonar: the secret scanner did not answer within ${scan_bound}s;" >&2
191
+ echo " skipping the local secret scan. Commit-time and CI secret scanning" >&2
192
+ echo " still gate this repository." >&2
193
+ exit 0
194
+ ;;
195
+ *)
196
+ echo "sonar: could not make a private pipe for the secret scanner;" >&2
197
+ echo " skipping the local secret scan. Commit-time and CI secret scanning" >&2
198
+ echo " still gate this repository." >&2
199
+ exit 0
200
+ ;;
201
+ esac
86
202
  }
87
203
 
88
204
  is_inactive() {
@@ -92,21 +208,15 @@ is_inactive() {
92
208
  esac
93
209
  }
94
210
 
95
- # Run the resolver with a ceiling, because the provider call crosses the network
211
+ # Resolve a secret with a ceiling, because the provider call crosses the network
96
212
  # and this sits in front of every prompt and every file read.
97
213
  #
98
214
  # The value never touches the filesystem. An earlier version captured it through
99
215
  # `mktemp` and deleted the file afterwards, which is a race, not a cleanup: a
100
216
  # kill between the write and the `rm` leaves the token readable on disk (CWE-922)
101
217
  # — the precise failure the one-store rule in lisa-secrets-access exists to
102
- # prevent, reintroduced by the code enforcing it. Process substitution gives a
103
- # `/dev/fd` pipe instead, so there is no path on disk to leak and nothing to
104
- # clean up on any exit path, signalled or not.
105
- #
106
- # `read -t` supplies the ceiling. `timeout` is absent on a stock macOS and
107
- # `coproc` needs Bash 4 (the hooks run under /bin/bash 3.2 there), so this is the
108
- # portable form. A timeout leaves `value` empty, which the caller treats as "the
109
- # provider had nothing" — the warn path, never a block.
218
+ # prevent, reintroduced by the code enforcing it. `capture_bounded` carries it
219
+ # over a FIFO instead, which holds nothing at rest.
110
220
  #
111
221
  # Ten seconds is the ceiling a consumer gets, and that is a product decision, not
112
222
  # a tuning constant: this runs in front of every prompt and every file read, so
@@ -119,44 +229,17 @@ is_inactive() {
119
229
  # (CodySwannGT/lisa#2905). The suite scales this the same way it scales its own
120
230
  # budgets, and stages a hang by shrinking it.
121
231
  #
122
- # Unset, empty, or unparseable all end in the warn path: `:-10` covers the first
123
- # two, and `read -t garbage` fails immediately, which leaves `value` empty. There
124
- # is no value of this variable that turns a warn into a block.
125
- #
126
- # Giving up on the read is not the same as stopping the work: a resolver blocked
127
- # on the network otherwise outlives the hook that started it, and this runs in
128
- # front of every prompt and every file read. So the child is killed and reaped,
129
- # which requires knowing its PID — and that is why the transport is a FIFO and
130
- # not the process substitution this function used to read from.
131
- #
132
- # On /bin/bash 3.2, `$!` after `< <(cmd)` is the SHELL'S OWN PID, not the
133
- # substitution's child (verified: the child's PPID is the shell, and `$!` equals
134
- # the shell). A `kill -9 "$!"` there tells the hook to kill itself. Backgrounding
135
- # the resolver explicitly is what makes `$!` mean the resolver.
136
- #
137
- # The FIFO is a rendezvous, not storage: a named pipe holds no data at rest, so
138
- # the value still never lands on disk (CWE-922) and a kill at any point leaves an
139
- # empty pipe behind rather than a readable token. The directory is `mktemp -d`,
140
- # which is 0700. Its explicit Lisa prefix makes an interrupted resolver
141
- # attributable to the owning scratch lifecycle instead of anonymous `tmp.*`.
232
+ # A timeout leaves the value empty, which the caller treats as "the provider had
233
+ # nothing" — the warn path, never a block. Unset, empty, or unparseable all fall
234
+ # back to the shipped ten seconds, so there is no value of this variable that
235
+ # turns a warn into a block.
142
236
  resolve_secret() {
143
- local resolver="$1" name="$2" value="" child="" dir="" fifo=""
144
- dir="$(mktemp -d "${TMPDIR:-/tmp}/lisa-sonar-resolver.XXXXXXXX")" || return 0
145
- fifo="$dir/resolver"
146
- if ! mkfifo -m 600 "$fifo" 2>/dev/null; then
147
- rm -rf "$dir"
148
- return 0
149
- fi
150
- node "$resolver" get "$name" >"$fifo" 2>/dev/null &
151
- child=$!
152
- IFS= read -r -t "${LISA_SONAR_RESOLVER_TIMEOUT_S:-10}" value < "$fifo" || true
153
- kill -9 "$child" 2>/dev/null
154
- wait "$child" 2>/dev/null
155
- rm -rf "$dir"
156
- printf '%s' "$value"
237
+ capture_bounded "$(bound_s "${LISA_SONAR_RESOLVER_TIMEOUT_S:-10}")" $'\n' resolver "" \
238
+ node "$1" get "$2"
239
+ printf '%s' "$captured"
157
240
  }
158
241
 
159
- out="$(run_scanner)"
242
+ run_scanner
160
243
 
161
244
  if is_inactive "$out"; then
162
245
  # Where lisa-secrets-access lives depends on how the project receives Lisa.
@@ -187,7 +270,7 @@ if is_inactive "$out"; then
187
270
  export SONARQUBE_CLI_TOKEN="$token"
188
271
  org="$(resolve_secret "$resolver" SONARQUBE_CLI_ORG)"
189
272
  [[ -n "$org" ]] && export SONARQUBE_CLI_ORG="$org"
190
- out="$(run_scanner)"
273
+ run_scanner
191
274
  fi
192
275
  unset token org
193
276
  fi
@@ -1 +1 @@
1
- {"version":3,"file":"lisa-owned-hash-ledger.d.ts","sourceRoot":"","sources":["../../src/core/lisa-owned-hash-ledger.ts"],"names":[],"mappings":"AACA,6EAA6E;AAE7E;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAC3C,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAk6FjC,CAAC;AAEH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CACpD,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAq0FjC,CAAC"}
1
+ {"version":3,"file":"lisa-owned-hash-ledger.d.ts","sourceRoot":"","sources":["../../src/core/lisa-owned-hash-ledger.ts"],"names":[],"mappings":"AACA,6EAA6E;AAE7E;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAC3C,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAm6FjC,CAAC;AAEH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CACpD,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAs0FjC,CAAC"}
@@ -2121,6 +2121,7 @@ export const LISA_OWNED_HASH_LEDGER = Object.freeze({
2121
2121
  "ff15992834e3bb911a560a6f65be76a791a8cd262f36b18972f25a8dc36d7c00",
2122
2122
  ]),
2123
2123
  "scripts/lisa-hooks/sonar-secrets.sh": Object.freeze([
2124
+ "18e1d963d4416ccd247158e6a4bfcf43234f47faeb3a4654b5a6c78001ab8ef5",
2124
2125
  "18e63683064305dab1200456896cbb9384ab35ee6bc51d3789ffbba46d1b1081",
2125
2126
  "7a408788975a6351d53e14aa32bb9a5d161f33df9dfea59ba32784ae33a62e67",
2126
2127
  "853bcf0bc455e78326186463287e32cc5906a40323c630a8e63935315197fd2f",
@@ -5046,6 +5047,7 @@ export const LISA_OWNED_HASH_HISTORY_DERIVED = Object.freeze({
5046
5047
  "ff15992834e3bb911a560a6f65be76a791a8cd262f36b18972f25a8dc36d7c00",
5047
5048
  ]),
5048
5049
  "scripts/lisa-hooks/sonar-secrets.sh": Object.freeze([
5050
+ "18e1d963d4416ccd247158e6a4bfcf43234f47faeb3a4654b5a6c78001ab8ef5",
5049
5051
  "18e63683064305dab1200456896cbb9384ab35ee6bc51d3789ffbba46d1b1081",
5050
5052
  "7a408788975a6351d53e14aa32bb9a5d161f33df9dfea59ba32784ae33a62e67",
5051
5053
  "853bcf0bc455e78326186463287e32cc5906a40323c630a8e63935315197fd2f",