@akasecurity/ai-tc-antigravity 0.9.17-beta.1 → 0.9.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akasecurity/ai-tc-antigravity",
3
- "version": "0.9.17-beta.1",
3
+ "version": "0.9.17",
4
4
  "description": "AI Traffic Control — inspect and govern AI prompts in Antigravity CLI",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -28,11 +28,11 @@
28
28
  "typescript": "^5.8.0",
29
29
  "vitest": "^4.1.11",
30
30
  "@akasecurity/eslint-config": "0.8.0",
31
- "@akasecurity/persistence": "0.8.0",
31
+ "@akasecurity/plugin-runtime": "0.8.0",
32
+ "@akasecurity/plugin-sdk": "0.8.0",
32
33
  "@akasecurity/scanner": "0.8.0",
34
+ "@akasecurity/persistence": "0.8.0",
33
35
  "@akasecurity/schema": "0.8.0",
34
- "@akasecurity/plugin-sdk": "0.8.0",
35
- "@akasecurity/plugin-runtime": "0.8.0",
36
36
  "@akasecurity/setup-wizard": "0.8.0"
37
37
  },
38
38
  "scripts": {
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://antigravity.google/schemas/v1/plugin.json",
3
3
  "name": "aka-antigravity",
4
- "version": "0.9.17-beta.1",
4
+ "version": "0.9.17",
5
5
  "description": "AI Traffic Control — inspect and govern AI prompts in Antigravity. Detection runs locally; events are recorded to a local SQLite store on your machine.",
6
6
  "hooks": "./hooks.json",
7
7
  "skills": "./skills",
@@ -21686,6 +21686,11 @@ var CaptureAttributes = external_exports.object({
21686
21686
  // here too. The full statement is on EventMetadata.redactDegradedTo; it is
21687
21687
  // repeated rather than referenced because a store reader opens this file.
21688
21688
  redact_degraded_to: ActionTaken.optional(),
21689
+ // Why a capture has no content and no findings: its field was refused
21690
+ // because its bounded scan did not finish (see EventMetadata.scanIncomplete,
21691
+ // whose value this is). Absent on every capture that was scanned, so a
21692
+ // reader can tell a refused row from an empty clean one.
21693
+ scan_incomplete: external_exports.enum(["timeout", "unavailable"]).optional(),
21689
21694
  // The scope key this capture was stamped with: the canonical repository
21690
21695
  // (`host/owner/repo`) of the path the capture names (a relative path is read
21691
21696
  // against its working directory), else of its own working directory, or a
@@ -22999,7 +23004,19 @@ var EventMetadata = external_exports.object({
22999
23004
  // Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
23000
23005
  // Closing either means moving the reason onto the finding row, which
23001
23006
  // already carries its own action.
23002
- redactDegradedTo: ActionTaken.optional()
23007
+ redactDegradedTo: ActionTaken.optional(),
23008
+ // Set when this capture's field was REFUSED rather than scanned: a hook
23009
+ // bounds the scan of a large field (see `LargeInputScanOptions` in
23010
+ // @akasecurity/plugin-sdk), and a scan that did not finish blocks the
23011
+ // field instead of letting it through unscanned.
23012
+ //
23013
+ // - 'timeout': the bounded scan ran out of time.
23014
+ // - 'unavailable': no worker could run it.
23015
+ //
23016
+ // A refused row stores '' as its content and has no findings, which is
23017
+ // exactly what a clean, empty capture looks like — this marker is the only
23018
+ // thing that tells the two apart. Absent on every capture that was scanned.
23019
+ scanIncomplete: external_exports.enum(["timeout", "unavailable"]).optional()
23003
23020
  }).meta({ id: "EventMetadata" });
23004
23021
  var Event = external_exports.object({
23005
23022
  id: external_exports.guid(),
@@ -24689,6 +24706,7 @@ function toCaptureAttributes(event) {
24689
24706
  ...metadata?.exceptionIds !== void 0 ? { exception_ids: metadata.exceptionIds } : {},
24690
24707
  ...metadata?.inspectionMs !== void 0 ? { inspection_ms: metadata.inspectionMs } : {},
24691
24708
  ...metadata?.redactDegradedTo !== void 0 ? { redact_degraded_to: metadata.redactDegradedTo } : {},
24709
+ ...metadata?.scanIncomplete !== void 0 ? { scan_incomplete: metadata.scanIncomplete } : {},
24692
24710
  // `model`/`turnIndex` have no dedicated CaptureAttributes field (no writer
24693
24711
  // has ever populated either), but every legacy metadata key still rides
24694
24712
  // the bag rather than being silently dropped — CaptureAttributes'
@@ -36178,6 +36196,38 @@ var POLYNOMIAL_PROBES = ["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].m
36178
36196
  );
36179
36197
  var CPU_CORROBORATION_SHARE = 0.2;
36180
36198
  var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
36199
+ function repeatTo(unit, length) {
36200
+ return unit.repeat(Math.ceil(length / unit.length)).slice(0, length);
36201
+ }
36202
+ function joinTo(length, open3, close, item) {
36203
+ const parts = [];
36204
+ let size = open3.length;
36205
+ for (let i = 0; size < length; i++) {
36206
+ const next = (i === 0 ? "" : ",") + item(i);
36207
+ parts.push(next);
36208
+ size += next.length;
36209
+ }
36210
+ return (open3 + parts.join("") + close).slice(0, length);
36211
+ }
36212
+ var SQL_WORDS = ["select", "insert", "update", "delete", "drop", "where"];
36213
+ var GROWTH_CORPORA = [
36214
+ {
36215
+ name: "one-line JSON dictionary",
36216
+ build: (length) => joinTo(length, "{", "}", (i) => `"id-${String(i)}":"label ${String(i)}"`)
36217
+ },
36218
+ {
36219
+ name: "JSON array of quoted SQL keywords",
36220
+ build: (length) => joinTo(length, "[", "]", (i) => `"${SQL_WORDS[i % SQL_WORDS.length] ?? ""} ${String(i)}"`)
36221
+ },
36222
+ { name: "single-quoted keyword run ('where)", build: (length) => repeatTo("'where", length) },
36223
+ { name: "double-quote run", build: (length) => repeatTo('"', length) },
36224
+ { name: "space run", build: (length) => repeatTo(" ", length) },
36225
+ { name: "newline run", build: (length) => repeatTo("\n", length) },
36226
+ ...["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].map((unit) => ({
36227
+ name: `unit run ${JSON.stringify(unit)}`,
36228
+ build: (length) => repeatTo(unit, length)
36229
+ }))
36230
+ ];
36181
36231
 
36182
36232
  // ../../packages/plugin-sdk/src/raw-egress.ts
36183
36233
  var RawEgressError = class extends Error {
@@ -36523,7 +36573,7 @@ var auth_jwt_no_verify_default = {
36523
36573
  severity: "critical",
36524
36574
  matcher: {
36525
36575
  type: "regex",
36526
- pattern: "(verify\\s*=\\s*false|verify_signature.*false|algorithms\\s*=\\s*\\[\\])",
36576
+ pattern: "(verify\\s*=\\s*false|verify_signature(?:(?!verify_signature).)*false|algorithms\\s*=\\s*\\[\\])",
36527
36577
  flags: "gi"
36528
36578
  },
36529
36579
  requiresNearby: {
@@ -36611,7 +36661,7 @@ var cmd_inject_shell_default = {
36611
36661
  severity: "critical",
36612
36662
  matcher: {
36613
36663
  type: "regex",
36614
- pattern: "subprocess\\.(run|Popen|call|check_output)\\s*\\([^)]*shell\\s*=\\s*True",
36664
+ pattern: "subprocess\\.(run|Popen|call|check_output)\\s*\\((?:(?!subprocess\\.(?:run|Popen|call|check_output)\\s*\\()[^)])*shell\\s*=\\s*True",
36615
36665
  flags: "gi"
36616
36666
  },
36617
36667
  requiresNearby: {
@@ -36740,7 +36790,7 @@ var deser_yaml_unsafe_default = {
36740
36790
  severity: "high",
36741
36791
  matcher: {
36742
36792
  type: "regex",
36743
- pattern: "\\byaml\\.load\\s*\\((?![^)]*SafeLoader|[^)]*safe_load)",
36793
+ pattern: "\\byaml\\.load\\s*\\((?!(?:(?!yaml\\.load\\s*\\()[^)])*?(?:SafeLoader|safe_load))",
36744
36794
  flags: "gi"
36745
36795
  },
36746
36796
  examples: ["data = yaml.load(user_input)", "config = yaml.load(f)"],
@@ -36957,7 +37007,7 @@ var sql_inject_concat_dot_default = {
36957
37007
  severity: "high",
36958
37008
  matcher: {
36959
37009
  type: "regex",
36960
- pattern: `["'][^\\n]*?(select|insert|update|delete|drop|where)[^\\n]*?["']\\s*\\.`,
37010
+ pattern: `["'](?=([^"'\\n]*?(?:select|insert|update|delete|drop|where)))\\1(?:(?!["'][^"'\\n]*?(?:select|insert|update|delete|drop|where))[^\\n])*?["']\\s*\\.`,
36961
37011
  flags: "gi"
36962
37012
  },
36963
37013
  appliesTo: {
@@ -36975,7 +37025,7 @@ var sql_inject_concat_default = {
36975
37025
  severity: "high",
36976
37026
  matcher: {
36977
37027
  type: "regex",
36978
- pattern: `["']\\s*(?:select\\b[^\\n]*?\\bfrom\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b[^\\n]*?=)[^\\n]*?["']\\s*\\+`,
37028
+ pattern: `(["'])\\s*(?=(select\\b(?:(?!\\1\\s*(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b))[^\\n])*?\\bfrom\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b(?:(?!\\1\\s*(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b))[^\\n])*?=))\\2(?:(?!\\1\\s*(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b))[^\\n])*?["']\\s*\\+`,
36979
37029
  flags: "gi"
36980
37030
  },
36981
37031
  examples: ['"SELECT * FROM users WHERE id = " + userId']
@@ -36990,7 +37040,7 @@ var sql_inject_format_default = {
36990
37040
  severity: "high",
36991
37041
  matcher: {
36992
37042
  type: "regex",
36993
- pattern: "\\b(?:select\\b[^\\n]*?\\bfrom\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b[^\\n]*?=)[^\\n]*?(?:[%][sd]|\\{[^}]+\\})",
37043
+ pattern: "\\b(?=(select\\b(?:(?!\\b(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b))[^\\n])*?\\bfrom\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b))\\1(?:(?!\\b(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b))[^\\n])*?(?:[%][sd]|\\{[^{}\\n]+\\})|\\b(?=(where\\b(?:(?!\\bwhere\\b)[^\\n])*?=))\\2(?:(?!\\bwhere\\b)[^\\n])*?(?:[%][sd]|\\{[^{}\\n]+\\})",
36994
37044
  flags: "gi"
36995
37045
  },
36996
37046
  examples: [
@@ -37008,7 +37058,7 @@ var sql_inject_interp_default = {
37008
37058
  severity: "high",
37009
37059
  matcher: {
37010
37060
  type: "regex",
37011
- pattern: "(select|insert|update|delete|where)[^\\n]*?(#\\{|\\$[a-z_])",
37061
+ pattern: "(select|insert|update|delete|where)(?:(?!(?:select|insert|update|delete|where))[^\\n])*?(#\\{|\\$[a-z_])",
37012
37062
  flags: "gi"
37013
37063
  },
37014
37064
  examples: [
@@ -37383,7 +37433,7 @@ var stack_trace_default = {
37383
37433
  severity: "low",
37384
37434
  matcher: {
37385
37435
  type: "regex",
37386
- pattern: "(?:^|\\s+)at\\s+[A-Za-z0-9._$<>]+\\.[A-Za-z0-9_$]+\\s*\\([A-Za-z0-9._\\-/:]+:\\d+:\\d+\\)",
37436
+ pattern: "(?:^|(?<!\\s)\\s+)at\\s+[A-Za-z0-9._$<>]+\\.[A-Za-z0-9_$]+\\s*\\([A-Za-z0-9._\\-/:]+:\\d+:\\d+\\)",
37387
37437
  flags: "g"
37388
37438
  },
37389
37439
  examples: ["at com.example.service.UserService.findUser(UserService.java:42:13)"]
@@ -38541,7 +38591,7 @@ var BUNDLED_PACKS = [
38541
38591
  {
38542
38592
  packId: "code-flaws",
38543
38593
  name: "Code Security Flaws",
38544
- version: "0.1.0",
38594
+ version: "0.1.1",
38545
38595
  rawRules: [
38546
38596
  sql_inject_concat_default,
38547
38597
  sql_inject_concat_dot_default,
@@ -38591,7 +38641,7 @@ var BUNDLED_PACKS = [
38591
38641
  {
38592
38642
  packId: "core-code-context",
38593
38643
  name: "Code Context",
38594
- version: "0.2.1",
38644
+ version: "0.2.2",
38595
38645
  rawRules: [
38596
38646
  internal_ip_default,
38597
38647
  localhost_ref_default,
@@ -21690,6 +21690,11 @@ var CaptureAttributes = external_exports.object({
21690
21690
  // here too. The full statement is on EventMetadata.redactDegradedTo; it is
21691
21691
  // repeated rather than referenced because a store reader opens this file.
21692
21692
  redact_degraded_to: ActionTaken.optional(),
21693
+ // Why a capture has no content and no findings: its field was refused
21694
+ // because its bounded scan did not finish (see EventMetadata.scanIncomplete,
21695
+ // whose value this is). Absent on every capture that was scanned, so a
21696
+ // reader can tell a refused row from an empty clean one.
21697
+ scan_incomplete: external_exports.enum(["timeout", "unavailable"]).optional(),
21693
21698
  // The scope key this capture was stamped with: the canonical repository
21694
21699
  // (`host/owner/repo`) of the path the capture names (a relative path is read
21695
21700
  // against its working directory), else of its own working directory, or a
@@ -23031,7 +23036,19 @@ var EventMetadata = external_exports.object({
23031
23036
  // Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
23032
23037
  // Closing either means moving the reason onto the finding row, which
23033
23038
  // already carries its own action.
23034
- redactDegradedTo: ActionTaken.optional()
23039
+ redactDegradedTo: ActionTaken.optional(),
23040
+ // Set when this capture's field was REFUSED rather than scanned: a hook
23041
+ // bounds the scan of a large field (see `LargeInputScanOptions` in
23042
+ // @akasecurity/plugin-sdk), and a scan that did not finish blocks the
23043
+ // field instead of letting it through unscanned.
23044
+ //
23045
+ // - 'timeout': the bounded scan ran out of time.
23046
+ // - 'unavailable': no worker could run it.
23047
+ //
23048
+ // A refused row stores '' as its content and has no findings, which is
23049
+ // exactly what a clean, empty capture looks like — this marker is the only
23050
+ // thing that tells the two apart. Absent on every capture that was scanned.
23051
+ scanIncomplete: external_exports.enum(["timeout", "unavailable"]).optional()
23035
23052
  }).meta({ id: "EventMetadata" });
23036
23053
  var Event = external_exports.object({
23037
23054
  id: external_exports.guid(),
@@ -24848,6 +24865,7 @@ function toCaptureAttributes(event) {
24848
24865
  ...metadata?.exceptionIds !== void 0 ? { exception_ids: metadata.exceptionIds } : {},
24849
24866
  ...metadata?.inspectionMs !== void 0 ? { inspection_ms: metadata.inspectionMs } : {},
24850
24867
  ...metadata?.redactDegradedTo !== void 0 ? { redact_degraded_to: metadata.redactDegradedTo } : {},
24868
+ ...metadata?.scanIncomplete !== void 0 ? { scan_incomplete: metadata.scanIncomplete } : {},
24851
24869
  // `model`/`turnIndex` have no dedicated CaptureAttributes field (no writer
24852
24870
  // has ever populated either), but every legacy metadata key still rides
24853
24871
  // the bag rather than being silently dropped — CaptureAttributes'
@@ -36821,6 +36839,38 @@ function worstProbeMs(rule, now = wallClock, corroborate) {
36821
36839
  }
36822
36840
  var CPU_CORROBORATION_SHARE = 0.2;
36823
36841
  var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
36842
+ function repeatTo(unit, length) {
36843
+ return unit.repeat(Math.ceil(length / unit.length)).slice(0, length);
36844
+ }
36845
+ function joinTo(length, open3, close, item) {
36846
+ const parts = [];
36847
+ let size = open3.length;
36848
+ for (let i = 0; size < length; i++) {
36849
+ const next = (i === 0 ? "" : ",") + item(i);
36850
+ parts.push(next);
36851
+ size += next.length;
36852
+ }
36853
+ return (open3 + parts.join("") + close).slice(0, length);
36854
+ }
36855
+ var SQL_WORDS = ["select", "insert", "update", "delete", "drop", "where"];
36856
+ var GROWTH_CORPORA = [
36857
+ {
36858
+ name: "one-line JSON dictionary",
36859
+ build: (length) => joinTo(length, "{", "}", (i) => `"id-${String(i)}":"label ${String(i)}"`)
36860
+ },
36861
+ {
36862
+ name: "JSON array of quoted SQL keywords",
36863
+ build: (length) => joinTo(length, "[", "]", (i) => `"${SQL_WORDS[i % SQL_WORDS.length] ?? ""} ${String(i)}"`)
36864
+ },
36865
+ { name: "single-quoted keyword run ('where)", build: (length) => repeatTo("'where", length) },
36866
+ { name: "double-quote run", build: (length) => repeatTo('"', length) },
36867
+ { name: "space run", build: (length) => repeatTo(" ", length) },
36868
+ { name: "newline run", build: (length) => repeatTo("\n", length) },
36869
+ ...["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].map((unit) => ({
36870
+ name: `unit run ${JSON.stringify(unit)}`,
36871
+ build: (length) => repeatTo(unit, length)
36872
+ }))
36873
+ ];
36824
36874
  function checkRuleTiming(rule, corroborate) {
36825
36875
  const { ms, probe, corroboratedMs } = worstProbeMs(rule, wallClock, corroborate);
36826
36876
  const work = corroboratedMs ?? 0;
@@ -37145,7 +37195,7 @@ var auth_jwt_no_verify_default = {
37145
37195
  severity: "critical",
37146
37196
  matcher: {
37147
37197
  type: "regex",
37148
- pattern: "(verify\\s*=\\s*false|verify_signature.*false|algorithms\\s*=\\s*\\[\\])",
37198
+ pattern: "(verify\\s*=\\s*false|verify_signature(?:(?!verify_signature).)*false|algorithms\\s*=\\s*\\[\\])",
37149
37199
  flags: "gi"
37150
37200
  },
37151
37201
  requiresNearby: {
@@ -37233,7 +37283,7 @@ var cmd_inject_shell_default = {
37233
37283
  severity: "critical",
37234
37284
  matcher: {
37235
37285
  type: "regex",
37236
- pattern: "subprocess\\.(run|Popen|call|check_output)\\s*\\([^)]*shell\\s*=\\s*True",
37286
+ pattern: "subprocess\\.(run|Popen|call|check_output)\\s*\\((?:(?!subprocess\\.(?:run|Popen|call|check_output)\\s*\\()[^)])*shell\\s*=\\s*True",
37237
37287
  flags: "gi"
37238
37288
  },
37239
37289
  requiresNearby: {
@@ -37362,7 +37412,7 @@ var deser_yaml_unsafe_default = {
37362
37412
  severity: "high",
37363
37413
  matcher: {
37364
37414
  type: "regex",
37365
- pattern: "\\byaml\\.load\\s*\\((?![^)]*SafeLoader|[^)]*safe_load)",
37415
+ pattern: "\\byaml\\.load\\s*\\((?!(?:(?!yaml\\.load\\s*\\()[^)])*?(?:SafeLoader|safe_load))",
37366
37416
  flags: "gi"
37367
37417
  },
37368
37418
  examples: ["data = yaml.load(user_input)", "config = yaml.load(f)"],
@@ -37579,7 +37629,7 @@ var sql_inject_concat_dot_default = {
37579
37629
  severity: "high",
37580
37630
  matcher: {
37581
37631
  type: "regex",
37582
- pattern: `["'][^\\n]*?(select|insert|update|delete|drop|where)[^\\n]*?["']\\s*\\.`,
37632
+ pattern: `["'](?=([^"'\\n]*?(?:select|insert|update|delete|drop|where)))\\1(?:(?!["'][^"'\\n]*?(?:select|insert|update|delete|drop|where))[^\\n])*?["']\\s*\\.`,
37583
37633
  flags: "gi"
37584
37634
  },
37585
37635
  appliesTo: {
@@ -37597,7 +37647,7 @@ var sql_inject_concat_default = {
37597
37647
  severity: "high",
37598
37648
  matcher: {
37599
37649
  type: "regex",
37600
- pattern: `["']\\s*(?:select\\b[^\\n]*?\\bfrom\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b[^\\n]*?=)[^\\n]*?["']\\s*\\+`,
37650
+ pattern: `(["'])\\s*(?=(select\\b(?:(?!\\1\\s*(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b))[^\\n])*?\\bfrom\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b(?:(?!\\1\\s*(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b))[^\\n])*?=))\\2(?:(?!\\1\\s*(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b))[^\\n])*?["']\\s*\\+`,
37601
37651
  flags: "gi"
37602
37652
  },
37603
37653
  examples: ['"SELECT * FROM users WHERE id = " + userId']
@@ -37612,7 +37662,7 @@ var sql_inject_format_default = {
37612
37662
  severity: "high",
37613
37663
  matcher: {
37614
37664
  type: "regex",
37615
- pattern: "\\b(?:select\\b[^\\n]*?\\bfrom\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b|where\\b[^\\n]*?=)[^\\n]*?(?:[%][sd]|\\{[^}]+\\})",
37665
+ pattern: "\\b(?=(select\\b(?:(?!\\b(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b))[^\\n])*?\\bfrom\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b))\\1(?:(?!\\b(?:select\\b|insert\\s+into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database)\\b))[^\\n])*?(?:[%][sd]|\\{[^{}\\n]+\\})|\\b(?=(where\\b(?:(?!\\bwhere\\b)[^\\n])*?=))\\2(?:(?!\\bwhere\\b)[^\\n])*?(?:[%][sd]|\\{[^{}\\n]+\\})",
37616
37666
  flags: "gi"
37617
37667
  },
37618
37668
  examples: [
@@ -37630,7 +37680,7 @@ var sql_inject_interp_default = {
37630
37680
  severity: "high",
37631
37681
  matcher: {
37632
37682
  type: "regex",
37633
- pattern: "(select|insert|update|delete|where)[^\\n]*?(#\\{|\\$[a-z_])",
37683
+ pattern: "(select|insert|update|delete|where)(?:(?!(?:select|insert|update|delete|where))[^\\n])*?(#\\{|\\$[a-z_])",
37634
37684
  flags: "gi"
37635
37685
  },
37636
37686
  examples: [
@@ -38005,7 +38055,7 @@ var stack_trace_default = {
38005
38055
  severity: "low",
38006
38056
  matcher: {
38007
38057
  type: "regex",
38008
- pattern: "(?:^|\\s+)at\\s+[A-Za-z0-9._$<>]+\\.[A-Za-z0-9_$]+\\s*\\([A-Za-z0-9._\\-/:]+:\\d+:\\d+\\)",
38058
+ pattern: "(?:^|(?<!\\s)\\s+)at\\s+[A-Za-z0-9._$<>]+\\.[A-Za-z0-9_$]+\\s*\\([A-Za-z0-9._\\-/:]+:\\d+:\\d+\\)",
38009
38059
  flags: "g"
38010
38060
  },
38011
38061
  examples: ["at com.example.service.UserService.findUser(UserService.java:42:13)"]
@@ -39163,7 +39213,7 @@ var BUNDLED_PACKS = [
39163
39213
  {
39164
39214
  packId: "code-flaws",
39165
39215
  name: "Code Security Flaws",
39166
- version: "0.1.0",
39216
+ version: "0.1.1",
39167
39217
  rawRules: [
39168
39218
  sql_inject_concat_default,
39169
39219
  sql_inject_concat_dot_default,
@@ -39213,7 +39263,7 @@ var BUNDLED_PACKS = [
39213
39263
  {
39214
39264
  packId: "core-code-context",
39215
39265
  name: "Code Context",
39216
- version: "0.2.1",
39266
+ version: "0.2.2",
39217
39267
  rawRules: [
39218
39268
  internal_ip_default,
39219
39269
  localhost_ref_default,
@@ -39709,9 +39759,10 @@ function createIsolatedScanner(data, opts = {}) {
39709
39759
  if (job.timer !== void 0) return;
39710
39760
  job.startedAt = performance.now();
39711
39761
  job.progressAt = job.startedAt;
39762
+ const budget = job.deadlineAt === void 0 ? job.budgetMs : Math.max(0, Math.min(job.budgetMs, job.deadlineAt - job.startedAt));
39712
39763
  job.timer = setTimeout(() => {
39713
39764
  onDeadline(job);
39714
- }, job.budgetMs);
39765
+ }, budget);
39715
39766
  }
39716
39767
  function runOne(spec, fail) {
39717
39768
  if (closed) {
@@ -39722,6 +39773,12 @@ function createIsolatedScanner(data, opts = {}) {
39722
39773
  fail({ status: "unavailable", reason: `the scan worker crashed: ${broken}` });
39723
39774
  return;
39724
39775
  }
39776
+ const now = performance.now();
39777
+ const deadlineAt = spec.deadlineAt;
39778
+ if (deadlineAt !== void 0 && deadlineAt <= now) {
39779
+ fail({ status: "timeout", culpritIndex: void 0, elapsedMs: 0 });
39780
+ return;
39781
+ }
39725
39782
  const started = ensureWorker();
39726
39783
  if (!(started instanceof Worker)) {
39727
39784
  broken = started.error;
@@ -39729,11 +39786,11 @@ function createIsolatedScanner(data, opts = {}) {
39729
39786
  return;
39730
39787
  }
39731
39788
  const id = nextJobId++;
39732
- const now = performance.now();
39733
39789
  const job = {
39734
39790
  id,
39735
39791
  worker: started,
39736
39792
  budgetMs: spec.budgetMs,
39793
+ deadlineAt,
39737
39794
  startedAt: now,
39738
39795
  progressIndex: -1,
39739
39796
  progressAt: now,
@@ -39747,14 +39804,19 @@ function createIsolatedScanner(data, opts = {}) {
39747
39804
  if (readyWorker === started) {
39748
39805
  beginDeadline(job);
39749
39806
  } else {
39807
+ const startBudget = spec.startBudgetMs ?? startBudgetMs;
39808
+ const callerLimited = deadlineAt !== void 0 && deadlineAt - now < startBudget;
39809
+ const startWaitMs = callerLimited ? deadlineAt - now : startBudget;
39750
39810
  job.startupTimer = setTimeout(() => {
39751
39811
  if (pending !== job) return;
39752
39812
  kill(job.worker);
39753
- failPending({
39754
- status: "unavailable",
39755
- reason: `the scan worker did not start within ${String(startBudgetMs)}ms`
39756
- });
39757
- }, startBudgetMs);
39813
+ failPending(
39814
+ callerLimited ? { status: "timeout", culpritIndex: void 0, elapsedMs: performance.now() - now } : {
39815
+ status: "unavailable",
39816
+ reason: `the scan worker did not start within ${String(startBudget)}ms`
39817
+ }
39818
+ );
39819
+ }, startWaitMs);
39758
39820
  }
39759
39821
  try {
39760
39822
  started.postMessage(spec.build(id));
@@ -39783,7 +39845,9 @@ function createIsolatedScanner(data, opts = {}) {
39783
39845
  return enqueue((resolve3) => {
39784
39846
  runOne(
39785
39847
  {
39786
- budgetMs,
39848
+ budgetMs: scanOpts?.budgetMs ?? budgetMs,
39849
+ startBudgetMs: scanOpts?.startBudgetMs,
39850
+ deadlineAt: scanOpts?.deadlineAt,
39787
39851
  build: (id) => ({
39788
39852
  kind: "scan",
39789
39853
  id,
@@ -39977,6 +40041,9 @@ function createGuardedScanner(partition, gateway, opts) {
39977
40041
  let unverified = partition.unverified;
39978
40042
  let isolated = unverified.length > 0 ? createIsolatedScanner({ verified, unverified }, opts) : void 0;
39979
40043
  let retired = false;
40044
+ let bounded;
40045
+ let boundedWarned = false;
40046
+ let closed = false;
39980
40047
  function inProcess(text, context) {
39981
40048
  return scan(text, verified, context);
39982
40049
  }
@@ -40038,11 +40105,48 @@ function createGuardedScanner(partition, gateway, opts) {
40038
40105
  await degrade();
40039
40106
  return inProcess(text, context);
40040
40107
  }
40108
+ async function scanBounded(text, context, bound) {
40109
+ const remainingMs = bound.remainingMs;
40110
+ let outcome;
40111
+ if (closed) {
40112
+ outcome = { status: "unavailable", reason: "the scan worker is closed" };
40113
+ } else if (remainingMs !== void 0 && !(remainingMs > 0)) {
40114
+ outcome = { status: "timeout", culpritIndex: void 0, elapsedMs: 0 };
40115
+ } else {
40116
+ bounded ??= createIsolatedScanner({ verified, unverified }, opts);
40117
+ const deadlineAt = remainingMs === void 0 ? void 0 : performance.now() + remainingMs;
40118
+ try {
40119
+ outcome = await bounded.scan(text, context, {
40120
+ budgetMs: bound.budgetMs,
40121
+ startBudgetMs: bound.startBudgetMs,
40122
+ deadlineAt
40123
+ });
40124
+ } catch (error62) {
40125
+ outcome = {
40126
+ status: "unavailable",
40127
+ reason: error62 instanceof Error ? error62.message : "the scan worker failed unexpectedly"
40128
+ };
40129
+ }
40130
+ }
40131
+ if (outcome.status !== "ok" && !boundedWarned) {
40132
+ boundedWarned = true;
40133
+ process.stderr.write(
40134
+ outcome.status === "timeout" ? `[aka] a large input could not be scanned within its time limit and was refused.
40135
+ ` : `[aka] a large input could not be scanned and was refused: ${outcome.reason}.
40136
+ `
40137
+ );
40138
+ }
40139
+ return outcome;
40140
+ }
40041
40141
  return {
40042
40142
  scan: guardedScan,
40143
+ scanBounded,
40043
40144
  degraded: () => retired,
40044
40145
  async close() {
40045
- await retire();
40146
+ closed = true;
40147
+ const live = bounded;
40148
+ bounded = void 0;
40149
+ await Promise.all([retire(), live?.close()]);
40046
40150
  }
40047
40151
  };
40048
40152
  }
@@ -40171,6 +40275,16 @@ function conditionsMatch(conditions, ctx) {
40171
40275
  if (conditions.provider !== void 0) return false;
40172
40276
  return true;
40173
40277
  }
40278
+ function readRemainingMs(largeInput) {
40279
+ const read = largeInput.remainingMs;
40280
+ if (read === void 0) return void 0;
40281
+ try {
40282
+ const remaining = read();
40283
+ return typeof remaining !== "number" || Number.isNaN(remaining) ? 0 : remaining;
40284
+ } catch {
40285
+ return 0;
40286
+ }
40287
+ }
40174
40288
  var bundlesPacked = false;
40175
40289
  function createPluginRuntime(gateway, settings, opts) {
40176
40290
  if (!bundlesPacked) {
@@ -40180,6 +40294,7 @@ function createPluginRuntime(gateway, settings, opts) {
40180
40294
  const policyMode = settings.policy;
40181
40295
  let redactFallback = settings.redactFallback;
40182
40296
  const dataDir2 = opts?.dataDir;
40297
+ const largeInput = opts?.largeInput;
40183
40298
  let rules = [];
40184
40299
  let evidenceOf = evidenceLookup(rules);
40185
40300
  let scanner;
@@ -40392,7 +40507,24 @@ function createPluginRuntime(gateway, settings, opts) {
40392
40507
  await ensureInitialized();
40393
40508
  if (!scanner) throw new Error("the runtime initialized without a scanner");
40394
40509
  const shielded = shieldPointers(text);
40395
- const matched = await scanner.scan(shielded.text, context);
40510
+ let matched;
40511
+ if (largeInput !== void 0 && shielded.text.length >= largeInput.thresholdChars) {
40512
+ const outcome = await scanner.scanBounded(shielded.text, context, {
40513
+ budgetMs: largeInput.budgetMs,
40514
+ startBudgetMs: largeInput.startBudgetMs,
40515
+ remainingMs: readRemainingMs(largeInput)
40516
+ });
40517
+ if (outcome.status !== "ok") {
40518
+ return {
40519
+ decision: { action: "block", text: null, findings: [], scanIncomplete: outcome.status },
40520
+ excepted: /* @__PURE__ */ new Set(),
40521
+ exceptionIds: []
40522
+ };
40523
+ }
40524
+ matched = outcome.findings;
40525
+ } else {
40526
+ matched = await scanner.scan(shielded.text, context);
40527
+ }
40396
40528
  const findings = dropShieldedFindings(matched, shielded.spans);
40397
40529
  const fpCache = /* @__PURE__ */ new Map();
40398
40530
  const { excepted, exceptionIds } = await applyExceptions(findings, ctx, fpCache);
@@ -40433,20 +40565,24 @@ function createPluginRuntime(gateway, settings, opts) {
40433
40565
  }
40434
40566
  async function persistCapture(input2, opts2, { decision, excepted, exceptionIds, timingStartedAt }) {
40435
40567
  const filePath = input2.metadata?.filePath;
40436
- if (opts2.persist === "with-findings" && decision.findings.length === 0) return;
40568
+ if (opts2.persist === "with-findings" && decision.findings.length === 0 && decision.scanIncomplete === void 0) {
40569
+ return;
40570
+ }
40437
40571
  try {
40438
40572
  const contentHash = contentHashOf(input2.text);
40439
40573
  const maskedFindings = decision.findings.filter(
40440
40574
  (match) => isActionAtLeast(actionForFinding(match, excepted, opts2.rewritable), "redact")
40441
40575
  );
40442
- const storedContent = maskedFindings.length > 0 ? redact(input2.text, maskedFindings) : input2.text;
40576
+ const storedContent = decision.scanIncomplete !== void 0 ? "" : maskedFindings.length > 0 ? redact(input2.text, maskedFindings) : input2.text;
40443
40577
  const inspectionMs = elapsedMs(timingStartedAt);
40444
40578
  const redactDegradedTo = decision.redactDegradedTo;
40445
- const metadata = exceptionIds.length > 0 || inspectionMs !== void 0 || redactDegradedTo !== void 0 ? {
40579
+ const scanIncomplete = decision.scanIncomplete;
40580
+ const metadata = exceptionIds.length > 0 || inspectionMs !== void 0 || redactDegradedTo !== void 0 || scanIncomplete !== void 0 ? {
40446
40581
  ...input2.metadata,
40447
40582
  ...exceptionIds.length > 0 ? { exceptionIds } : {},
40448
40583
  ...inspectionMs !== void 0 ? { inspectionMs } : {},
40449
- ...redactDegradedTo !== void 0 ? { redactDegradedTo } : {}
40584
+ ...redactDegradedTo !== void 0 ? { redactDegradedTo } : {},
40585
+ ...scanIncomplete !== void 0 ? { scanIncomplete } : {}
40450
40586
  } : input2.metadata;
40451
40587
  const event = buildIngestEvent({
40452
40588
  kind: input2.kind,
@@ -42122,6 +42258,7 @@ var CORRELATION_ID = EventMetadata.shape.correlationId;
42122
42258
  var TRACE_ID = EventMetadata.shape.traceId;
42123
42259
  var EXCEPTION_ID = EventMetadata.shape.exceptionIds.unwrap().element;
42124
42260
  var REDACT_DEGRADED_TO = EventMetadata.shape.redactDegradedTo.unwrap();
42261
+ var SCAN_INCOMPLETE = EventMetadata.shape.scanIncomplete.unwrap();
42125
42262
 
42126
42263
  // ../../packages/plugin-runtime/src/attached/history-sync.ts
42127
42264
  var CAPTURE_BATCH_BYTES = 1024 * 1024;
@@ -21674,6 +21674,11 @@ var CaptureAttributes = external_exports.object({
21674
21674
  // here too. The full statement is on EventMetadata.redactDegradedTo; it is
21675
21675
  // repeated rather than referenced because a store reader opens this file.
21676
21676
  redact_degraded_to: ActionTaken.optional(),
21677
+ // Why a capture has no content and no findings: its field was refused
21678
+ // because its bounded scan did not finish (see EventMetadata.scanIncomplete,
21679
+ // whose value this is). Absent on every capture that was scanned, so a
21680
+ // reader can tell a refused row from an empty clean one.
21681
+ scan_incomplete: external_exports.enum(["timeout", "unavailable"]).optional(),
21677
21682
  // The scope key this capture was stamped with: the canonical repository
21678
21683
  // (`host/owner/repo`) of the path the capture names (a relative path is read
21679
21684
  // against its working directory), else of its own working directory, or a
@@ -23007,7 +23012,19 @@ var EventMetadata = external_exports.object({
23007
23012
  // Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
23008
23013
  // Closing either means moving the reason onto the finding row, which
23009
23014
  // already carries its own action.
23010
- redactDegradedTo: ActionTaken.optional()
23015
+ redactDegradedTo: ActionTaken.optional(),
23016
+ // Set when this capture's field was REFUSED rather than scanned: a hook
23017
+ // bounds the scan of a large field (see `LargeInputScanOptions` in
23018
+ // @akasecurity/plugin-sdk), and a scan that did not finish blocks the
23019
+ // field instead of letting it through unscanned.
23020
+ //
23021
+ // - 'timeout': the bounded scan ran out of time.
23022
+ // - 'unavailable': no worker could run it.
23023
+ //
23024
+ // A refused row stores '' as its content and has no findings, which is
23025
+ // exactly what a clean, empty capture looks like — this marker is the only
23026
+ // thing that tells the two apart. Absent on every capture that was scanned.
23027
+ scanIncomplete: external_exports.enum(["timeout", "unavailable"]).optional()
23011
23028
  }).meta({ id: "EventMetadata" });
23012
23029
  var Event = external_exports.object({
23013
23030
  id: external_exports.guid(),
@@ -24753,6 +24770,7 @@ function toCaptureAttributes(event) {
24753
24770
  ...metadata?.exceptionIds !== void 0 ? { exception_ids: metadata.exceptionIds } : {},
24754
24771
  ...metadata?.inspectionMs !== void 0 ? { inspection_ms: metadata.inspectionMs } : {},
24755
24772
  ...metadata?.redactDegradedTo !== void 0 ? { redact_degraded_to: metadata.redactDegradedTo } : {},
24773
+ ...metadata?.scanIncomplete !== void 0 ? { scan_incomplete: metadata.scanIncomplete } : {},
24756
24774
  // `model`/`turnIndex` have no dedicated CaptureAttributes field (no writer
24757
24775
  // has ever populated either), but every legacy metadata key still rides
24758
24776
  // the bag rather than being silently dropped — CaptureAttributes'
@@ -34958,6 +34976,7 @@ var CORRELATION_ID = EventMetadata.shape.correlationId;
34958
34976
  var TRACE_ID = EventMetadata.shape.traceId;
34959
34977
  var EXCEPTION_ID = EventMetadata.shape.exceptionIds.unwrap().element;
34960
34978
  var REDACT_DEGRADED_TO = EventMetadata.shape.redactDegradedTo.unwrap();
34979
+ var SCAN_INCOMPLETE = EventMetadata.shape.scanIncomplete.unwrap();
34961
34980
 
34962
34981
  // ../../packages/plugin-runtime/src/attached/history-sync.ts
34963
34982
  var CAPTURE_BATCH_BYTES = 1024 * 1024;