@akasecurity/ai-tc-codex 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/.codex-plugin/plugin.json +1 -1
- package/package.json +4 -4
- package/scripts/apply-suppressions.js +61 -11
- package/scripts/backfill.js +162 -25
- package/scripts/content-retention.js +20 -1
- package/scripts/filescan.js +162 -25
- package/scripts/firstrun.js +62 -11
- package/scripts/history-sync.js +27 -1
- package/scripts/intro.js +18 -1
- package/scripts/onboard.js +61 -11
- package/scripts/post-tool-use.js +211 -33
- package/scripts/pre-tool-use.js +193 -26
- package/scripts/query.js +62 -11
- package/scripts/reconcile.js +62 -11
- package/scripts/remediate.js +162 -25
- package/scripts/scan-worker.js +50 -1
- package/scripts/session-start.js +84 -19
- package/scripts/start-light.js +50 -1
- package/scripts/stop.js +51 -1
- package/scripts/sync.js +162 -25
- package/scripts/user-prompt-submit.js +254 -86
package/scripts/onboard.js
CHANGED
|
@@ -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
|
|
@@ -22987,7 +22992,19 @@ var EventMetadata = external_exports.object({
|
|
|
22987
22992
|
// Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
|
|
22988
22993
|
// Closing either means moving the reason onto the finding row, which
|
|
22989
22994
|
// already carries its own action.
|
|
22990
|
-
redactDegradedTo: ActionTaken.optional()
|
|
22995
|
+
redactDegradedTo: ActionTaken.optional(),
|
|
22996
|
+
// Set when this capture's field was REFUSED rather than scanned: a hook
|
|
22997
|
+
// bounds the scan of a large field (see `LargeInputScanOptions` in
|
|
22998
|
+
// @akasecurity/plugin-sdk), and a scan that did not finish blocks the
|
|
22999
|
+
// field instead of letting it through unscanned.
|
|
23000
|
+
//
|
|
23001
|
+
// - 'timeout': the bounded scan ran out of time.
|
|
23002
|
+
// - 'unavailable': no worker could run it.
|
|
23003
|
+
//
|
|
23004
|
+
// A refused row stores '' as its content and has no findings, which is
|
|
23005
|
+
// exactly what a clean, empty capture looks like — this marker is the only
|
|
23006
|
+
// thing that tells the two apart. Absent on every capture that was scanned.
|
|
23007
|
+
scanIncomplete: external_exports.enum(["timeout", "unavailable"]).optional()
|
|
22991
23008
|
}).meta({ id: "EventMetadata" });
|
|
22992
23009
|
var Event = external_exports.object({
|
|
22993
23010
|
id: external_exports.guid(),
|
|
@@ -24677,6 +24694,7 @@ function toCaptureAttributes(event) {
|
|
|
24677
24694
|
...metadata?.exceptionIds !== void 0 ? { exception_ids: metadata.exceptionIds } : {},
|
|
24678
24695
|
...metadata?.inspectionMs !== void 0 ? { inspection_ms: metadata.inspectionMs } : {},
|
|
24679
24696
|
...metadata?.redactDegradedTo !== void 0 ? { redact_degraded_to: metadata.redactDegradedTo } : {},
|
|
24697
|
+
...metadata?.scanIncomplete !== void 0 ? { scan_incomplete: metadata.scanIncomplete } : {},
|
|
24680
24698
|
// `model`/`turnIndex` have no dedicated CaptureAttributes field (no writer
|
|
24681
24699
|
// has ever populated either), but every legacy metadata key still rides
|
|
24682
24700
|
// the bag rather than being silently dropped — CaptureAttributes'
|
|
@@ -36051,6 +36069,38 @@ var POLYNOMIAL_PROBES = ["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].m
|
|
|
36051
36069
|
);
|
|
36052
36070
|
var CPU_CORROBORATION_SHARE = 0.2;
|
|
36053
36071
|
var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
|
|
36072
|
+
function repeatTo(unit, length) {
|
|
36073
|
+
return unit.repeat(Math.ceil(length / unit.length)).slice(0, length);
|
|
36074
|
+
}
|
|
36075
|
+
function joinTo(length, open3, close, item) {
|
|
36076
|
+
const parts = [];
|
|
36077
|
+
let size = open3.length;
|
|
36078
|
+
for (let i = 0; size < length; i++) {
|
|
36079
|
+
const next = (i === 0 ? "" : ",") + item(i);
|
|
36080
|
+
parts.push(next);
|
|
36081
|
+
size += next.length;
|
|
36082
|
+
}
|
|
36083
|
+
return (open3 + parts.join("") + close).slice(0, length);
|
|
36084
|
+
}
|
|
36085
|
+
var SQL_WORDS = ["select", "insert", "update", "delete", "drop", "where"];
|
|
36086
|
+
var GROWTH_CORPORA = [
|
|
36087
|
+
{
|
|
36088
|
+
name: "one-line JSON dictionary",
|
|
36089
|
+
build: (length) => joinTo(length, "{", "}", (i) => `"id-${String(i)}":"label ${String(i)}"`)
|
|
36090
|
+
},
|
|
36091
|
+
{
|
|
36092
|
+
name: "JSON array of quoted SQL keywords",
|
|
36093
|
+
build: (length) => joinTo(length, "[", "]", (i) => `"${SQL_WORDS[i % SQL_WORDS.length] ?? ""} ${String(i)}"`)
|
|
36094
|
+
},
|
|
36095
|
+
{ name: "single-quoted keyword run ('where)", build: (length) => repeatTo("'where", length) },
|
|
36096
|
+
{ name: "double-quote run", build: (length) => repeatTo('"', length) },
|
|
36097
|
+
{ name: "space run", build: (length) => repeatTo(" ", length) },
|
|
36098
|
+
{ name: "newline run", build: (length) => repeatTo("\n", length) },
|
|
36099
|
+
...["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].map((unit) => ({
|
|
36100
|
+
name: `unit run ${JSON.stringify(unit)}`,
|
|
36101
|
+
build: (length) => repeatTo(unit, length)
|
|
36102
|
+
}))
|
|
36103
|
+
];
|
|
36054
36104
|
|
|
36055
36105
|
// ../../rules/code-flaws/auth-jwt-no-verify.json
|
|
36056
36106
|
var auth_jwt_no_verify_default = {
|
|
@@ -36061,7 +36111,7 @@ var auth_jwt_no_verify_default = {
|
|
|
36061
36111
|
severity: "critical",
|
|
36062
36112
|
matcher: {
|
|
36063
36113
|
type: "regex",
|
|
36064
|
-
pattern: "(verify\\s*=\\s*false|verify_signature
|
|
36114
|
+
pattern: "(verify\\s*=\\s*false|verify_signature(?:(?!verify_signature).)*false|algorithms\\s*=\\s*\\[\\])",
|
|
36065
36115
|
flags: "gi"
|
|
36066
36116
|
},
|
|
36067
36117
|
requiresNearby: {
|
|
@@ -36149,7 +36199,7 @@ var cmd_inject_shell_default = {
|
|
|
36149
36199
|
severity: "critical",
|
|
36150
36200
|
matcher: {
|
|
36151
36201
|
type: "regex",
|
|
36152
|
-
pattern: "subprocess\\.(run|Popen|call|check_output)\\s*\\([^)]*shell\\s*=\\s*True",
|
|
36202
|
+
pattern: "subprocess\\.(run|Popen|call|check_output)\\s*\\((?:(?!subprocess\\.(?:run|Popen|call|check_output)\\s*\\()[^)])*shell\\s*=\\s*True",
|
|
36153
36203
|
flags: "gi"
|
|
36154
36204
|
},
|
|
36155
36205
|
requiresNearby: {
|
|
@@ -36278,7 +36328,7 @@ var deser_yaml_unsafe_default = {
|
|
|
36278
36328
|
severity: "high",
|
|
36279
36329
|
matcher: {
|
|
36280
36330
|
type: "regex",
|
|
36281
|
-
pattern: "\\byaml\\.load\\s*\\((?![^)]
|
|
36331
|
+
pattern: "\\byaml\\.load\\s*\\((?!(?:(?!yaml\\.load\\s*\\()[^)])*?(?:SafeLoader|safe_load))",
|
|
36282
36332
|
flags: "gi"
|
|
36283
36333
|
},
|
|
36284
36334
|
examples: ["data = yaml.load(user_input)", "config = yaml.load(f)"],
|
|
@@ -36495,7 +36545,7 @@ var sql_inject_concat_dot_default = {
|
|
|
36495
36545
|
severity: "high",
|
|
36496
36546
|
matcher: {
|
|
36497
36547
|
type: "regex",
|
|
36498
|
-
pattern: `["'][
|
|
36548
|
+
pattern: `["'](?=([^"'\\n]*?(?:select|insert|update|delete|drop|where)))\\1(?:(?!["'][^"'\\n]*?(?:select|insert|update|delete|drop|where))[^\\n])*?["']\\s*\\.`,
|
|
36499
36549
|
flags: "gi"
|
|
36500
36550
|
},
|
|
36501
36551
|
appliesTo: {
|
|
@@ -36513,7 +36563,7 @@ var sql_inject_concat_default = {
|
|
|
36513
36563
|
severity: "high",
|
|
36514
36564
|
matcher: {
|
|
36515
36565
|
type: "regex",
|
|
36516
|
-
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*\\+`,
|
|
36566
|
+
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*\\+`,
|
|
36517
36567
|
flags: "gi"
|
|
36518
36568
|
},
|
|
36519
36569
|
examples: ['"SELECT * FROM users WHERE id = " + userId']
|
|
@@ -36528,7 +36578,7 @@ var sql_inject_format_default = {
|
|
|
36528
36578
|
severity: "high",
|
|
36529
36579
|
matcher: {
|
|
36530
36580
|
type: "regex",
|
|
36531
|
-
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]|\\{[^}]+\\})",
|
|
36581
|
+
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]+\\})",
|
|
36532
36582
|
flags: "gi"
|
|
36533
36583
|
},
|
|
36534
36584
|
examples: [
|
|
@@ -36546,7 +36596,7 @@ var sql_inject_interp_default = {
|
|
|
36546
36596
|
severity: "high",
|
|
36547
36597
|
matcher: {
|
|
36548
36598
|
type: "regex",
|
|
36549
|
-
pattern: "(select|insert|update|delete|where)[^\\n]*?(#\\{|\\$[a-z_])",
|
|
36599
|
+
pattern: "(select|insert|update|delete|where)(?:(?!(?:select|insert|update|delete|where))[^\\n])*?(#\\{|\\$[a-z_])",
|
|
36550
36600
|
flags: "gi"
|
|
36551
36601
|
},
|
|
36552
36602
|
examples: [
|
|
@@ -36921,7 +36971,7 @@ var stack_trace_default = {
|
|
|
36921
36971
|
severity: "low",
|
|
36922
36972
|
matcher: {
|
|
36923
36973
|
type: "regex",
|
|
36924
|
-
pattern: "(
|
|
36974
|
+
pattern: "(?:^|(?<!\\s)\\s+)at\\s+[A-Za-z0-9._$<>]+\\.[A-Za-z0-9_$]+\\s*\\([A-Za-z0-9._\\-/:]+:\\d+:\\d+\\)",
|
|
36925
36975
|
flags: "g"
|
|
36926
36976
|
},
|
|
36927
36977
|
examples: ["at com.example.service.UserService.findUser(UserService.java:42:13)"]
|
|
@@ -38079,7 +38129,7 @@ var BUNDLED_PACKS = [
|
|
|
38079
38129
|
{
|
|
38080
38130
|
packId: "code-flaws",
|
|
38081
38131
|
name: "Code Security Flaws",
|
|
38082
|
-
version: "0.1.
|
|
38132
|
+
version: "0.1.1",
|
|
38083
38133
|
rawRules: [
|
|
38084
38134
|
sql_inject_concat_default,
|
|
38085
38135
|
sql_inject_concat_dot_default,
|
|
@@ -38129,7 +38179,7 @@ var BUNDLED_PACKS = [
|
|
|
38129
38179
|
{
|
|
38130
38180
|
packId: "core-code-context",
|
|
38131
38181
|
name: "Code Context",
|
|
38132
|
-
version: "0.2.
|
|
38182
|
+
version: "0.2.2",
|
|
38133
38183
|
rawRules: [
|
|
38134
38184
|
internal_ip_default,
|
|
38135
38185
|
localhost_ref_default,
|
package/scripts/post-tool-use.js
CHANGED
|
@@ -21680,6 +21680,11 @@ var CaptureAttributes = external_exports.object({
|
|
|
21680
21680
|
// here too. The full statement is on EventMetadata.redactDegradedTo; it is
|
|
21681
21681
|
// repeated rather than referenced because a store reader opens this file.
|
|
21682
21682
|
redact_degraded_to: ActionTaken.optional(),
|
|
21683
|
+
// Why a capture has no content and no findings: its field was refused
|
|
21684
|
+
// because its bounded scan did not finish (see EventMetadata.scanIncomplete,
|
|
21685
|
+
// whose value this is). Absent on every capture that was scanned, so a
|
|
21686
|
+
// reader can tell a refused row from an empty clean one.
|
|
21687
|
+
scan_incomplete: external_exports.enum(["timeout", "unavailable"]).optional(),
|
|
21683
21688
|
// The scope key this capture was stamped with: the canonical repository
|
|
21684
21689
|
// (`host/owner/repo`) of the path the capture names (a relative path is read
|
|
21685
21690
|
// against its working directory), else of its own working directory, or a
|
|
@@ -23021,7 +23026,19 @@ var EventMetadata = external_exports.object({
|
|
|
23021
23026
|
// Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
|
|
23022
23027
|
// Closing either means moving the reason onto the finding row, which
|
|
23023
23028
|
// already carries its own action.
|
|
23024
|
-
redactDegradedTo: ActionTaken.optional()
|
|
23029
|
+
redactDegradedTo: ActionTaken.optional(),
|
|
23030
|
+
// Set when this capture's field was REFUSED rather than scanned: a hook
|
|
23031
|
+
// bounds the scan of a large field (see `LargeInputScanOptions` in
|
|
23032
|
+
// @akasecurity/plugin-sdk), and a scan that did not finish blocks the
|
|
23033
|
+
// field instead of letting it through unscanned.
|
|
23034
|
+
//
|
|
23035
|
+
// - 'timeout': the bounded scan ran out of time.
|
|
23036
|
+
// - 'unavailable': no worker could run it.
|
|
23037
|
+
//
|
|
23038
|
+
// A refused row stores '' as its content and has no findings, which is
|
|
23039
|
+
// exactly what a clean, empty capture looks like — this marker is the only
|
|
23040
|
+
// thing that tells the two apart. Absent on every capture that was scanned.
|
|
23041
|
+
scanIncomplete: external_exports.enum(["timeout", "unavailable"]).optional()
|
|
23025
23042
|
}).meta({ id: "EventMetadata" });
|
|
23026
23043
|
var Event = external_exports.object({
|
|
23027
23044
|
id: external_exports.guid(),
|
|
@@ -24838,6 +24855,7 @@ function toCaptureAttributes(event) {
|
|
|
24838
24855
|
...metadata?.exceptionIds !== void 0 ? { exception_ids: metadata.exceptionIds } : {},
|
|
24839
24856
|
...metadata?.inspectionMs !== void 0 ? { inspection_ms: metadata.inspectionMs } : {},
|
|
24840
24857
|
...metadata?.redactDegradedTo !== void 0 ? { redact_degraded_to: metadata.redactDegradedTo } : {},
|
|
24858
|
+
...metadata?.scanIncomplete !== void 0 ? { scan_incomplete: metadata.scanIncomplete } : {},
|
|
24841
24859
|
// `model`/`turnIndex` have no dedicated CaptureAttributes field (no writer
|
|
24842
24860
|
// has ever populated either), but every legacy metadata key still rides
|
|
24843
24861
|
// the bag rather than being silently dropped — CaptureAttributes'
|
|
@@ -36865,6 +36883,38 @@ function worstProbeMs(rule, now = wallClock, corroborate) {
|
|
|
36865
36883
|
}
|
|
36866
36884
|
var CPU_CORROBORATION_SHARE = 0.2;
|
|
36867
36885
|
var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
|
|
36886
|
+
function repeatTo(unit, length) {
|
|
36887
|
+
return unit.repeat(Math.ceil(length / unit.length)).slice(0, length);
|
|
36888
|
+
}
|
|
36889
|
+
function joinTo(length, open3, close, item) {
|
|
36890
|
+
const parts = [];
|
|
36891
|
+
let size = open3.length;
|
|
36892
|
+
for (let i = 0; size < length; i++) {
|
|
36893
|
+
const next = (i === 0 ? "" : ",") + item(i);
|
|
36894
|
+
parts.push(next);
|
|
36895
|
+
size += next.length;
|
|
36896
|
+
}
|
|
36897
|
+
return (open3 + parts.join("") + close).slice(0, length);
|
|
36898
|
+
}
|
|
36899
|
+
var SQL_WORDS = ["select", "insert", "update", "delete", "drop", "where"];
|
|
36900
|
+
var GROWTH_CORPORA = [
|
|
36901
|
+
{
|
|
36902
|
+
name: "one-line JSON dictionary",
|
|
36903
|
+
build: (length) => joinTo(length, "{", "}", (i) => `"id-${String(i)}":"label ${String(i)}"`)
|
|
36904
|
+
},
|
|
36905
|
+
{
|
|
36906
|
+
name: "JSON array of quoted SQL keywords",
|
|
36907
|
+
build: (length) => joinTo(length, "[", "]", (i) => `"${SQL_WORDS[i % SQL_WORDS.length] ?? ""} ${String(i)}"`)
|
|
36908
|
+
},
|
|
36909
|
+
{ name: "single-quoted keyword run ('where)", build: (length) => repeatTo("'where", length) },
|
|
36910
|
+
{ name: "double-quote run", build: (length) => repeatTo('"', length) },
|
|
36911
|
+
{ name: "space run", build: (length) => repeatTo(" ", length) },
|
|
36912
|
+
{ name: "newline run", build: (length) => repeatTo("\n", length) },
|
|
36913
|
+
...["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].map((unit) => ({
|
|
36914
|
+
name: `unit run ${JSON.stringify(unit)}`,
|
|
36915
|
+
build: (length) => repeatTo(unit, length)
|
|
36916
|
+
}))
|
|
36917
|
+
];
|
|
36868
36918
|
function checkRuleTiming(rule, corroborate) {
|
|
36869
36919
|
const { ms, probe, corroboratedMs } = worstProbeMs(rule, wallClock, corroborate);
|
|
36870
36920
|
const work = corroboratedMs ?? 0;
|
|
@@ -37166,7 +37216,7 @@ var auth_jwt_no_verify_default = {
|
|
|
37166
37216
|
severity: "critical",
|
|
37167
37217
|
matcher: {
|
|
37168
37218
|
type: "regex",
|
|
37169
|
-
pattern: "(verify\\s*=\\s*false|verify_signature
|
|
37219
|
+
pattern: "(verify\\s*=\\s*false|verify_signature(?:(?!verify_signature).)*false|algorithms\\s*=\\s*\\[\\])",
|
|
37170
37220
|
flags: "gi"
|
|
37171
37221
|
},
|
|
37172
37222
|
requiresNearby: {
|
|
@@ -37254,7 +37304,7 @@ var cmd_inject_shell_default = {
|
|
|
37254
37304
|
severity: "critical",
|
|
37255
37305
|
matcher: {
|
|
37256
37306
|
type: "regex",
|
|
37257
|
-
pattern: "subprocess\\.(run|Popen|call|check_output)\\s*\\([^)]*shell\\s*=\\s*True",
|
|
37307
|
+
pattern: "subprocess\\.(run|Popen|call|check_output)\\s*\\((?:(?!subprocess\\.(?:run|Popen|call|check_output)\\s*\\()[^)])*shell\\s*=\\s*True",
|
|
37258
37308
|
flags: "gi"
|
|
37259
37309
|
},
|
|
37260
37310
|
requiresNearby: {
|
|
@@ -37383,7 +37433,7 @@ var deser_yaml_unsafe_default = {
|
|
|
37383
37433
|
severity: "high",
|
|
37384
37434
|
matcher: {
|
|
37385
37435
|
type: "regex",
|
|
37386
|
-
pattern: "\\byaml\\.load\\s*\\((?![^)]
|
|
37436
|
+
pattern: "\\byaml\\.load\\s*\\((?!(?:(?!yaml\\.load\\s*\\()[^)])*?(?:SafeLoader|safe_load))",
|
|
37387
37437
|
flags: "gi"
|
|
37388
37438
|
},
|
|
37389
37439
|
examples: ["data = yaml.load(user_input)", "config = yaml.load(f)"],
|
|
@@ -37600,7 +37650,7 @@ var sql_inject_concat_dot_default = {
|
|
|
37600
37650
|
severity: "high",
|
|
37601
37651
|
matcher: {
|
|
37602
37652
|
type: "regex",
|
|
37603
|
-
pattern: `["'][
|
|
37653
|
+
pattern: `["'](?=([^"'\\n]*?(?:select|insert|update|delete|drop|where)))\\1(?:(?!["'][^"'\\n]*?(?:select|insert|update|delete|drop|where))[^\\n])*?["']\\s*\\.`,
|
|
37604
37654
|
flags: "gi"
|
|
37605
37655
|
},
|
|
37606
37656
|
appliesTo: {
|
|
@@ -37618,7 +37668,7 @@ var sql_inject_concat_default = {
|
|
|
37618
37668
|
severity: "high",
|
|
37619
37669
|
matcher: {
|
|
37620
37670
|
type: "regex",
|
|
37621
|
-
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*\\+`,
|
|
37671
|
+
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*\\+`,
|
|
37622
37672
|
flags: "gi"
|
|
37623
37673
|
},
|
|
37624
37674
|
examples: ['"SELECT * FROM users WHERE id = " + userId']
|
|
@@ -37633,7 +37683,7 @@ var sql_inject_format_default = {
|
|
|
37633
37683
|
severity: "high",
|
|
37634
37684
|
matcher: {
|
|
37635
37685
|
type: "regex",
|
|
37636
|
-
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]|\\{[^}]+\\})",
|
|
37686
|
+
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]+\\})",
|
|
37637
37687
|
flags: "gi"
|
|
37638
37688
|
},
|
|
37639
37689
|
examples: [
|
|
@@ -37651,7 +37701,7 @@ var sql_inject_interp_default = {
|
|
|
37651
37701
|
severity: "high",
|
|
37652
37702
|
matcher: {
|
|
37653
37703
|
type: "regex",
|
|
37654
|
-
pattern: "(select|insert|update|delete|where)[^\\n]*?(#\\{|\\$[a-z_])",
|
|
37704
|
+
pattern: "(select|insert|update|delete|where)(?:(?!(?:select|insert|update|delete|where))[^\\n])*?(#\\{|\\$[a-z_])",
|
|
37655
37705
|
flags: "gi"
|
|
37656
37706
|
},
|
|
37657
37707
|
examples: [
|
|
@@ -38026,7 +38076,7 @@ var stack_trace_default = {
|
|
|
38026
38076
|
severity: "low",
|
|
38027
38077
|
matcher: {
|
|
38028
38078
|
type: "regex",
|
|
38029
|
-
pattern: "(
|
|
38079
|
+
pattern: "(?:^|(?<!\\s)\\s+)at\\s+[A-Za-z0-9._$<>]+\\.[A-Za-z0-9_$]+\\s*\\([A-Za-z0-9._\\-/:]+:\\d+:\\d+\\)",
|
|
38030
38080
|
flags: "g"
|
|
38031
38081
|
},
|
|
38032
38082
|
examples: ["at com.example.service.UserService.findUser(UserService.java:42:13)"]
|
|
@@ -39184,7 +39234,7 @@ var BUNDLED_PACKS = [
|
|
|
39184
39234
|
{
|
|
39185
39235
|
packId: "code-flaws",
|
|
39186
39236
|
name: "Code Security Flaws",
|
|
39187
|
-
version: "0.1.
|
|
39237
|
+
version: "0.1.1",
|
|
39188
39238
|
rawRules: [
|
|
39189
39239
|
sql_inject_concat_default,
|
|
39190
39240
|
sql_inject_concat_dot_default,
|
|
@@ -39234,7 +39284,7 @@ var BUNDLED_PACKS = [
|
|
|
39234
39284
|
{
|
|
39235
39285
|
packId: "core-code-context",
|
|
39236
39286
|
name: "Code Context",
|
|
39237
|
-
version: "0.2.
|
|
39287
|
+
version: "0.2.2",
|
|
39238
39288
|
rawRules: [
|
|
39239
39289
|
internal_ip_default,
|
|
39240
39290
|
localhost_ref_default,
|
|
@@ -39684,9 +39734,10 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
39684
39734
|
if (job.timer !== void 0) return;
|
|
39685
39735
|
job.startedAt = performance.now();
|
|
39686
39736
|
job.progressAt = job.startedAt;
|
|
39737
|
+
const budget = job.deadlineAt === void 0 ? job.budgetMs : Math.max(0, Math.min(job.budgetMs, job.deadlineAt - job.startedAt));
|
|
39687
39738
|
job.timer = setTimeout(() => {
|
|
39688
39739
|
onDeadline(job);
|
|
39689
|
-
},
|
|
39740
|
+
}, budget);
|
|
39690
39741
|
}
|
|
39691
39742
|
function runOne(spec, fail) {
|
|
39692
39743
|
if (closed) {
|
|
@@ -39697,6 +39748,12 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
39697
39748
|
fail({ status: "unavailable", reason: `the scan worker crashed: ${broken}` });
|
|
39698
39749
|
return;
|
|
39699
39750
|
}
|
|
39751
|
+
const now = performance.now();
|
|
39752
|
+
const deadlineAt = spec.deadlineAt;
|
|
39753
|
+
if (deadlineAt !== void 0 && deadlineAt <= now) {
|
|
39754
|
+
fail({ status: "timeout", culpritIndex: void 0, elapsedMs: 0 });
|
|
39755
|
+
return;
|
|
39756
|
+
}
|
|
39700
39757
|
const started = ensureWorker();
|
|
39701
39758
|
if (!(started instanceof Worker)) {
|
|
39702
39759
|
broken = started.error;
|
|
@@ -39704,11 +39761,11 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
39704
39761
|
return;
|
|
39705
39762
|
}
|
|
39706
39763
|
const id = nextJobId++;
|
|
39707
|
-
const now = performance.now();
|
|
39708
39764
|
const job = {
|
|
39709
39765
|
id,
|
|
39710
39766
|
worker: started,
|
|
39711
39767
|
budgetMs: spec.budgetMs,
|
|
39768
|
+
deadlineAt,
|
|
39712
39769
|
startedAt: now,
|
|
39713
39770
|
progressIndex: -1,
|
|
39714
39771
|
progressAt: now,
|
|
@@ -39722,14 +39779,19 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
39722
39779
|
if (readyWorker === started) {
|
|
39723
39780
|
beginDeadline(job);
|
|
39724
39781
|
} else {
|
|
39782
|
+
const startBudget = spec.startBudgetMs ?? startBudgetMs;
|
|
39783
|
+
const callerLimited = deadlineAt !== void 0 && deadlineAt - now < startBudget;
|
|
39784
|
+
const startWaitMs = callerLimited ? deadlineAt - now : startBudget;
|
|
39725
39785
|
job.startupTimer = setTimeout(() => {
|
|
39726
39786
|
if (pending !== job) return;
|
|
39727
39787
|
kill(job.worker);
|
|
39728
|
-
failPending(
|
|
39729
|
-
status: "
|
|
39730
|
-
|
|
39731
|
-
|
|
39732
|
-
|
|
39788
|
+
failPending(
|
|
39789
|
+
callerLimited ? { status: "timeout", culpritIndex: void 0, elapsedMs: performance.now() - now } : {
|
|
39790
|
+
status: "unavailable",
|
|
39791
|
+
reason: `the scan worker did not start within ${String(startBudget)}ms`
|
|
39792
|
+
}
|
|
39793
|
+
);
|
|
39794
|
+
}, startWaitMs);
|
|
39733
39795
|
}
|
|
39734
39796
|
try {
|
|
39735
39797
|
started.postMessage(spec.build(id));
|
|
@@ -39758,7 +39820,9 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
39758
39820
|
return enqueue((resolve3) => {
|
|
39759
39821
|
runOne(
|
|
39760
39822
|
{
|
|
39761
|
-
budgetMs,
|
|
39823
|
+
budgetMs: scanOpts?.budgetMs ?? budgetMs,
|
|
39824
|
+
startBudgetMs: scanOpts?.startBudgetMs,
|
|
39825
|
+
deadlineAt: scanOpts?.deadlineAt,
|
|
39762
39826
|
build: (id) => ({
|
|
39763
39827
|
kind: "scan",
|
|
39764
39828
|
id,
|
|
@@ -39952,6 +40016,9 @@ function createGuardedScanner(partition, gateway, opts) {
|
|
|
39952
40016
|
let unverified = partition.unverified;
|
|
39953
40017
|
let isolated = unverified.length > 0 ? createIsolatedScanner({ verified, unverified }, opts) : void 0;
|
|
39954
40018
|
let retired = false;
|
|
40019
|
+
let bounded;
|
|
40020
|
+
let boundedWarned = false;
|
|
40021
|
+
let closed = false;
|
|
39955
40022
|
function inProcess(text, context) {
|
|
39956
40023
|
return scan(text, verified, context);
|
|
39957
40024
|
}
|
|
@@ -40013,11 +40080,48 @@ function createGuardedScanner(partition, gateway, opts) {
|
|
|
40013
40080
|
await degrade();
|
|
40014
40081
|
return inProcess(text, context);
|
|
40015
40082
|
}
|
|
40083
|
+
async function scanBounded(text, context, bound) {
|
|
40084
|
+
const remainingMs = bound.remainingMs;
|
|
40085
|
+
let outcome;
|
|
40086
|
+
if (closed) {
|
|
40087
|
+
outcome = { status: "unavailable", reason: "the scan worker is closed" };
|
|
40088
|
+
} else if (remainingMs !== void 0 && !(remainingMs > 0)) {
|
|
40089
|
+
outcome = { status: "timeout", culpritIndex: void 0, elapsedMs: 0 };
|
|
40090
|
+
} else {
|
|
40091
|
+
bounded ??= createIsolatedScanner({ verified, unverified }, opts);
|
|
40092
|
+
const deadlineAt = remainingMs === void 0 ? void 0 : performance.now() + remainingMs;
|
|
40093
|
+
try {
|
|
40094
|
+
outcome = await bounded.scan(text, context, {
|
|
40095
|
+
budgetMs: bound.budgetMs,
|
|
40096
|
+
startBudgetMs: bound.startBudgetMs,
|
|
40097
|
+
deadlineAt
|
|
40098
|
+
});
|
|
40099
|
+
} catch (error62) {
|
|
40100
|
+
outcome = {
|
|
40101
|
+
status: "unavailable",
|
|
40102
|
+
reason: error62 instanceof Error ? error62.message : "the scan worker failed unexpectedly"
|
|
40103
|
+
};
|
|
40104
|
+
}
|
|
40105
|
+
}
|
|
40106
|
+
if (outcome.status !== "ok" && !boundedWarned) {
|
|
40107
|
+
boundedWarned = true;
|
|
40108
|
+
process.stderr.write(
|
|
40109
|
+
outcome.status === "timeout" ? `[aka] a large input could not be scanned within its time limit and was refused.
|
|
40110
|
+
` : `[aka] a large input could not be scanned and was refused: ${outcome.reason}.
|
|
40111
|
+
`
|
|
40112
|
+
);
|
|
40113
|
+
}
|
|
40114
|
+
return outcome;
|
|
40115
|
+
}
|
|
40016
40116
|
return {
|
|
40017
40117
|
scan: guardedScan,
|
|
40118
|
+
scanBounded,
|
|
40018
40119
|
degraded: () => retired,
|
|
40019
40120
|
async close() {
|
|
40020
|
-
|
|
40121
|
+
closed = true;
|
|
40122
|
+
const live = bounded;
|
|
40123
|
+
bounded = void 0;
|
|
40124
|
+
await Promise.all([retire(), live?.close()]);
|
|
40021
40125
|
}
|
|
40022
40126
|
};
|
|
40023
40127
|
}
|
|
@@ -40144,6 +40248,19 @@ function conditionsMatch(conditions, ctx) {
|
|
|
40144
40248
|
if (conditions.provider !== void 0) return false;
|
|
40145
40249
|
return true;
|
|
40146
40250
|
}
|
|
40251
|
+
var LARGE_INPUT_THRESHOLD_CHARS = 32768;
|
|
40252
|
+
var LARGE_INPUT_SCAN_BUDGET_MS = 2e3;
|
|
40253
|
+
var LARGE_INPUT_START_BUDGET_MS = 1500;
|
|
40254
|
+
function readRemainingMs(largeInput) {
|
|
40255
|
+
const read = largeInput.remainingMs;
|
|
40256
|
+
if (read === void 0) return void 0;
|
|
40257
|
+
try {
|
|
40258
|
+
const remaining = read();
|
|
40259
|
+
return typeof remaining !== "number" || Number.isNaN(remaining) ? 0 : remaining;
|
|
40260
|
+
} catch {
|
|
40261
|
+
return 0;
|
|
40262
|
+
}
|
|
40263
|
+
}
|
|
40147
40264
|
var bundlesPacked = false;
|
|
40148
40265
|
function createPluginRuntime(gateway, settings, opts) {
|
|
40149
40266
|
if (!bundlesPacked) {
|
|
@@ -40153,6 +40270,7 @@ function createPluginRuntime(gateway, settings, opts) {
|
|
|
40153
40270
|
const policyMode = settings.policy;
|
|
40154
40271
|
let redactFallback = settings.redactFallback;
|
|
40155
40272
|
const dataDir2 = opts?.dataDir;
|
|
40273
|
+
const largeInput = opts?.largeInput;
|
|
40156
40274
|
let rules = [];
|
|
40157
40275
|
let evidenceOf = evidenceLookup(rules);
|
|
40158
40276
|
let scanner;
|
|
@@ -40365,7 +40483,24 @@ function createPluginRuntime(gateway, settings, opts) {
|
|
|
40365
40483
|
await ensureInitialized();
|
|
40366
40484
|
if (!scanner) throw new Error("the runtime initialized without a scanner");
|
|
40367
40485
|
const shielded = shieldPointers(text);
|
|
40368
|
-
|
|
40486
|
+
let matched;
|
|
40487
|
+
if (largeInput !== void 0 && shielded.text.length >= largeInput.thresholdChars) {
|
|
40488
|
+
const outcome = await scanner.scanBounded(shielded.text, context, {
|
|
40489
|
+
budgetMs: largeInput.budgetMs,
|
|
40490
|
+
startBudgetMs: largeInput.startBudgetMs,
|
|
40491
|
+
remainingMs: readRemainingMs(largeInput)
|
|
40492
|
+
});
|
|
40493
|
+
if (outcome.status !== "ok") {
|
|
40494
|
+
return {
|
|
40495
|
+
decision: { action: "block", text: null, findings: [], scanIncomplete: outcome.status },
|
|
40496
|
+
excepted: /* @__PURE__ */ new Set(),
|
|
40497
|
+
exceptionIds: []
|
|
40498
|
+
};
|
|
40499
|
+
}
|
|
40500
|
+
matched = outcome.findings;
|
|
40501
|
+
} else {
|
|
40502
|
+
matched = await scanner.scan(shielded.text, context);
|
|
40503
|
+
}
|
|
40369
40504
|
const findings = dropShieldedFindings(matched, shielded.spans);
|
|
40370
40505
|
const fpCache = /* @__PURE__ */ new Map();
|
|
40371
40506
|
const { excepted, exceptionIds } = await applyExceptions(findings, ctx, fpCache);
|
|
@@ -40406,20 +40541,24 @@ function createPluginRuntime(gateway, settings, opts) {
|
|
|
40406
40541
|
}
|
|
40407
40542
|
async function persistCapture(input2, opts2, { decision, excepted, exceptionIds, timingStartedAt }) {
|
|
40408
40543
|
const filePath = input2.metadata?.filePath;
|
|
40409
|
-
if (opts2.persist === "with-findings" && decision.findings.length === 0)
|
|
40544
|
+
if (opts2.persist === "with-findings" && decision.findings.length === 0 && decision.scanIncomplete === void 0) {
|
|
40545
|
+
return;
|
|
40546
|
+
}
|
|
40410
40547
|
try {
|
|
40411
40548
|
const contentHash = contentHashOf(input2.text);
|
|
40412
40549
|
const maskedFindings = decision.findings.filter(
|
|
40413
40550
|
(match) => isActionAtLeast(actionForFinding(match, excepted, opts2.rewritable), "redact")
|
|
40414
40551
|
);
|
|
40415
|
-
const storedContent = maskedFindings.length > 0 ? redact(input2.text, maskedFindings) : input2.text;
|
|
40552
|
+
const storedContent = decision.scanIncomplete !== void 0 ? "" : maskedFindings.length > 0 ? redact(input2.text, maskedFindings) : input2.text;
|
|
40416
40553
|
const inspectionMs = elapsedMs(timingStartedAt);
|
|
40417
40554
|
const redactDegradedTo = decision.redactDegradedTo;
|
|
40418
|
-
const
|
|
40555
|
+
const scanIncomplete = decision.scanIncomplete;
|
|
40556
|
+
const metadata = exceptionIds.length > 0 || inspectionMs !== void 0 || redactDegradedTo !== void 0 || scanIncomplete !== void 0 ? {
|
|
40419
40557
|
...input2.metadata,
|
|
40420
40558
|
...exceptionIds.length > 0 ? { exceptionIds } : {},
|
|
40421
40559
|
...inspectionMs !== void 0 ? { inspectionMs } : {},
|
|
40422
|
-
...redactDegradedTo !== void 0 ? { redactDegradedTo } : {}
|
|
40560
|
+
...redactDegradedTo !== void 0 ? { redactDegradedTo } : {},
|
|
40561
|
+
...scanIncomplete !== void 0 ? { scanIncomplete } : {}
|
|
40423
40562
|
} : input2.metadata;
|
|
40424
40563
|
const event = buildIngestEvent({
|
|
40425
40564
|
kind: input2.kind,
|
|
@@ -42005,6 +42144,7 @@ var CORRELATION_ID = EventMetadata.shape.correlationId;
|
|
|
42005
42144
|
var TRACE_ID = EventMetadata.shape.traceId;
|
|
42006
42145
|
var EXCEPTION_ID = EventMetadata.shape.exceptionIds.unwrap().element;
|
|
42007
42146
|
var REDACT_DEGRADED_TO = EventMetadata.shape.redactDegradedTo.unwrap();
|
|
42147
|
+
var SCAN_INCOMPLETE = EventMetadata.shape.scanIncomplete.unwrap();
|
|
42008
42148
|
|
|
42009
42149
|
// ../../packages/plugin-runtime/src/attached/history-sync.ts
|
|
42010
42150
|
var CAPTURE_BATCH_BYTES = 1024 * 1024;
|
|
@@ -42974,6 +43114,16 @@ function resolveDataGateway(config2, meta4, gatewayFactory = defaultGatewayFacto
|
|
|
42974
43114
|
import { randomUUID as randomUUID19 } from "crypto";
|
|
42975
43115
|
var EXCEPTION_RETENTION_MS = 90 * 24 * 60 * 60 * 1e3;
|
|
42976
43116
|
|
|
43117
|
+
// src/hooks/large-input.ts
|
|
43118
|
+
function largeInputBound(deadlineAt, now = () => performance.now()) {
|
|
43119
|
+
return {
|
|
43120
|
+
thresholdChars: LARGE_INPUT_THRESHOLD_CHARS,
|
|
43121
|
+
budgetMs: LARGE_INPUT_SCAN_BUDGET_MS,
|
|
43122
|
+
startBudgetMs: LARGE_INPUT_START_BUDGET_MS,
|
|
43123
|
+
remainingMs: () => deadlineAt - now()
|
|
43124
|
+
};
|
|
43125
|
+
}
|
|
43126
|
+
|
|
42977
43127
|
// src/present.ts
|
|
42978
43128
|
var SHADE = {
|
|
42979
43129
|
light: "\u2591",
|
|
@@ -43011,16 +43161,26 @@ function withheldBanner(input2) {
|
|
|
43011
43161
|
const header = `${SHADE.full}${SHADE.dark}${SHADE.medium}${SHADE.light} AKA ${SHADE.light}${SHADE.medium}${SHADE.dark}${SHADE.full}`;
|
|
43012
43162
|
const subject = input2.action === "withheld" ? "The flagged value" : "Redacted spans";
|
|
43013
43163
|
const approve = input2.blockedRef ? `Allow this exact value (${input2.blockedRef.maskedValue}) intentionally: aka exception approve ${input2.blockedRef.reference}` : "Allow intentionally: aka exception approve";
|
|
43164
|
+
const flagged = Boolean(input2.withheldRuleIds) || Boolean(input2.redactedRuleIds);
|
|
43014
43165
|
return [
|
|
43015
43166
|
`${header} ${input2.toolName} output ${input2.action}`,
|
|
43016
43167
|
...input2.withheldRuleIds ? [`${SHADE.full} Withheld: ${input2.withheldRuleIds}`] : [],
|
|
43017
43168
|
...input2.redactedRuleIds ? [`${SHADE.full} Redacted: ${input2.redactedRuleIds}`] : [],
|
|
43169
|
+
...input2.tooLargeFields ? [
|
|
43170
|
+
`${SHADE.full} Too large to scan in time: ${input2.tooLargeFields} \u2014 withheld, never reached the model.`
|
|
43171
|
+
] : [],
|
|
43018
43172
|
...input2.warnedRuleIds ? [`${SHADE.full} Also flagged (warn): ${input2.warnedRuleIds}`] : [],
|
|
43019
|
-
|
|
43020
|
-
|
|
43021
|
-
|
|
43173
|
+
...flagged ? [
|
|
43174
|
+
`${SHADE.full} ${subject} never reached the model.`,
|
|
43175
|
+
`${SHADE.full} ${approve}`,
|
|
43176
|
+
`${SHADE.full} More: aka exception --help`
|
|
43177
|
+
] : []
|
|
43022
43178
|
].join("\n");
|
|
43023
43179
|
}
|
|
43180
|
+
function tooLargeToolText(toolName, field) {
|
|
43181
|
+
const part = field !== void 0 && field !== "" ? field : "output";
|
|
43182
|
+
return `[AKA SECURITY] ${toolName} ${part} withheld \u2014 too large to scan within the time limit. The content was not added to your context. This notice is a placeholder, not the real content: the underlying file or command output is unchanged, so never write this notice back to a file or treat it as data. Tell the user AKA withheld this output because it was too large to scan. If the task needs it, read it in smaller parts (for example a narrower range of lines).`;
|
|
43183
|
+
}
|
|
43024
43184
|
function withheldToolText(toolName, ruleIds, field) {
|
|
43025
43185
|
const part = field !== void 0 && field !== "" ? field : "output";
|
|
43026
43186
|
return `[AKA SECURITY] ${toolName} ${part} withheld \u2014 flagged ${ruleIds}. The flagged content was not added to your context. This notice is a placeholder, not the real content: the underlying file or command output is unchanged, so never write this notice back to a file or treat it as data. Do not attempt to obtain the withheld content through other channels. Tell the user AKA withheld this output and why. If the user asks again \u2014 for example after granting an AKA exception \u2014 re-run this same tool call if it is safe to repeat: AKA re-evaluates every capture and passes values the user has excepted.`;
|
|
@@ -43036,7 +43196,8 @@ async function scanResponseFields(toolName, fields, capture, deadline) {
|
|
|
43036
43196
|
blockedReferences: [],
|
|
43037
43197
|
redactedReferences: [],
|
|
43038
43198
|
toolName,
|
|
43039
|
-
unscannedFields: 0
|
|
43199
|
+
unscannedFields: 0,
|
|
43200
|
+
tooLargeFields: []
|
|
43040
43201
|
};
|
|
43041
43202
|
for (const [index, field] of fields.entries()) {
|
|
43042
43203
|
if (deadline !== void 0 && deadline.now() >= deadline.at) {
|
|
@@ -43044,6 +43205,11 @@ async function scanResponseFields(toolName, fields, capture, deadline) {
|
|
|
43044
43205
|
break;
|
|
43045
43206
|
}
|
|
43046
43207
|
const result = await capture(field.text);
|
|
43208
|
+
if (result.scanIncomplete !== void 0) {
|
|
43209
|
+
const name = field.path.join(".");
|
|
43210
|
+
if (!outcome.tooLargeFields.includes(name)) outcome.tooLargeFields.push(name);
|
|
43211
|
+
continue;
|
|
43212
|
+
}
|
|
43047
43213
|
if (result.findings.length === 0) continue;
|
|
43048
43214
|
if (result.action === "block") {
|
|
43049
43215
|
outcome.withheldFindings.push(...result.findings);
|
|
@@ -43058,21 +43224,30 @@ async function scanResponseFields(toolName, fields, capture, deadline) {
|
|
|
43058
43224
|
return outcome;
|
|
43059
43225
|
}
|
|
43060
43226
|
function responseEmitPayload(outcome) {
|
|
43061
|
-
const {
|
|
43227
|
+
const {
|
|
43228
|
+
toolName,
|
|
43229
|
+
withheldFindings,
|
|
43230
|
+
redactedButWithheldFindings,
|
|
43231
|
+
warnedFindings,
|
|
43232
|
+
tooLargeFields
|
|
43233
|
+
} = outcome;
|
|
43062
43234
|
const allWithheld = [...withheldFindings, ...redactedButWithheldFindings];
|
|
43063
|
-
if (allWithheld.length > 0) {
|
|
43235
|
+
if (allWithheld.length > 0 || tooLargeFields.length > 0) {
|
|
43064
43236
|
const withheldRuleIds = withheldFindings.length > 0 ? uniqueRuleIds(withheldFindings) : void 0;
|
|
43065
43237
|
const redactedRuleIds = redactedButWithheldFindings.length > 0 ? uniqueRuleIds(redactedButWithheldFindings) : void 0;
|
|
43066
43238
|
const ref = outcome.blockedReferences[0] ?? outcome.redactedReferences[0];
|
|
43067
43239
|
return {
|
|
43068
43240
|
decision: "block",
|
|
43069
|
-
|
|
43241
|
+
// The whole result goes either way; a flagged rule is the more specific
|
|
43242
|
+
// reason when there is one.
|
|
43243
|
+
reason: allWithheld.length > 0 ? withheldToolText(toolName, uniqueRuleIds(allWithheld)) : tooLargeToolText(toolName),
|
|
43070
43244
|
systemMessage: withheldBanner({
|
|
43071
43245
|
toolName,
|
|
43072
43246
|
action: "withheld",
|
|
43073
43247
|
withheldRuleIds,
|
|
43074
43248
|
redactedRuleIds,
|
|
43075
43249
|
warnedRuleIds: warnedFindings.length > 0 ? uniqueRuleIds(warnedFindings) : void 0,
|
|
43250
|
+
tooLargeFields: tooLargeFields.length > 0 ? tooLargeFields.join(", ") : void 0,
|
|
43076
43251
|
blockedRef: ref
|
|
43077
43252
|
})
|
|
43078
43253
|
};
|
|
@@ -43346,7 +43521,10 @@ async function main() {
|
|
|
43346
43521
|
const config2 = loadConfig();
|
|
43347
43522
|
warnIfStoreRedirected(config2, getString(input2, "session_id"));
|
|
43348
43523
|
const gateway = resolveDataGateway(config2);
|
|
43349
|
-
const runtime = createPluginRuntime(gateway, config2.settings, {
|
|
43524
|
+
const runtime = createPluginRuntime(gateway, config2.settings, {
|
|
43525
|
+
dataDir: config2.dataDir,
|
|
43526
|
+
largeInput: largeInputBound(RESPONSE_SCAN_DEADLINE_MS)
|
|
43527
|
+
});
|
|
43350
43528
|
let outcome;
|
|
43351
43529
|
try {
|
|
43352
43530
|
outcome = await scanResponseFields(
|