@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/reconcile.js
CHANGED
|
@@ -21687,6 +21687,11 @@ var CaptureAttributes = external_exports.object({
|
|
|
21687
21687
|
// here too. The full statement is on EventMetadata.redactDegradedTo; it is
|
|
21688
21688
|
// repeated rather than referenced because a store reader opens this file.
|
|
21689
21689
|
redact_degraded_to: ActionTaken.optional(),
|
|
21690
|
+
// Why a capture has no content and no findings: its field was refused
|
|
21691
|
+
// because its bounded scan did not finish (see EventMetadata.scanIncomplete,
|
|
21692
|
+
// whose value this is). Absent on every capture that was scanned, so a
|
|
21693
|
+
// reader can tell a refused row from an empty clean one.
|
|
21694
|
+
scan_incomplete: external_exports.enum(["timeout", "unavailable"]).optional(),
|
|
21690
21695
|
// The scope key this capture was stamped with: the canonical repository
|
|
21691
21696
|
// (`host/owner/repo`) of the path the capture names (a relative path is read
|
|
21692
21697
|
// against its working directory), else of its own working directory, or a
|
|
@@ -23028,7 +23033,19 @@ var EventMetadata = external_exports.object({
|
|
|
23028
23033
|
// Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
|
|
23029
23034
|
// Closing either means moving the reason onto the finding row, which
|
|
23030
23035
|
// already carries its own action.
|
|
23031
|
-
redactDegradedTo: ActionTaken.optional()
|
|
23036
|
+
redactDegradedTo: ActionTaken.optional(),
|
|
23037
|
+
// Set when this capture's field was REFUSED rather than scanned: a hook
|
|
23038
|
+
// bounds the scan of a large field (see `LargeInputScanOptions` in
|
|
23039
|
+
// @akasecurity/plugin-sdk), and a scan that did not finish blocks the
|
|
23040
|
+
// field instead of letting it through unscanned.
|
|
23041
|
+
//
|
|
23042
|
+
// - 'timeout': the bounded scan ran out of time.
|
|
23043
|
+
// - 'unavailable': no worker could run it.
|
|
23044
|
+
//
|
|
23045
|
+
// A refused row stores '' as its content and has no findings, which is
|
|
23046
|
+
// exactly what a clean, empty capture looks like — this marker is the only
|
|
23047
|
+
// thing that tells the two apart. Absent on every capture that was scanned.
|
|
23048
|
+
scanIncomplete: external_exports.enum(["timeout", "unavailable"]).optional()
|
|
23032
23049
|
}).meta({ id: "EventMetadata" });
|
|
23033
23050
|
var Event = external_exports.object({
|
|
23034
23051
|
id: external_exports.guid(),
|
|
@@ -24840,6 +24857,7 @@ function toCaptureAttributes(event) {
|
|
|
24840
24857
|
...metadata?.exceptionIds !== void 0 ? { exception_ids: metadata.exceptionIds } : {},
|
|
24841
24858
|
...metadata?.inspectionMs !== void 0 ? { inspection_ms: metadata.inspectionMs } : {},
|
|
24842
24859
|
...metadata?.redactDegradedTo !== void 0 ? { redact_degraded_to: metadata.redactDegradedTo } : {},
|
|
24860
|
+
...metadata?.scanIncomplete !== void 0 ? { scan_incomplete: metadata.scanIncomplete } : {},
|
|
24843
24861
|
// `model`/`turnIndex` have no dedicated CaptureAttributes field (no writer
|
|
24844
24862
|
// has ever populated either), but every legacy metadata key still rides
|
|
24845
24863
|
// the bag rather than being silently dropped — CaptureAttributes'
|
|
@@ -36602,6 +36620,38 @@ var POLYNOMIAL_PROBES = ["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].m
|
|
|
36602
36620
|
);
|
|
36603
36621
|
var CPU_CORROBORATION_SHARE = 0.2;
|
|
36604
36622
|
var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
|
|
36623
|
+
function repeatTo(unit, length) {
|
|
36624
|
+
return unit.repeat(Math.ceil(length / unit.length)).slice(0, length);
|
|
36625
|
+
}
|
|
36626
|
+
function joinTo(length, open3, close, item) {
|
|
36627
|
+
const parts = [];
|
|
36628
|
+
let size = open3.length;
|
|
36629
|
+
for (let i = 0; size < length; i++) {
|
|
36630
|
+
const next = (i === 0 ? "" : ",") + item(i);
|
|
36631
|
+
parts.push(next);
|
|
36632
|
+
size += next.length;
|
|
36633
|
+
}
|
|
36634
|
+
return (open3 + parts.join("") + close).slice(0, length);
|
|
36635
|
+
}
|
|
36636
|
+
var SQL_WORDS = ["select", "insert", "update", "delete", "drop", "where"];
|
|
36637
|
+
var GROWTH_CORPORA = [
|
|
36638
|
+
{
|
|
36639
|
+
name: "one-line JSON dictionary",
|
|
36640
|
+
build: (length) => joinTo(length, "{", "}", (i) => `"id-${String(i)}":"label ${String(i)}"`)
|
|
36641
|
+
},
|
|
36642
|
+
{
|
|
36643
|
+
name: "JSON array of quoted SQL keywords",
|
|
36644
|
+
build: (length) => joinTo(length, "[", "]", (i) => `"${SQL_WORDS[i % SQL_WORDS.length] ?? ""} ${String(i)}"`)
|
|
36645
|
+
},
|
|
36646
|
+
{ name: "single-quoted keyword run ('where)", build: (length) => repeatTo("'where", length) },
|
|
36647
|
+
{ name: "double-quote run", build: (length) => repeatTo('"', length) },
|
|
36648
|
+
{ name: "space run", build: (length) => repeatTo(" ", length) },
|
|
36649
|
+
{ name: "newline run", build: (length) => repeatTo("\n", length) },
|
|
36650
|
+
...["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].map((unit) => ({
|
|
36651
|
+
name: `unit run ${JSON.stringify(unit)}`,
|
|
36652
|
+
build: (length) => repeatTo(unit, length)
|
|
36653
|
+
}))
|
|
36654
|
+
];
|
|
36605
36655
|
|
|
36606
36656
|
// ../../packages/plugin-sdk/src/raw-egress.ts
|
|
36607
36657
|
var RawEgressError = class extends Error {
|
|
@@ -36897,7 +36947,7 @@ var auth_jwt_no_verify_default = {
|
|
|
36897
36947
|
severity: "critical",
|
|
36898
36948
|
matcher: {
|
|
36899
36949
|
type: "regex",
|
|
36900
|
-
pattern: "(verify\\s*=\\s*false|verify_signature
|
|
36950
|
+
pattern: "(verify\\s*=\\s*false|verify_signature(?:(?!verify_signature).)*false|algorithms\\s*=\\s*\\[\\])",
|
|
36901
36951
|
flags: "gi"
|
|
36902
36952
|
},
|
|
36903
36953
|
requiresNearby: {
|
|
@@ -36985,7 +37035,7 @@ var cmd_inject_shell_default = {
|
|
|
36985
37035
|
severity: "critical",
|
|
36986
37036
|
matcher: {
|
|
36987
37037
|
type: "regex",
|
|
36988
|
-
pattern: "subprocess\\.(run|Popen|call|check_output)\\s*\\([^)]*shell\\s*=\\s*True",
|
|
37038
|
+
pattern: "subprocess\\.(run|Popen|call|check_output)\\s*\\((?:(?!subprocess\\.(?:run|Popen|call|check_output)\\s*\\()[^)])*shell\\s*=\\s*True",
|
|
36989
37039
|
flags: "gi"
|
|
36990
37040
|
},
|
|
36991
37041
|
requiresNearby: {
|
|
@@ -37114,7 +37164,7 @@ var deser_yaml_unsafe_default = {
|
|
|
37114
37164
|
severity: "high",
|
|
37115
37165
|
matcher: {
|
|
37116
37166
|
type: "regex",
|
|
37117
|
-
pattern: "\\byaml\\.load\\s*\\((?![^)]
|
|
37167
|
+
pattern: "\\byaml\\.load\\s*\\((?!(?:(?!yaml\\.load\\s*\\()[^)])*?(?:SafeLoader|safe_load))",
|
|
37118
37168
|
flags: "gi"
|
|
37119
37169
|
},
|
|
37120
37170
|
examples: ["data = yaml.load(user_input)", "config = yaml.load(f)"],
|
|
@@ -37331,7 +37381,7 @@ var sql_inject_concat_dot_default = {
|
|
|
37331
37381
|
severity: "high",
|
|
37332
37382
|
matcher: {
|
|
37333
37383
|
type: "regex",
|
|
37334
|
-
pattern: `["'][
|
|
37384
|
+
pattern: `["'](?=([^"'\\n]*?(?:select|insert|update|delete|drop|where)))\\1(?:(?!["'][^"'\\n]*?(?:select|insert|update|delete|drop|where))[^\\n])*?["']\\s*\\.`,
|
|
37335
37385
|
flags: "gi"
|
|
37336
37386
|
},
|
|
37337
37387
|
appliesTo: {
|
|
@@ -37349,7 +37399,7 @@ var sql_inject_concat_default = {
|
|
|
37349
37399
|
severity: "high",
|
|
37350
37400
|
matcher: {
|
|
37351
37401
|
type: "regex",
|
|
37352
|
-
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*\\+`,
|
|
37402
|
+
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*\\+`,
|
|
37353
37403
|
flags: "gi"
|
|
37354
37404
|
},
|
|
37355
37405
|
examples: ['"SELECT * FROM users WHERE id = " + userId']
|
|
@@ -37364,7 +37414,7 @@ var sql_inject_format_default = {
|
|
|
37364
37414
|
severity: "high",
|
|
37365
37415
|
matcher: {
|
|
37366
37416
|
type: "regex",
|
|
37367
|
-
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]|\\{[^}]+\\})",
|
|
37417
|
+
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]+\\})",
|
|
37368
37418
|
flags: "gi"
|
|
37369
37419
|
},
|
|
37370
37420
|
examples: [
|
|
@@ -37382,7 +37432,7 @@ var sql_inject_interp_default = {
|
|
|
37382
37432
|
severity: "high",
|
|
37383
37433
|
matcher: {
|
|
37384
37434
|
type: "regex",
|
|
37385
|
-
pattern: "(select|insert|update|delete|where)[^\\n]*?(#\\{|\\$[a-z_])",
|
|
37435
|
+
pattern: "(select|insert|update|delete|where)(?:(?!(?:select|insert|update|delete|where))[^\\n])*?(#\\{|\\$[a-z_])",
|
|
37386
37436
|
flags: "gi"
|
|
37387
37437
|
},
|
|
37388
37438
|
examples: [
|
|
@@ -37757,7 +37807,7 @@ var stack_trace_default = {
|
|
|
37757
37807
|
severity: "low",
|
|
37758
37808
|
matcher: {
|
|
37759
37809
|
type: "regex",
|
|
37760
|
-
pattern: "(
|
|
37810
|
+
pattern: "(?:^|(?<!\\s)\\s+)at\\s+[A-Za-z0-9._$<>]+\\.[A-Za-z0-9_$]+\\s*\\([A-Za-z0-9._\\-/:]+:\\d+:\\d+\\)",
|
|
37761
37811
|
flags: "g"
|
|
37762
37812
|
},
|
|
37763
37813
|
examples: ["at com.example.service.UserService.findUser(UserService.java:42:13)"]
|
|
@@ -38915,7 +38965,7 @@ var BUNDLED_PACKS = [
|
|
|
38915
38965
|
{
|
|
38916
38966
|
packId: "code-flaws",
|
|
38917
38967
|
name: "Code Security Flaws",
|
|
38918
|
-
version: "0.1.
|
|
38968
|
+
version: "0.1.1",
|
|
38919
38969
|
rawRules: [
|
|
38920
38970
|
sql_inject_concat_default,
|
|
38921
38971
|
sql_inject_concat_dot_default,
|
|
@@ -38965,7 +39015,7 @@ var BUNDLED_PACKS = [
|
|
|
38965
39015
|
{
|
|
38966
39016
|
packId: "core-code-context",
|
|
38967
39017
|
name: "Code Context",
|
|
38968
|
-
version: "0.2.
|
|
39018
|
+
version: "0.2.2",
|
|
38969
39019
|
rawRules: [
|
|
38970
39020
|
internal_ip_default,
|
|
38971
39021
|
localhost_ref_default,
|
|
@@ -40829,6 +40879,7 @@ var CORRELATION_ID = EventMetadata.shape.correlationId;
|
|
|
40829
40879
|
var TRACE_ID = EventMetadata.shape.traceId;
|
|
40830
40880
|
var EXCEPTION_ID = EventMetadata.shape.exceptionIds.unwrap().element;
|
|
40831
40881
|
var REDACT_DEGRADED_TO = EventMetadata.shape.redactDegradedTo.unwrap();
|
|
40882
|
+
var SCAN_INCOMPLETE = EventMetadata.shape.scanIncomplete.unwrap();
|
|
40832
40883
|
|
|
40833
40884
|
// ../../packages/plugin-runtime/src/attached/history-sync.ts
|
|
40834
40885
|
var CAPTURE_BATCH_BYTES = 1024 * 1024;
|
package/scripts/remediate.js
CHANGED
|
@@ -21684,6 +21684,11 @@ var CaptureAttributes = external_exports.object({
|
|
|
21684
21684
|
// here too. The full statement is on EventMetadata.redactDegradedTo; it is
|
|
21685
21685
|
// repeated rather than referenced because a store reader opens this file.
|
|
21686
21686
|
redact_degraded_to: ActionTaken.optional(),
|
|
21687
|
+
// Why a capture has no content and no findings: its field was refused
|
|
21688
|
+
// because its bounded scan did not finish (see EventMetadata.scanIncomplete,
|
|
21689
|
+
// whose value this is). Absent on every capture that was scanned, so a
|
|
21690
|
+
// reader can tell a refused row from an empty clean one.
|
|
21691
|
+
scan_incomplete: external_exports.enum(["timeout", "unavailable"]).optional(),
|
|
21687
21692
|
// The scope key this capture was stamped with: the canonical repository
|
|
21688
21693
|
// (`host/owner/repo`) of the path the capture names (a relative path is read
|
|
21689
21694
|
// against its working directory), else of its own working directory, or a
|
|
@@ -23025,7 +23030,19 @@ var EventMetadata = external_exports.object({
|
|
|
23025
23030
|
// Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
|
|
23026
23031
|
// Closing either means moving the reason onto the finding row, which
|
|
23027
23032
|
// already carries its own action.
|
|
23028
|
-
redactDegradedTo: ActionTaken.optional()
|
|
23033
|
+
redactDegradedTo: ActionTaken.optional(),
|
|
23034
|
+
// Set when this capture's field was REFUSED rather than scanned: a hook
|
|
23035
|
+
// bounds the scan of a large field (see `LargeInputScanOptions` in
|
|
23036
|
+
// @akasecurity/plugin-sdk), and a scan that did not finish blocks the
|
|
23037
|
+
// field instead of letting it through unscanned.
|
|
23038
|
+
//
|
|
23039
|
+
// - 'timeout': the bounded scan ran out of time.
|
|
23040
|
+
// - 'unavailable': no worker could run it.
|
|
23041
|
+
//
|
|
23042
|
+
// A refused row stores '' as its content and has no findings, which is
|
|
23043
|
+
// exactly what a clean, empty capture looks like — this marker is the only
|
|
23044
|
+
// thing that tells the two apart. Absent on every capture that was scanned.
|
|
23045
|
+
scanIncomplete: external_exports.enum(["timeout", "unavailable"]).optional()
|
|
23029
23046
|
}).meta({ id: "EventMetadata" });
|
|
23030
23047
|
var Event = external_exports.object({
|
|
23031
23048
|
id: external_exports.guid(),
|
|
@@ -24842,6 +24859,7 @@ function toCaptureAttributes(event) {
|
|
|
24842
24859
|
...metadata?.exceptionIds !== void 0 ? { exception_ids: metadata.exceptionIds } : {},
|
|
24843
24860
|
...metadata?.inspectionMs !== void 0 ? { inspection_ms: metadata.inspectionMs } : {},
|
|
24844
24861
|
...metadata?.redactDegradedTo !== void 0 ? { redact_degraded_to: metadata.redactDegradedTo } : {},
|
|
24862
|
+
...metadata?.scanIncomplete !== void 0 ? { scan_incomplete: metadata.scanIncomplete } : {},
|
|
24845
24863
|
// `model`/`turnIndex` have no dedicated CaptureAttributes field (no writer
|
|
24846
24864
|
// has ever populated either), but every legacy metadata key still rides
|
|
24847
24865
|
// the bag rather than being silently dropped — CaptureAttributes'
|
|
@@ -36819,6 +36837,38 @@ function worstProbeMs(rule, now = wallClock, corroborate) {
|
|
|
36819
36837
|
}
|
|
36820
36838
|
var CPU_CORROBORATION_SHARE = 0.2;
|
|
36821
36839
|
var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
|
|
36840
|
+
function repeatTo(unit, length) {
|
|
36841
|
+
return unit.repeat(Math.ceil(length / unit.length)).slice(0, length);
|
|
36842
|
+
}
|
|
36843
|
+
function joinTo(length, open3, close, item) {
|
|
36844
|
+
const parts = [];
|
|
36845
|
+
let size = open3.length;
|
|
36846
|
+
for (let i = 0; size < length; i++) {
|
|
36847
|
+
const next = (i === 0 ? "" : ",") + item(i);
|
|
36848
|
+
parts.push(next);
|
|
36849
|
+
size += next.length;
|
|
36850
|
+
}
|
|
36851
|
+
return (open3 + parts.join("") + close).slice(0, length);
|
|
36852
|
+
}
|
|
36853
|
+
var SQL_WORDS = ["select", "insert", "update", "delete", "drop", "where"];
|
|
36854
|
+
var GROWTH_CORPORA = [
|
|
36855
|
+
{
|
|
36856
|
+
name: "one-line JSON dictionary",
|
|
36857
|
+
build: (length) => joinTo(length, "{", "}", (i) => `"id-${String(i)}":"label ${String(i)}"`)
|
|
36858
|
+
},
|
|
36859
|
+
{
|
|
36860
|
+
name: "JSON array of quoted SQL keywords",
|
|
36861
|
+
build: (length) => joinTo(length, "[", "]", (i) => `"${SQL_WORDS[i % SQL_WORDS.length] ?? ""} ${String(i)}"`)
|
|
36862
|
+
},
|
|
36863
|
+
{ name: "single-quoted keyword run ('where)", build: (length) => repeatTo("'where", length) },
|
|
36864
|
+
{ name: "double-quote run", build: (length) => repeatTo('"', length) },
|
|
36865
|
+
{ name: "space run", build: (length) => repeatTo(" ", length) },
|
|
36866
|
+
{ name: "newline run", build: (length) => repeatTo("\n", length) },
|
|
36867
|
+
...["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].map((unit) => ({
|
|
36868
|
+
name: `unit run ${JSON.stringify(unit)}`,
|
|
36869
|
+
build: (length) => repeatTo(unit, length)
|
|
36870
|
+
}))
|
|
36871
|
+
];
|
|
36822
36872
|
function checkRuleTiming(rule, corroborate) {
|
|
36823
36873
|
const { ms, probe, corroboratedMs } = worstProbeMs(rule, wallClock, corroborate);
|
|
36824
36874
|
const work = corroboratedMs ?? 0;
|
|
@@ -37120,7 +37170,7 @@ var auth_jwt_no_verify_default = {
|
|
|
37120
37170
|
severity: "critical",
|
|
37121
37171
|
matcher: {
|
|
37122
37172
|
type: "regex",
|
|
37123
|
-
pattern: "(verify\\s*=\\s*false|verify_signature
|
|
37173
|
+
pattern: "(verify\\s*=\\s*false|verify_signature(?:(?!verify_signature).)*false|algorithms\\s*=\\s*\\[\\])",
|
|
37124
37174
|
flags: "gi"
|
|
37125
37175
|
},
|
|
37126
37176
|
requiresNearby: {
|
|
@@ -37208,7 +37258,7 @@ var cmd_inject_shell_default = {
|
|
|
37208
37258
|
severity: "critical",
|
|
37209
37259
|
matcher: {
|
|
37210
37260
|
type: "regex",
|
|
37211
|
-
pattern: "subprocess\\.(run|Popen|call|check_output)\\s*\\([^)]*shell\\s*=\\s*True",
|
|
37261
|
+
pattern: "subprocess\\.(run|Popen|call|check_output)\\s*\\((?:(?!subprocess\\.(?:run|Popen|call|check_output)\\s*\\()[^)])*shell\\s*=\\s*True",
|
|
37212
37262
|
flags: "gi"
|
|
37213
37263
|
},
|
|
37214
37264
|
requiresNearby: {
|
|
@@ -37337,7 +37387,7 @@ var deser_yaml_unsafe_default = {
|
|
|
37337
37387
|
severity: "high",
|
|
37338
37388
|
matcher: {
|
|
37339
37389
|
type: "regex",
|
|
37340
|
-
pattern: "\\byaml\\.load\\s*\\((?![^)]
|
|
37390
|
+
pattern: "\\byaml\\.load\\s*\\((?!(?:(?!yaml\\.load\\s*\\()[^)])*?(?:SafeLoader|safe_load))",
|
|
37341
37391
|
flags: "gi"
|
|
37342
37392
|
},
|
|
37343
37393
|
examples: ["data = yaml.load(user_input)", "config = yaml.load(f)"],
|
|
@@ -37554,7 +37604,7 @@ var sql_inject_concat_dot_default = {
|
|
|
37554
37604
|
severity: "high",
|
|
37555
37605
|
matcher: {
|
|
37556
37606
|
type: "regex",
|
|
37557
|
-
pattern: `["'][
|
|
37607
|
+
pattern: `["'](?=([^"'\\n]*?(?:select|insert|update|delete|drop|where)))\\1(?:(?!["'][^"'\\n]*?(?:select|insert|update|delete|drop|where))[^\\n])*?["']\\s*\\.`,
|
|
37558
37608
|
flags: "gi"
|
|
37559
37609
|
},
|
|
37560
37610
|
appliesTo: {
|
|
@@ -37572,7 +37622,7 @@ var sql_inject_concat_default = {
|
|
|
37572
37622
|
severity: "high",
|
|
37573
37623
|
matcher: {
|
|
37574
37624
|
type: "regex",
|
|
37575
|
-
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*\\+`,
|
|
37625
|
+
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*\\+`,
|
|
37576
37626
|
flags: "gi"
|
|
37577
37627
|
},
|
|
37578
37628
|
examples: ['"SELECT * FROM users WHERE id = " + userId']
|
|
@@ -37587,7 +37637,7 @@ var sql_inject_format_default = {
|
|
|
37587
37637
|
severity: "high",
|
|
37588
37638
|
matcher: {
|
|
37589
37639
|
type: "regex",
|
|
37590
|
-
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]|\\{[^}]+\\})",
|
|
37640
|
+
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]+\\})",
|
|
37591
37641
|
flags: "gi"
|
|
37592
37642
|
},
|
|
37593
37643
|
examples: [
|
|
@@ -37605,7 +37655,7 @@ var sql_inject_interp_default = {
|
|
|
37605
37655
|
severity: "high",
|
|
37606
37656
|
matcher: {
|
|
37607
37657
|
type: "regex",
|
|
37608
|
-
pattern: "(select|insert|update|delete|where)[^\\n]*?(#\\{|\\$[a-z_])",
|
|
37658
|
+
pattern: "(select|insert|update|delete|where)(?:(?!(?:select|insert|update|delete|where))[^\\n])*?(#\\{|\\$[a-z_])",
|
|
37609
37659
|
flags: "gi"
|
|
37610
37660
|
},
|
|
37611
37661
|
examples: [
|
|
@@ -37980,7 +38030,7 @@ var stack_trace_default = {
|
|
|
37980
38030
|
severity: "low",
|
|
37981
38031
|
matcher: {
|
|
37982
38032
|
type: "regex",
|
|
37983
|
-
pattern: "(
|
|
38033
|
+
pattern: "(?:^|(?<!\\s)\\s+)at\\s+[A-Za-z0-9._$<>]+\\.[A-Za-z0-9_$]+\\s*\\([A-Za-z0-9._\\-/:]+:\\d+:\\d+\\)",
|
|
37984
38034
|
flags: "g"
|
|
37985
38035
|
},
|
|
37986
38036
|
examples: ["at com.example.service.UserService.findUser(UserService.java:42:13)"]
|
|
@@ -39138,7 +39188,7 @@ var BUNDLED_PACKS = [
|
|
|
39138
39188
|
{
|
|
39139
39189
|
packId: "code-flaws",
|
|
39140
39190
|
name: "Code Security Flaws",
|
|
39141
|
-
version: "0.1.
|
|
39191
|
+
version: "0.1.1",
|
|
39142
39192
|
rawRules: [
|
|
39143
39193
|
sql_inject_concat_default,
|
|
39144
39194
|
sql_inject_concat_dot_default,
|
|
@@ -39188,7 +39238,7 @@ var BUNDLED_PACKS = [
|
|
|
39188
39238
|
{
|
|
39189
39239
|
packId: "core-code-context",
|
|
39190
39240
|
name: "Code Context",
|
|
39191
|
-
version: "0.2.
|
|
39241
|
+
version: "0.2.2",
|
|
39192
39242
|
rawRules: [
|
|
39193
39243
|
internal_ip_default,
|
|
39194
39244
|
localhost_ref_default,
|
|
@@ -39625,9 +39675,10 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
39625
39675
|
if (job.timer !== void 0) return;
|
|
39626
39676
|
job.startedAt = performance.now();
|
|
39627
39677
|
job.progressAt = job.startedAt;
|
|
39678
|
+
const budget = job.deadlineAt === void 0 ? job.budgetMs : Math.max(0, Math.min(job.budgetMs, job.deadlineAt - job.startedAt));
|
|
39628
39679
|
job.timer = setTimeout(() => {
|
|
39629
39680
|
onDeadline(job);
|
|
39630
|
-
},
|
|
39681
|
+
}, budget);
|
|
39631
39682
|
}
|
|
39632
39683
|
function runOne(spec, fail2) {
|
|
39633
39684
|
if (closed) {
|
|
@@ -39638,6 +39689,12 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
39638
39689
|
fail2({ status: "unavailable", reason: `the scan worker crashed: ${broken}` });
|
|
39639
39690
|
return;
|
|
39640
39691
|
}
|
|
39692
|
+
const now = performance.now();
|
|
39693
|
+
const deadlineAt = spec.deadlineAt;
|
|
39694
|
+
if (deadlineAt !== void 0 && deadlineAt <= now) {
|
|
39695
|
+
fail2({ status: "timeout", culpritIndex: void 0, elapsedMs: 0 });
|
|
39696
|
+
return;
|
|
39697
|
+
}
|
|
39641
39698
|
const started = ensureWorker();
|
|
39642
39699
|
if (!(started instanceof Worker)) {
|
|
39643
39700
|
broken = started.error;
|
|
@@ -39645,11 +39702,11 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
39645
39702
|
return;
|
|
39646
39703
|
}
|
|
39647
39704
|
const id = nextJobId++;
|
|
39648
|
-
const now = performance.now();
|
|
39649
39705
|
const job = {
|
|
39650
39706
|
id,
|
|
39651
39707
|
worker: started,
|
|
39652
39708
|
budgetMs: spec.budgetMs,
|
|
39709
|
+
deadlineAt,
|
|
39653
39710
|
startedAt: now,
|
|
39654
39711
|
progressIndex: -1,
|
|
39655
39712
|
progressAt: now,
|
|
@@ -39663,14 +39720,19 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
39663
39720
|
if (readyWorker === started) {
|
|
39664
39721
|
beginDeadline(job);
|
|
39665
39722
|
} else {
|
|
39723
|
+
const startBudget = spec.startBudgetMs ?? startBudgetMs;
|
|
39724
|
+
const callerLimited = deadlineAt !== void 0 && deadlineAt - now < startBudget;
|
|
39725
|
+
const startWaitMs = callerLimited ? deadlineAt - now : startBudget;
|
|
39666
39726
|
job.startupTimer = setTimeout(() => {
|
|
39667
39727
|
if (pending !== job) return;
|
|
39668
39728
|
kill(job.worker);
|
|
39669
|
-
failPending(
|
|
39670
|
-
status: "
|
|
39671
|
-
|
|
39672
|
-
|
|
39673
|
-
|
|
39729
|
+
failPending(
|
|
39730
|
+
callerLimited ? { status: "timeout", culpritIndex: void 0, elapsedMs: performance.now() - now } : {
|
|
39731
|
+
status: "unavailable",
|
|
39732
|
+
reason: `the scan worker did not start within ${String(startBudget)}ms`
|
|
39733
|
+
}
|
|
39734
|
+
);
|
|
39735
|
+
}, startWaitMs);
|
|
39674
39736
|
}
|
|
39675
39737
|
try {
|
|
39676
39738
|
started.postMessage(spec.build(id));
|
|
@@ -39699,7 +39761,9 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
39699
39761
|
return enqueue((resolve4) => {
|
|
39700
39762
|
runOne(
|
|
39701
39763
|
{
|
|
39702
|
-
budgetMs,
|
|
39764
|
+
budgetMs: scanOpts?.budgetMs ?? budgetMs,
|
|
39765
|
+
startBudgetMs: scanOpts?.startBudgetMs,
|
|
39766
|
+
deadlineAt: scanOpts?.deadlineAt,
|
|
39703
39767
|
build: (id) => ({
|
|
39704
39768
|
kind: "scan",
|
|
39705
39769
|
id,
|
|
@@ -39893,6 +39957,9 @@ function createGuardedScanner(partition, gateway, opts) {
|
|
|
39893
39957
|
let unverified = partition.unverified;
|
|
39894
39958
|
let isolated = unverified.length > 0 ? createIsolatedScanner({ verified, unverified }, opts) : void 0;
|
|
39895
39959
|
let retired = false;
|
|
39960
|
+
let bounded;
|
|
39961
|
+
let boundedWarned = false;
|
|
39962
|
+
let closed = false;
|
|
39896
39963
|
function inProcess(text, context) {
|
|
39897
39964
|
return scan(text, verified, context);
|
|
39898
39965
|
}
|
|
@@ -39954,11 +40021,48 @@ function createGuardedScanner(partition, gateway, opts) {
|
|
|
39954
40021
|
await degrade();
|
|
39955
40022
|
return inProcess(text, context);
|
|
39956
40023
|
}
|
|
40024
|
+
async function scanBounded(text, context, bound) {
|
|
40025
|
+
const remainingMs = bound.remainingMs;
|
|
40026
|
+
let outcome;
|
|
40027
|
+
if (closed) {
|
|
40028
|
+
outcome = { status: "unavailable", reason: "the scan worker is closed" };
|
|
40029
|
+
} else if (remainingMs !== void 0 && !(remainingMs > 0)) {
|
|
40030
|
+
outcome = { status: "timeout", culpritIndex: void 0, elapsedMs: 0 };
|
|
40031
|
+
} else {
|
|
40032
|
+
bounded ??= createIsolatedScanner({ verified, unverified }, opts);
|
|
40033
|
+
const deadlineAt = remainingMs === void 0 ? void 0 : performance.now() + remainingMs;
|
|
40034
|
+
try {
|
|
40035
|
+
outcome = await bounded.scan(text, context, {
|
|
40036
|
+
budgetMs: bound.budgetMs,
|
|
40037
|
+
startBudgetMs: bound.startBudgetMs,
|
|
40038
|
+
deadlineAt
|
|
40039
|
+
});
|
|
40040
|
+
} catch (error62) {
|
|
40041
|
+
outcome = {
|
|
40042
|
+
status: "unavailable",
|
|
40043
|
+
reason: error62 instanceof Error ? error62.message : "the scan worker failed unexpectedly"
|
|
40044
|
+
};
|
|
40045
|
+
}
|
|
40046
|
+
}
|
|
40047
|
+
if (outcome.status !== "ok" && !boundedWarned) {
|
|
40048
|
+
boundedWarned = true;
|
|
40049
|
+
process.stderr.write(
|
|
40050
|
+
outcome.status === "timeout" ? `[aka] a large input could not be scanned within its time limit and was refused.
|
|
40051
|
+
` : `[aka] a large input could not be scanned and was refused: ${outcome.reason}.
|
|
40052
|
+
`
|
|
40053
|
+
);
|
|
40054
|
+
}
|
|
40055
|
+
return outcome;
|
|
40056
|
+
}
|
|
39957
40057
|
return {
|
|
39958
40058
|
scan: guardedScan,
|
|
40059
|
+
scanBounded,
|
|
39959
40060
|
degraded: () => retired,
|
|
39960
40061
|
async close() {
|
|
39961
|
-
|
|
40062
|
+
closed = true;
|
|
40063
|
+
const live = bounded;
|
|
40064
|
+
bounded = void 0;
|
|
40065
|
+
await Promise.all([retire(), live?.close()]);
|
|
39962
40066
|
}
|
|
39963
40067
|
};
|
|
39964
40068
|
}
|
|
@@ -40060,6 +40164,16 @@ function conditionsMatch(conditions, ctx) {
|
|
|
40060
40164
|
if (conditions.provider !== void 0) return false;
|
|
40061
40165
|
return true;
|
|
40062
40166
|
}
|
|
40167
|
+
function readRemainingMs(largeInput) {
|
|
40168
|
+
const read = largeInput.remainingMs;
|
|
40169
|
+
if (read === void 0) return void 0;
|
|
40170
|
+
try {
|
|
40171
|
+
const remaining = read();
|
|
40172
|
+
return typeof remaining !== "number" || Number.isNaN(remaining) ? 0 : remaining;
|
|
40173
|
+
} catch {
|
|
40174
|
+
return 0;
|
|
40175
|
+
}
|
|
40176
|
+
}
|
|
40063
40177
|
var bundlesPacked = false;
|
|
40064
40178
|
function createPluginRuntime(gateway, settings, opts) {
|
|
40065
40179
|
if (!bundlesPacked) {
|
|
@@ -40069,6 +40183,7 @@ function createPluginRuntime(gateway, settings, opts) {
|
|
|
40069
40183
|
const policyMode = settings.policy;
|
|
40070
40184
|
let redactFallback = settings.redactFallback;
|
|
40071
40185
|
const dataDir2 = opts?.dataDir;
|
|
40186
|
+
const largeInput = opts?.largeInput;
|
|
40072
40187
|
let rules = [];
|
|
40073
40188
|
let evidenceOf = evidenceLookup(rules);
|
|
40074
40189
|
let scanner;
|
|
@@ -40281,7 +40396,24 @@ function createPluginRuntime(gateway, settings, opts) {
|
|
|
40281
40396
|
await ensureInitialized();
|
|
40282
40397
|
if (!scanner) throw new Error("the runtime initialized without a scanner");
|
|
40283
40398
|
const shielded = shieldPointers(text);
|
|
40284
|
-
|
|
40399
|
+
let matched;
|
|
40400
|
+
if (largeInput !== void 0 && shielded.text.length >= largeInput.thresholdChars) {
|
|
40401
|
+
const outcome = await scanner.scanBounded(shielded.text, context, {
|
|
40402
|
+
budgetMs: largeInput.budgetMs,
|
|
40403
|
+
startBudgetMs: largeInput.startBudgetMs,
|
|
40404
|
+
remainingMs: readRemainingMs(largeInput)
|
|
40405
|
+
});
|
|
40406
|
+
if (outcome.status !== "ok") {
|
|
40407
|
+
return {
|
|
40408
|
+
decision: { action: "block", text: null, findings: [], scanIncomplete: outcome.status },
|
|
40409
|
+
excepted: /* @__PURE__ */ new Set(),
|
|
40410
|
+
exceptionIds: []
|
|
40411
|
+
};
|
|
40412
|
+
}
|
|
40413
|
+
matched = outcome.findings;
|
|
40414
|
+
} else {
|
|
40415
|
+
matched = await scanner.scan(shielded.text, context);
|
|
40416
|
+
}
|
|
40285
40417
|
const findings = dropShieldedFindings(matched, shielded.spans);
|
|
40286
40418
|
const fpCache = /* @__PURE__ */ new Map();
|
|
40287
40419
|
const { excepted, exceptionIds } = await applyExceptions(findings, ctx, fpCache);
|
|
@@ -40322,20 +40454,24 @@ function createPluginRuntime(gateway, settings, opts) {
|
|
|
40322
40454
|
}
|
|
40323
40455
|
async function persistCapture(input2, opts2, { decision, excepted, exceptionIds, timingStartedAt }) {
|
|
40324
40456
|
const filePath = input2.metadata?.filePath;
|
|
40325
|
-
if (opts2.persist === "with-findings" && decision.findings.length === 0)
|
|
40457
|
+
if (opts2.persist === "with-findings" && decision.findings.length === 0 && decision.scanIncomplete === void 0) {
|
|
40458
|
+
return;
|
|
40459
|
+
}
|
|
40326
40460
|
try {
|
|
40327
40461
|
const contentHash = contentHashOf(input2.text);
|
|
40328
40462
|
const maskedFindings = decision.findings.filter(
|
|
40329
40463
|
(match) => isActionAtLeast(actionForFinding(match, excepted, opts2.rewritable), "redact")
|
|
40330
40464
|
);
|
|
40331
|
-
const storedContent = maskedFindings.length > 0 ? redact(input2.text, maskedFindings) : input2.text;
|
|
40465
|
+
const storedContent = decision.scanIncomplete !== void 0 ? "" : maskedFindings.length > 0 ? redact(input2.text, maskedFindings) : input2.text;
|
|
40332
40466
|
const inspectionMs = elapsedMs(timingStartedAt);
|
|
40333
40467
|
const redactDegradedTo = decision.redactDegradedTo;
|
|
40334
|
-
const
|
|
40468
|
+
const scanIncomplete = decision.scanIncomplete;
|
|
40469
|
+
const metadata = exceptionIds.length > 0 || inspectionMs !== void 0 || redactDegradedTo !== void 0 || scanIncomplete !== void 0 ? {
|
|
40335
40470
|
...input2.metadata,
|
|
40336
40471
|
...exceptionIds.length > 0 ? { exceptionIds } : {},
|
|
40337
40472
|
...inspectionMs !== void 0 ? { inspectionMs } : {},
|
|
40338
|
-
...redactDegradedTo !== void 0 ? { redactDegradedTo } : {}
|
|
40473
|
+
...redactDegradedTo !== void 0 ? { redactDegradedTo } : {},
|
|
40474
|
+
...scanIncomplete !== void 0 ? { scanIncomplete } : {}
|
|
40339
40475
|
} : input2.metadata;
|
|
40340
40476
|
const event = buildIngestEvent({
|
|
40341
40477
|
kind: input2.kind,
|
|
@@ -42396,6 +42532,7 @@ var CORRELATION_ID = EventMetadata.shape.correlationId;
|
|
|
42396
42532
|
var TRACE_ID = EventMetadata.shape.traceId;
|
|
42397
42533
|
var EXCEPTION_ID = EventMetadata.shape.exceptionIds.unwrap().element;
|
|
42398
42534
|
var REDACT_DEGRADED_TO = EventMetadata.shape.redactDegradedTo.unwrap();
|
|
42535
|
+
var SCAN_INCOMPLETE = EventMetadata.shape.scanIncomplete.unwrap();
|
|
42399
42536
|
|
|
42400
42537
|
// ../../packages/plugin-runtime/src/attached/history-sync.ts
|
|
42401
42538
|
var CAPTURE_BATCH_BYTES = 1024 * 1024;
|
package/scripts/scan-worker.js
CHANGED
|
@@ -22280,6 +22280,11 @@ var CaptureAttributes = external_exports.object({
|
|
|
22280
22280
|
// here too. The full statement is on EventMetadata.redactDegradedTo; it is
|
|
22281
22281
|
// repeated rather than referenced because a store reader opens this file.
|
|
22282
22282
|
redact_degraded_to: ActionTaken.optional(),
|
|
22283
|
+
// Why a capture has no content and no findings: its field was refused
|
|
22284
|
+
// because its bounded scan did not finish (see EventMetadata.scanIncomplete,
|
|
22285
|
+
// whose value this is). Absent on every capture that was scanned, so a
|
|
22286
|
+
// reader can tell a refused row from an empty clean one.
|
|
22287
|
+
scan_incomplete: external_exports.enum(["timeout", "unavailable"]).optional(),
|
|
22283
22288
|
// The scope key this capture was stamped with: the canonical repository
|
|
22284
22289
|
// (`host/owner/repo`) of the path the capture names (a relative path is read
|
|
22285
22290
|
// against its working directory), else of its own working directory, or a
|
|
@@ -23590,7 +23595,19 @@ var EventMetadata = external_exports.object({
|
|
|
23590
23595
|
// Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
|
|
23591
23596
|
// Closing either means moving the reason onto the finding row, which
|
|
23592
23597
|
// already carries its own action.
|
|
23593
|
-
redactDegradedTo: ActionTaken.optional()
|
|
23598
|
+
redactDegradedTo: ActionTaken.optional(),
|
|
23599
|
+
// Set when this capture's field was REFUSED rather than scanned: a hook
|
|
23600
|
+
// bounds the scan of a large field (see `LargeInputScanOptions` in
|
|
23601
|
+
// @akasecurity/plugin-sdk), and a scan that did not finish blocks the
|
|
23602
|
+
// field instead of letting it through unscanned.
|
|
23603
|
+
//
|
|
23604
|
+
// - 'timeout': the bounded scan ran out of time.
|
|
23605
|
+
// - 'unavailable': no worker could run it.
|
|
23606
|
+
//
|
|
23607
|
+
// A refused row stores '' as its content and has no findings, which is
|
|
23608
|
+
// exactly what a clean, empty capture looks like — this marker is the only
|
|
23609
|
+
// thing that tells the two apart. Absent on every capture that was scanned.
|
|
23610
|
+
scanIncomplete: external_exports.enum(["timeout", "unavailable"]).optional()
|
|
23594
23611
|
}).meta({ id: "EventMetadata" });
|
|
23595
23612
|
var Event = external_exports.object({
|
|
23596
23613
|
id: external_exports.guid(),
|
|
@@ -25453,6 +25470,38 @@ function worstProbeMs(rule, now = wallClock, corroborate) {
|
|
|
25453
25470
|
}
|
|
25454
25471
|
var CPU_CORROBORATION_SHARE = 0.2;
|
|
25455
25472
|
var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
|
|
25473
|
+
function repeatTo(unit, length) {
|
|
25474
|
+
return unit.repeat(Math.ceil(length / unit.length)).slice(0, length);
|
|
25475
|
+
}
|
|
25476
|
+
function joinTo(length, open2, close, item) {
|
|
25477
|
+
const parts = [];
|
|
25478
|
+
let size = open2.length;
|
|
25479
|
+
for (let i = 0; size < length; i++) {
|
|
25480
|
+
const next = (i === 0 ? "" : ",") + item(i);
|
|
25481
|
+
parts.push(next);
|
|
25482
|
+
size += next.length;
|
|
25483
|
+
}
|
|
25484
|
+
return (open2 + parts.join("") + close).slice(0, length);
|
|
25485
|
+
}
|
|
25486
|
+
var SQL_WORDS = ["select", "insert", "update", "delete", "drop", "where"];
|
|
25487
|
+
var GROWTH_CORPORA = [
|
|
25488
|
+
{
|
|
25489
|
+
name: "one-line JSON dictionary",
|
|
25490
|
+
build: (length) => joinTo(length, "{", "}", (i) => `"id-${String(i)}":"label ${String(i)}"`)
|
|
25491
|
+
},
|
|
25492
|
+
{
|
|
25493
|
+
name: "JSON array of quoted SQL keywords",
|
|
25494
|
+
build: (length) => joinTo(length, "[", "]", (i) => `"${SQL_WORDS[i % SQL_WORDS.length] ?? ""} ${String(i)}"`)
|
|
25495
|
+
},
|
|
25496
|
+
{ name: "single-quoted keyword run ('where)", build: (length) => repeatTo("'where", length) },
|
|
25497
|
+
{ name: "double-quote run", build: (length) => repeatTo('"', length) },
|
|
25498
|
+
{ name: "space run", build: (length) => repeatTo(" ", length) },
|
|
25499
|
+
{ name: "newline run", build: (length) => repeatTo("\n", length) },
|
|
25500
|
+
...["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].map((unit) => ({
|
|
25501
|
+
name: `unit run ${JSON.stringify(unit)}`,
|
|
25502
|
+
build: (length) => repeatTo(unit, length)
|
|
25503
|
+
}))
|
|
25504
|
+
];
|
|
25456
25505
|
function checkRuleTiming(rule, corroborate) {
|
|
25457
25506
|
const { ms, probe, corroboratedMs } = worstProbeMs(rule, wallClock, corroborate);
|
|
25458
25507
|
const work = corroboratedMs ?? 0;
|