@akasecurity/ai-tc-codex 0.9.15 → 0.9.16
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/hooks/hooks.json +1 -1
- package/package.json +5 -5
- package/scripts/apply-suppressions.js +1472 -393
- package/scripts/backfill.js +1963 -424
- package/scripts/content-retention.js +825 -227
- package/scripts/filescan.js +1900 -361
- package/scripts/firstrun.js +1406 -301
- package/scripts/history-sync.js +841 -228
- package/scripts/intro.js +328 -170
- package/scripts/onboard.js +823 -219
- package/scripts/post-tool-use.js +1960 -343
- package/scripts/pre-tool-use.js +1864 -338
- package/scripts/query.js +1405 -300
- package/scripts/reconcile.js +1873 -329
- package/scripts/remediate.js +1838 -350
- package/scripts/scan-worker.js +281 -149
- package/scripts/session-start.js +1821 -331
- package/scripts/start-light.js +328 -170
- package/scripts/stop.js +346 -190
- package/scripts/sync.js +1898 -359
- package/scripts/user-prompt-submit.js +1906 -373
- package/skills/setup/SKILL.md +27 -12
|
@@ -32,9 +32,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
32
32
|
mod
|
|
33
33
|
));
|
|
34
34
|
|
|
35
|
-
// ../../node_modules/.pnpm/ignore@7.0.
|
|
35
|
+
// ../../node_modules/.pnpm/ignore@7.0.11/node_modules/ignore/index.js
|
|
36
36
|
var require_ignore = __commonJS({
|
|
37
|
-
"../../node_modules/.pnpm/ignore@7.0.
|
|
37
|
+
"../../node_modules/.pnpm/ignore@7.0.11/node_modules/ignore/index.js"(exports, module) {
|
|
38
38
|
"use strict";
|
|
39
39
|
function makeArray(subject) {
|
|
40
40
|
return Array.isArray(subject) ? subject : [subject];
|
|
@@ -169,6 +169,7 @@ var require_ignore = __commonJS({
|
|
|
169
169
|
"g"
|
|
170
170
|
);
|
|
171
171
|
var TRAILING_WILDCARD = "\uE000";
|
|
172
|
+
var TRAILING_DOUBLESTAR = "\uE001";
|
|
172
173
|
var extractBrackets = (pattern) => {
|
|
173
174
|
const sources = [];
|
|
174
175
|
const hold = (source) => `${PLACEHOLDER}${sources.push(source) - 1}${PLACEHOLDER}`;
|
|
@@ -329,7 +330,7 @@ var require_ignore = __commonJS({
|
|
|
329
330
|
// Zero, one or several directories
|
|
330
331
|
// should not use '*', or it will be replaced by the next replacer
|
|
331
332
|
// Check if it is not the last `'/**'`
|
|
332
|
-
(_, index, str2) => index + 6 < str2.length ? str2.slice(index + 6) === "\\/" ? "(?:\\/[^\\/]+)+" : "(?:\\/[^\\/]+)*" :
|
|
333
|
+
(_, index, str2) => index + 6 < str2.length ? str2.slice(index + 6) === "\\/" ? "(?:\\/[^\\/]+)+" : "(?:\\/[^\\/]+)*" : `\\/${TRAILING_DOUBLESTAR}`,
|
|
333
334
|
"*"
|
|
334
335
|
],
|
|
335
336
|
// normal intermediate wildcards
|
|
@@ -407,7 +408,7 @@ var require_ignore = __commonJS({
|
|
|
407
408
|
// 'js' will match 'a.js' and 'a.js/'
|
|
408
409
|
(source) => {
|
|
409
410
|
const last = source[source.length - 1];
|
|
410
|
-
if (!last || last === TRAILING_WILDCARD) {
|
|
411
|
+
if (!last || last === TRAILING_WILDCARD || last === TRAILING_DOUBLESTAR) {
|
|
411
412
|
return source;
|
|
412
413
|
}
|
|
413
414
|
return last === SLASH2 ? `${source}$` : `${source}(?=$|\\/$)`;
|
|
@@ -418,16 +419,12 @@ var require_ignore = __commonJS({
|
|
|
418
419
|
var MODE_IGNORE = "regex";
|
|
419
420
|
var MODE_CHECK_IGNORE = "checkRegex";
|
|
420
421
|
var UNDERSCORE = "_";
|
|
421
|
-
var
|
|
422
|
-
[
|
|
423
|
-
|
|
424
|
-
return `${prefix}(?=$|\\/$)`;
|
|
425
|
-
},
|
|
426
|
-
[MODE_CHECK_IGNORE](_, p1) {
|
|
427
|
-
const prefix = p1 ? `${p1}[^/]*` : "[^/]*";
|
|
428
|
-
return `${prefix}(?=$|\\/$)`;
|
|
429
|
-
}
|
|
422
|
+
var replaceTrailingWildcard = (_, p1) => {
|
|
423
|
+
const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
|
|
424
|
+
return `${prefix}(?=$|\\/$)`;
|
|
430
425
|
};
|
|
426
|
+
var REGEX_REPLACE_TRAILING_DOUBLESTAR = /\uE001$/;
|
|
427
|
+
var replaceTrailingDoublestar = () => ".+(?=$|\\/$)";
|
|
431
428
|
var WILDCARD = "[^\\/]*";
|
|
432
429
|
var separatorAfter = (run, at) => {
|
|
433
430
|
let separator = EMPTY;
|
|
@@ -543,6 +540,14 @@ var require_ignore = __commonJS({
|
|
|
543
540
|
(match, index) => sources[index]
|
|
544
541
|
) : replaced;
|
|
545
542
|
};
|
|
543
|
+
var checkSourceOf = (body, prefix) => {
|
|
544
|
+
if (body[body.length - 1] === SLASH2) {
|
|
545
|
+
prefix = makeRegexPrefix(body.slice(0, -1));
|
|
546
|
+
}
|
|
547
|
+
const head = prefix.slice(0, -1);
|
|
548
|
+
const last = prefix[prefix.length - 1];
|
|
549
|
+
return last === TRAILING_WILDCARD ? `${head}$` : last === TRAILING_DOUBLESTAR ? `${head}.*$` : NEVER_MATCH;
|
|
550
|
+
};
|
|
546
551
|
var matchesBasename = (body) => {
|
|
547
552
|
const index = body.indexOf(SLASH2);
|
|
548
553
|
return index < 0 || index === body.length - 1;
|
|
@@ -603,11 +608,9 @@ var require_ignore = __commonJS({
|
|
|
603
608
|
return this._make(MODE_CHECK_IGNORE, key);
|
|
604
609
|
}
|
|
605
610
|
_make(mode, key) {
|
|
606
|
-
const str2 = pinWildcards(
|
|
607
|
-
REGEX_REPLACE_TRAILING_WILDCARD,
|
|
608
|
-
|
|
609
|
-
TRAILING_WILD_CARD_REPLACERS[mode]
|
|
610
|
-
));
|
|
611
|
+
const str2 = pinWildcards(
|
|
612
|
+
mode === MODE_IGNORE ? this.regexPrefix.replace(REGEX_REPLACE_TRAILING_WILDCARD, replaceTrailingWildcard).replace(REGEX_REPLACE_TRAILING_DOUBLESTAR, replaceTrailingDoublestar) : checkSourceOf(this.body, this.regexPrefix)
|
|
613
|
+
);
|
|
611
614
|
const regex = this.ignoreCase ? new RegExp(str2, "i") : new RegExp(str2);
|
|
612
615
|
return define(this, key, regex);
|
|
613
616
|
}
|
|
@@ -666,8 +669,39 @@ var require_ignore = __commonJS({
|
|
|
666
669
|
makeArray(
|
|
667
670
|
isString(pattern) ? splitPattern(pattern) : pattern
|
|
668
671
|
).forEach(this._add, this);
|
|
672
|
+
if (this._added) {
|
|
673
|
+
this._literalRules = UNDEFINED;
|
|
674
|
+
}
|
|
669
675
|
return this._added;
|
|
670
676
|
}
|
|
677
|
+
// Match the literal 'abc/' for `checkIgnore`, last rule wins. Only a rule
|
|
678
|
+
// ending in a wildcard can match it (see `checkSourceOf`), so the rest
|
|
679
|
+
// are left out once, rather than tested or compiled for every path.
|
|
680
|
+
testLiteral(path) {
|
|
681
|
+
const rules = this._literalRules || (this._literalRules = this._rules.filter(
|
|
682
|
+
({ body }) => body[body.length - (body[body.length - 1] === SLASH2 ? 2 : 1)] === "*"
|
|
683
|
+
));
|
|
684
|
+
let ignored = false;
|
|
685
|
+
let unignored = false;
|
|
686
|
+
let matchedRule;
|
|
687
|
+
for (let index = rules.length - 1; index >= 0; index--) {
|
|
688
|
+
const rule = rules[index];
|
|
689
|
+
if (rule.checkRegex.test(path)) {
|
|
690
|
+
ignored = !rule.negative;
|
|
691
|
+
unignored = rule.negative;
|
|
692
|
+
matchedRule = rule.negative ? UNDEFINED : rule;
|
|
693
|
+
break;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
const ret = {
|
|
697
|
+
ignored,
|
|
698
|
+
unignored
|
|
699
|
+
};
|
|
700
|
+
if (matchedRule) {
|
|
701
|
+
ret.rule = matchedRule;
|
|
702
|
+
}
|
|
703
|
+
return ret;
|
|
704
|
+
}
|
|
671
705
|
// Test one single path without recursively checking parent directories
|
|
672
706
|
//
|
|
673
707
|
// - checkUnignored `boolean` whether should check if the path is unignored,
|
|
@@ -788,14 +822,12 @@ var require_ignore = __commonJS({
|
|
|
788
822
|
if (path.charCodeAt(path.length - 1) !== SLASH_CODE) {
|
|
789
823
|
return this.test(path);
|
|
790
824
|
}
|
|
791
|
-
const
|
|
792
|
-
if (
|
|
793
|
-
|
|
794
|
-
if (parent.ignored) {
|
|
795
|
-
return parent;
|
|
796
|
-
}
|
|
825
|
+
const dir = this._t(path, this._testCache, true);
|
|
826
|
+
if (dir.ignored) {
|
|
827
|
+
return dir;
|
|
797
828
|
}
|
|
798
|
-
|
|
829
|
+
const literal2 = this._rules.testLiteral(path);
|
|
830
|
+
return literal2.ignored || literal2.unignored ? literal2 : dir;
|
|
799
831
|
}
|
|
800
832
|
_t(path, cache, checkUnignored) {
|
|
801
833
|
if (path in cache) {
|
|
@@ -841,9 +873,9 @@ var require_ignore = __commonJS({
|
|
|
841
873
|
});
|
|
842
874
|
|
|
843
875
|
// src/apply-suppressions.ts
|
|
844
|
-
import { existsSync as
|
|
876
|
+
import { existsSync as existsSync13, readFileSync as readFileSync20 } from "fs";
|
|
845
877
|
import { userInfo } from "os";
|
|
846
|
-
import { dirname as
|
|
878
|
+
import { dirname as dirname9, join as join31 } from "path";
|
|
847
879
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
848
880
|
|
|
849
881
|
// ../../packages/persistence/src/attached-derived.ts
|
|
@@ -1012,6 +1044,10 @@ var SQLITE_MIGRATIONS = [
|
|
|
1012
1044
|
{
|
|
1013
1045
|
tag: "0036_secret_vault_identity_fingerprint",
|
|
1014
1046
|
sql: "ALTER TABLE `secret_vault` ADD `value_identity_fingerprint` text DEFAULT '' NOT NULL;--> statement-breakpoint\nUPDATE `secret_vault` SET `value_identity_fingerprint` = `value_fingerprint`;\n"
|
|
1047
|
+
},
|
|
1048
|
+
{
|
|
1049
|
+
tag: "0037_finding_location",
|
|
1050
|
+
sql: "ALTER TABLE `inspection_findings` ADD `line` integer;--> statement-breakpoint\nALTER TABLE `inspection_findings` ADD `col` integer;--> statement-breakpoint\nALTER TABLE `inspection_findings` ADD `context` text;--> statement-breakpoint\nCREATE INDEX `idx_inspection_findings_context` ON `inspection_findings` (`first_detected_at`) WHERE context IS NOT NULL;"
|
|
1015
1051
|
}
|
|
1016
1052
|
];
|
|
1017
1053
|
|
|
@@ -21905,11 +21941,33 @@ var ResolutionMethod = external_exports.enum([
|
|
|
21905
21941
|
"false-positive",
|
|
21906
21942
|
"redetected"
|
|
21907
21943
|
]).meta({ id: "ResolutionMethod" });
|
|
21944
|
+
var FindingContextBasis = external_exports.enum(["file", "excerpt"]).meta({ id: "FindingContextBasis" });
|
|
21945
|
+
var FindingContext = external_exports.object({
|
|
21946
|
+
basis: FindingContextBasis,
|
|
21947
|
+
// 1-based line number of `lines[0]`.
|
|
21948
|
+
firstLine: external_exports.number().int().positive(),
|
|
21949
|
+
lines: external_exports.array(external_exports.string()).min(1).max(5),
|
|
21950
|
+
match: external_exports.object({
|
|
21951
|
+
// 1-based line number, within [firstLine, firstLine + lines.length).
|
|
21952
|
+
line: external_exports.number().int().positive(),
|
|
21953
|
+
// Offsets into that entry of `lines`, end exclusive.
|
|
21954
|
+
start: external_exports.number().int().nonnegative(),
|
|
21955
|
+
end: external_exports.number().int().nonnegative()
|
|
21956
|
+
}).nullable()
|
|
21957
|
+
}).meta({ id: "FindingContext" });
|
|
21958
|
+
var FindingLocation = external_exports.object({
|
|
21959
|
+
line: external_exports.number().int().positive(),
|
|
21960
|
+
col: external_exports.number().int().positive(),
|
|
21961
|
+
context: FindingContext.nullable()
|
|
21962
|
+
});
|
|
21908
21963
|
var FindingMatch = external_exports.object({
|
|
21909
21964
|
// Masked preview of the matched value. Never raw content.
|
|
21910
21965
|
maskedValue: external_exports.string(),
|
|
21911
|
-
//
|
|
21912
|
-
contextPrefix: external_exports.string()
|
|
21966
|
+
// Deprecated: always empty. Superseded by `context`.
|
|
21967
|
+
contextPrefix: external_exports.string(),
|
|
21968
|
+
// The masked lines around the match. Absent when the finding predates
|
|
21969
|
+
// context capture or none could be built safely.
|
|
21970
|
+
context: FindingContext.optional()
|
|
21913
21971
|
}).meta({ id: "FindingMatch" });
|
|
21914
21972
|
var FindingDetectionRef = external_exports.object({
|
|
21915
21973
|
id: external_exports.string(),
|
|
@@ -21929,6 +21987,11 @@ var FindingInstance = external_exports.object({
|
|
|
21929
21987
|
provider: FindingProvider,
|
|
21930
21988
|
repo: external_exports.string(),
|
|
21931
21989
|
file: external_exports.string(),
|
|
21990
|
+
// 1-based line and column of the match start in the scanned text (the
|
|
21991
|
+
// column in UTF-16 code units). Absent for findings that predate location
|
|
21992
|
+
// capture or have no source text.
|
|
21993
|
+
line: external_exports.number().int().positive().optional(),
|
|
21994
|
+
col: external_exports.number().int().positive().optional(),
|
|
21932
21995
|
// Who the capturing event is attributed to. Optional: a single-user store
|
|
21933
21996
|
// has no one to attribute a finding to and never sets it.
|
|
21934
21997
|
user: FindingUser.optional(),
|
|
@@ -21990,6 +22053,13 @@ var FindingStats = external_exports.object({
|
|
|
21990
22053
|
low: external_exports.number().int().nonnegative()
|
|
21991
22054
|
})
|
|
21992
22055
|
}).meta({ id: "FindingStats" });
|
|
22056
|
+
var FindingsOverview = external_exports.object({
|
|
22057
|
+
findings: external_exports.number().int().nonnegative(),
|
|
22058
|
+
open: external_exports.number().int().nonnegative(),
|
|
22059
|
+
handled: external_exports.number().int().nonnegative(),
|
|
22060
|
+
resolved: external_exports.number().int().nonnegative(),
|
|
22061
|
+
dismissed: external_exports.number().int().nonnegative()
|
|
22062
|
+
}).meta({ id: "FindingsOverview" });
|
|
21993
22063
|
var FindingFacetItem = external_exports.object({
|
|
21994
22064
|
value: external_exports.string(),
|
|
21995
22065
|
count: external_exports.number().int().nonnegative()
|
|
@@ -22109,6 +22179,7 @@ var FindingInstanceDetail = FindingInstance.extend({
|
|
|
22109
22179
|
}).meta({ id: "FindingInstanceDetail" });
|
|
22110
22180
|
var DEFAULT_FLAT_FINDINGS_LIMIT = 50;
|
|
22111
22181
|
var MAX_FLAT_FINDINGS_LIMIT = 200;
|
|
22182
|
+
var FindingContextQuery = external_exports.object({ id: external_exports.string().min(1).max(256) });
|
|
22112
22183
|
var ListFindingInstancesQuery = external_exports.object({
|
|
22113
22184
|
severity: external_exports.array(Severity).optional(),
|
|
22114
22185
|
// Rule ids, the same vocabulary the types list's `subtype` carries. Pinning
|
|
@@ -22441,7 +22512,23 @@ var CaptureAttributes = external_exports.object({
|
|
|
22441
22512
|
// capture denied by another finding's own Block policy carries `block`
|
|
22442
22513
|
// here too. The full statement is on EventMetadata.redactDegradedTo; it is
|
|
22443
22514
|
// repeated rather than referenced because a store reader opens this file.
|
|
22444
|
-
redact_degraded_to: ActionTaken.optional()
|
|
22515
|
+
redact_degraded_to: ActionTaken.optional(),
|
|
22516
|
+
// The scope key this capture was stamped with: the canonical repository
|
|
22517
|
+
// (`host/owner/repo`) of the path the capture names (a relative path is read
|
|
22518
|
+
// against its working directory), else of its own working directory, or a
|
|
22519
|
+
// chat account's identity. The store's local `scope_key` column reads it, so
|
|
22520
|
+
// a scoped attachment has a per-row key to work from. Absent when no key
|
|
22521
|
+
// could be derived.
|
|
22522
|
+
//
|
|
22523
|
+
// LOCAL ONLY. That is the contract for every path that sends a row. Producers
|
|
22524
|
+
// stamp it in every attachment mode, and the two structural choke points strip
|
|
22525
|
+
// it: the attached gateway's `reKeyForForward` on the live path, and the
|
|
22526
|
+
// history drain's `rebuildAuditEvent`, which drops it through `withoutScopeKey`.
|
|
22527
|
+
// A capture row's bag reaches the wire through `rebuildCapture`, which builds
|
|
22528
|
+
// the metadata from named keys and never names this one; `toCaptureAttributes`,
|
|
22529
|
+
// which builds the bag from a wire event, never emits it. What a scoped
|
|
22530
|
+
// attachment does with the key is not part of this shape's contract.
|
|
22531
|
+
scope_key: external_exports.string().optional()
|
|
22445
22532
|
}).catchall(external_exports.unknown());
|
|
22446
22533
|
var CaptureStatusAttributes = external_exports.object({
|
|
22447
22534
|
source_tool: external_exports.string().optional(),
|
|
@@ -22471,6 +22558,12 @@ var ToolCallInspection = external_exports.object({
|
|
|
22471
22558
|
actionTaken: ActionTaken,
|
|
22472
22559
|
confidence: external_exports.number().min(0).max(1)
|
|
22473
22560
|
});
|
|
22561
|
+
var findingLocationFields = {
|
|
22562
|
+
line: external_exports.number().int().positive().optional(),
|
|
22563
|
+
col: external_exports.number().int().positive().optional(),
|
|
22564
|
+
context: FindingContext.nullable().optional()
|
|
22565
|
+
};
|
|
22566
|
+
var ToolCallInspectionInput = ToolCallInspection.extend(findingLocationFields);
|
|
22474
22567
|
var ToolCallInput = external_exports.object({
|
|
22475
22568
|
sessionId: external_exports.string().min(1),
|
|
22476
22569
|
toolUseId: external_exports.string().min(1),
|
|
@@ -22480,7 +22573,7 @@ var ToolCallInput = external_exports.object({
|
|
|
22480
22573
|
attributes: ToolCallAttributes,
|
|
22481
22574
|
// Secrets detected in the tool's (masked) target — written as linked
|
|
22482
22575
|
// `inspection_findings`. Empty for a clean tool call.
|
|
22483
|
-
inspections: external_exports.array(
|
|
22576
|
+
inspections: external_exports.array(ToolCallInspectionInput).default([])
|
|
22484
22577
|
});
|
|
22485
22578
|
var InventoryInput = external_exports.object({
|
|
22486
22579
|
objectType: InventoryObjectType,
|
|
@@ -22554,7 +22647,8 @@ var InspectionFindingInput = external_exports.object({
|
|
|
22554
22647
|
// same findingKey — mirrors the legacy `findings.first_detected_at`.
|
|
22555
22648
|
// Optional: when omitted, the writer derives it from the referenced audit
|
|
22556
22649
|
// event's startedAt on first insert (see SqliteInspectionFindingsRepository).
|
|
22557
|
-
firstDetectedAt: external_exports.iso.datetime().optional()
|
|
22650
|
+
firstDetectedAt: external_exports.iso.datetime().optional(),
|
|
22651
|
+
...findingLocationFields
|
|
22558
22652
|
});
|
|
22559
22653
|
var InventoryContext = external_exports.object({
|
|
22560
22654
|
host: InventoryInput.optional(),
|
|
@@ -23332,6 +23426,17 @@ var AttachedCredential = external_exports.object({
|
|
|
23332
23426
|
keyPrefix: external_exports.string().min(1).max(16).optional(),
|
|
23333
23427
|
mintedAt: external_exports.iso.datetime().optional()
|
|
23334
23428
|
});
|
|
23429
|
+
var AttachmentMode = external_exports.enum(["machine", "scoped"]);
|
|
23430
|
+
var ATTACHED_CREDENTIAL_SCOPED_SPEC_VERSION = 2;
|
|
23431
|
+
var AttachedCredentialV1 = AttachedCredential;
|
|
23432
|
+
var AttachedCredentialV2 = AttachedCredential.extend({
|
|
23433
|
+
specVersion: external_exports.literal(ATTACHED_CREDENTIAL_SCOPED_SPEC_VERSION),
|
|
23434
|
+
mode: external_exports.literal("scoped")
|
|
23435
|
+
});
|
|
23436
|
+
var AttachedCredentialAny = external_exports.discriminatedUnion("specVersion", [
|
|
23437
|
+
AttachedCredentialV1,
|
|
23438
|
+
AttachedCredentialV2
|
|
23439
|
+
]);
|
|
23335
23440
|
var MAX_DATE_MS = 253402300799999;
|
|
23336
23441
|
var MAX_INT4 = 2147483647;
|
|
23337
23442
|
var StorePosturePack = external_exports.object({
|
|
@@ -23613,6 +23718,130 @@ var PackId = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
|
23613
23718
|
var SemVer = external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?$/);
|
|
23614
23719
|
var PublisherKind = external_exports.enum(["labs", "user", "org"]);
|
|
23615
23720
|
|
|
23721
|
+
// ../../packages/schema/src/zod/builtin-policy-id.ts
|
|
23722
|
+
var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
|
|
23723
|
+
var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
|
|
23724
|
+
|
|
23725
|
+
// ../../packages/schema/src/zod/event.ts
|
|
23726
|
+
var EventKind = external_exports.enum(["prompt", "response", "code_change", "tool_use"]).meta({ id: "EventKind" });
|
|
23727
|
+
var CAPTURE_EVENT_TYPES_SQL = EventKind.options.map((k) => `'${k}'`).join(",");
|
|
23728
|
+
var EventMetadata = external_exports.object({
|
|
23729
|
+
sessionId: external_exports.string().optional(),
|
|
23730
|
+
repo: external_exports.string().optional(),
|
|
23731
|
+
filePath: external_exports.string().optional(),
|
|
23732
|
+
// The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
|
|
23733
|
+
// set by the tool-scanning hooks. The tool NAME only — never the tool's
|
|
23734
|
+
// arguments or output, which can carry the very value a finding masked
|
|
23735
|
+
// (metadata is stored unredacted). Gives findings on non-file captures a
|
|
23736
|
+
// display location ("via Bash") when no filePath exists.
|
|
23737
|
+
toolName: external_exports.string().optional(),
|
|
23738
|
+
// Set (true) by the worktree scanner when the file is excluded by the
|
|
23739
|
+
// repo's .gitignore. Gitignored files ARE still scanned — local scratch and
|
|
23740
|
+
// generated code can leak real secrets — but the provenance is recorded so
|
|
23741
|
+
// policy/dashboards can treat those findings as informational rather than
|
|
23742
|
+
// blocking. Omitted (not false) for tracked files and non-scan events.
|
|
23743
|
+
gitignored: external_exports.boolean().optional(),
|
|
23744
|
+
// Set (true) ONLY when the event's `content` is the COMPLETE file at
|
|
23745
|
+
// capture time (a worktree scan reading from disk). Hook-captured edits
|
|
23746
|
+
// (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
|
|
23747
|
+
// this. The resolver-on-ingest keys its fixed-at-source dropout
|
|
23748
|
+
// diff on this marker: only a whole-file snapshot can prove a previously
|
|
23749
|
+
// open finding is gone; a fragment's absence proves nothing (the secret
|
|
23750
|
+
// may live outside the hunk). Omitted (not false) for fragments and
|
|
23751
|
+
// non-scan events, so pre-marker clients safely default to the
|
|
23752
|
+
// non-authoritative path.
|
|
23753
|
+
wholeFile: external_exports.boolean().optional(),
|
|
23754
|
+
model: external_exports.string().optional(),
|
|
23755
|
+
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
23756
|
+
// Distributed-tracing correlation. `correlationId` ties a recorded event back
|
|
23757
|
+
// to the request that captured/ingested it (a UUID, generated independently of
|
|
23758
|
+
// the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
|
|
23759
|
+
// originating span when telemetry is enabled. Both optional + backward
|
|
23760
|
+
// compatible — populated by the plugin (see @akasecurity/plugin-sdk).
|
|
23761
|
+
correlationId: external_exports.uuid().optional(),
|
|
23762
|
+
traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
|
|
23763
|
+
// Ids of the detection exceptions that downgraded findings in this capture
|
|
23764
|
+
// to 'allow' — the enforcement audit trail's link back to the grant that
|
|
23765
|
+
// authorized the bypass. Absent on captures where no exception applied.
|
|
23766
|
+
exceptionIds: external_exports.array(external_exports.guid()).optional(),
|
|
23767
|
+
// The assistant message this capture belongs to, and the conversation it sits
|
|
23768
|
+
// in — set by the browser extension's network capture so a stored `response`
|
|
23769
|
+
// row can be joined to the `llm_call` leaf describing the same turn. Absent
|
|
23770
|
+
// on every other capture path, which has no such id.
|
|
23771
|
+
//
|
|
23772
|
+
// Non-empty for the reason WebExchange.messageId is: it is the join key, and
|
|
23773
|
+
// a blank one matches no `llm_call` leaf. That refusal reaches only the
|
|
23774
|
+
// places an event is PARSED; the local write path types the event and parses
|
|
23775
|
+
// nothing, which is why `toCaptureAttributes` omits a blank one separately.
|
|
23776
|
+
messageId: external_exports.string().min(1).optional(),
|
|
23777
|
+
conversationId: external_exports.string().optional(),
|
|
23778
|
+
// How long THIS capture's inspection blocked its caller, in whole
|
|
23779
|
+
// milliseconds — the plugin's own added latency, NOT the LLM call it sat in
|
|
23780
|
+
// front of. Measured inside `capture()` (@akasecurity/plugin-sdk) across
|
|
23781
|
+
// detection + redaction, the work the host session actually waits on.
|
|
23782
|
+
//
|
|
23783
|
+
// Stamped ONLY on live in-flight captures. A capture that carries its own
|
|
23784
|
+
// `occurredAt` is replaying past work (the transcript backfill, the worktree
|
|
23785
|
+
// scan), and its scan duration is not latency any host session experienced,
|
|
23786
|
+
// so those rows leave this ABSENT rather than reporting a misleading number.
|
|
23787
|
+
// Absent is also what every pre-measurement client writes, and what a
|
|
23788
|
+
// clock failure degrades to — a reader must treat absence as "not measured"
|
|
23789
|
+
// and never as a zero, which would read as "inspection is free".
|
|
23790
|
+
inspectionMs: external_exports.number().int().nonnegative().optional(),
|
|
23791
|
+
// What a `redact` this capture COULD NOT CARRY OUT became instead — the
|
|
23792
|
+
// workspace's `redactFallback`, applied because the field could not be
|
|
23793
|
+
// masked in place (a shell command, a URL, or any argument on a host whose
|
|
23794
|
+
// hook contract offers no rewrite channel).
|
|
23795
|
+
//
|
|
23796
|
+
// It exists because the action alone cannot say why. A finding recorded as
|
|
23797
|
+
// `warn` reads identically whether its detection was ASSIGNED Warn or was
|
|
23798
|
+
// assigned Redact on a field that could not take one — and those are
|
|
23799
|
+
// different facts about the same row: the first is a policy the user chose,
|
|
23800
|
+
// the second is a masking the host could not perform. Absent means no
|
|
23801
|
+
// degrade happened, which is every ordinary capture.
|
|
23802
|
+
//
|
|
23803
|
+
// TWO LIMITS a reader of a stored row has to know, because the grain here
|
|
23804
|
+
// is the CAPTURE while `actionTaken` is per FINDING:
|
|
23805
|
+
//
|
|
23806
|
+
// - It does not say WHICH finding degraded. A capture carrying a degraded
|
|
23807
|
+
// `redact` alongside a finding ASSIGNED the same action stores both
|
|
23808
|
+
// identically and one reason for the pair; attributing it to both
|
|
23809
|
+
// describes the assigned one wrongly, and to neither loses the degrade.
|
|
23810
|
+
// - PRESENCE IS NOT CAUSATION. The value is the action the lost redact
|
|
23811
|
+
// became, not the reason the capture ended as it did — a capture denied
|
|
23812
|
+
// by some other finding's own Block policy still carries `block` here,
|
|
23813
|
+
// and clearing the workspace's fallback would not have let it through.
|
|
23814
|
+
// Gate on the value against what a fallback can produce; never read the
|
|
23815
|
+
// field's presence as "this was the fallback's doing".
|
|
23816
|
+
//
|
|
23817
|
+
// Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
|
|
23818
|
+
// Closing either means moving the reason onto the finding row, which
|
|
23819
|
+
// already carries its own action.
|
|
23820
|
+
redactDegradedTo: ActionTaken.optional()
|
|
23821
|
+
}).meta({ id: "EventMetadata" });
|
|
23822
|
+
var Event = external_exports.object({
|
|
23823
|
+
id: external_exports.guid(),
|
|
23824
|
+
sourceTool: SourceTool,
|
|
23825
|
+
kind: EventKind,
|
|
23826
|
+
occurredAt: external_exports.iso.datetime(),
|
|
23827
|
+
contentHash: external_exports.string(),
|
|
23828
|
+
content: external_exports.string(),
|
|
23829
|
+
metadata: EventMetadata.optional()
|
|
23830
|
+
}).meta({ id: "Event" });
|
|
23831
|
+
var IngestEvent = Event.meta({ id: "IngestEvent" });
|
|
23832
|
+
var INGEST_BATCH_MAX = 100;
|
|
23833
|
+
var IngestBatch = external_exports.object({
|
|
23834
|
+
events: external_exports.array(IngestEvent).min(1).max(INGEST_BATCH_MAX),
|
|
23835
|
+
// Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
|
|
23836
|
+
// additionally rejects any event whose contentHash the store has already
|
|
23837
|
+
// recorded — for re-runnable bulk ingest (worktree scan, transcript
|
|
23838
|
+
// backfill), where a re-run mints fresh event ids for identical content and
|
|
23839
|
+
// would otherwise accumulate duplicates. Live hook traffic must NOT set it:
|
|
23840
|
+
// two genuinely separate prompts can be byte-identical and both belong on
|
|
23841
|
+
// the timeline.
|
|
23842
|
+
dedupe: external_exports.literal("content-hash").optional()
|
|
23843
|
+
}).meta({ id: "IngestBatch" });
|
|
23844
|
+
|
|
23616
23845
|
// ../../packages/schema/src/zod/rule.ts
|
|
23617
23846
|
var MatcherType = external_exports.enum(["keyword", "regex"]).meta({ id: "MatcherType" });
|
|
23618
23847
|
var RuleProbeVerdict = external_exports.enum(["safe", "quarantined"]).meta({ id: "RuleProbeVerdict" });
|
|
@@ -23681,7 +23910,10 @@ var Matcher = external_exports.discriminatedUnion("type", [KeywordMatcher, Regex
|
|
|
23681
23910
|
var MATCHER_TYPES = MatcherType.options;
|
|
23682
23911
|
var AppliesTo = external_exports.strictObject({
|
|
23683
23912
|
// Dot-prefixed, e.g. ".py" — matches the scanner's SOURCE_EXTENSIONS shape.
|
|
23684
|
-
extensions: external_exports.array(external_exports.string().regex(/^\.[A-Za-z0-9]+$/)).min(1)
|
|
23913
|
+
extensions: external_exports.array(external_exports.string().regex(/^\.[A-Za-z0-9]+$/)).min(1).optional(),
|
|
23914
|
+
eventKinds: external_exports.array(EventKind).min(1).optional()
|
|
23915
|
+
}).refine((v) => v.extensions !== void 0 || v.eventKinds !== void 0, {
|
|
23916
|
+
message: "appliesTo needs extensions, eventKinds, or both"
|
|
23685
23917
|
}).meta({ id: "AppliesTo" });
|
|
23686
23918
|
var PostValidatorName = external_exports.enum(["entropy", "luhn"]).meta({ id: "PostValidatorName" });
|
|
23687
23919
|
var PostValidatorRef = external_exports.union(
|
|
@@ -23704,6 +23936,7 @@ var PostValidatorRef = external_exports.union(
|
|
|
23704
23936
|
)}) or { "name": ..., "config": { ... } }. An unrecognized name would be a false-positive guard that never runs.`
|
|
23705
23937
|
}
|
|
23706
23938
|
).meta({ id: "PostValidatorRef" });
|
|
23939
|
+
var RuleEvidence = external_exports.enum(["code", "value"]).meta({ id: "RuleEvidence" });
|
|
23707
23940
|
var RequiresNearby = external_exports.strictObject({
|
|
23708
23941
|
// Each array, when present, must be non-empty and contain non-empty strings —
|
|
23709
23942
|
// an empty/blank criterion would either never fire or (for labels) match
|
|
@@ -23726,6 +23959,8 @@ var RuleFixture = external_exports.strictObject({
|
|
|
23726
23959
|
// Simulated file context for the scan, so fixtures can assert `appliesTo`
|
|
23727
23960
|
// gating (e.g. a Python-only pattern must NOT fire in a .ts file).
|
|
23728
23961
|
filePath: external_exports.string().optional(),
|
|
23962
|
+
// Simulated capture kind, so fixtures can assert `appliesTo.eventKinds`.
|
|
23963
|
+
eventKind: EventKind.optional(),
|
|
23729
23964
|
expectedSpans: external_exports.array(external_exports.strictObject({ start: external_exports.number(), end: external_exports.number() })).optional()
|
|
23730
23965
|
}).meta({ id: "RuleFixture" });
|
|
23731
23966
|
var Rule = external_exports.strictObject({
|
|
@@ -23751,7 +23986,9 @@ var Rule = external_exports.strictObject({
|
|
|
23751
23986
|
appliesTo: AppliesTo.optional(),
|
|
23752
23987
|
postValidators: external_exports.array(PostValidatorRef).optional(),
|
|
23753
23988
|
requiresNearby: RequiresNearby.optional(),
|
|
23754
|
-
examples: external_exports.array(external_exports.string()).optional()
|
|
23989
|
+
examples: external_exports.array(external_exports.string()).optional(),
|
|
23990
|
+
// Whether the matched text is itself sensitive. Absent means 'value'.
|
|
23991
|
+
evidence: RuleEvidence.optional()
|
|
23755
23992
|
}).meta({ id: "Rule" });
|
|
23756
23993
|
var Author = external_exports.object({
|
|
23757
23994
|
name: external_exports.string(),
|
|
@@ -23768,7 +24005,11 @@ var PackManifest = external_exports.object({
|
|
|
23768
24005
|
description: external_exports.string().optional(),
|
|
23769
24006
|
author: Author.optional(),
|
|
23770
24007
|
license: external_exports.string().optional(),
|
|
23771
|
-
sourceUrl: external_exports.url().optional()
|
|
24008
|
+
sourceUrl: external_exports.url().optional(),
|
|
24009
|
+
// The built-in policy a FIRST install of this pack assigns
|
|
24010
|
+
// (installed_packs.policy_id). Absent leaves the pack unassigned, so its
|
|
24011
|
+
// rules follow the category policies. An existing install never takes it.
|
|
24012
|
+
defaultPolicy: BuiltinPolicyId.optional()
|
|
23772
24013
|
}).meta({ id: "PackManifest" });
|
|
23773
24014
|
|
|
23774
24015
|
// ../../packages/schema/src/zod/detection.ts
|
|
@@ -23796,10 +24037,12 @@ var DetectionListItem = external_exports.object({
|
|
|
23796
24037
|
// Per-pack enforcement-policy assignment. Holds a BuiltinPolicyId ARCHETYPE
|
|
23797
24038
|
// (monitor|warn|redact|block) — NOT a policies-table Policy.id guid; a
|
|
23798
24039
|
// detection is a PACK, and its policy is the archetype applied to all its
|
|
23799
|
-
// rules. Absent == unassigned, which resolves to Monitor
|
|
23800
|
-
// (DEFAULT_PACK_POLICY_ID)
|
|
23801
|
-
//
|
|
23802
|
-
//
|
|
24040
|
+
// rules. Absent == unassigned, which resolves to Monitor by default
|
|
24041
|
+
// (DEFAULT_PACK_POLICY_ID); a host may resolve it to a policy of its own
|
|
24042
|
+
// (see the dashboard's `unassignedPolicy`). Every enforcement surface
|
|
24043
|
+
// expands it into per-rule policies (see policyIdToAction). Typed
|
|
24044
|
+
// z.string() (not the enum) to keep the OpenAPI response tolerant of a
|
|
24045
|
+
// future custom id.
|
|
23803
24046
|
policyId: external_exports.string().optional(),
|
|
23804
24047
|
// Set ONLY when a newer snapshot is available for this pack (OSS: the
|
|
23805
24048
|
// bundled inventory recorded in available_packs differs from the installed
|
|
@@ -23868,10 +24111,12 @@ var DetectionDetail = external_exports.object({
|
|
|
23868
24111
|
// Per-pack enforcement-policy assignment. Holds a BuiltinPolicyId ARCHETYPE
|
|
23869
24112
|
// (monitor|warn|redact|block) — NOT a policies-table Policy.id guid; a
|
|
23870
24113
|
// detection is a PACK, and its policy is the archetype applied to all its
|
|
23871
|
-
// rules. Absent == unassigned, which resolves to Monitor
|
|
23872
|
-
// (DEFAULT_PACK_POLICY_ID)
|
|
23873
|
-
//
|
|
23874
|
-
//
|
|
24114
|
+
// rules. Absent == unassigned, which resolves to Monitor by default
|
|
24115
|
+
// (DEFAULT_PACK_POLICY_ID); a host may resolve it to a policy of its own
|
|
24116
|
+
// (see the dashboard's `unassignedPolicy`). Every enforcement surface
|
|
24117
|
+
// expands it into per-rule policies (see policyIdToAction). Typed
|
|
24118
|
+
// z.string() (not the enum) to keep the OpenAPI response tolerant of a
|
|
24119
|
+
// future custom id.
|
|
23875
24120
|
policyId: external_exports.string().optional()
|
|
23876
24121
|
}).meta({ id: "DetectionDetail" });
|
|
23877
24122
|
var LibraryItem = external_exports.object({
|
|
@@ -24018,126 +24263,6 @@ function buildDetectionsList(summaries, query) {
|
|
|
24018
24263
|
return { counts, items: filtered.map(summaryToDetectionListItem) };
|
|
24019
24264
|
}
|
|
24020
24265
|
|
|
24021
|
-
// ../../packages/schema/src/zod/event.ts
|
|
24022
|
-
var EventKind = external_exports.enum(["prompt", "response", "code_change", "tool_use"]).meta({ id: "EventKind" });
|
|
24023
|
-
var CAPTURE_EVENT_TYPES_SQL = EventKind.options.map((k) => `'${k}'`).join(",");
|
|
24024
|
-
var EventMetadata = external_exports.object({
|
|
24025
|
-
sessionId: external_exports.string().optional(),
|
|
24026
|
-
repo: external_exports.string().optional(),
|
|
24027
|
-
filePath: external_exports.string().optional(),
|
|
24028
|
-
// The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
|
|
24029
|
-
// set by the tool-scanning hooks. The tool NAME only — never the tool's
|
|
24030
|
-
// arguments or output, which can carry the very value a finding masked
|
|
24031
|
-
// (metadata is stored unredacted). Gives findings on non-file captures a
|
|
24032
|
-
// display location ("via Bash") when no filePath exists.
|
|
24033
|
-
toolName: external_exports.string().optional(),
|
|
24034
|
-
// Set (true) by the worktree scanner when the file is excluded by the
|
|
24035
|
-
// repo's .gitignore. Gitignored files ARE still scanned — local scratch and
|
|
24036
|
-
// generated code can leak real secrets — but the provenance is recorded so
|
|
24037
|
-
// policy/dashboards can treat those findings as informational rather than
|
|
24038
|
-
// blocking. Omitted (not false) for tracked files and non-scan events.
|
|
24039
|
-
gitignored: external_exports.boolean().optional(),
|
|
24040
|
-
// Set (true) ONLY when the event's `content` is the COMPLETE file at
|
|
24041
|
-
// capture time (a worktree scan reading from disk). Hook-captured edits
|
|
24042
|
-
// (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
|
|
24043
|
-
// this. The resolver-on-ingest keys its fixed-at-source dropout
|
|
24044
|
-
// diff on this marker: only a whole-file snapshot can prove a previously
|
|
24045
|
-
// open finding is gone; a fragment's absence proves nothing (the secret
|
|
24046
|
-
// may live outside the hunk). Omitted (not false) for fragments and
|
|
24047
|
-
// non-scan events, so pre-marker clients safely default to the
|
|
24048
|
-
// non-authoritative path.
|
|
24049
|
-
wholeFile: external_exports.boolean().optional(),
|
|
24050
|
-
model: external_exports.string().optional(),
|
|
24051
|
-
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
24052
|
-
// Distributed-tracing correlation. `correlationId` ties a recorded event back
|
|
24053
|
-
// to the request that captured/ingested it (a UUID, generated independently of
|
|
24054
|
-
// the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
|
|
24055
|
-
// originating span when telemetry is enabled. Both optional + backward
|
|
24056
|
-
// compatible — populated by the plugin (see @akasecurity/plugin-sdk).
|
|
24057
|
-
correlationId: external_exports.uuid().optional(),
|
|
24058
|
-
traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
|
|
24059
|
-
// Ids of the detection exceptions that downgraded findings in this capture
|
|
24060
|
-
// to 'allow' — the enforcement audit trail's link back to the grant that
|
|
24061
|
-
// authorized the bypass. Absent on captures where no exception applied.
|
|
24062
|
-
exceptionIds: external_exports.array(external_exports.guid()).optional(),
|
|
24063
|
-
// The assistant message this capture belongs to, and the conversation it sits
|
|
24064
|
-
// in — set by the browser extension's network capture so a stored `response`
|
|
24065
|
-
// row can be joined to the `llm_call` leaf describing the same turn. Absent
|
|
24066
|
-
// on every other capture path, which has no such id.
|
|
24067
|
-
//
|
|
24068
|
-
// Non-empty for the reason WebExchange.messageId is: it is the join key, and
|
|
24069
|
-
// a blank one matches no `llm_call` leaf. That refusal reaches only the
|
|
24070
|
-
// places an event is PARSED; the local write path types the event and parses
|
|
24071
|
-
// nothing, which is why `toCaptureAttributes` omits a blank one separately.
|
|
24072
|
-
messageId: external_exports.string().min(1).optional(),
|
|
24073
|
-
conversationId: external_exports.string().optional(),
|
|
24074
|
-
// How long THIS capture's inspection blocked its caller, in whole
|
|
24075
|
-
// milliseconds — the plugin's own added latency, NOT the LLM call it sat in
|
|
24076
|
-
// front of. Measured inside `capture()` (@akasecurity/plugin-sdk) across
|
|
24077
|
-
// detection + redaction, the work the host session actually waits on.
|
|
24078
|
-
//
|
|
24079
|
-
// Stamped ONLY on live in-flight captures. A capture that carries its own
|
|
24080
|
-
// `occurredAt` is replaying past work (the transcript backfill, the worktree
|
|
24081
|
-
// scan), and its scan duration is not latency any host session experienced,
|
|
24082
|
-
// so those rows leave this ABSENT rather than reporting a misleading number.
|
|
24083
|
-
// Absent is also what every pre-measurement client writes, and what a
|
|
24084
|
-
// clock failure degrades to — a reader must treat absence as "not measured"
|
|
24085
|
-
// and never as a zero, which would read as "inspection is free".
|
|
24086
|
-
inspectionMs: external_exports.number().int().nonnegative().optional(),
|
|
24087
|
-
// What a `redact` this capture COULD NOT CARRY OUT became instead — the
|
|
24088
|
-
// workspace's `redactFallback`, applied because the field could not be
|
|
24089
|
-
// masked in place (a shell command, a URL, or any argument on a host whose
|
|
24090
|
-
// hook contract offers no rewrite channel).
|
|
24091
|
-
//
|
|
24092
|
-
// It exists because the action alone cannot say why. A finding recorded as
|
|
24093
|
-
// `warn` reads identically whether its detection was ASSIGNED Warn or was
|
|
24094
|
-
// assigned Redact on a field that could not take one — and those are
|
|
24095
|
-
// different facts about the same row: the first is a policy the user chose,
|
|
24096
|
-
// the second is a masking the host could not perform. Absent means no
|
|
24097
|
-
// degrade happened, which is every ordinary capture.
|
|
24098
|
-
//
|
|
24099
|
-
// TWO LIMITS a reader of a stored row has to know, because the grain here
|
|
24100
|
-
// is the CAPTURE while `actionTaken` is per FINDING:
|
|
24101
|
-
//
|
|
24102
|
-
// - It does not say WHICH finding degraded. A capture carrying a degraded
|
|
24103
|
-
// `redact` alongside a finding ASSIGNED the same action stores both
|
|
24104
|
-
// identically and one reason for the pair; attributing it to both
|
|
24105
|
-
// describes the assigned one wrongly, and to neither loses the degrade.
|
|
24106
|
-
// - PRESENCE IS NOT CAUSATION. The value is the action the lost redact
|
|
24107
|
-
// became, not the reason the capture ended as it did — a capture denied
|
|
24108
|
-
// by some other finding's own Block policy still carries `block` here,
|
|
24109
|
-
// and clearing the workspace's fallback would not have let it through.
|
|
24110
|
-
// Gate on the value against what a fallback can produce; never read the
|
|
24111
|
-
// field's presence as "this was the fallback's doing".
|
|
24112
|
-
//
|
|
24113
|
-
// Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
|
|
24114
|
-
// Closing either means moving the reason onto the finding row, which
|
|
24115
|
-
// already carries its own action.
|
|
24116
|
-
redactDegradedTo: ActionTaken.optional()
|
|
24117
|
-
}).meta({ id: "EventMetadata" });
|
|
24118
|
-
var Event = external_exports.object({
|
|
24119
|
-
id: external_exports.guid(),
|
|
24120
|
-
sourceTool: SourceTool,
|
|
24121
|
-
kind: EventKind,
|
|
24122
|
-
occurredAt: external_exports.iso.datetime(),
|
|
24123
|
-
contentHash: external_exports.string(),
|
|
24124
|
-
content: external_exports.string(),
|
|
24125
|
-
metadata: EventMetadata.optional()
|
|
24126
|
-
}).meta({ id: "Event" });
|
|
24127
|
-
var IngestEvent = Event.meta({ id: "IngestEvent" });
|
|
24128
|
-
var INGEST_BATCH_MAX = 100;
|
|
24129
|
-
var IngestBatch = external_exports.object({
|
|
24130
|
-
events: external_exports.array(IngestEvent).min(1).max(INGEST_BATCH_MAX),
|
|
24131
|
-
// Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
|
|
24132
|
-
// additionally rejects any event whose contentHash the store has already
|
|
24133
|
-
// recorded — for re-runnable bulk ingest (worktree scan, transcript
|
|
24134
|
-
// backfill), where a re-run mints fresh event ids for identical content and
|
|
24135
|
-
// would otherwise accumulate duplicates. Live hook traffic must NOT set it:
|
|
24136
|
-
// two genuinely separate prompts can be byte-identical and both belong on
|
|
24137
|
-
// the timeline.
|
|
24138
|
-
dedupe: external_exports.literal("content-hash").optional()
|
|
24139
|
-
}).meta({ id: "IngestBatch" });
|
|
24140
|
-
|
|
24141
24266
|
// ../../packages/schema/src/zod/exception.ts
|
|
24142
24267
|
var ExceptionScope = external_exports.enum(["once", "temporary", "permanent"]);
|
|
24143
24268
|
var ExceptionConditions = external_exports.object({
|
|
@@ -24605,6 +24730,8 @@ function toInstanceDetail(row) {
|
|
|
24605
24730
|
provider: toApiProvider(row.sourceTool),
|
|
24606
24731
|
repo: row.repo,
|
|
24607
24732
|
file: row.file,
|
|
24733
|
+
...row.line === void 0 ? {} : { line: row.line },
|
|
24734
|
+
...row.col === void 0 ? {} : { col: row.col },
|
|
24608
24735
|
...row.toolName === void 0 ? {} : { toolName: row.toolName },
|
|
24609
24736
|
eventId: row.eventId,
|
|
24610
24737
|
...row.sessionId === void 0 ? {} : { sessionId: row.sessionId },
|
|
@@ -24618,7 +24745,11 @@ function toInstanceDetail(row) {
|
|
|
24618
24745
|
category,
|
|
24619
24746
|
subtype: row.ruleId,
|
|
24620
24747
|
severity: row.severity,
|
|
24621
|
-
match: {
|
|
24748
|
+
match: {
|
|
24749
|
+
maskedValue: row.maskedMatch,
|
|
24750
|
+
contextPrefix: "",
|
|
24751
|
+
...row.context === void 0 ? {} : { context: row.context }
|
|
24752
|
+
},
|
|
24622
24753
|
detection: { id: row.ruleId, name: null },
|
|
24623
24754
|
policy: { id: `category:${category}`, name: category }
|
|
24624
24755
|
};
|
|
@@ -24730,8 +24861,6 @@ var Policy = external_exports.object({
|
|
|
24730
24861
|
// test `prohibitedModels` passes and `reversibleRuleIds` fails.
|
|
24731
24862
|
provenance: PolicyProvenance.optional()
|
|
24732
24863
|
}).meta({ id: "Policy" });
|
|
24733
|
-
var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
|
|
24734
|
-
var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
|
|
24735
24864
|
var RedactFallback = BuiltinPolicyId.extract(["monitor", "warn", "block"]).meta({
|
|
24736
24865
|
id: "RedactFallback"
|
|
24737
24866
|
});
|
|
@@ -25126,7 +25255,7 @@ var VaultConsent = external_exports.object({
|
|
|
25126
25255
|
});
|
|
25127
25256
|
|
|
25128
25257
|
// ../../packages/schema/src/zod/local.ts
|
|
25129
|
-
var WORKSPACE_SETTINGS_SPEC_VERSION =
|
|
25258
|
+
var WORKSPACE_SETTINGS_SPEC_VERSION = 9;
|
|
25130
25259
|
var MODEL_JUDGE_PAYLOAD_VERSION = 1;
|
|
25131
25260
|
var RunMode = external_exports.enum(["standalone", "attached"]);
|
|
25132
25261
|
var ControlPlaneConnection = external_exports.object({
|
|
@@ -25149,6 +25278,18 @@ var HistorySyncConsent = external_exports.object({
|
|
|
25149
25278
|
payloadVersion: external_exports.number().int().positive(),
|
|
25150
25279
|
endpoint: external_exports.string()
|
|
25151
25280
|
});
|
|
25281
|
+
var ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH = 512;
|
|
25282
|
+
var AttachmentScopeEntry = external_exports.object({
|
|
25283
|
+
kind: external_exports.enum(["repo", "account"]),
|
|
25284
|
+
identity: printable(ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH).min(1),
|
|
25285
|
+
label: printable(80).optional(),
|
|
25286
|
+
enrolledAt: external_exports.iso.datetime()
|
|
25287
|
+
});
|
|
25288
|
+
var AttachmentScope = external_exports.object({
|
|
25289
|
+
endpoint: external_exports.string().min(1),
|
|
25290
|
+
entries: external_exports.array(AttachmentScopeEntry)
|
|
25291
|
+
});
|
|
25292
|
+
var AttachmentScopeEnvelope = AttachmentScope.extend({ entries: external_exports.array(external_exports.unknown()) });
|
|
25152
25293
|
var WebChatCaptureConsent = external_exports.object({
|
|
25153
25294
|
acknowledgedAt: external_exports.iso.datetime(),
|
|
25154
25295
|
version: external_exports.number().int().positive()
|
|
@@ -25219,6 +25360,23 @@ var WorkspaceSettings = external_exports.object({
|
|
|
25219
25360
|
// both widenings. Absent until granted, and a grant for a different endpoint
|
|
25220
25361
|
// or an older payload no longer counts.
|
|
25221
25362
|
historySyncConsent: HistorySyncConsent.optional(),
|
|
25363
|
+
// The identities a SCOPED attachment forwards and the deployment they were
|
|
25364
|
+
// enrolled for (see AttachmentScope). Absent until something is enrolled.
|
|
25365
|
+
//
|
|
25366
|
+
// `z.unknown()`, NOT `AttachmentScope`, and the difference is this field's
|
|
25367
|
+
// whole failure mode. A settings.json that fails this schema reads as the
|
|
25368
|
+
// unonboarded defaults (readUserSettings in @akasecurity/persistence), and the
|
|
25369
|
+
// next save writes those defaults back over it. Typed, one entry with an
|
|
25370
|
+
// unknown `kind`, a control character or a bad timestamp would cost the
|
|
25371
|
+
// attachment, every consent and onboardedAt, permanently. Untyped, the value
|
|
25372
|
+
// is kept exactly as found and validated where it is used: parseAttachmentScope
|
|
25373
|
+
// drops a bad entry by itself, and on a scoped attachment resolveScope reads a
|
|
25374
|
+
// bad envelope as no entries, which keeps every event local.
|
|
25375
|
+
//
|
|
25376
|
+
// No default: absent must stay absent, so defaultWorkspaceSettings() and a
|
|
25377
|
+
// fresh settings.json do not change. No `.meta({ id })`, like every field
|
|
25378
|
+
// here. Not a ManagedSettingKey.
|
|
25379
|
+
attachmentScope: external_exports.unknown().optional(),
|
|
25222
25380
|
// What the browser extension may record from a web chat, and the grant that
|
|
25223
25381
|
// authorizes it. Absent until the user answers: recording something that was
|
|
25224
25382
|
// never recorded before is never an assumed grant on upgrade, so the whole
|
|
@@ -25313,7 +25471,10 @@ function toInspectionFindingRow(input2) {
|
|
|
25313
25471
|
actionTaken: input2.actionTaken,
|
|
25314
25472
|
confidence: input2.confidence,
|
|
25315
25473
|
findingKey: input2.findingKey ?? null,
|
|
25316
|
-
firstDetectedAt: input2.firstDetectedAt ? isoToEpochMillis(input2.firstDetectedAt) : null
|
|
25474
|
+
firstDetectedAt: input2.firstDetectedAt ? isoToEpochMillis(input2.firstDetectedAt) : null,
|
|
25475
|
+
line: input2.line ?? null,
|
|
25476
|
+
col: input2.col ?? null,
|
|
25477
|
+
context: input2.context ? JSON.stringify(input2.context) : null
|
|
25317
25478
|
};
|
|
25318
25479
|
}
|
|
25319
25480
|
function toCaptureAttributes(event) {
|
|
@@ -26465,6 +26626,15 @@ var COUNTED_SCOPE = `
|
|
|
26465
26626
|
OR outbox_owed = 1
|
|
26466
26627
|
)`;
|
|
26467
26628
|
var SKIPPED = -1;
|
|
26629
|
+
function inScope(column) {
|
|
26630
|
+
return `${column} IN (SELECT value FROM json_each(:scopeKeys))`;
|
|
26631
|
+
}
|
|
26632
|
+
function scopeKeysParam(scopeKeys) {
|
|
26633
|
+
return JSON.stringify(scopeKeys);
|
|
26634
|
+
}
|
|
26635
|
+
var ROOT_SCOPE_KEY = `(SELECT session_root.scope_key
|
|
26636
|
+
FROM audit_events AS session_root
|
|
26637
|
+
WHERE session_root.id = COALESCE(audit_events.root_session_id, audit_events.id))`;
|
|
26468
26638
|
var ROW_COLUMNS = `id,
|
|
26469
26639
|
parent_id AS parentId,
|
|
26470
26640
|
root_session_id AS rootSessionId,
|
|
@@ -26493,6 +26663,18 @@ var SqliteHistorySyncRepository = class {
|
|
|
26493
26663
|
ORDER BY earliest
|
|
26494
26664
|
LIMIT :limit`
|
|
26495
26665
|
);
|
|
26666
|
+
this.scopedSessionsStmt = db.prepare(
|
|
26667
|
+
`SELECT COALESCE(root_session_id, id) AS sessionId, MIN(started_at) AS earliest
|
|
26668
|
+
FROM audit_events
|
|
26669
|
+
WHERE synced_at IS NULL
|
|
26670
|
+
AND event_type IN (${TYPE_LIST})
|
|
26671
|
+
AND started_at < :before
|
|
26672
|
+
AND ${inScope("scope_key")}
|
|
26673
|
+
AND ${inScope(ROOT_SCOPE_KEY)}
|
|
26674
|
+
GROUP BY sessionId
|
|
26675
|
+
ORDER BY earliest
|
|
26676
|
+
LIMIT :limit`
|
|
26677
|
+
);
|
|
26496
26678
|
this.rowsStmt = db.prepare(
|
|
26497
26679
|
`SELECT ${ROW_COLUMNS}
|
|
26498
26680
|
FROM audit_events
|
|
@@ -26503,6 +26685,18 @@ var SqliteHistorySyncRepository = class {
|
|
|
26503
26685
|
ORDER BY (event_type = 'session') DESC, started_at
|
|
26504
26686
|
LIMIT :limit`
|
|
26505
26687
|
);
|
|
26688
|
+
this.scopedRowsStmt = db.prepare(
|
|
26689
|
+
`SELECT ${ROW_COLUMNS}
|
|
26690
|
+
FROM audit_events
|
|
26691
|
+
WHERE synced_at IS NULL
|
|
26692
|
+
AND event_type IN (${TYPE_LIST})
|
|
26693
|
+
AND started_at < :before
|
|
26694
|
+
AND COALESCE(root_session_id, id) = :sessionId
|
|
26695
|
+
AND ${inScope("scope_key")}
|
|
26696
|
+
AND ${inScope(ROOT_SCOPE_KEY)}
|
|
26697
|
+
ORDER BY (event_type = 'session') DESC, started_at
|
|
26698
|
+
LIMIT :limit`
|
|
26699
|
+
);
|
|
26506
26700
|
this.captureRowsStmt = db.prepare(
|
|
26507
26701
|
`SELECT ${ROW_COLUMNS}
|
|
26508
26702
|
FROM audit_events
|
|
@@ -26514,6 +26708,18 @@ var SqliteHistorySyncRepository = class {
|
|
|
26514
26708
|
ORDER BY started_at
|
|
26515
26709
|
LIMIT :limit`
|
|
26516
26710
|
);
|
|
26711
|
+
this.scopedCaptureRowsStmt = db.prepare(
|
|
26712
|
+
`SELECT ${ROW_COLUMNS}
|
|
26713
|
+
FROM audit_events
|
|
26714
|
+
WHERE synced_at IS NULL
|
|
26715
|
+
AND sync_claimed_at IS NULL
|
|
26716
|
+
AND outbox_owed = 1
|
|
26717
|
+
AND event_type IN (${CAPTURE_TYPE_LIST})
|
|
26718
|
+
AND started_at < :before
|
|
26719
|
+
AND ${inScope("scope_key")}
|
|
26720
|
+
ORDER BY started_at
|
|
26721
|
+
LIMIT :limit`
|
|
26722
|
+
);
|
|
26517
26723
|
this.markOwedStmt = db.prepare(
|
|
26518
26724
|
`UPDATE audit_events SET outbox_owed = 1 WHERE id = :id AND synced_at IS NULL`
|
|
26519
26725
|
);
|
|
@@ -26523,6 +26729,20 @@ var SqliteHistorySyncRepository = class {
|
|
|
26523
26729
|
AND event_type IN (${CAPTURE_TYPE_LIST})
|
|
26524
26730
|
AND started_at < :before`
|
|
26525
26731
|
);
|
|
26732
|
+
this.scopedCaptureBacklogOwedStmt = db.prepare(
|
|
26733
|
+
`UPDATE audit_events SET outbox_owed = 1
|
|
26734
|
+
WHERE synced_at IS NULL
|
|
26735
|
+
AND event_type IN (${CAPTURE_TYPE_LIST})
|
|
26736
|
+
AND started_at < :before
|
|
26737
|
+
AND ${inScope("scope_key")}`
|
|
26738
|
+
);
|
|
26739
|
+
this.markScopeCapturesOwedStmt = db.prepare(
|
|
26740
|
+
`UPDATE audit_events SET outbox_owed = 1
|
|
26741
|
+
WHERE synced_at IS NULL
|
|
26742
|
+
AND outbox_owed IS NULL
|
|
26743
|
+
AND event_type IN (${CAPTURE_TYPE_LIST})
|
|
26744
|
+
AND ${inScope("scope_key")}`
|
|
26745
|
+
);
|
|
26526
26746
|
this.stampStmt = db.prepare(
|
|
26527
26747
|
`UPDATE audit_events
|
|
26528
26748
|
SET synced_at = :at,
|
|
@@ -26681,6 +26901,15 @@ var SqliteHistorySyncRepository = class {
|
|
|
26681
26901
|
claimRowStmt;
|
|
26682
26902
|
releaseRowStmt;
|
|
26683
26903
|
releaseStaleClaimsStmt;
|
|
26904
|
+
// The SCOPED twins, for a scoped attachment: the same reads and seeds with the
|
|
26905
|
+
// scope clause added, prepared once here beside the machine statements, so a
|
|
26906
|
+
// machine attachment's statements are untouched and neither form is compiled
|
|
26907
|
+
// per call.
|
|
26908
|
+
scopedSessionsStmt;
|
|
26909
|
+
scopedRowsStmt;
|
|
26910
|
+
scopedCaptureRowsStmt;
|
|
26911
|
+
scopedCaptureBacklogOwedStmt;
|
|
26912
|
+
markScopeCapturesOwedStmt;
|
|
26684
26913
|
/**
|
|
26685
26914
|
* The masked detections recorded against one tool call.
|
|
26686
26915
|
*
|
|
@@ -26700,15 +26929,33 @@ var SqliteHistorySyncRepository = class {
|
|
|
26700
26929
|
* path's to deliver; this drain exists for what was recorded before it, and a
|
|
26701
26930
|
* row both paths send is at best a duplicate request and at worst — for a
|
|
26702
26931
|
* session root — an overwrite of the inventory ids the live path resolved.
|
|
26932
|
+
*
|
|
26933
|
+
* `scopeKeys` is a scoped attachment's filter: a session is offered only while
|
|
26934
|
+
* its root's key is one of them AND at least one of its unsent rows' keys is
|
|
26935
|
+
* (see scopedSessionsStmt). Omitted, this runs the machine statement,
|
|
26936
|
+
* unchanged; an empty list offers nothing.
|
|
26703
26937
|
*/
|
|
26704
|
-
pendingSessions(limit, before) {
|
|
26705
|
-
|
|
26706
|
-
|
|
26707
|
-
|
|
26938
|
+
pendingSessions(limit, before, scopeKeys) {
|
|
26939
|
+
const rows = scopeKeys === void 0 ? allRows(this.sessionsStmt, { limit, before }) : allRows(this.scopedSessionsStmt, {
|
|
26940
|
+
limit,
|
|
26941
|
+
before,
|
|
26942
|
+
scopeKeys: scopeKeysParam(scopeKeys)
|
|
26943
|
+
});
|
|
26944
|
+
return rows.map((r) => r.sessionId);
|
|
26708
26945
|
}
|
|
26709
|
-
/**
|
|
26710
|
-
|
|
26711
|
-
|
|
26946
|
+
/**
|
|
26947
|
+
* One session's undelivered structural rows within the backlog, root first.
|
|
26948
|
+
*
|
|
26949
|
+
* With `scopeKeys`, only the rows whose own key AND whose session root's key
|
|
26950
|
+
* are among them, whichever session id is passed.
|
|
26951
|
+
*/
|
|
26952
|
+
pendingRows(sessionId, limit, before, scopeKeys) {
|
|
26953
|
+
return scopeKeys === void 0 ? allRows(this.rowsStmt, { sessionId, limit, before }) : allRows(this.scopedRowsStmt, {
|
|
26954
|
+
sessionId,
|
|
26955
|
+
limit,
|
|
26956
|
+
before,
|
|
26957
|
+
scopeKeys: scopeKeysParam(scopeKeys)
|
|
26958
|
+
});
|
|
26712
26959
|
}
|
|
26713
26960
|
/**
|
|
26714
26961
|
* Captures this machine still owes the deployment, oldest first.
|
|
@@ -26717,9 +26964,17 @@ var SqliteHistorySyncRepository = class {
|
|
|
26717
26964
|
* by a time window — see captureRowsStmt for why a window could not express
|
|
26718
26965
|
* this. `before` is the grace window that leaves a just-recorded capture to
|
|
26719
26966
|
* the live path.
|
|
26967
|
+
*
|
|
26968
|
+
* With `scopeKeys`, only captures stamped with one of them, decided per
|
|
26969
|
+
* capture: /v1/events stubs a missing root, so a capture never waits on its
|
|
26970
|
+
* session's scope. An empty list reads nothing.
|
|
26720
26971
|
*/
|
|
26721
|
-
pendingCaptureRows(limit, before) {
|
|
26722
|
-
return allRows(this.captureRowsStmt, { limit, before })
|
|
26972
|
+
pendingCaptureRows(limit, before, scopeKeys) {
|
|
26973
|
+
return scopeKeys === void 0 ? allRows(this.captureRowsStmt, { limit, before }) : allRows(this.scopedCaptureRowsStmt, {
|
|
26974
|
+
limit,
|
|
26975
|
+
before,
|
|
26976
|
+
scopeKeys: scopeKeysParam(scopeKeys)
|
|
26977
|
+
});
|
|
26723
26978
|
}
|
|
26724
26979
|
/**
|
|
26725
26980
|
* Record that a capture is OWED to the deployment.
|
|
@@ -26751,9 +27006,37 @@ var SqliteHistorySyncRepository = class {
|
|
|
26751
27006
|
* Returns how many rows matched, for the caller to log or test against. Not a
|
|
26752
27007
|
* count of NEWLY marked rows — a row still unsynced from an earlier call
|
|
26753
27008
|
* matches again and is counted again, the same as `UPDATE`'s own `changes`.
|
|
27009
|
+
*
|
|
27010
|
+
* `scopeKeys` scopes it for a scoped attachment: only captures stamped with one
|
|
27011
|
+
* of the keys are marked, and an empty list marks none. The scoped capture read
|
|
27012
|
+
* is what keeps a personal capture out of a batch; this keeps the marker to
|
|
27013
|
+
* what the grant covers. Omitted, it runs the machine statement, unchanged.
|
|
26754
27014
|
*/
|
|
26755
|
-
markCaptureBacklogOwed(before) {
|
|
26756
|
-
|
|
27015
|
+
markCaptureBacklogOwed(before, scopeKeys) {
|
|
27016
|
+
const result = scopeKeys === void 0 ? this.markCaptureBacklogOwedStmt.run({ before }) : this.scopedCaptureBacklogOwedStmt.run({ before, scopeKeys: scopeKeysParam(scopeKeys) });
|
|
27017
|
+
return Number(result.changes);
|
|
27018
|
+
}
|
|
27019
|
+
/**
|
|
27020
|
+
* Mark owed every unsent capture stamped with one of `scopeKeys`: the re-seed
|
|
27021
|
+
* an enrollment runs.
|
|
27022
|
+
*
|
|
27023
|
+
* This ASSUMES the contract a scoped caller keeps, and cannot check it: nothing
|
|
27024
|
+
* else marks an out-of-scope capture owed (the live forward must refuse it
|
|
27025
|
+
* before its owed branch, and the consent-time seed must be handed the key
|
|
27026
|
+
* list). Under that contract, an enrolled repository's unsent captures are
|
|
27027
|
+
* reachable only if this runs when the repository is enrolled. Like the
|
|
27028
|
+
* consent seed it is one explicit human action, never something a pass infers,
|
|
27029
|
+
* and its caller must know the history grant is in force: this method cannot
|
|
27030
|
+
* check consent and must not be called without it.
|
|
27031
|
+
*
|
|
27032
|
+
* No time bound. Delivered and skipped rows are never re-opened, and a row
|
|
27033
|
+
* already owed is not counted, so the return value is how many rows this call
|
|
27034
|
+
* newly marked. An empty list marks nothing.
|
|
27035
|
+
*/
|
|
27036
|
+
markScopeCapturesOwed(scopeKeys) {
|
|
27037
|
+
return Number(
|
|
27038
|
+
this.markScopeCapturesOwedStmt.run({ scopeKeys: scopeKeysParam(scopeKeys) }).changes
|
|
27039
|
+
);
|
|
26757
27040
|
}
|
|
26758
27041
|
/**
|
|
26759
27042
|
* Record delivery. Called only AFTER the far side has accepted the rows.
|
|
@@ -26958,8 +27241,12 @@ var SqliteHistorySyncRepository = class {
|
|
|
26958
27241
|
* disown from eating THIS SAME CALL's own re-mark is the order, not the
|
|
26959
27242
|
* bound — disown runs first, re-mark second, both inside the one
|
|
26960
27243
|
* transaction above.
|
|
27244
|
+
*
|
|
27245
|
+
* `scopeKeys` scopes the re-mark exactly as `markCaptureBacklogOwed` is scoped.
|
|
27246
|
+
* The disown before it is not scoped, and must not be: it clears the previous
|
|
27247
|
+
* deployment's markers whatever their scope.
|
|
26961
27248
|
*/
|
|
26962
|
-
rearmFor(fingerprint, backlogBefore, backfillCapturesBefore) {
|
|
27249
|
+
rearmFor(fingerprint, backlogBefore, backfillCapturesBefore, scopeKeys) {
|
|
26963
27250
|
this.ensureRowStmt.run();
|
|
26964
27251
|
withTransaction(
|
|
26965
27252
|
this.db,
|
|
@@ -26970,7 +27257,7 @@ var SqliteHistorySyncRepository = class {
|
|
|
26970
27257
|
this.disownCapturesStmt.run({ attachedAt: backlogBefore });
|
|
26971
27258
|
}
|
|
26972
27259
|
if (backfillCapturesBefore !== void 0) {
|
|
26973
|
-
this.
|
|
27260
|
+
this.markCaptureBacklogOwed(backfillCapturesBefore, scopeKeys);
|
|
26974
27261
|
}
|
|
26975
27262
|
this.setFingerprintStmt.run({ fingerprint, backlogBefore });
|
|
26976
27263
|
},
|
|
@@ -27136,6 +27423,7 @@ function applyMigrations(db, file2, options = {}) {
|
|
|
27136
27423
|
db.exec(`PRAGMA user_version = ${String(SQLITE_MIGRATIONS.length)}`);
|
|
27137
27424
|
}
|
|
27138
27425
|
ensureSyncedAtColumn(db, "audit_events");
|
|
27426
|
+
ensureScopeKeyColumn(db);
|
|
27139
27427
|
ensureScanLedgerTable(db);
|
|
27140
27428
|
ensureHistorySyncTable(db);
|
|
27141
27429
|
ensureBlockedDetectionsTable(db);
|
|
@@ -27561,6 +27849,21 @@ function ensureSyncedAtColumn(db, table2) {
|
|
|
27561
27849
|
ON audit_events (sync_claimed_at) WHERE sync_claimed_at IS NOT NULL`
|
|
27562
27850
|
);
|
|
27563
27851
|
}
|
|
27852
|
+
var SCOPE_KEY_COLUMN_DDL = "ALTER TABLE audit_events ADD COLUMN scope_key text GENERATED ALWAYS AS (CASE WHEN json_valid(attributes) THEN json_extract(attributes, '$.scope_key') END) VIRTUAL";
|
|
27853
|
+
function ensureScopeKeyColumn(db) {
|
|
27854
|
+
if (!schemaObjectExists(db, "table", "audit_events")) return;
|
|
27855
|
+
if (hasScopeKeyColumn(db)) return;
|
|
27856
|
+
withTransaction(
|
|
27857
|
+
db,
|
|
27858
|
+
() => {
|
|
27859
|
+
if (!hasScopeKeyColumn(db)) db.exec(SCOPE_KEY_COLUMN_DDL);
|
|
27860
|
+
},
|
|
27861
|
+
"IMMEDIATE"
|
|
27862
|
+
);
|
|
27863
|
+
}
|
|
27864
|
+
function hasScopeKeyColumn(db) {
|
|
27865
|
+
return columnNames(db, "audit_events", { includeGenerated: true }).includes("scope_key");
|
|
27866
|
+
}
|
|
27564
27867
|
function ensureScanLedgerTable(db) {
|
|
27565
27868
|
db.exec(`CREATE TABLE IF NOT EXISTS scan_ledger (
|
|
27566
27869
|
path TEXT PRIMARY KEY,
|
|
@@ -28438,6 +28741,19 @@ var SqliteAuditEventsRepository = class {
|
|
|
28438
28741
|
if (typeof provider === "string") return provider;
|
|
28439
28742
|
return void 0;
|
|
28440
28743
|
}
|
|
28744
|
+
// The `scope_key` stored on a session root's attributes: the key the history
|
|
28745
|
+
// drain decides that root by. It is NOT necessarily the key of the root event a
|
|
28746
|
+
// caller just wrote, because roots are first-write-wins (see the session-root
|
|
28747
|
+
// upsert above) and the root event that arrives second leaves the stored row as
|
|
28748
|
+
// it was. Returns undefined when the id is not a session root, when the root is
|
|
28749
|
+
// a stub or carries no key, and when the stored value is not a string, which is
|
|
28750
|
+
// what the drain's scoped reads would not match either.
|
|
28751
|
+
sessionScopeKey(sessionId) {
|
|
28752
|
+
const row = this.findById(sessionId);
|
|
28753
|
+
if (row?.event_type !== "session" || !row.attributes) return void 0;
|
|
28754
|
+
const key = parseJsonObject(row.attributes)?.scope_key;
|
|
28755
|
+
return typeof key === "string" ? key : void 0;
|
|
28756
|
+
}
|
|
28441
28757
|
// Every `llm_call` leaf's session id + raw attribute bag, for the read-time token
|
|
28442
28758
|
// rollups. The caller parses each bag and prices it via the
|
|
28443
28759
|
// cost model — we stay a thin reader here (no business logic, no cost). `root_session_id`
|
|
@@ -28458,6 +28774,8 @@ var SqliteAuditEventsRepository = class {
|
|
|
28458
28774
|
var DEFAULT_BATCH_SIZE = 500;
|
|
28459
28775
|
var DEFAULT_MAX_ROWS = 5e4;
|
|
28460
28776
|
var SYNC_LANE_TYPES_SQL = OUTBOX_CAPTURE_TYPE_LIST;
|
|
28777
|
+
var SWEEP = { kind: "sweep" };
|
|
28778
|
+
var HOLD_ALL = { kind: "hold-all" };
|
|
28461
28779
|
var SqliteBodyRetentionRepository = class {
|
|
28462
28780
|
constructor(db) {
|
|
28463
28781
|
this.db = db;
|
|
@@ -28474,6 +28792,14 @@ var SqliteBodyRetentionRepository = class {
|
|
|
28474
28792
|
this.candidatesSyncSafeStmt = this.db.prepare(
|
|
28475
28793
|
select(`AND (event_type NOT IN (${SYNC_LANE_TYPES_SQL}) OR synced_at IS NOT NULL)`)
|
|
28476
28794
|
);
|
|
28795
|
+
this.candidatesScopedStmt = this.db.prepare(
|
|
28796
|
+
select(
|
|
28797
|
+
`AND (event_type NOT IN (${SYNC_LANE_TYPES_SQL}) OR synced_at IS NOT NULL
|
|
28798
|
+
OR (outbox_owed IS NOT 1
|
|
28799
|
+
AND (scope_key IS NULL
|
|
28800
|
+
OR scope_key NOT IN (SELECT value FROM json_each(:scopeKeys)))))`
|
|
28801
|
+
)
|
|
28802
|
+
);
|
|
28477
28803
|
this.heldBySyncStmt = this.db.prepare(`
|
|
28478
28804
|
SELECT COUNT(*) AS n
|
|
28479
28805
|
FROM audit_events
|
|
@@ -28481,37 +28807,63 @@ var SqliteBodyRetentionRepository = class {
|
|
|
28481
28807
|
AND started_at < :cutoff
|
|
28482
28808
|
AND event_type IN (${SYNC_LANE_TYPES_SQL})
|
|
28483
28809
|
AND synced_at IS NULL`);
|
|
28810
|
+
this.heldByScopeStmt = this.db.prepare(`
|
|
28811
|
+
SELECT COUNT(*) AS n
|
|
28812
|
+
FROM audit_events
|
|
28813
|
+
WHERE content IS NOT NULL
|
|
28814
|
+
AND started_at < :cutoff
|
|
28815
|
+
AND event_type IN (${SYNC_LANE_TYPES_SQL})
|
|
28816
|
+
AND synced_at IS NULL
|
|
28817
|
+
AND (outbox_owed = 1
|
|
28818
|
+
OR scope_key IN (SELECT value FROM json_each(:scopeKeys)))`);
|
|
28484
28819
|
this.expireStmt = this.db.prepare(
|
|
28485
28820
|
`UPDATE audit_events SET content = NULL, content_expired_at = :now WHERE id = :id`
|
|
28486
28821
|
);
|
|
28822
|
+
this.expireContextsStmt = this.db.prepare(
|
|
28823
|
+
`UPDATE inspection_findings SET context = NULL
|
|
28824
|
+
WHERE id IN (
|
|
28825
|
+
SELECT f.id
|
|
28826
|
+
FROM inspection_findings f INDEXED BY idx_inspection_findings_context
|
|
28827
|
+
JOIN audit_events e ON e.id = f.audit_event_id
|
|
28828
|
+
WHERE f.context IS NOT NULL
|
|
28829
|
+
AND f.first_detected_at < :cutoff
|
|
28830
|
+
AND e.content IS NULL
|
|
28831
|
+
AND e.started_at < :cutoff
|
|
28832
|
+
LIMIT :limit)`
|
|
28833
|
+
);
|
|
28487
28834
|
}
|
|
28488
28835
|
db;
|
|
28489
28836
|
candidatesStmt;
|
|
28490
28837
|
candidatesSyncSafeStmt;
|
|
28838
|
+
candidatesScopedStmt;
|
|
28491
28839
|
heldBySyncStmt;
|
|
28840
|
+
heldByScopeStmt;
|
|
28492
28841
|
expireStmt;
|
|
28493
|
-
|
|
28842
|
+
expireContextsStmt;
|
|
28843
|
+
/**
|
|
28844
|
+
* How many body bytes a pass with these options would free, changing
|
|
28845
|
+
* nothing. Finding excerpts are not counted (see `bytesFreed`).
|
|
28846
|
+
*/
|
|
28494
28847
|
preview(opts) {
|
|
28495
|
-
const
|
|
28496
|
-
const
|
|
28497
|
-
const rows = stmt.all({ cutoff: opts.cutoff, limit });
|
|
28848
|
+
const lane = laneOf(opts.sweepSyncLane);
|
|
28849
|
+
const rows = this.candidates(lane, opts.cutoff, opts.maxRows ?? DEFAULT_MAX_ROWS);
|
|
28498
28850
|
return {
|
|
28499
28851
|
rowsExpired: rows.length,
|
|
28500
28852
|
bytesFreed: rows.reduce((sum, r) => sum + r.bytes, 0),
|
|
28501
|
-
rowsHeldBySync: this.countHeldBySync(opts)
|
|
28853
|
+
rowsHeldBySync: this.countHeldBySync(lane, opts.cutoff)
|
|
28502
28854
|
};
|
|
28503
28855
|
}
|
|
28504
28856
|
/** Clear eligible bodies, in bounded batches. */
|
|
28505
28857
|
expire(opts) {
|
|
28506
28858
|
const batchSize = opts.batchSize ?? DEFAULT_BATCH_SIZE;
|
|
28507
28859
|
const maxRows = opts.maxRows ?? DEFAULT_MAX_ROWS;
|
|
28508
|
-
const
|
|
28860
|
+
const lane = laneOf(opts.sweepSyncLane);
|
|
28509
28861
|
let rowsExpired = 0;
|
|
28510
28862
|
let bytesFreed = 0;
|
|
28511
28863
|
let done = true;
|
|
28512
28864
|
while (rowsExpired < maxRows) {
|
|
28513
28865
|
const remaining = Math.min(batchSize, maxRows - rowsExpired);
|
|
28514
|
-
const batch =
|
|
28866
|
+
const batch = this.candidates(lane, opts.cutoff, remaining);
|
|
28515
28867
|
if (batch.length === 0) break;
|
|
28516
28868
|
withTransaction(
|
|
28517
28869
|
this.db,
|
|
@@ -28524,17 +28876,60 @@ var SqliteBodyRetentionRepository = class {
|
|
|
28524
28876
|
bytesFreed += batch.reduce((sum, r) => sum + r.bytes, 0);
|
|
28525
28877
|
if (batch.length < remaining) break;
|
|
28526
28878
|
if (rowsExpired >= maxRows) {
|
|
28527
|
-
done =
|
|
28879
|
+
done = this.candidates(lane, opts.cutoff, 1).length === 0;
|
|
28528
28880
|
}
|
|
28529
28881
|
}
|
|
28530
|
-
|
|
28882
|
+
this.expireContexts(opts.cutoff, batchSize, maxRows);
|
|
28883
|
+
return {
|
|
28884
|
+
rowsExpired,
|
|
28885
|
+
bytesFreed,
|
|
28886
|
+
rowsHeldBySync: this.countHeldBySync(lane, opts.cutoff),
|
|
28887
|
+
done
|
|
28888
|
+
};
|
|
28889
|
+
}
|
|
28890
|
+
// Clear the excerpts that outlived their body, one bounded transaction per
|
|
28891
|
+
// batch for the same reason the body sweep batches, and at most `maxRows` of
|
|
28892
|
+
// them per pass under the same cap: the next pass picks up the rest.
|
|
28893
|
+
expireContexts(cutoff, batchSize, maxRows) {
|
|
28894
|
+
let total = 0;
|
|
28895
|
+
while (total < maxRows) {
|
|
28896
|
+
const limit = Math.min(batchSize, maxRows - total);
|
|
28897
|
+
let cleared = 0;
|
|
28898
|
+
withTransaction(
|
|
28899
|
+
this.db,
|
|
28900
|
+
() => {
|
|
28901
|
+
cleared = Number(this.expireContextsStmt.run({ cutoff, limit }).changes);
|
|
28902
|
+
},
|
|
28903
|
+
"IMMEDIATE"
|
|
28904
|
+
);
|
|
28905
|
+
total += cleared;
|
|
28906
|
+
if (cleared < limit) return;
|
|
28907
|
+
}
|
|
28531
28908
|
}
|
|
28532
|
-
|
|
28533
|
-
|
|
28534
|
-
|
|
28909
|
+
/**
|
|
28910
|
+
* One batch of candidates under `lane`, bound with exactly the parameters its
|
|
28911
|
+
* statement names — node:sqlite refuses a named parameter a statement does not
|
|
28912
|
+
* declare, so the key list goes to the scoped statements only.
|
|
28913
|
+
*
|
|
28914
|
+
* Anything that is not `sweep` or `hold-keys` takes the hold-all statement.
|
|
28915
|
+
* The type admits no fourth kind, but this decides what is destroyed, and the
|
|
28916
|
+
* direction an unforeseen value falls has to be holding.
|
|
28917
|
+
*/
|
|
28918
|
+
candidates(lane, cutoff, limit) {
|
|
28919
|
+
const rows = lane.kind === "sweep" ? this.candidatesStmt.all({ cutoff, limit }) : lane.kind === "hold-keys" ? this.candidatesScopedStmt.all({ cutoff, limit, scopeKeys: JSON.stringify(lane.keys) }) : this.candidatesSyncSafeStmt.all({ cutoff, limit });
|
|
28920
|
+
return rows;
|
|
28921
|
+
}
|
|
28922
|
+
countHeldBySync(lane, cutoff) {
|
|
28923
|
+
if (lane.kind === "sweep") return 0;
|
|
28924
|
+
const row = lane.kind === "hold-keys" ? this.heldByScopeStmt.get({ cutoff, scopeKeys: JSON.stringify(lane.keys) }) : this.heldBySyncStmt.get({ cutoff });
|
|
28535
28925
|
return row.n;
|
|
28536
28926
|
}
|
|
28537
28927
|
};
|
|
28928
|
+
function laneOf(gate2) {
|
|
28929
|
+
if (gate2 === true) return SWEEP;
|
|
28930
|
+
if (gate2 === false) return HOLD_ALL;
|
|
28931
|
+
return gate2;
|
|
28932
|
+
}
|
|
28538
28933
|
|
|
28539
28934
|
// ../../packages/persistence/src/repositories/capture-status.ts
|
|
28540
28935
|
var STATUS_LOOKBACK_ROWS = 128;
|
|
@@ -29443,6 +29838,8 @@ function toFlatFindingRow(r) {
|
|
|
29443
29838
|
repo: r.repo ?? "",
|
|
29444
29839
|
file: r.file ?? "",
|
|
29445
29840
|
...r.tool_name === null ? {} : { toolName: r.tool_name },
|
|
29841
|
+
...r.line === null ? {} : { line: r.line },
|
|
29842
|
+
...r.col === null ? {} : { col: r.col },
|
|
29446
29843
|
eventId: r.event_id,
|
|
29447
29844
|
...r.session_id === null ? {} : { sessionId: r.session_id },
|
|
29448
29845
|
status: deriveInstanceStatus(r),
|
|
@@ -29520,7 +29917,8 @@ var FINDING_ROW_COLUMNS_SQL = `f.id AS id, d.rule_id AS rule_id, d.category AS c
|
|
|
29520
29917
|
${latestResolutionStatusSql("f")} AS latest_status,
|
|
29521
29918
|
e.synced_at AS synced_at, e.sync_claimed_at AS sync_claimed_at,
|
|
29522
29919
|
e.sync_failed_at AS sync_failed_at, e.sync_failure AS sync_failure,
|
|
29523
|
-
e.outbox_owed AS outbox_owed
|
|
29920
|
+
e.outbox_owed AS outbox_owed,
|
|
29921
|
+
f.line AS line, f.col AS col`;
|
|
29524
29922
|
var DAY_MS3 = 864e5;
|
|
29525
29923
|
var SqliteFindingsRepository = class {
|
|
29526
29924
|
constructor(db) {
|
|
@@ -29943,6 +30341,27 @@ var SqliteFindingsRepository = class {
|
|
|
29943
30341
|
).get(id);
|
|
29944
30342
|
return Promise.resolve(row === void 0 ? null : toInstanceDetail(toFlatFindingRow(row)));
|
|
29945
30343
|
}
|
|
30344
|
+
/**
|
|
30345
|
+
* One finding's excerpt source (see FindingContextSource). A primary-key
|
|
30346
|
+
* seek, like `findingInstance`, and the only findings read that touches the
|
|
30347
|
+
* event's text — which is why the list never projects the excerpt and the
|
|
30348
|
+
* drawer asks for it here, one finding at a time.
|
|
30349
|
+
*/
|
|
30350
|
+
findingContextSource(id) {
|
|
30351
|
+
const row = this.db.prepare(
|
|
30352
|
+
`SELECT f.context AS context, e.content AS content,
|
|
30353
|
+
f.span_start AS spanStart, f.span_end AS spanEnd,
|
|
30354
|
+
d.rule_id AS ruleId, d.category AS category,
|
|
30355
|
+
json_extract(e.attributes, '$.whole_file') AS wholeFile,
|
|
30356
|
+
e.tool_name AS toolName, e.event_type AS eventType
|
|
30357
|
+
FROM inspection_findings f
|
|
30358
|
+
JOIN audit_events e ON e.id = f.audit_event_id
|
|
30359
|
+
JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
30360
|
+
WHERE f.id = ?`
|
|
30361
|
+
).get(id);
|
|
30362
|
+
if (row === void 0) return null;
|
|
30363
|
+
return { ...row, wholeFile: row.wholeFile === 1 };
|
|
30364
|
+
}
|
|
29946
30365
|
/**
|
|
29947
30366
|
* The one statement both instance-level scans run: every finding in scope,
|
|
29948
30367
|
* joined to its event and definition, newest first.
|
|
@@ -30079,6 +30498,61 @@ var SqliteFindingsRepository = class {
|
|
|
30079
30498
|
])
|
|
30080
30499
|
);
|
|
30081
30500
|
}
|
|
30501
|
+
/**
|
|
30502
|
+
* The Findings page's summary strip: whole-store counts over exactly the rows
|
|
30503
|
+
* the instance reads list (the four capture kinds), each equal to what
|
|
30504
|
+
* listFindingInstances totals for the same filters — see FindingsOverview.
|
|
30505
|
+
*
|
|
30506
|
+
* ONE grouped aggregate whose keys are the raw classifier inputs, not the
|
|
30507
|
+
* answers: the statement groups by the three inputs deriveFindingStatus
|
|
30508
|
+
* reads, and each group is then classified here by that same function. So
|
|
30509
|
+
* SQL never restates the status rule, and the strip cannot disagree with the
|
|
30510
|
+
* list about which status a finding has. The group count is bounded by a
|
|
30511
|
+
* handful of status inputs, not by the store, so only the scan grows with it
|
|
30512
|
+
* — the same linear cost every other unscoped read on the page already pays.
|
|
30513
|
+
*
|
|
30514
|
+
* The definitions join selects nothing. It is there because the list's scan
|
|
30515
|
+
* joins it too, so a finding whose definition row is missing is left out of
|
|
30516
|
+
* both rather than counted here and absent there.
|
|
30517
|
+
*
|
|
30518
|
+
* The latest-resolution join is the derived-table form, which
|
|
30519
|
+
* resolution-sql.ts recommends for an aggregate over many findings.
|
|
30520
|
+
*/
|
|
30521
|
+
findingsOverview() {
|
|
30522
|
+
const rows = allRows(
|
|
30523
|
+
this.db.prepare(
|
|
30524
|
+
`SELECT e.event_type AS kind, (f.finding_key IS NOT NULL) AS keyed,
|
|
30525
|
+
latest.status AS latest_status, count(*) AS c
|
|
30526
|
+
FROM inspection_findings f
|
|
30527
|
+
JOIN audit_events e ON e.id = f.audit_event_id
|
|
30528
|
+
JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
30529
|
+
LEFT JOIN ${LATEST_RESOLUTION_BY_KEY_SQL} latest
|
|
30530
|
+
ON latest.finding_key = f.finding_key
|
|
30531
|
+
WHERE e.event_type IN (${CAPTURE_EVENT_TYPES_SQL})
|
|
30532
|
+
GROUP BY e.event_type, keyed, latest.status`
|
|
30533
|
+
)
|
|
30534
|
+
);
|
|
30535
|
+
const byStatus = {
|
|
30536
|
+
open: 0,
|
|
30537
|
+
handled: 0,
|
|
30538
|
+
resolved: 0,
|
|
30539
|
+
dismissed: 0
|
|
30540
|
+
};
|
|
30541
|
+
let findings = 0;
|
|
30542
|
+
for (const row of rows) {
|
|
30543
|
+
const status = deriveFindingStatus({
|
|
30544
|
+
kind: row.kind,
|
|
30545
|
+
// The classifier only asks whether a key exists, never what it is. The
|
|
30546
|
+
// stand-in is non-empty so a truthiness test of the key reads it as
|
|
30547
|
+
// present, exactly as it would a real one.
|
|
30548
|
+
findingKey: row.keyed ? "keyed" : null,
|
|
30549
|
+
latestResolutionStatus: row.latest_status
|
|
30550
|
+
});
|
|
30551
|
+
findings += row.c;
|
|
30552
|
+
byStatus[status] += row.c;
|
|
30553
|
+
}
|
|
30554
|
+
return Promise.resolve({ findings, ...byStatus });
|
|
30555
|
+
}
|
|
30082
30556
|
healthSummary() {
|
|
30083
30557
|
const total = countScalar(
|
|
30084
30558
|
this.db,
|
|
@@ -30206,12 +30680,13 @@ var SqliteInspectionFindingsRepository = class {
|
|
|
30206
30680
|
`INSERT INTO inspection_findings
|
|
30207
30681
|
(id, audit_event_id, inspection_definition_id, classified_data_id,
|
|
30208
30682
|
span_start, span_end, masked_match, action_taken, confidence,
|
|
30209
|
-
finding_key, first_detected_at)
|
|
30683
|
+
finding_key, first_detected_at, line, col, context)
|
|
30210
30684
|
VALUES
|
|
30211
30685
|
(:id, :auditEventId, :inspectionDefinitionId, :classifiedDataId,
|
|
30212
30686
|
:spanStart, :spanEnd, :maskedMatch, :actionTaken, :confidence,
|
|
30213
30687
|
:findingKey,
|
|
30214
|
-
COALESCE(:firstDetectedAt, (SELECT started_at FROM audit_events WHERE id = :auditEventId))
|
|
30688
|
+
COALESCE(:firstDetectedAt, (SELECT started_at FROM audit_events WHERE id = :auditEventId)),
|
|
30689
|
+
:line, :col, :context)
|
|
30215
30690
|
ON CONFLICT(id) DO UPDATE SET
|
|
30216
30691
|
inspection_definition_id = excluded.inspection_definition_id
|
|
30217
30692
|
ON CONFLICT (finding_key) DO UPDATE SET
|
|
@@ -30222,7 +30697,10 @@ var SqliteInspectionFindingsRepository = class {
|
|
|
30222
30697
|
span_end = excluded.span_end,
|
|
30223
30698
|
masked_match = excluded.masked_match,
|
|
30224
30699
|
action_taken = excluded.action_taken,
|
|
30225
|
-
confidence = excluded.confidence
|
|
30700
|
+
confidence = excluded.confidence,
|
|
30701
|
+
line = excluded.line,
|
|
30702
|
+
col = excluded.col,
|
|
30703
|
+
context = excluded.context`
|
|
30226
30704
|
);
|
|
30227
30705
|
this.sessionDupStmt = db.prepare(
|
|
30228
30706
|
`SELECT 1 FROM inspection_findings f
|
|
@@ -30272,7 +30750,10 @@ var SqliteInspectionFindingsRepository = class {
|
|
|
30272
30750
|
actionTaken: row.actionTaken,
|
|
30273
30751
|
confidence: row.confidence,
|
|
30274
30752
|
findingKey: row.findingKey,
|
|
30275
|
-
firstDetectedAt: row.firstDetectedAt
|
|
30753
|
+
firstDetectedAt: row.firstDetectedAt,
|
|
30754
|
+
line: row.line,
|
|
30755
|
+
col: row.col,
|
|
30756
|
+
context: row.context
|
|
30276
30757
|
})
|
|
30277
30758
|
);
|
|
30278
30759
|
}
|
|
@@ -30634,8 +31115,8 @@ var SqliteInstalledPacksRepository = class {
|
|
|
30634
31115
|
this.db = db;
|
|
30635
31116
|
this.baseDir = baseDir;
|
|
30636
31117
|
this.insertMissingStmt = db.prepare(
|
|
30637
|
-
`INSERT INTO installed_packs (id, namespace, pack_id, version, name, rules_json, enabled, created_at, updated_at)
|
|
30638
|
-
VALUES (:id, :namespace, :packId, :version, :name, :rulesJson, 1, :now, :now)
|
|
31118
|
+
`INSERT INTO installed_packs (id, namespace, pack_id, version, name, rules_json, enabled, policy_id, created_at, updated_at)
|
|
31119
|
+
VALUES (:id, :namespace, :packId, :version, :name, :rulesJson, 1, :policyId, :now, :now)
|
|
30639
31120
|
ON CONFLICT (namespace, pack_id) DO NOTHING`
|
|
30640
31121
|
);
|
|
30641
31122
|
this.upsertAvailableStmt = db.prepare(
|
|
@@ -30695,7 +31176,10 @@ var SqliteInstalledPacksRepository = class {
|
|
|
30695
31176
|
version: pack.version,
|
|
30696
31177
|
name: pack.name,
|
|
30697
31178
|
rulesJson: JSON.stringify(pack.rules),
|
|
30698
|
-
ruleIds: new Set(pack.rules.map((r) => r.id))
|
|
31179
|
+
ruleIds: new Set(pack.rules.map((r) => r.id)),
|
|
31180
|
+
// Only a first install takes it: an existing row is never modified here,
|
|
31181
|
+
// so a policy the user chose (or cleared) is never overwritten.
|
|
31182
|
+
defaultPolicyId: pack.defaultPolicyId ?? null
|
|
30699
31183
|
}));
|
|
30700
31184
|
if (this.storedSignature() === inventorySignature(rows)) return;
|
|
30701
31185
|
const now = Date.now();
|
|
@@ -30724,7 +31208,7 @@ var SqliteInstalledPacksRepository = class {
|
|
|
30724
31208
|
} else {
|
|
30725
31209
|
behind = true;
|
|
30726
31210
|
}
|
|
30727
|
-
this.insertMissingStmt.run(params);
|
|
31211
|
+
this.insertMissingStmt.run({ ...params, policyId: row.defaultPolicyId });
|
|
30728
31212
|
}
|
|
30729
31213
|
if (!behind) this.pruneAvailable(rows.map((r) => `${r.namespace}/${r.packId}`));
|
|
30730
31214
|
},
|
|
@@ -30842,7 +31326,8 @@ var SqliteInstalledPacksRepository = class {
|
|
|
30842
31326
|
rejectedRules: [],
|
|
30843
31327
|
ruleActions: /* @__PURE__ */ new Map(),
|
|
30844
31328
|
ruleVersions: /* @__PURE__ */ new Map(),
|
|
30845
|
-
reversibleRules: /* @__PURE__ */ new Set()
|
|
31329
|
+
reversibleRules: /* @__PURE__ */ new Set(),
|
|
31330
|
+
assignedRules: /* @__PURE__ */ new Set()
|
|
30846
31331
|
};
|
|
30847
31332
|
const reject = (pack, ruleId, reason) => {
|
|
30848
31333
|
if (out.rejectedRules.length >= REJECTED_RULE_DETAIL_CAP) return;
|
|
@@ -30875,6 +31360,8 @@ var SqliteInstalledPacksRepository = class {
|
|
|
30875
31360
|
out.ruleVersions.set(parsed.data.id, row.version);
|
|
30876
31361
|
if (reversible) out.reversibleRules.add(parsed.data.id);
|
|
30877
31362
|
else out.reversibleRules.delete(parsed.data.id);
|
|
31363
|
+
if (row.policyId !== null) out.assignedRules.add(parsed.data.id);
|
|
31364
|
+
else out.assignedRules.delete(parsed.data.id);
|
|
30878
31365
|
} else {
|
|
30879
31366
|
out.invalidRules += 1;
|
|
30880
31367
|
reject(pack, printableRuleId(entry), firstIssueReason(parsed.error));
|
|
@@ -31961,6 +32448,7 @@ var SqliteInventoryAssetsRepository = class {
|
|
|
31961
32448
|
|
|
31962
32449
|
// ../../packages/persistence/src/repositories/policies.ts
|
|
31963
32450
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
32451
|
+
var SEED_BATCH_WINDOW_MS = 6e4;
|
|
31964
32452
|
var SqlitePoliciesRepository = class {
|
|
31965
32453
|
constructor(db) {
|
|
31966
32454
|
this.db = db;
|
|
@@ -31982,39 +32470,123 @@ var SqlitePoliciesRepository = class {
|
|
|
31982
32470
|
});
|
|
31983
32471
|
return Promise.resolve(policies);
|
|
31984
32472
|
}
|
|
31985
|
-
// Seed one policy per bundled category
|
|
31986
|
-
//
|
|
31987
|
-
//
|
|
32473
|
+
// Seed one policy per bundled category at Monitor so the detection-type config
|
|
32474
|
+
// exists from first run. An unassigned pack's rules follow these rows, so
|
|
32475
|
+
// Monitor here is the posture of every pack that ships no defaultPolicy; a pack
|
|
32476
|
+
// that ships one carries its own assignment instead. Only when the
|
|
32477
|
+
// table is empty, so a user's edits are never clobbered.
|
|
31988
32478
|
seedDefaults() {
|
|
31989
32479
|
const count = countScalar(this.db, "SELECT count(*) AS n FROM policies");
|
|
31990
|
-
if (count > 0)
|
|
32480
|
+
if (count > 0) {
|
|
32481
|
+
this.markEarlierChoices();
|
|
32482
|
+
this.monitorUntouchedSeeds();
|
|
32483
|
+
return;
|
|
32484
|
+
}
|
|
31991
32485
|
const stmt = this.db.prepare(
|
|
31992
32486
|
`INSERT INTO policies (id, scope, target, action, enabled, created_at, updated_at)
|
|
31993
32487
|
VALUES (:id, 'global', :target, :action, 1, :now, :now)`
|
|
31994
32488
|
);
|
|
31995
32489
|
failOpenTransaction(this.db, () => {
|
|
31996
|
-
for (const
|
|
32490
|
+
for (const category of Object.keys(DEFAULT_ACTIONS)) {
|
|
31997
32491
|
stmt.run({
|
|
31998
32492
|
id: randomUUID6(),
|
|
31999
32493
|
target: JSON.stringify({ category }),
|
|
32000
|
-
action,
|
|
32494
|
+
action: "log",
|
|
32001
32495
|
now: Date.now()
|
|
32002
32496
|
});
|
|
32003
32497
|
}
|
|
32004
32498
|
});
|
|
32005
32499
|
}
|
|
32500
|
+
// Before this build, upsertCategoryAction INSERTed a new row with updated_at
|
|
32501
|
+
// equal to created_at, so a choice made for a category that had no row yet
|
|
32502
|
+
// (one added in a release after the store was seeded) looks exactly like a
|
|
32503
|
+
// seed. Left alone, fill-gaps would overwrite it and monitorUntouchedSeeds
|
|
32504
|
+
// could reset it. This pass marks such rows as chosen (updated_at =
|
|
32505
|
+
// created_at + 1) before either can read them. A row is an earlier build's
|
|
32506
|
+
// choice, not its seed, when either:
|
|
32507
|
+
// - its action is neither the old seed value (DEFAULT_ACTIONS) nor Monitor,
|
|
32508
|
+
// which no seed of any build ever wrote; or
|
|
32509
|
+
// - it was created well after the seed batch. Every build seeds all of its
|
|
32510
|
+
// categories in one transaction, and only into an empty table, so a row
|
|
32511
|
+
// created later came from upsertCategoryAction.
|
|
32512
|
+
// It needs no marker of its own: every row this build writes has updated_at >
|
|
32513
|
+
// created_at, and the seeds it leaves equal (fresh 'log' seeds, and seeds
|
|
32514
|
+
// moved to Monitor below, which keep their created_at) match neither test, so
|
|
32515
|
+
// after one pass it finds nothing and stays a read. What it cannot tell apart
|
|
32516
|
+
// is an earlier build's choice that equals the seed value AND was made within
|
|
32517
|
+
// the seed batch window; that row is read as a seed.
|
|
32518
|
+
markEarlierChoices() {
|
|
32519
|
+
const rows = allRows(
|
|
32520
|
+
this.db.prepare(
|
|
32521
|
+
`SELECT id, json_extract(target, '$.category') AS category, action,
|
|
32522
|
+
created_at AS c, updated_at AS u
|
|
32523
|
+
FROM policies
|
|
32524
|
+
WHERE scope = 'global' AND json_extract(target, '$.category') IS NOT NULL`
|
|
32525
|
+
)
|
|
32526
|
+
);
|
|
32527
|
+
if (rows.length === 0) return;
|
|
32528
|
+
const seedBatchStart = Math.min(...rows.map((row) => row.c));
|
|
32529
|
+
const seeded = DEFAULT_ACTIONS;
|
|
32530
|
+
const choices = rows.filter(
|
|
32531
|
+
(row) => row.u === row.c && (row.action !== "log" && row.action !== seeded[row.category] || row.c > seedBatchStart + SEED_BATCH_WINDOW_MS)
|
|
32532
|
+
);
|
|
32533
|
+
if (choices.length === 0) return;
|
|
32534
|
+
const stmt = this.db.prepare(
|
|
32535
|
+
`UPDATE policies SET updated_at = created_at + 1 WHERE id = :id AND updated_at = created_at`
|
|
32536
|
+
);
|
|
32537
|
+
failOpenTransaction(this.db, () => {
|
|
32538
|
+
for (const row of choices) stmt.run({ id: row.id });
|
|
32539
|
+
});
|
|
32540
|
+
}
|
|
32541
|
+
// Stores seeded by an earlier build hold DEFAULT_ACTIONS in their category
|
|
32542
|
+
// rows. Those rows used to be shadowed by the Monitor every unassigned pack
|
|
32543
|
+
// emitted; now that unassigned packs defer to them, an untouched one would
|
|
32544
|
+
// turn Monitor into Warn on upgrade with nobody having asked. So a row still
|
|
32545
|
+
// exactly as seeded — the seeded action, never updated since it was created —
|
|
32546
|
+
// is moved to Monitor. A row the user, the setup wizard or the warn-era cap
|
|
32547
|
+
// ever wrote has a later updated_at and is left alone. updated_at is NOT
|
|
32548
|
+
// advanced, so a moved row still reads as an untouched seed (see
|
|
32549
|
+
// isCategoryChosen); it never matches again because it is no longer off 'log'.
|
|
32550
|
+
// One knock-on: when the installed snapshot is unusable (corrupt rules_json)
|
|
32551
|
+
// the gateway falls back to the bundled packs with no per-rule policies, so
|
|
32552
|
+
// every rule follows these rows. On an upgraded store that fallback now
|
|
32553
|
+
// monitors where the earlier build warned.
|
|
32554
|
+
monitorUntouchedSeeds() {
|
|
32555
|
+
const untouched = allRows(
|
|
32556
|
+
this.db.prepare(
|
|
32557
|
+
`SELECT json_extract(target, '$.category') AS category, action FROM policies
|
|
32558
|
+
WHERE scope = 'global' AND json_extract(target, '$.category') IS NOT NULL
|
|
32559
|
+
AND action <> 'log' AND updated_at = created_at`
|
|
32560
|
+
)
|
|
32561
|
+
).filter(
|
|
32562
|
+
(row) => DEFAULT_ACTIONS[row.category] === row.action
|
|
32563
|
+
);
|
|
32564
|
+
if (untouched.length === 0) return;
|
|
32565
|
+
const stmt = this.db.prepare(
|
|
32566
|
+
`UPDATE policies SET action = 'log'
|
|
32567
|
+
WHERE scope = 'global' AND json_extract(target, '$.category') = :category
|
|
32568
|
+
AND action = :seeded AND action <> 'log' AND updated_at = created_at`
|
|
32569
|
+
);
|
|
32570
|
+
failOpenTransaction(this.db, () => {
|
|
32571
|
+
for (const row of untouched) {
|
|
32572
|
+
stmt.run({ category: row.category, seeded: row.action });
|
|
32573
|
+
}
|
|
32574
|
+
});
|
|
32575
|
+
}
|
|
32006
32576
|
// Insert-or-update the single global per-category policy row, keyed on the
|
|
32007
32577
|
// existing uq_policies_scope_target unique index (scope, target). `action`
|
|
32008
32578
|
// uses the SAME vocabulary seedDefaults writes (DEFAULT_ACTIONS' ActionTaken
|
|
32009
32579
|
// values), so the runtime's resolveAction reads rows written by either path
|
|
32010
32580
|
// identically. On conflict, `action`, `enabled`, and `updated_at` are updated;
|
|
32011
|
-
// `id` and `created_at` are left exactly as they were.
|
|
32581
|
+
// `id` and `created_at` are left exactly as they were. Either way updated_at
|
|
32582
|
+
// ends up later than created_at, which is what marks the row as chosen.
|
|
32012
32583
|
upsertCategoryAction(category, action) {
|
|
32013
32584
|
const now = Date.now();
|
|
32014
32585
|
this.db.prepare(
|
|
32015
32586
|
`INSERT INTO policies (id, scope, target, action, enabled, created_at, updated_at)
|
|
32016
|
-
VALUES (:id, 'global', :target, :action, 1, :now, :now)
|
|
32017
|
-
ON CONFLICT(scope, target) DO UPDATE SET action = excluded.action, enabled = 1,
|
|
32587
|
+
VALUES (:id, 'global', :target, :action, 1, :now, :now + 1)
|
|
32588
|
+
ON CONFLICT(scope, target) DO UPDATE SET action = excluded.action, enabled = 1,
|
|
32589
|
+
updated_at = MAX(excluded.updated_at, policies.created_at + 1)`
|
|
32018
32590
|
).run({ id: randomUUID6(), target: JSON.stringify({ category }), action, now });
|
|
32019
32591
|
}
|
|
32020
32592
|
// Caps every global per-category policy currently set to block/redact down
|
|
@@ -32028,6 +32600,16 @@ var SqlitePoliciesRepository = class {
|
|
|
32028
32600
|
).run({ now: Date.now() });
|
|
32029
32601
|
return Number(info.changes);
|
|
32030
32602
|
}
|
|
32603
|
+
// Whether the category's row was ever written after it was created — by the
|
|
32604
|
+
// user, the setup wizard or a cap. A row still as seeded (updated_at equal to
|
|
32605
|
+
// created_at) is not a choice, so a posture filling gaps may replace it.
|
|
32606
|
+
isCategoryChosen(category) {
|
|
32607
|
+
const row = this.db.prepare(
|
|
32608
|
+
`SELECT created_at AS c, updated_at AS u FROM policies
|
|
32609
|
+
WHERE scope='global' AND json_extract(target,'$.category') = :category`
|
|
32610
|
+
).get({ category });
|
|
32611
|
+
return row !== void 0 && row.u !== row.c;
|
|
32612
|
+
}
|
|
32031
32613
|
// Read the current action for a single global per-category policy row, mirroring
|
|
32032
32614
|
// upsertCategoryAction's category-lookup predicate. Returns undefined when no
|
|
32033
32615
|
// row exists yet, so callers can distinguish an unset category from a set one.
|
|
@@ -34273,6 +34855,11 @@ var UNSAFE_TEST_ONLY_RAW_HANDLE = /* @__PURE__ */ Symbol(
|
|
|
34273
34855
|
function linkHost(input2, hostId) {
|
|
34274
34856
|
return hostId ? { ...input2, hostId } : input2;
|
|
34275
34857
|
}
|
|
34858
|
+
function captureAttributesOf(event, scopeKey) {
|
|
34859
|
+
const attributes = toCaptureAttributes(event);
|
|
34860
|
+
if (scopeKey === void 0 || scopeKey === "") return attributes;
|
|
34861
|
+
return { ...attributes, scope_key: scopeKey };
|
|
34862
|
+
}
|
|
34276
34863
|
function closeQuietly(db) {
|
|
34277
34864
|
try {
|
|
34278
34865
|
db.close();
|
|
@@ -34458,7 +35045,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
34458
35045
|
);
|
|
34459
35046
|
return dismissed;
|
|
34460
35047
|
}
|
|
34461
|
-
function recordCapture(event, detected) {
|
|
35048
|
+
function recordCapture(event, detected, scopeKey) {
|
|
34462
35049
|
failOpenTransaction(db, () => {
|
|
34463
35050
|
const sessionId = event.metadata?.sessionId;
|
|
34464
35051
|
if (sessionId) {
|
|
@@ -34473,7 +35060,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
34473
35060
|
rootSessionId: sessionId,
|
|
34474
35061
|
content: event.content,
|
|
34475
35062
|
contentHash: event.contentHash,
|
|
34476
|
-
attributes:
|
|
35063
|
+
attributes: captureAttributesOf(event, scopeKey)
|
|
34477
35064
|
});
|
|
34478
35065
|
const definitionIds = /* @__PURE__ */ new Map();
|
|
34479
35066
|
for (const finding of detected) {
|
|
@@ -34503,7 +35090,12 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
34503
35090
|
maskedMatch: finding.maskedMatch,
|
|
34504
35091
|
actionTaken: finding.actionTaken,
|
|
34505
35092
|
confidence: finding.confidence,
|
|
34506
|
-
findingKey: finding.findingKey ?? void 0
|
|
35093
|
+
findingKey: finding.findingKey ?? void 0,
|
|
35094
|
+
...finding.location === void 0 ? {} : {
|
|
35095
|
+
line: finding.location.line,
|
|
35096
|
+
col: finding.location.col,
|
|
35097
|
+
context: finding.location.context
|
|
35098
|
+
}
|
|
34507
35099
|
});
|
|
34508
35100
|
}
|
|
34509
35101
|
});
|
|
@@ -34666,6 +35258,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
34666
35258
|
// ../../packages/persistence/src/egress-wire.ts
|
|
34667
35259
|
import { createHash as createHash3 } from "crypto";
|
|
34668
35260
|
var SLASH = "/".charCodeAt(0);
|
|
35261
|
+
var SCOPE_KEY = printable(ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH);
|
|
34669
35262
|
|
|
34670
35263
|
// ../../packages/persistence/src/finding-key.ts
|
|
34671
35264
|
import { createHash as createHash4 } from "crypto";
|
|
@@ -35393,6 +35986,23 @@ var WEBHOOK_URL = new RegExp(
|
|
|
35393
35986
|
).join("|")}))[^\\s'"\`<>()[\\]{},;]+`,
|
|
35394
35987
|
"gi"
|
|
35395
35988
|
);
|
|
35989
|
+
function lineStartOffsets(text) {
|
|
35990
|
+
const starts = [0];
|
|
35991
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
35992
|
+
if (text[i] === "\n") starts.push(i + 1);
|
|
35993
|
+
}
|
|
35994
|
+
return starts;
|
|
35995
|
+
}
|
|
35996
|
+
function lineIndexAt(starts, offset) {
|
|
35997
|
+
let low = 0;
|
|
35998
|
+
let high = starts.length - 1;
|
|
35999
|
+
while (low < high) {
|
|
36000
|
+
const mid = Math.ceil((low + high) / 2);
|
|
36001
|
+
if ((starts[mid] ?? 0) <= offset) low = mid;
|
|
36002
|
+
else high = mid - 1;
|
|
36003
|
+
}
|
|
36004
|
+
return low;
|
|
36005
|
+
}
|
|
35396
36006
|
|
|
35397
36007
|
// ../../packages/detections/src/escape-regexp.ts
|
|
35398
36008
|
function escapeRegExp2(value) {
|
|
@@ -35680,10 +36290,10 @@ function isCorroborated(candidate, candidates, text, normalization) {
|
|
|
35680
36290
|
}
|
|
35681
36291
|
return false;
|
|
35682
36292
|
}
|
|
35683
|
-
function buildCandidates(matchText, ruleset, extension) {
|
|
36293
|
+
function buildCandidates(matchText, ruleset, extension, eventKind) {
|
|
35684
36294
|
const candidates = [];
|
|
35685
36295
|
for (const rule of ruleset) {
|
|
35686
|
-
if (!ruleApplies(rule, extension)) continue;
|
|
36296
|
+
if (!ruleApplies(rule, extension, eventKind)) continue;
|
|
35687
36297
|
const spans = MATCHERS[rule.matcher.type](matchText, rule);
|
|
35688
36298
|
for (const span of spans) {
|
|
35689
36299
|
const rawMatch = matchText.slice(span.start, span.end);
|
|
@@ -35793,22 +36403,30 @@ function extensionOf(filePath) {
|
|
|
35793
36403
|
const dot = base.lastIndexOf(".");
|
|
35794
36404
|
return dot > 0 ? base.slice(dot).toLowerCase() : void 0;
|
|
35795
36405
|
}
|
|
35796
|
-
function ruleApplies(rule, extension) {
|
|
35797
|
-
|
|
35798
|
-
|
|
36406
|
+
function ruleApplies(rule, extension, eventKind) {
|
|
36407
|
+
const scope = rule.appliesTo;
|
|
36408
|
+
if (!scope) return true;
|
|
36409
|
+
if (scope.eventKinds && (eventKind === void 0 || !scope.eventKinds.some((k) => k === eventKind))) {
|
|
36410
|
+
return false;
|
|
36411
|
+
}
|
|
36412
|
+
if (!scope.extensions || extension === void 0) return true;
|
|
36413
|
+
return scope.extensions.some((e) => e.toLowerCase() === extension);
|
|
35799
36414
|
}
|
|
35800
36415
|
function scan(text, rules, context) {
|
|
35801
36416
|
const ruleset = rules ?? getLoadedRules();
|
|
35802
36417
|
const extension = context?.filePath ? extensionOf(context.filePath) : void 0;
|
|
35803
36418
|
const normalization = normalizeFormatChars(text);
|
|
35804
|
-
const originalCandidates = buildCandidates(text, ruleset, extension);
|
|
36419
|
+
const originalCandidates = buildCandidates(text, ruleset, extension, context?.eventKind);
|
|
35805
36420
|
if (!normalization) return gate(originalCandidates, text, void 0);
|
|
35806
36421
|
const pooledOriginal = originalCandidates.map(
|
|
35807
36422
|
(candidate) => withNormalizedSpan(candidate, normalization)
|
|
35808
36423
|
);
|
|
35809
|
-
const normalizedCandidates = buildCandidates(
|
|
35810
|
-
|
|
35811
|
-
|
|
36424
|
+
const normalizedCandidates = buildCandidates(
|
|
36425
|
+
normalization.normalized,
|
|
36426
|
+
ruleset,
|
|
36427
|
+
extension,
|
|
36428
|
+
context?.eventKind
|
|
36429
|
+
).map((candidate) => mapCandidateToOriginal(candidate, normalization, text));
|
|
35812
36430
|
const findings = gate([...pooledOriginal, ...normalizedCandidates], text, normalization);
|
|
35813
36431
|
return mergeOverlappingSameRule(findings, text);
|
|
35814
36432
|
}
|
|
@@ -35845,6 +36463,47 @@ function redact(text, findings) {
|
|
|
35845
36463
|
return result;
|
|
35846
36464
|
}
|
|
35847
36465
|
|
|
36466
|
+
// ../../packages/detections/src/evidence.ts
|
|
36467
|
+
var BUNDLED_CODE_EVIDENCE = /* @__PURE__ */ new Set([
|
|
36468
|
+
"code-flaws/auth-jwt-no-verify",
|
|
36469
|
+
"code-flaws/auth-ssl-verify-false",
|
|
36470
|
+
"code-flaws/cmd-inject-exec",
|
|
36471
|
+
"code-flaws/cmd-inject-node-exec",
|
|
36472
|
+
"code-flaws/cmd-inject-shell",
|
|
36473
|
+
"code-flaws/crypto-insecure-random",
|
|
36474
|
+
"code-flaws/crypto-weak-hash-md5",
|
|
36475
|
+
"code-flaws/crypto-weak-hash-sha1",
|
|
36476
|
+
"code-flaws/deser-java-ois",
|
|
36477
|
+
"code-flaws/deser-pickle",
|
|
36478
|
+
"code-flaws/deser-yaml-unsafe",
|
|
36479
|
+
"code-flaws/dev-debug-enabled",
|
|
36480
|
+
"code-flaws/dev-wildcard-cors",
|
|
36481
|
+
"code-flaws/eval-dynamic-exec",
|
|
36482
|
+
"code-flaws/path-traversal-join",
|
|
36483
|
+
"code-flaws/path-traversal-open",
|
|
36484
|
+
"code-flaws/prototype-pollution-merge",
|
|
36485
|
+
"code-flaws/regex-redos-backtrack",
|
|
36486
|
+
"code-flaws/sql-inject-concat",
|
|
36487
|
+
"code-flaws/sql-inject-concat-dot",
|
|
36488
|
+
"code-flaws/sql-inject-format",
|
|
36489
|
+
"code-flaws/sql-inject-interp",
|
|
36490
|
+
"code-flaws/ssrf-user-url",
|
|
36491
|
+
"code-flaws/xss-dangerously-set",
|
|
36492
|
+
"code-flaws/xss-inner-html",
|
|
36493
|
+
"code-flaws/xss-unescaped-render"
|
|
36494
|
+
]);
|
|
36495
|
+
var VALUE_CATEGORIES = /* @__PURE__ */ new Set([
|
|
36496
|
+
"secret",
|
|
36497
|
+
"pii",
|
|
36498
|
+
"financial",
|
|
36499
|
+
"phi"
|
|
36500
|
+
]);
|
|
36501
|
+
function ruleEvidence(rule) {
|
|
36502
|
+
if (rule.category !== void 0 && VALUE_CATEGORIES.has(rule.category)) return "value";
|
|
36503
|
+
if (rule.evidence !== void 0) return rule.evidence;
|
|
36504
|
+
return BUNDLED_CODE_EVIDENCE.has(rule.id) ? "code" : "value";
|
|
36505
|
+
}
|
|
36506
|
+
|
|
35848
36507
|
// ../../packages/detections/src/mask.ts
|
|
35849
36508
|
function maskMatch(raw) {
|
|
35850
36509
|
if (raw.length <= 5) return "***";
|
|
@@ -36013,6 +36672,331 @@ var POLYNOMIAL_PROBES = ["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].m
|
|
|
36013
36672
|
var CPU_CORROBORATION_SHARE = 0.2;
|
|
36014
36673
|
var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
|
|
36015
36674
|
|
|
36675
|
+
// ../../packages/plugin-sdk/src/raw-egress.ts
|
|
36676
|
+
var RawEgressError = class extends Error {
|
|
36677
|
+
// The text as far as masking got it, when the throw came from a verifier that
|
|
36678
|
+
// had already produced one. A caller that must not propagate the throw (the
|
|
36679
|
+
// history walk) blunt-redacts THIS rather than the raw input: starting over
|
|
36680
|
+
// from the raw text discards every span the masker did cover, which for a
|
|
36681
|
+
// value clipped by the window edge is the only redaction it was ever going to
|
|
36682
|
+
// get — the blunt pass splits on whole values and cannot remove a partial run.
|
|
36683
|
+
masked;
|
|
36684
|
+
constructor(message, masked) {
|
|
36685
|
+
super(message);
|
|
36686
|
+
this.name = "RawEgressError";
|
|
36687
|
+
if (masked !== void 0) this.masked = masked;
|
|
36688
|
+
}
|
|
36689
|
+
};
|
|
36690
|
+
var MIN_RAW_LEN = 4;
|
|
36691
|
+
var RAW_RUN_LEN = 8;
|
|
36692
|
+
function carriesRawRun(text, rawValues) {
|
|
36693
|
+
let windows = null;
|
|
36694
|
+
for (const raw of new Set(rawValues)) {
|
|
36695
|
+
if (raw.length < MIN_RAW_LEN) continue;
|
|
36696
|
+
if (raw.length < RAW_RUN_LEN) {
|
|
36697
|
+
if (text.includes(raw)) return true;
|
|
36698
|
+
continue;
|
|
36699
|
+
}
|
|
36700
|
+
if (windows === null) {
|
|
36701
|
+
windows = /* @__PURE__ */ new Set();
|
|
36702
|
+
for (let i = 0; i + RAW_RUN_LEN <= text.length; i += 1) {
|
|
36703
|
+
windows.add(text.slice(i, i + RAW_RUN_LEN));
|
|
36704
|
+
}
|
|
36705
|
+
}
|
|
36706
|
+
if (windows.size === 0) continue;
|
|
36707
|
+
let preview = null;
|
|
36708
|
+
for (let i = 0; i + RAW_RUN_LEN <= raw.length; i += 1) {
|
|
36709
|
+
const window = raw.slice(i, i + RAW_RUN_LEN);
|
|
36710
|
+
if (!windows.has(window)) continue;
|
|
36711
|
+
preview ??= safeMaskedMatch(raw);
|
|
36712
|
+
if (!preview.includes(window)) return true;
|
|
36713
|
+
}
|
|
36714
|
+
}
|
|
36715
|
+
return false;
|
|
36716
|
+
}
|
|
36717
|
+
function edgeTruncatedSpans(text, rawValues) {
|
|
36718
|
+
const spans = [];
|
|
36719
|
+
if (text.length < RAW_RUN_LEN) return spans;
|
|
36720
|
+
const head = text.slice(0, RAW_RUN_LEN);
|
|
36721
|
+
const tail = text.slice(text.length - RAW_RUN_LEN);
|
|
36722
|
+
for (const raw of rawValues) {
|
|
36723
|
+
if (raw.length < RAW_RUN_LEN) continue;
|
|
36724
|
+
const maxK = Math.min(raw.length - 1, text.length);
|
|
36725
|
+
if (raw.includes(head)) {
|
|
36726
|
+
for (let k = maxK; k >= RAW_RUN_LEN; k -= 1) {
|
|
36727
|
+
if (text.startsWith(raw.slice(raw.length - k))) {
|
|
36728
|
+
spans.push({ rawMatch: raw, span: { start: 0, end: k } });
|
|
36729
|
+
break;
|
|
36730
|
+
}
|
|
36731
|
+
}
|
|
36732
|
+
}
|
|
36733
|
+
if (raw.includes(tail)) {
|
|
36734
|
+
for (let k = maxK; k >= RAW_RUN_LEN; k -= 1) {
|
|
36735
|
+
if (text.endsWith(raw.slice(0, k))) {
|
|
36736
|
+
spans.push({ rawMatch: raw, span: { start: text.length - k, end: text.length } });
|
|
36737
|
+
break;
|
|
36738
|
+
}
|
|
36739
|
+
}
|
|
36740
|
+
}
|
|
36741
|
+
}
|
|
36742
|
+
return spans;
|
|
36743
|
+
}
|
|
36744
|
+
function maskContextSlice(slice, sliceStart, hits) {
|
|
36745
|
+
const findings = [];
|
|
36746
|
+
for (const h of hits) {
|
|
36747
|
+
const start = Math.max(0, h.span.start - sliceStart);
|
|
36748
|
+
const end = Math.min(slice.length, h.span.end - sliceStart);
|
|
36749
|
+
if (end > start) {
|
|
36750
|
+
findings.push({
|
|
36751
|
+
ruleId: "raw-egress",
|
|
36752
|
+
category: "secret",
|
|
36753
|
+
severity: "critical",
|
|
36754
|
+
span: { start, end },
|
|
36755
|
+
rawMatch: "",
|
|
36756
|
+
confidence: 1
|
|
36757
|
+
});
|
|
36758
|
+
}
|
|
36759
|
+
}
|
|
36760
|
+
const masked = findings.length > 0 ? redact(slice, findings) : slice;
|
|
36761
|
+
const rawValues = hits.map((h) => h.rawMatch);
|
|
36762
|
+
if (carriesRawRun(masked, rawValues)) {
|
|
36763
|
+
throw new RawEgressError("raw match survived context masking", masked);
|
|
36764
|
+
}
|
|
36765
|
+
return masked;
|
|
36766
|
+
}
|
|
36767
|
+
function safeMaskedMatch(rawMatch) {
|
|
36768
|
+
const masked = maskMatch(rawMatch);
|
|
36769
|
+
if (masked === rawMatch || rawMatch.length >= MIN_RAW_LEN && masked.includes(rawMatch)) {
|
|
36770
|
+
return "***";
|
|
36771
|
+
}
|
|
36772
|
+
return masked;
|
|
36773
|
+
}
|
|
36774
|
+
function assertRawFree(text, rawValues) {
|
|
36775
|
+
if (carriesRawRun(text, rawValues)) {
|
|
36776
|
+
throw new RawEgressError("text contained a raw detected value");
|
|
36777
|
+
}
|
|
36778
|
+
return text;
|
|
36779
|
+
}
|
|
36780
|
+
|
|
36781
|
+
// ../../packages/plugin-sdk/src/finding-context.ts
|
|
36782
|
+
var CONTEXT_RADIUS = 2;
|
|
36783
|
+
var CONTEXT_LINE_MAX = 240;
|
|
36784
|
+
var BACKSTOP_MARGIN = 256;
|
|
36785
|
+
var CONTEXT_MAX_PER_TEXT = 200;
|
|
36786
|
+
var ELLIPSIS = "\u2026";
|
|
36787
|
+
function evidenceLookup(rules) {
|
|
36788
|
+
const byId = new Map(rules.map((rule) => [rule.id, rule]));
|
|
36789
|
+
return (ruleId) => ruleEvidence(byId.get(ruleId) ?? { id: ruleId });
|
|
36790
|
+
}
|
|
36791
|
+
function createFindingLocator(input2) {
|
|
36792
|
+
let prepared;
|
|
36793
|
+
let built = 0;
|
|
36794
|
+
return (hit) => {
|
|
36795
|
+
prepared ??= prepare(input2);
|
|
36796
|
+
const { starts } = prepared;
|
|
36797
|
+
const lineIndex = lineIndexAt(starts, hit.span.start);
|
|
36798
|
+
const lineStart = starts[lineIndex] ?? 0;
|
|
36799
|
+
let context = null;
|
|
36800
|
+
if (input2.backstopRules !== null && built < CONTEXT_MAX_PER_TEXT) {
|
|
36801
|
+
built += 1;
|
|
36802
|
+
try {
|
|
36803
|
+
context = buildContext(input2, prepared, hit, lineIndex);
|
|
36804
|
+
} catch {
|
|
36805
|
+
context = null;
|
|
36806
|
+
}
|
|
36807
|
+
}
|
|
36808
|
+
return { line: lineIndex + 1, col: hit.span.start - lineStart + 1, context };
|
|
36809
|
+
};
|
|
36810
|
+
}
|
|
36811
|
+
function prepare(input2) {
|
|
36812
|
+
const sorted = [...input2.hits].sort((a, b) => a.span.start - b.span.start);
|
|
36813
|
+
const enforced = input2.enforcedHits;
|
|
36814
|
+
const backstopRules = [...input2.backstopRules ?? []];
|
|
36815
|
+
return {
|
|
36816
|
+
starts: lineStartOffsets(input2.text),
|
|
36817
|
+
sorted,
|
|
36818
|
+
longest: sorted.reduce((max, h) => Math.max(max, h.span.end - h.span.start), 0),
|
|
36819
|
+
isValue: (hit) => enforced?.has(hit) === true || input2.evidenceOf(hit.ruleId) !== "code",
|
|
36820
|
+
backstopRules,
|
|
36821
|
+
backstopEvidence: new Map(backstopRules.map((rule) => [rule.id, ruleEvidence(rule)]))
|
|
36822
|
+
};
|
|
36823
|
+
}
|
|
36824
|
+
function buildContext(input2, prepared, hit, lineIndex) {
|
|
36825
|
+
const { text } = input2;
|
|
36826
|
+
const { starts, sorted, longest, isValue } = prepared;
|
|
36827
|
+
const isCode = !isValue(hit);
|
|
36828
|
+
const radius = isCode ? CONTEXT_RADIUS : 0;
|
|
36829
|
+
const hitColumn = hit.span.start - (starts[lineIndex] ?? 0);
|
|
36830
|
+
const segments = [];
|
|
36831
|
+
const firstIndex = Math.max(0, lineIndex - radius);
|
|
36832
|
+
const lastIndex = Math.min(starts.length - 1, lineIndex + radius);
|
|
36833
|
+
for (let index = firstIndex; index <= lastIndex; index += 1) {
|
|
36834
|
+
const lineStart = starts[index] ?? 0;
|
|
36835
|
+
if (index > lineIndex && lineStart >= text.length) break;
|
|
36836
|
+
const next = starts[index + 1];
|
|
36837
|
+
let lineEnd = next === void 0 ? text.length : next - 1;
|
|
36838
|
+
if (lineEnd > lineStart && text.charCodeAt(lineEnd - 1) === 13) lineEnd -= 1;
|
|
36839
|
+
const length = lineEnd - lineStart;
|
|
36840
|
+
const offset = Math.min(
|
|
36841
|
+
Math.max(0, hitColumn - Math.floor(CONTEXT_LINE_MAX / 2)),
|
|
36842
|
+
Math.max(0, length - CONTEXT_LINE_MAX)
|
|
36843
|
+
);
|
|
36844
|
+
const start = lineStart + offset;
|
|
36845
|
+
segments.push({
|
|
36846
|
+
lineIndex: index,
|
|
36847
|
+
start,
|
|
36848
|
+
end: Math.min(lineEnd, start + CONTEXT_LINE_MAX),
|
|
36849
|
+
lineStart,
|
|
36850
|
+
lineEnd
|
|
36851
|
+
});
|
|
36852
|
+
}
|
|
36853
|
+
const regions = [];
|
|
36854
|
+
const rawValues = [];
|
|
36855
|
+
const windowStart = segments[0]?.start ?? hit.span.start;
|
|
36856
|
+
const windowEnd = segments[segments.length - 1]?.end ?? hit.span.end;
|
|
36857
|
+
for (const other of overlapping(sorted, longest, windowStart, windowEnd)) {
|
|
36858
|
+
if (!isValue(other)) continue;
|
|
36859
|
+
regions.push({ start: other.span.start, end: other.span.end, category: other.category });
|
|
36860
|
+
rawValues.push(other.rawMatch);
|
|
36861
|
+
}
|
|
36862
|
+
for (const found of backstop(text, segments, prepared)) {
|
|
36863
|
+
regions.push(found.region);
|
|
36864
|
+
rawValues.push(found.rawMatch);
|
|
36865
|
+
}
|
|
36866
|
+
const merged = mergeRegions(regions);
|
|
36867
|
+
const shown = cutAtValues(segments, lineIndex, valueLinesOf(merged, starts));
|
|
36868
|
+
const lines = [];
|
|
36869
|
+
let match = null;
|
|
36870
|
+
for (const segment of shown) {
|
|
36871
|
+
const rendered = renderSegment(text, segment, merged);
|
|
36872
|
+
lines.push(rendered.text);
|
|
36873
|
+
if (isCode && segment.lineIndex === lineIndex) {
|
|
36874
|
+
const matchEnd = Math.min(hit.span.end, segment.end);
|
|
36875
|
+
const start = rendered.position(hit.span.start, "start");
|
|
36876
|
+
const end = rendered.position(matchEnd, "end");
|
|
36877
|
+
match = end > start ? { line: lineIndex + 1, start, end } : null;
|
|
36878
|
+
}
|
|
36879
|
+
}
|
|
36880
|
+
assertRawFree(lines.join("\n"), rawValues);
|
|
36881
|
+
return {
|
|
36882
|
+
basis: input2.basis,
|
|
36883
|
+
firstLine: (shown[0]?.lineIndex ?? lineIndex) + 1,
|
|
36884
|
+
lines,
|
|
36885
|
+
match
|
|
36886
|
+
};
|
|
36887
|
+
}
|
|
36888
|
+
function valueLinesOf(regions, starts) {
|
|
36889
|
+
const lines = /* @__PURE__ */ new Set();
|
|
36890
|
+
for (const region of regions) {
|
|
36891
|
+
const last = lineIndexAt(starts, Math.max(region.start, region.end - 1));
|
|
36892
|
+
for (let index = lineIndexAt(starts, region.start); index <= last; index += 1) {
|
|
36893
|
+
lines.add(index);
|
|
36894
|
+
}
|
|
36895
|
+
}
|
|
36896
|
+
return lines;
|
|
36897
|
+
}
|
|
36898
|
+
function cutAtValues(segments, lineIndex, valueLines) {
|
|
36899
|
+
if (!segments.some((segment) => valueLines.has(segment.lineIndex))) return [...segments];
|
|
36900
|
+
return segments.filter((segment) => segment.lineIndex === lineIndex);
|
|
36901
|
+
}
|
|
36902
|
+
function overlapping(sorted, longest, start, end) {
|
|
36903
|
+
let low = 0;
|
|
36904
|
+
let high = sorted.length;
|
|
36905
|
+
const floor = start - longest;
|
|
36906
|
+
while (low < high) {
|
|
36907
|
+
const mid = low + high >>> 1;
|
|
36908
|
+
if ((sorted[mid]?.span.start ?? 0) < floor) low = mid + 1;
|
|
36909
|
+
else high = mid;
|
|
36910
|
+
}
|
|
36911
|
+
const out = [];
|
|
36912
|
+
for (let i = low; i < sorted.length; i += 1) {
|
|
36913
|
+
const hit = sorted[i];
|
|
36914
|
+
if (hit === void 0 || hit.span.start >= end) break;
|
|
36915
|
+
if (hit.span.end > start) out.push(hit);
|
|
36916
|
+
}
|
|
36917
|
+
return out;
|
|
36918
|
+
}
|
|
36919
|
+
function backstop(text, segments, prepared) {
|
|
36920
|
+
const { backstopRules: rules, backstopEvidence: evidence } = prepared;
|
|
36921
|
+
if (rules.length === 0) return [];
|
|
36922
|
+
const pieces = [];
|
|
36923
|
+
let joined = "";
|
|
36924
|
+
for (const segment of segments) {
|
|
36925
|
+
const from = Math.max(segment.lineStart, segment.start - BACKSTOP_MARGIN);
|
|
36926
|
+
const to = Math.min(segment.lineEnd, segment.end + BACKSTOP_MARGIN);
|
|
36927
|
+
if (joined.length > 0) joined += "\n";
|
|
36928
|
+
pieces.push({ from, to, at: joined.length });
|
|
36929
|
+
joined += text.slice(from, to);
|
|
36930
|
+
}
|
|
36931
|
+
const out = [];
|
|
36932
|
+
for (const found of scan(joined, rules)) {
|
|
36933
|
+
if ((evidence.get(found.ruleId) ?? "value") === "code") continue;
|
|
36934
|
+
for (const piece of pieces) {
|
|
36935
|
+
const length = piece.to - piece.from;
|
|
36936
|
+
const start = Math.max(found.span.start, piece.at);
|
|
36937
|
+
const end = Math.min(found.span.end, piece.at + length);
|
|
36938
|
+
if (end <= start) continue;
|
|
36939
|
+
out.push({
|
|
36940
|
+
region: {
|
|
36941
|
+
start: piece.from + (start - piece.at),
|
|
36942
|
+
end: piece.from + (end - piece.at),
|
|
36943
|
+
category: found.category
|
|
36944
|
+
},
|
|
36945
|
+
rawMatch: found.rawMatch
|
|
36946
|
+
});
|
|
36947
|
+
}
|
|
36948
|
+
}
|
|
36949
|
+
return out;
|
|
36950
|
+
}
|
|
36951
|
+
function mergeRegions(regions) {
|
|
36952
|
+
const sorted = [...regions].sort((a, b) => a.start - b.start || a.end - b.end);
|
|
36953
|
+
const out = [];
|
|
36954
|
+
for (const region of sorted) {
|
|
36955
|
+
const open3 = out[out.length - 1];
|
|
36956
|
+
if (open3 && region.start < open3.end) open3.end = Math.max(open3.end, region.end);
|
|
36957
|
+
else out.push({ ...region });
|
|
36958
|
+
}
|
|
36959
|
+
return out;
|
|
36960
|
+
}
|
|
36961
|
+
function renderSegment(text, segment, regions) {
|
|
36962
|
+
const pieces = [];
|
|
36963
|
+
let out = segment.start > segment.lineStart ? ELLIPSIS : "";
|
|
36964
|
+
let cursor = segment.start;
|
|
36965
|
+
const emit = (to, replacement) => {
|
|
36966
|
+
const piece = replacement ?? text.slice(cursor, to);
|
|
36967
|
+
pieces.push({
|
|
36968
|
+
from: cursor,
|
|
36969
|
+
to,
|
|
36970
|
+
outFrom: out.length,
|
|
36971
|
+
outTo: out.length + piece.length,
|
|
36972
|
+
redacted: replacement !== null
|
|
36973
|
+
});
|
|
36974
|
+
out += piece;
|
|
36975
|
+
cursor = to;
|
|
36976
|
+
};
|
|
36977
|
+
for (const region of regions) {
|
|
36978
|
+
if (region.end <= segment.start || region.start >= segment.end) continue;
|
|
36979
|
+
const start = Math.max(region.start, segment.start);
|
|
36980
|
+
if (start > cursor) emit(start, null);
|
|
36981
|
+
emit(Math.min(region.end, segment.end), `[REDACTED:${region.category.toUpperCase()}]`);
|
|
36982
|
+
}
|
|
36983
|
+
if (cursor < segment.end) emit(segment.end, null);
|
|
36984
|
+
const body = out.length;
|
|
36985
|
+
if (segment.end < segment.lineEnd) out += ELLIPSIS;
|
|
36986
|
+
const position = (offset, side) => {
|
|
36987
|
+
for (const piece of pieces) {
|
|
36988
|
+
if (offset < piece.from || offset > piece.to) continue;
|
|
36989
|
+
if (piece.redacted) {
|
|
36990
|
+
if (side === "start" && offset === piece.to) continue;
|
|
36991
|
+
return side === "start" ? piece.outFrom : piece.outTo;
|
|
36992
|
+
}
|
|
36993
|
+
return piece.outFrom + (offset - piece.from);
|
|
36994
|
+
}
|
|
36995
|
+
return offset <= segment.start ? pieces[0]?.outFrom ?? 0 : body;
|
|
36996
|
+
};
|
|
36997
|
+
return { text: out, position };
|
|
36998
|
+
}
|
|
36999
|
+
|
|
36016
37000
|
// ../../rules/code-flaws/auth-jwt-no-verify.json
|
|
36017
37001
|
var auth_jwt_no_verify_default = {
|
|
36018
37002
|
specVersion: 1,
|
|
@@ -36087,8 +37071,9 @@ var cmd_inject_node_exec_default = {
|
|
|
36087
37071
|
severity: "critical",
|
|
36088
37072
|
matcher: {
|
|
36089
37073
|
type: "regex",
|
|
36090
|
-
pattern: "\\
|
|
36091
|
-
flags: "g"
|
|
37074
|
+
pattern: `(?:\\b(?:(?:node_)?child_process|childProcess|cp)\\s*\\??\\.\\s*|\\brequire\\s*\\(\\s*['"](?:node:)?child_process['"]\\s*\\)\\s*\\??\\.\\s*|(?<![\\w$.]))(exec(?:Sync)?\\s*\\(\\s*)(?!['"\`])`,
|
|
37075
|
+
flags: "g",
|
|
37076
|
+
captureGroup: 1
|
|
36092
37077
|
},
|
|
36093
37078
|
requiresNearby: {
|
|
36094
37079
|
labels: ["input", "request", "param", "argv", "user", "query", "body"],
|
|
@@ -36590,6 +37575,120 @@ var xss_unescaped_render_default = {
|
|
|
36590
37575
|
}
|
|
36591
37576
|
};
|
|
36592
37577
|
|
|
37578
|
+
// ../../rules/command-risk/credential-file-read.json
|
|
37579
|
+
var credential_file_read_default = {
|
|
37580
|
+
specVersion: 1,
|
|
37581
|
+
id: "command-risk/credential-file-read",
|
|
37582
|
+
name: "Dump of a credential-bearing file",
|
|
37583
|
+
category: "custom",
|
|
37584
|
+
severity: "medium",
|
|
37585
|
+
matcher: {
|
|
37586
|
+
type: "regex",
|
|
37587
|
+
pattern: `\\b(?:cat|bat|less|more|head|tail|sed|awk|nl|xxd|strings|base64)(?<=(?:^|[;&|({\\x60]|\\$\\(|-[A-Za-z]*c[ \\t]+["'])[ \\t]*(?:(?:then|do|else|!)[ \\t]+)?(?:(?:sudo|doas|env|command|exec|nohup|nice|time|xargs)(?:[ \\t]+[^\\s;|&"'\\x60]{1,100}){0,4}?[ \\t]+)?(?:[\\w.~-]*/){0,8}(?:cat|bat|less|more|head|tail|sed|awk|nl|xxd|strings|base64))[ \\t]+(?:[^\\s;|&]{1,200}[ \\t]+){0,8}?["']?(?:[^\\s;|&"']*/)?(?:\\.env(?!\\.(?:example|sample|template|dist))(?:\\.[A-Za-z0-9_-]+)?|[A-Za-z0-9_-]*\\.env|\\.zshenv|\\.zshrc|\\.zprofile|\\.bashrc|\\.bash_profile|\\.netrc|\\.npmrc|\\.pgpass|\\.git-credentials|\\.aws/(?:credentials|config)|(?:[A-Za-z0-9_.-]*[_.-])?auth\\.json|\\.?credentials\\.json|id_(?:rsa|ed25519|ecdsa|dsa))(?=$|[\\s"';|&)])`,
|
|
37588
|
+
flags: "gm"
|
|
37589
|
+
},
|
|
37590
|
+
examples: ["cat ~/.zshenv", "cat /tmp/host-auth.json"],
|
|
37591
|
+
appliesTo: {
|
|
37592
|
+
eventKinds: ["tool_use"]
|
|
37593
|
+
}
|
|
37594
|
+
};
|
|
37595
|
+
|
|
37596
|
+
// ../../rules/command-risk/curl-pipe-shell.json
|
|
37597
|
+
var curl_pipe_shell_default = {
|
|
37598
|
+
specVersion: 1,
|
|
37599
|
+
id: "command-risk/curl-pipe-shell",
|
|
37600
|
+
name: "curl/wget piped to a shell",
|
|
37601
|
+
category: "custom",
|
|
37602
|
+
severity: "high",
|
|
37603
|
+
matcher: {
|
|
37604
|
+
type: "regex",
|
|
37605
|
+
pattern: `\\b(?:curl|wget)(?<=(?:^|[;&|({\\x60]|\\$\\(|-[A-Za-z]*c[ \\t]+["'])[ \\t]*(?:(?:then|do|else|!)[ \\t]+)?(?:(?:sudo|doas|env|command|exec|nohup|nice|time|xargs)(?:[ \\t]+[^\\s;|&"'\\x60]{1,100}){0,4}?[ \\t]+)?(?:[\\w.~-]*/){0,8}(?:curl|wget))\\b(?:[^\\n|;&\\\\]|\\\\[\\s\\S]){0,300}\\|[ \\t]*(?:(?:sudo|doas|env)(?:[ \\t]+[^\\s|;&]{1,200}){0,4}?[ \\t]+)?(?:[^\\s|;&]{0,200}/)?(?:ba|z|da|k)?sh(?![\\w.-])`,
|
|
37606
|
+
flags: "gm"
|
|
37607
|
+
},
|
|
37608
|
+
examples: [
|
|
37609
|
+
"curl -fsSL https://get.example.dev/install.sh | bash",
|
|
37610
|
+
"wget -qO- https://get.example.dev/setup | sudo sh -s -- --yes"
|
|
37611
|
+
],
|
|
37612
|
+
appliesTo: {
|
|
37613
|
+
eventKinds: ["tool_use"]
|
|
37614
|
+
}
|
|
37615
|
+
};
|
|
37616
|
+
|
|
37617
|
+
// ../../rules/command-risk/git-force-push.json
|
|
37618
|
+
var git_force_push_default = {
|
|
37619
|
+
specVersion: 1,
|
|
37620
|
+
id: "command-risk/git-force-push",
|
|
37621
|
+
name: "git push --force / -f",
|
|
37622
|
+
category: "custom",
|
|
37623
|
+
severity: "high",
|
|
37624
|
+
matcher: {
|
|
37625
|
+
type: "regex",
|
|
37626
|
+
pattern: `\\bgit(?<=(?:^|[;&|({\\x60]|\\$\\(|-[A-Za-z]*c[ \\t]+["'])[ \\t]*(?:(?:then|do|else|!)[ \\t]+)?(?:(?:sudo|doas|env|command|exec|nohup|nice|time|xargs)(?:[ \\t]+[^\\s;|&"'\\x60]{1,100}){0,4}?[ \\t]+)?(?:[\\w.~-]*/){0,8}git)(?:[ \\t]+(?:-[Cc][ \\t]+[^\\s;|&]{1,200}|--[a-z][a-z-]{0,40}(?:=[^\\s;|&]{1,200})?)){0,4}[ \\t]+push(?:[ \\t]+[^\\s;|&]{1,200}){0,8}?[ \\t]+(?:-[A-Za-z]*f[A-Za-z]*|--force(?![\\w-])|\\+[^\\s;|&+]{1,200})(?=[\\s;|&)"'\\x60]|$)`,
|
|
37627
|
+
flags: "gm"
|
|
37628
|
+
},
|
|
37629
|
+
examples: ["git push -q -f origin feature-x", "git push --force origin main"],
|
|
37630
|
+
appliesTo: {
|
|
37631
|
+
eventKinds: ["tool_use"]
|
|
37632
|
+
}
|
|
37633
|
+
};
|
|
37634
|
+
|
|
37635
|
+
// ../../rules/command-risk/git-reset-hard.json
|
|
37636
|
+
var git_reset_hard_default = {
|
|
37637
|
+
specVersion: 1,
|
|
37638
|
+
id: "command-risk/git-reset-hard",
|
|
37639
|
+
name: "git reset --hard at command position",
|
|
37640
|
+
category: "custom",
|
|
37641
|
+
severity: "high",
|
|
37642
|
+
matcher: {
|
|
37643
|
+
type: "regex",
|
|
37644
|
+
pattern: `\\bgit(?<=(?:^|[;&|({\\x60]|\\$\\(|-[A-Za-z]*c[ \\t]+["'])[ \\t]*(?:(?:then|do|else|!)[ \\t]+)?(?:(?:sudo|doas|env|command|exec|nohup|nice|time|xargs)(?:[ \\t]+[^\\s;|&"'\\x60]{1,100}){0,4}?[ \\t]+)?(?:[\\w.~-]*/){0,8}git)(?:[ \\t]+(?:-[Cc][ \\t]+[^\\s;|&]{1,200}|--[a-z][a-z-]{0,40}(?:=[^\\s;|&]{1,200})?)){0,4}[ \\t]+reset(?:[ \\t]+[^\\s;|&]{1,200}){0,8}?[ \\t]+--hard\\b`,
|
|
37645
|
+
flags: "gm"
|
|
37646
|
+
},
|
|
37647
|
+
examples: ["git reset --hard HEAD~1", "cd /tmp/demo-repo && git reset --hard origin/main"],
|
|
37648
|
+
appliesTo: {
|
|
37649
|
+
eventKinds: ["tool_use"]
|
|
37650
|
+
}
|
|
37651
|
+
};
|
|
37652
|
+
|
|
37653
|
+
// ../../rules/command-risk/pkill-broad.json
|
|
37654
|
+
var pkill_broad_default = {
|
|
37655
|
+
specVersion: 1,
|
|
37656
|
+
id: "command-risk/pkill-broad",
|
|
37657
|
+
name: "pkill -f (command-line pattern kill)",
|
|
37658
|
+
category: "custom",
|
|
37659
|
+
severity: "medium",
|
|
37660
|
+
matcher: {
|
|
37661
|
+
type: "regex",
|
|
37662
|
+
pattern: `\\bpkill(?<=(?:^|[;&|({\\x60]|\\$\\(|-[A-Za-z]*c[ \\t]+["'])[ \\t]*(?:(?:then|do|else|!)[ \\t]+)?(?:(?:sudo|doas|env|command|exec|nohup|nice|time|xargs)(?:[ \\t]+[^\\s;|&"'\\x60]{1,100}){0,4}?[ \\t]+)?(?:[\\w.~-]*/){0,8}pkill)(?:[ \\t]+[^\\s;|&]{1,200}){0,8}?[ \\t]+(?:-[A-Za-z0-9]*f[A-Za-z0-9]*|--full)[ \\t]+["'\\w]`,
|
|
37663
|
+
flags: "gm"
|
|
37664
|
+
},
|
|
37665
|
+
examples: ['pkill -f "Brave Browser"', 'pkill -TERM -f "bun src/main.ts"'],
|
|
37666
|
+
appliesTo: {
|
|
37667
|
+
eventKinds: ["tool_use"]
|
|
37668
|
+
}
|
|
37669
|
+
};
|
|
37670
|
+
|
|
37671
|
+
// ../../rules/command-risk/rm-rf-home-or-shared.json
|
|
37672
|
+
var rm_rf_home_or_shared_default = {
|
|
37673
|
+
specVersion: 1,
|
|
37674
|
+
id: "command-risk/rm-rf-home-or-shared",
|
|
37675
|
+
name: "Recursive rm of home, /Users or a system directory",
|
|
37676
|
+
category: "custom",
|
|
37677
|
+
severity: "high",
|
|
37678
|
+
matcher: {
|
|
37679
|
+
type: "regex",
|
|
37680
|
+
pattern: `\\brm(?<=(?:^|[;&|({\\x60]|\\$\\(|-[A-Za-z]*c[ \\t]+["'])[ \\t]*(?:(?:then|do|else|!)[ \\t]+)?(?:(?:sudo|doas|env|command|exec|nohup|nice|time|xargs)(?:[ \\t]+[^\\s;|&"'\\x60]{1,100}){0,4}?[ \\t]+)?(?:[\\w.~-]*/){0,8}rm)(?:[ \\t]+[^\\s;|&]{1,200}){0,8}?[ \\t]+(?:-[A-Za-z]*[rR][A-Za-z]*|--recursive)(?:[ \\t]+[^\\s;|&]{1,200}){0,8}?[ \\t]+["']?(?:~|\\$HOME(?!\\w)|\\$\\{HOME\\}|/(?:Users|home)(?=[/\\s"';|&)]|$)|/(?:etc|var|usr|bin|sbin|lib|opt|System|Library)?/?\\*?(?=[\\s"';|&)]|$)|\\.\\.(?:/\\.\\.)*/?(?=[\\s"';|&)]|$))`,
|
|
37681
|
+
flags: "gm"
|
|
37682
|
+
},
|
|
37683
|
+
examples: [
|
|
37684
|
+
"rm -rf ~/projects/demo-app/$WORKDIR",
|
|
37685
|
+
"rm -rf ~/worktrees/x ~/.claude-demo/projects/-Users-x"
|
|
37686
|
+
],
|
|
37687
|
+
appliesTo: {
|
|
37688
|
+
eventKinds: ["tool_use"]
|
|
37689
|
+
}
|
|
37690
|
+
};
|
|
37691
|
+
|
|
36593
37692
|
// ../../rules/core-code-context/db-table-name.json
|
|
36594
37693
|
var db_table_name_default = {
|
|
36595
37694
|
specVersion: 1,
|
|
@@ -36666,6 +37765,24 @@ var file_path_default = {
|
|
|
36666
37765
|
]
|
|
36667
37766
|
};
|
|
36668
37767
|
|
|
37768
|
+
// ../../rules/core-code-context/gcp-service-account-email.json
|
|
37769
|
+
var gcp_service_account_email_default = {
|
|
37770
|
+
specVersion: 1,
|
|
37771
|
+
id: "core-code-context/gcp-service-account-email",
|
|
37772
|
+
name: "GCP service account email",
|
|
37773
|
+
category: "code_context",
|
|
37774
|
+
severity: "low",
|
|
37775
|
+
matcher: {
|
|
37776
|
+
type: "regex",
|
|
37777
|
+
pattern: "(?<![a-z0-9-])[a-z0-9-]{3,}@[a-z0-9][a-z0-9-]{2,60}\\.iam\\.gserviceaccount\\.com\\b",
|
|
37778
|
+
flags: "g"
|
|
37779
|
+
},
|
|
37780
|
+
examples: [
|
|
37781
|
+
"deploy-bot@sample-project.iam.gserviceaccount.com",
|
|
37782
|
+
"12345678-1234-1234-1234-123456789012@my-project.iam.gserviceaccount.com"
|
|
37783
|
+
]
|
|
37784
|
+
};
|
|
37785
|
+
|
|
36669
37786
|
// ../../rules/core-code-context/internal-domain.json
|
|
36670
37787
|
var internal_domain_default = {
|
|
36671
37788
|
specVersion: 1,
|
|
@@ -36675,7 +37792,7 @@ var internal_domain_default = {
|
|
|
36675
37792
|
severity: "low",
|
|
36676
37793
|
matcher: {
|
|
36677
37794
|
type: "regex",
|
|
36678
|
-
pattern: "(?<![A-Za-z0-9.-])[A-Za-z0-9][A-Za-z0-9.-]{0,251}\\.(?:internal|corp|local|lan|intranet|private|
|
|
37795
|
+
pattern: "(?<![A-Za-z0-9.-])[A-Za-z0-9][A-Za-z0-9.-]{0,251}\\.(?:internal|corp|local|lan|intranet|private|staging|test|qa)(?:\\.(?:com|net|org|io|co|app))?\\b(?!\\.[A-Za-z0-9-]+(?!\\.?[A-Za-z0-9]))(?!\\.(?:d|tsx?|jsx?|mjs|cjs|json|md|py|sh|ya?ml|toml|txt|log|snap|html|css|rs|go)\\b)",
|
|
36679
37796
|
flags: "gi"
|
|
36680
37797
|
},
|
|
36681
37798
|
examples: ["db.internal.com", "app.corp.local", "api.staging.example.com"]
|
|
@@ -36690,7 +37807,7 @@ var internal_ip_default = {
|
|
|
36690
37807
|
severity: "low",
|
|
36691
37808
|
matcher: {
|
|
36692
37809
|
type: "regex",
|
|
36693
|
-
pattern: "(
|
|
37810
|
+
pattern: "(?<!\\d\\.?)(?:10\\.(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)|172\\.(?:1[6-9]|2\\d|3[01])\\.(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)|192\\.168\\.(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?))(?!\\d|\\.\\d+\\.\\d)",
|
|
36694
37811
|
flags: "g"
|
|
36695
37812
|
},
|
|
36696
37813
|
examples: ["10.0.0.1", "192.168.1.1", "172.16.0.1"]
|
|
@@ -36764,7 +37881,7 @@ var credit_card_default = {
|
|
|
36764
37881
|
severity: "critical",
|
|
36765
37882
|
matcher: {
|
|
36766
37883
|
type: "regex",
|
|
36767
|
-
pattern: "\\b(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|6(?:011|5[0-9]{2})[0-9]{12})\\b",
|
|
37884
|
+
pattern: "(?<![.\\d])\\b(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|6(?:011|5[0-9]{2})[0-9]{12})\\b",
|
|
36768
37885
|
flags: "g"
|
|
36769
37886
|
},
|
|
36770
37887
|
postValidators: ["luhn"],
|
|
@@ -36887,8 +38004,8 @@ var swift_default = {
|
|
|
36887
38004
|
severity: "high",
|
|
36888
38005
|
matcher: {
|
|
36889
38006
|
type: "regex",
|
|
36890
|
-
pattern: "\\b(?:
|
|
36891
|
-
flags: "
|
|
38007
|
+
pattern: "\\b(?:[Ss][Ww][Ii][Ff][Tt]|[Bb][Ii][Cc])\\b[\\s#:=-]{0,8}([A-Z]{6}[A-Z0-9]{2}(?:[A-Z0-9]{3})?)\\b",
|
|
38008
|
+
flags: "g",
|
|
36892
38009
|
captureGroup: 1
|
|
36893
38010
|
},
|
|
36894
38011
|
examples: ["SWIFT: BOFAUS3N", "BIC: CHASGB2LXXX"]
|
|
@@ -37056,7 +38173,17 @@ var dob_default = {
|
|
|
37056
38173
|
},
|
|
37057
38174
|
requiresNearby: {
|
|
37058
38175
|
categories: ["pii"],
|
|
37059
|
-
labels: [
|
|
38176
|
+
labels: [
|
|
38177
|
+
"dob",
|
|
38178
|
+
"date of birth",
|
|
38179
|
+
"birth",
|
|
38180
|
+
"d.o.b",
|
|
38181
|
+
"nascimento",
|
|
38182
|
+
"naissance",
|
|
38183
|
+
"nacimiento",
|
|
38184
|
+
"geburtsdatum",
|
|
38185
|
+
"nascita"
|
|
38186
|
+
],
|
|
37060
38187
|
windowChars: 160
|
|
37061
38188
|
},
|
|
37062
38189
|
examples: ["DOB: 1985-03-22", "Date of birth: 03/22/1985"]
|
|
@@ -37125,7 +38252,7 @@ var ip_address_default = {
|
|
|
37125
38252
|
severity: "low",
|
|
37126
38253
|
matcher: {
|
|
37127
38254
|
type: "regex",
|
|
37128
|
-
pattern: "\\b(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\b",
|
|
38255
|
+
pattern: "(?<!\\d\\.)\\b(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\b(?!\\.\\d+\\.\\d)",
|
|
37129
38256
|
flags: "g"
|
|
37130
38257
|
},
|
|
37131
38258
|
examples: ["192.168.1.1", "10.0.0.1"]
|
|
@@ -37226,7 +38353,7 @@ var phone_intl_default = {
|
|
|
37226
38353
|
severity: "high",
|
|
37227
38354
|
matcher: {
|
|
37228
38355
|
type: "regex",
|
|
37229
|
-
pattern: "
|
|
38356
|
+
pattern: "\\+(?=(?:\\D?\\d){8})\\d{1,3}(?:[-.\\s]\\d{1,14}){1,5}\\b",
|
|
37230
38357
|
flags: "g"
|
|
37231
38358
|
},
|
|
37232
38359
|
examples: ["+44 20 7946 0958", "+86 138 0013 8000"]
|
|
@@ -37275,7 +38402,7 @@ var vin_default = {
|
|
|
37275
38402
|
severity: "medium",
|
|
37276
38403
|
matcher: {
|
|
37277
38404
|
type: "regex",
|
|
37278
|
-
pattern: "\\b[A-HJ-NPR-Z0-9]{17}\\b",
|
|
38405
|
+
pattern: "\\b(?=[A-HJ-NPR-Z0-9]{0,16}[A-HJ-NPR-Z])(?=[A-HJ-NPR-Z0-9]{0,16}\\d)[A-HJ-NPR-Z0-9]{17}\\b",
|
|
37279
38406
|
flags: "g"
|
|
37280
38407
|
},
|
|
37281
38408
|
examples: ["1HGCM82633A004352"]
|
|
@@ -37434,7 +38561,7 @@ var generic_high_entropy_secret_default = {
|
|
|
37434
38561
|
severity: "high",
|
|
37435
38562
|
matcher: {
|
|
37436
38563
|
type: "regex",
|
|
37437
|
-
pattern: `(?<![A-Za-z0-9_-])[A-Za-z0-9_]{0,34}(?:(?:secret|token|passw(?:or)?d|credentials?|(?<!api[_-]?)key)(?:["']?\\s*:|\\s+=)|(?:passwd|credential|(?<!api[_-]?)(?<!secret_)(?<!private_)(?<!encryption_)(?<!signing_)key)=)\\s*["']?((?!eyJ)[A-Za-z0-9+/_\\-]{20,200})`,
|
|
38564
|
+
pattern: `(?<![A-Za-z0-9_-])[A-Za-z0-9_]{0,34}(?:(?:secret|token|(?<!no)passw(?:or)?d|credentials?|(?<!api[_-]?)key)(?:["']?\\s*:|\\s+=)|(?:(?<!no)passwd|credential|(?<!api[_-]?)(?<!secret_)(?<!private_)(?<!encryption_)(?<!signing_)key)=)\\s*["']?((?!eyJ)[A-Za-z0-9+/_\\-]{20,200})`,
|
|
37438
38565
|
flags: "gi",
|
|
37439
38566
|
captureGroup: 1
|
|
37440
38567
|
},
|
|
@@ -37488,7 +38615,7 @@ var password_field_default = {
|
|
|
37488
38615
|
severity: "high",
|
|
37489
38616
|
matcher: {
|
|
37490
38617
|
type: "regex",
|
|
37491
|
-
pattern: `["']?\\b(?:password|passwd|pwd|pass|secret|token|api[_-]?key|apikey)\\b["']?\\s*:\\s*["']([^"'\\n]{4,})["']`,
|
|
38618
|
+
pattern: `["']?\\b(?:password|passwd|pwd|pass|secret|token|api[_-]?key|apikey)\\b["']?\\s*:\\s*["'](?!(?:fail|pass|true|false|null|none|string|required)["'])([^"'\\n]{4,})["']`,
|
|
37492
38619
|
flags: "gi",
|
|
37493
38620
|
captureGroup: 1
|
|
37494
38621
|
},
|
|
@@ -37521,7 +38648,7 @@ var ssh_private_key_default = {
|
|
|
37521
38648
|
severity: "critical",
|
|
37522
38649
|
matcher: {
|
|
37523
38650
|
type: "regex",
|
|
37524
|
-
pattern: "-----BEGIN (?:RSA |DSA |EC |OPENSSH |SSH2 )?PRIVATE KEY-----",
|
|
38651
|
+
pattern: "-----BEGIN ((?:RSA |DSA |EC |OPENSSH |SSH2 |ENCRYPTED )?)PRIVATE KEY-----(?:(?:[A-Za-z0-9+/=\\s\\\\:,]|-(?!-)){0,8000}?-----END \\1PRIVATE KEY-----)?",
|
|
37525
38652
|
flags: "g"
|
|
37526
38653
|
},
|
|
37527
38654
|
examples: [
|
|
@@ -37602,7 +38729,7 @@ var cloudflare_api_key_default = {
|
|
|
37602
38729
|
severity: "critical",
|
|
37603
38730
|
matcher: {
|
|
37604
38731
|
type: "regex",
|
|
37605
|
-
pattern: `cloudflare.{0,40}?["'\\s:=]([A-Za-z0-9_-]{40})`,
|
|
38732
|
+
pattern: `cloudflare.{0,40}?(?<![?&][A-Za-z0-9_]{1,20})(?<!sha(?:1|256|384|512))["'\\s:=]([A-Za-z0-9_-]{40})`,
|
|
37606
38733
|
flags: "gi",
|
|
37607
38734
|
captureGroup: 1
|
|
37608
38735
|
},
|
|
@@ -37658,21 +38785,25 @@ var discord_token_default = {
|
|
|
37658
38785
|
examples: ["AbCdEfGhIjKlMnOpQrStUvWx.YzAbCd.ABCdEfGhIjKlMnOpQrStUvWxYzAbCdEf"]
|
|
37659
38786
|
};
|
|
37660
38787
|
|
|
37661
|
-
// ../../rules/secrets/gcp-service-account.json
|
|
37662
|
-
var
|
|
38788
|
+
// ../../rules/secrets/gcp-service-account-key.json
|
|
38789
|
+
var gcp_service_account_key_default = {
|
|
37663
38790
|
specVersion: 1,
|
|
37664
|
-
id: "secrets/gcp-service-account",
|
|
37665
|
-
name: "GCP service account key",
|
|
38791
|
+
id: "secrets/gcp-service-account-key",
|
|
38792
|
+
name: "GCP service account key file",
|
|
37666
38793
|
category: "secret",
|
|
37667
38794
|
severity: "critical",
|
|
37668
38795
|
matcher: {
|
|
37669
38796
|
type: "regex",
|
|
37670
|
-
pattern: "(
|
|
37671
|
-
flags: "g"
|
|
38797
|
+
pattern: '"private_key_id"\\s*:\\s*"([a-f0-9]{40})"',
|
|
38798
|
+
flags: "g",
|
|
38799
|
+
captureGroup: 1
|
|
38800
|
+
},
|
|
38801
|
+
requiresNearby: {
|
|
38802
|
+
labels: ["service_account", "client_email"],
|
|
38803
|
+
windowChars: 400
|
|
37672
38804
|
},
|
|
37673
38805
|
examples: [
|
|
37674
|
-
"
|
|
37675
|
-
"12345678-1234-1234-1234-123456789012@my-project.iam.gserviceaccount.com"
|
|
38806
|
+
'{"type": "service_account", "project_id": "sample-project", "private_key_id": "0a1b2c3d0a1b2c3d0a1b2c3d0a1b2c3d0a1b2c3d"}'
|
|
37676
38807
|
]
|
|
37677
38808
|
};
|
|
37678
38809
|
|
|
@@ -37821,6 +38952,24 @@ var stripe_live_key_default = {
|
|
|
37821
38952
|
examples: ["sk_live_aBcDeFgHiJkLmNoPqRsTuVwXyZ"]
|
|
37822
38953
|
};
|
|
37823
38954
|
|
|
38955
|
+
// ../../rules/secrets/tailscale-key.json
|
|
38956
|
+
var tailscale_key_default = {
|
|
38957
|
+
specVersion: 1,
|
|
38958
|
+
id: "secrets/tailscale-key",
|
|
38959
|
+
name: "Tailscale auth/API/client key",
|
|
38960
|
+
category: "secret",
|
|
38961
|
+
severity: "critical",
|
|
38962
|
+
matcher: {
|
|
38963
|
+
type: "regex",
|
|
38964
|
+
pattern: "\\btskey-(?:auth|api|client)-(?![Xx]+-)[A-Za-z0-9]{8,32}-[A-Za-z0-9]{16,64}\\b",
|
|
38965
|
+
flags: "g"
|
|
38966
|
+
},
|
|
38967
|
+
examples: [
|
|
38968
|
+
"sudo tailscale up --auth-key=tskey-auth-kAb3Xk9QzCNTRL-Ab3Xk9QzAb3Xk9QzAb3Xk9QzAb3Xk9Qz",
|
|
38969
|
+
"TS_API_KEY=tskey-api-kEXAMPLE1CNTRL-EXAMPLEEXAMPLEEXAMPLEEXAMPLE12"
|
|
38970
|
+
]
|
|
38971
|
+
};
|
|
38972
|
+
|
|
37824
38973
|
// ../../rules/secrets/terraform-cloud-token.json
|
|
37825
38974
|
var terraform_cloud_token_default = {
|
|
37826
38975
|
specVersion: 1,
|
|
@@ -37863,7 +39012,7 @@ var vault_token_default = {
|
|
|
37863
39012
|
severity: "critical",
|
|
37864
39013
|
matcher: {
|
|
37865
39014
|
type: "regex",
|
|
37866
|
-
pattern: "\\b(?:hvs\\.[A-Za-z0-9\\-_]{20,
|
|
39015
|
+
pattern: "\\b(?:hvs\\.[A-Za-z0-9\\-_]{20,200}|s\\.(?=[A-Za-z0-9_-]{0,49}\\d)(?=[A-Za-z0-9_-]{0,49}[A-Z])[A-Za-z0-9\\-_]{20,50})\\b",
|
|
37867
39016
|
flags: "g"
|
|
37868
39017
|
},
|
|
37869
39018
|
postValidators: ["entropy"],
|
|
@@ -37908,10 +39057,24 @@ var BUNDLED_PACKS = [
|
|
|
37908
39057
|
regex_redos_backtrack_default
|
|
37909
39058
|
]
|
|
37910
39059
|
},
|
|
39060
|
+
{
|
|
39061
|
+
packId: "command-risk",
|
|
39062
|
+
name: "Risky agent commands",
|
|
39063
|
+
version: "0.1.0",
|
|
39064
|
+
defaultPolicy: "warn",
|
|
39065
|
+
rawRules: [
|
|
39066
|
+
pkill_broad_default,
|
|
39067
|
+
rm_rf_home_or_shared_default,
|
|
39068
|
+
git_force_push_default,
|
|
39069
|
+
git_reset_hard_default,
|
|
39070
|
+
curl_pipe_shell_default,
|
|
39071
|
+
credential_file_read_default
|
|
39072
|
+
]
|
|
39073
|
+
},
|
|
37911
39074
|
{
|
|
37912
39075
|
packId: "core-code-context",
|
|
37913
39076
|
name: "Code Context",
|
|
37914
|
-
version: "0.1
|
|
39077
|
+
version: "0.2.1",
|
|
37915
39078
|
rawRules: [
|
|
37916
39079
|
internal_ip_default,
|
|
37917
39080
|
localhost_ref_default,
|
|
@@ -37920,13 +39083,14 @@ var BUNDLED_PACKS = [
|
|
|
37920
39083
|
stack_trace_default,
|
|
37921
39084
|
internal_url_default,
|
|
37922
39085
|
feature_flag_default,
|
|
37923
|
-
db_table_name_default
|
|
39086
|
+
db_table_name_default,
|
|
39087
|
+
gcp_service_account_email_default
|
|
37924
39088
|
]
|
|
37925
39089
|
},
|
|
37926
39090
|
{
|
|
37927
39091
|
packId: "core-financial",
|
|
37928
39092
|
name: "Financial Information",
|
|
37929
|
-
version: "0.1.
|
|
39093
|
+
version: "0.1.1",
|
|
37930
39094
|
rawRules: [
|
|
37931
39095
|
credit_card_default,
|
|
37932
39096
|
iban_default,
|
|
@@ -37956,7 +39120,7 @@ var BUNDLED_PACKS = [
|
|
|
37956
39120
|
{
|
|
37957
39121
|
packId: "core-pii",
|
|
37958
39122
|
name: "Core PII",
|
|
37959
|
-
version: "0.2.
|
|
39123
|
+
version: "0.2.2",
|
|
37960
39124
|
rawRules: [
|
|
37961
39125
|
email_default,
|
|
37962
39126
|
ssn_default,
|
|
@@ -37977,11 +39141,11 @@ var BUNDLED_PACKS = [
|
|
|
37977
39141
|
{
|
|
37978
39142
|
packId: "secrets",
|
|
37979
39143
|
name: "Secrets & Credentials",
|
|
37980
|
-
version: "0.
|
|
39144
|
+
version: "0.2.0",
|
|
39145
|
+
defaultPolicy: "warn",
|
|
37981
39146
|
rawRules: [
|
|
37982
39147
|
aws_access_key_default,
|
|
37983
39148
|
aws_secret_key_default,
|
|
37984
|
-
gcp_service_account_default,
|
|
37985
39149
|
azure_connection_string_default,
|
|
37986
39150
|
openai_api_key_default,
|
|
37987
39151
|
anthropic_api_key_default,
|
|
@@ -37999,13 +39163,15 @@ var BUNDLED_PACKS = [
|
|
|
37999
39163
|
pulumi_access_token_default,
|
|
38000
39164
|
terraform_cloud_token_default,
|
|
38001
39165
|
vault_token_default,
|
|
38002
|
-
github_pat_default
|
|
39166
|
+
github_pat_default,
|
|
39167
|
+
gcp_service_account_key_default,
|
|
39168
|
+
tailscale_key_default
|
|
38003
39169
|
]
|
|
38004
39170
|
},
|
|
38005
39171
|
{
|
|
38006
39172
|
packId: "secrets-infra",
|
|
38007
39173
|
name: "Infrastructure Secrets",
|
|
38008
|
-
version: "0.1.
|
|
39174
|
+
version: "0.1.1",
|
|
38009
39175
|
rawRules: [
|
|
38010
39176
|
ssh_private_key_default,
|
|
38011
39177
|
db_connection_string_default,
|
|
@@ -38048,7 +39214,7 @@ function ensureBundledPacks() {
|
|
|
38048
39214
|
return false;
|
|
38049
39215
|
}
|
|
38050
39216
|
}
|
|
38051
|
-
function scanText(text, ruleVersions) {
|
|
39217
|
+
function scanText(text, ruleVersions, options = {}) {
|
|
38052
39218
|
if (!ensureBundledPacks()) return { masked: "[REDACTED]", findings: [] };
|
|
38053
39219
|
try {
|
|
38054
39220
|
const rules = getLoadedRules();
|
|
@@ -38056,6 +39222,13 @@ function scanText(text, ruleVersions) {
|
|
|
38056
39222
|
const matches = dropShieldedFindings(scan(shielded.text, rules), shielded.spans);
|
|
38057
39223
|
if (matches.length === 0) return { masked: text, findings: [] };
|
|
38058
39224
|
const byId = new Map(rules.map((r) => [r.id, r]));
|
|
39225
|
+
const locate = options.locate === true ? createFindingLocator({
|
|
39226
|
+
text,
|
|
39227
|
+
basis: "excerpt",
|
|
39228
|
+
hits: matches,
|
|
39229
|
+
evidenceOf: evidenceLookup(rules),
|
|
39230
|
+
backstopRules: rules
|
|
39231
|
+
}) : void 0;
|
|
38059
39232
|
const findings = matches.map((m) => {
|
|
38060
39233
|
const rule = byId.get(m.ruleId);
|
|
38061
39234
|
return {
|
|
@@ -38066,7 +39239,8 @@ function scanText(text, ruleVersions) {
|
|
|
38066
39239
|
severity: m.severity,
|
|
38067
39240
|
span: m.span,
|
|
38068
39241
|
maskedMatch: maskMatch(m.rawMatch),
|
|
38069
|
-
confidence: m.confidence
|
|
39242
|
+
confidence: m.confidence,
|
|
39243
|
+
...locate === void 0 ? {} : { location: locate(m) }
|
|
38070
39244
|
};
|
|
38071
39245
|
});
|
|
38072
39246
|
return { masked: redact(text, matches), findings };
|
|
@@ -38081,6 +39255,7 @@ function maskText(text) {
|
|
|
38081
39255
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
38082
39256
|
import { existsSync as existsSync9, readFileSync as readFileSync10, statSync as statSync6 } from "fs";
|
|
38083
39257
|
import { basename as basename2, dirname as dirname4, isAbsolute, join as join17, sep as sep2 } from "path";
|
|
39258
|
+
var NO_ATTRIBUTION = Object.freeze({});
|
|
38084
39259
|
|
|
38085
39260
|
// ../../packages/plugin-sdk/src/events.ts
|
|
38086
39261
|
import { createHash as createHash5, randomUUID as randomUUID13 } from "crypto";
|
|
@@ -38155,12 +39330,18 @@ import { join as join23 } from "path";
|
|
|
38155
39330
|
import { readdirSync as readdirSync3, realpathSync as realpathSync3 } from "fs";
|
|
38156
39331
|
import { basename as basename4, dirname as dirname5, sep as sep3 } from "path";
|
|
38157
39332
|
|
|
39333
|
+
// ../../packages/plugin-sdk/src/policy-resolver.ts
|
|
39334
|
+
import { randomUUID as randomUUID14 } from "crypto";
|
|
39335
|
+
|
|
38158
39336
|
// ../../packages/plugin-sdk/src/posture.ts
|
|
38159
39337
|
function applyCategoryPosture(posture, repo, mode = "fill-gaps") {
|
|
38160
39338
|
for (const category of Object.keys(posture)) {
|
|
38161
39339
|
const policyId = posture[category];
|
|
38162
39340
|
if (!policyId) continue;
|
|
38163
|
-
if (mode === "fill-gaps"
|
|
39341
|
+
if (mode === "fill-gaps") {
|
|
39342
|
+
const chosen = repo.isCategoryChosen ? repo.isCategoryChosen(category) : repo.getCategoryAction(category) !== void 0;
|
|
39343
|
+
if (chosen) continue;
|
|
39344
|
+
}
|
|
38164
39345
|
repo.upsertCategoryAction(category, builtinPolicyToAction(policyId));
|
|
38165
39346
|
}
|
|
38166
39347
|
}
|
|
@@ -38195,114 +39376,12 @@ var codexProviderEnvShape = {
|
|
|
38195
39376
|
};
|
|
38196
39377
|
var CodexProviderEnvSchema = external_exports.object(codexProviderEnvShape);
|
|
38197
39378
|
|
|
38198
|
-
// ../../packages/plugin-sdk/src/raw-egress.ts
|
|
38199
|
-
var RawEgressError = class extends Error {
|
|
38200
|
-
// The text as far as masking got it, when the throw came from a verifier that
|
|
38201
|
-
// had already produced one. A caller that must not propagate the throw (the
|
|
38202
|
-
// history walk) blunt-redacts THIS rather than the raw input: starting over
|
|
38203
|
-
// from the raw text discards every span the masker did cover, which for a
|
|
38204
|
-
// value clipped by the window edge is the only redaction it was ever going to
|
|
38205
|
-
// get — the blunt pass splits on whole values and cannot remove a partial run.
|
|
38206
|
-
masked;
|
|
38207
|
-
constructor(message, masked) {
|
|
38208
|
-
super(message);
|
|
38209
|
-
this.name = "RawEgressError";
|
|
38210
|
-
if (masked !== void 0) this.masked = masked;
|
|
38211
|
-
}
|
|
38212
|
-
};
|
|
38213
|
-
var MIN_RAW_LEN = 4;
|
|
38214
|
-
var RAW_RUN_LEN = 8;
|
|
38215
|
-
function carriesRawRun(text, rawValues) {
|
|
38216
|
-
let windows = null;
|
|
38217
|
-
for (const raw of new Set(rawValues)) {
|
|
38218
|
-
if (raw.length < MIN_RAW_LEN) continue;
|
|
38219
|
-
if (raw.length < RAW_RUN_LEN) {
|
|
38220
|
-
if (text.includes(raw)) return true;
|
|
38221
|
-
continue;
|
|
38222
|
-
}
|
|
38223
|
-
if (windows === null) {
|
|
38224
|
-
windows = /* @__PURE__ */ new Set();
|
|
38225
|
-
for (let i = 0; i + RAW_RUN_LEN <= text.length; i += 1) {
|
|
38226
|
-
windows.add(text.slice(i, i + RAW_RUN_LEN));
|
|
38227
|
-
}
|
|
38228
|
-
}
|
|
38229
|
-
if (windows.size === 0) continue;
|
|
38230
|
-
let preview = null;
|
|
38231
|
-
for (let i = 0; i + RAW_RUN_LEN <= raw.length; i += 1) {
|
|
38232
|
-
const window = raw.slice(i, i + RAW_RUN_LEN);
|
|
38233
|
-
if (!windows.has(window)) continue;
|
|
38234
|
-
preview ??= safeMaskedMatch(raw);
|
|
38235
|
-
if (!preview.includes(window)) return true;
|
|
38236
|
-
}
|
|
38237
|
-
}
|
|
38238
|
-
return false;
|
|
38239
|
-
}
|
|
38240
|
-
function edgeTruncatedSpans(text, rawValues) {
|
|
38241
|
-
const spans = [];
|
|
38242
|
-
if (text.length < RAW_RUN_LEN) return spans;
|
|
38243
|
-
const head = text.slice(0, RAW_RUN_LEN);
|
|
38244
|
-
const tail = text.slice(text.length - RAW_RUN_LEN);
|
|
38245
|
-
for (const raw of rawValues) {
|
|
38246
|
-
if (raw.length < RAW_RUN_LEN) continue;
|
|
38247
|
-
const maxK = Math.min(raw.length - 1, text.length);
|
|
38248
|
-
if (raw.includes(head)) {
|
|
38249
|
-
for (let k = maxK; k >= RAW_RUN_LEN; k -= 1) {
|
|
38250
|
-
if (text.startsWith(raw.slice(raw.length - k))) {
|
|
38251
|
-
spans.push({ rawMatch: raw, span: { start: 0, end: k } });
|
|
38252
|
-
break;
|
|
38253
|
-
}
|
|
38254
|
-
}
|
|
38255
|
-
}
|
|
38256
|
-
if (raw.includes(tail)) {
|
|
38257
|
-
for (let k = maxK; k >= RAW_RUN_LEN; k -= 1) {
|
|
38258
|
-
if (text.endsWith(raw.slice(0, k))) {
|
|
38259
|
-
spans.push({ rawMatch: raw, span: { start: text.length - k, end: text.length } });
|
|
38260
|
-
break;
|
|
38261
|
-
}
|
|
38262
|
-
}
|
|
38263
|
-
}
|
|
38264
|
-
}
|
|
38265
|
-
return spans;
|
|
38266
|
-
}
|
|
38267
|
-
function maskContextSlice(slice, sliceStart, hits) {
|
|
38268
|
-
const findings = [];
|
|
38269
|
-
for (const h of hits) {
|
|
38270
|
-
const start = Math.max(0, h.span.start - sliceStart);
|
|
38271
|
-
const end = Math.min(slice.length, h.span.end - sliceStart);
|
|
38272
|
-
if (end > start) {
|
|
38273
|
-
findings.push({
|
|
38274
|
-
ruleId: "raw-egress",
|
|
38275
|
-
category: "secret",
|
|
38276
|
-
severity: "critical",
|
|
38277
|
-
span: { start, end },
|
|
38278
|
-
rawMatch: "",
|
|
38279
|
-
confidence: 1
|
|
38280
|
-
});
|
|
38281
|
-
}
|
|
38282
|
-
}
|
|
38283
|
-
const masked = findings.length > 0 ? redact(slice, findings) : slice;
|
|
38284
|
-
const rawValues = hits.map((h) => h.rawMatch);
|
|
38285
|
-
if (carriesRawRun(masked, rawValues)) {
|
|
38286
|
-
throw new RawEgressError("raw match survived context masking", masked);
|
|
38287
|
-
}
|
|
38288
|
-
return masked;
|
|
38289
|
-
}
|
|
38290
|
-
function safeMaskedMatch(rawMatch) {
|
|
38291
|
-
const masked = maskMatch(rawMatch);
|
|
38292
|
-
if (masked === rawMatch || rawMatch.length >= MIN_RAW_LEN && masked.includes(rawMatch)) {
|
|
38293
|
-
return "***";
|
|
38294
|
-
}
|
|
38295
|
-
return masked;
|
|
38296
|
-
}
|
|
38297
|
-
function assertRawFree(text, rawValues) {
|
|
38298
|
-
if (carriesRawRun(text, rawValues)) {
|
|
38299
|
-
throw new RawEgressError("text contained a raw detected value");
|
|
38300
|
-
}
|
|
38301
|
-
return text;
|
|
38302
|
-
}
|
|
38303
|
-
|
|
38304
39379
|
// ../../packages/plugin-sdk/src/runtime.ts
|
|
38305
|
-
import { randomUUID as
|
|
39380
|
+
import { randomUUID as randomUUID15 } from "crypto";
|
|
39381
|
+
|
|
39382
|
+
// ../../packages/plugin-sdk/src/scope-key.ts
|
|
39383
|
+
import { existsSync as existsSync12 } from "fs";
|
|
39384
|
+
import { dirname as dirname6, isAbsolute as isAbsolute2, join as join25, normalize } from "path";
|
|
38306
39385
|
|
|
38307
39386
|
// ../../packages/plugin-sdk/src/suppressions.ts
|
|
38308
39387
|
var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
@@ -38343,11 +39422,11 @@ async function applySetupTriageSuppressions(entries, writer, opts) {
|
|
|
38343
39422
|
|
|
38344
39423
|
// ../../packages/plugin-sdk/src/throttle.ts
|
|
38345
39424
|
import { mkdirSync as mkdirSync4, statSync as statSync8, writeFileSync as writeFileSync7 } from "fs";
|
|
38346
|
-
import { join as
|
|
39425
|
+
import { join as join26 } from "path";
|
|
38347
39426
|
|
|
38348
39427
|
// ../../packages/setup-wizard/src/remediation/rotation-checklist.ts
|
|
38349
39428
|
import { writeFileSync as writeFileSync8 } from "fs";
|
|
38350
|
-
import { join as
|
|
39429
|
+
import { join as join27 } from "path";
|
|
38351
39430
|
|
|
38352
39431
|
// ../../packages/setup-wizard/src/triage/dedupe.ts
|
|
38353
39432
|
function dedupeKey(hit) {
|
|
@@ -38402,12 +39481,12 @@ function deriveFalsePositivePatterns(hits, rec, plan) {
|
|
|
38402
39481
|
}
|
|
38403
39482
|
|
|
38404
39483
|
// ../../packages/setup-wizard/src/triage/gate-display.ts
|
|
38405
|
-
function findContext(entry,
|
|
38406
|
-
const byFingerprint =
|
|
39484
|
+
function findContext(entry, join32) {
|
|
39485
|
+
const byFingerprint = join32.find(
|
|
38407
39486
|
(j) => j.valueFingerprint !== void 0 && j.valueFingerprint === entry.valueFingerprint
|
|
38408
39487
|
);
|
|
38409
39488
|
if (byFingerprint) return byFingerprint.maskedContext;
|
|
38410
|
-
const byRuleAndMask =
|
|
39489
|
+
const byRuleAndMask = join32.find(
|
|
38411
39490
|
(j) => j.ruleId === entry.ruleId && j.maskedMatch === entry.maskedValue
|
|
38412
39491
|
);
|
|
38413
39492
|
return byRuleAndMask?.maskedContext;
|
|
@@ -38478,13 +39557,13 @@ function renderShowcase(showcase) {
|
|
|
38478
39557
|
|
|
38479
39558
|
${blocks.join("\n\n")}`;
|
|
38480
39559
|
}
|
|
38481
|
-
function renderSuppressionGate(entries,
|
|
39560
|
+
function renderSuppressionGate(entries, join32) {
|
|
38482
39561
|
if (entries.length === 0) {
|
|
38483
39562
|
return "No false-positive suppressions to confirm \u2014 nothing will be written.";
|
|
38484
39563
|
}
|
|
38485
39564
|
const header = entries.length === 1 ? "This looks like a false positive \u2014 take a look before I suppress it:" : `These ${String(entries.length)} look like false positives \u2014 take a look before I suppress them:`;
|
|
38486
39565
|
const blocks = entries.map((entry, i) => {
|
|
38487
|
-
const context = findContext(entry,
|
|
39566
|
+
const context = findContext(entry, join32);
|
|
38488
39567
|
const lines = [
|
|
38489
39568
|
`${String(i + 1)}. ${entry.ruleId} [${entry.category}]`,
|
|
38490
39569
|
` value: ${entry.maskedValue}`,
|
|
@@ -38572,7 +39651,7 @@ function mergeRecommendations(verdicts) {
|
|
|
38572
39651
|
// ../../packages/setup-wizard/src/triage/plan-file.ts
|
|
38573
39652
|
import { mkdtempSync, readFileSync as readFileSync17, rmdirSync, rmSync as rmSync7, writeFileSync as writeFileSync9 } from "fs";
|
|
38574
39653
|
import { tmpdir } from "os";
|
|
38575
|
-
import { basename as basename6, dirname as
|
|
39654
|
+
import { basename as basename6, dirname as dirname7, join as join28 } from "path";
|
|
38576
39655
|
var SuppressionEntrySchema = external_exports.object({
|
|
38577
39656
|
ruleId: external_exports.string(),
|
|
38578
39657
|
category: DetectionCategory,
|
|
@@ -38627,8 +39706,8 @@ function serializePlan(plan, current) {
|
|
|
38627
39706
|
function writePlanFile(plan, current, rawValues, deps = {}) {
|
|
38628
39707
|
const serialized = serializePlan(plan, current);
|
|
38629
39708
|
assertRawFree(serialized, rawValues);
|
|
38630
|
-
const dir = (deps.mkTempDir ?? (() => mkdtempSync(
|
|
38631
|
-
const path =
|
|
39709
|
+
const dir = (deps.mkTempDir ?? (() => mkdtempSync(join28(tmpdir(), "aka-plan-"))))();
|
|
39710
|
+
const path = join28(dir, "setup-plan.json");
|
|
38632
39711
|
writeFileSync9(path, serialized, { encoding: "utf8", mode: 384 });
|
|
38633
39712
|
return path;
|
|
38634
39713
|
}
|
|
@@ -38639,7 +39718,7 @@ function readPlanFile(path) {
|
|
|
38639
39718
|
}
|
|
38640
39719
|
function deletePlanFile(path) {
|
|
38641
39720
|
rmSync7(path, { force: true });
|
|
38642
|
-
const dir =
|
|
39721
|
+
const dir = dirname7(path);
|
|
38643
39722
|
if (!basename6(dir).startsWith("aka-plan-")) return;
|
|
38644
39723
|
try {
|
|
38645
39724
|
rmdirSync(dir);
|
|
@@ -38708,8 +39787,8 @@ function buildJoinEntries(hits) {
|
|
|
38708
39787
|
}
|
|
38709
39788
|
|
|
38710
39789
|
// ../../packages/setup-wizard/src/triage/resolve.ts
|
|
38711
|
-
function resolveSuppressions(rec,
|
|
38712
|
-
const byId = new Map(
|
|
39790
|
+
function resolveSuppressions(rec, join32) {
|
|
39791
|
+
const byId = new Map(join32.map((e) => [e.id, e]));
|
|
38713
39792
|
const entries = [];
|
|
38714
39793
|
const skipped = [];
|
|
38715
39794
|
for (const cat of rec.perCategory) {
|
|
@@ -38811,7 +39890,7 @@ function parseTriageStream(text) {
|
|
|
38811
39890
|
return { hits, status: "complete" };
|
|
38812
39891
|
}
|
|
38813
39892
|
function planTriageWriteback(hits, rec) {
|
|
38814
|
-
const
|
|
39893
|
+
const join32 = buildJoinEntries(hits);
|
|
38815
39894
|
const rawValues = hits.map((h) => h.rawMatch);
|
|
38816
39895
|
const skipped = [];
|
|
38817
39896
|
const posture = {};
|
|
@@ -38851,7 +39930,7 @@ function planTriageWriteback(hits, rec) {
|
|
|
38851
39930
|
}
|
|
38852
39931
|
const { entries, skipped: resolveSkips } = resolveSuppressions(
|
|
38853
39932
|
{ perCategory: safeCategories, notes: rec.notes },
|
|
38854
|
-
|
|
39933
|
+
join32
|
|
38855
39934
|
);
|
|
38856
39935
|
skipped.push(...resolveSkips);
|
|
38857
39936
|
let notes = rec.notes;
|
|
@@ -38861,7 +39940,7 @@ function planTriageWriteback(hits, rec) {
|
|
|
38861
39940
|
if (err instanceof RawEgressError) notes = SCRUBBED_NOTES;
|
|
38862
39941
|
else throw err;
|
|
38863
39942
|
}
|
|
38864
|
-
return { entries, posture, showcase, join:
|
|
39943
|
+
return { entries, posture, showcase, join: join32, notes, skipped };
|
|
38865
39944
|
}
|
|
38866
39945
|
function recommendedPosture(evidence) {
|
|
38867
39946
|
return { ...severityFloorPosture(), ...evidence };
|
|
@@ -39132,7 +40211,7 @@ function parseRecommendation(text) {
|
|
|
39132
40211
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
39133
40212
|
import { mkdtempSync as mkdtempSync2, readFileSync as readFileSync18, rmSync as rmSync8 } from "fs";
|
|
39134
40213
|
import { tmpdir as tmpdir2 } from "os";
|
|
39135
|
-
import { dirname as
|
|
40214
|
+
import { dirname as dirname8, join as join29 } from "path";
|
|
39136
40215
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
39137
40216
|
|
|
39138
40217
|
// ../../packages/plugin-sdk/src/bare-command.ts
|
|
@@ -39243,8 +40322,8 @@ function planBareCommand(command, args, deps = {}) {
|
|
|
39243
40322
|
}
|
|
39244
40323
|
|
|
39245
40324
|
// src/triage/judge.ts
|
|
39246
|
-
var TRIAGE_DIR =
|
|
39247
|
-
var DEFAULT_RUBRIC_PATH =
|
|
40325
|
+
var TRIAGE_DIR = dirname8(fileURLToPath2(import.meta.url));
|
|
40326
|
+
var DEFAULT_RUBRIC_PATH = join29(
|
|
39248
40327
|
TRIAGE_DIR,
|
|
39249
40328
|
"..",
|
|
39250
40329
|
"..",
|
|
@@ -39310,8 +40389,8 @@ function runJudge(hits, deps) {
|
|
|
39310
40389
|
${hitsJsonl}
|
|
39311
40390
|
\`\`\`
|
|
39312
40391
|
`;
|
|
39313
|
-
const outDir = mkdtempSync2(
|
|
39314
|
-
const outFile =
|
|
40392
|
+
const outDir = mkdtempSync2(join29(tmpdir2(), "aka-judge-"));
|
|
40393
|
+
const outFile = join29(outDir, "last-message.txt");
|
|
39315
40394
|
const argv = [
|
|
39316
40395
|
"exec",
|
|
39317
40396
|
"--ephemeral",
|
|
@@ -39436,7 +40515,7 @@ function show(body) {
|
|
|
39436
40515
|
|
|
39437
40516
|
// src/skills-registry.ts
|
|
39438
40517
|
import { readdirSync as readdirSync5, readFileSync as readFileSync19 } from "fs";
|
|
39439
|
-
import { join as
|
|
40518
|
+
import { join as join30 } from "path";
|
|
39440
40519
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
39441
40520
|
var SKILLS_DIR = fileURLToPath3(new URL("../skills", import.meta.url));
|
|
39442
40521
|
function frontmatterName(content) {
|
|
@@ -39449,7 +40528,7 @@ function readRegisteredSkills() {
|
|
|
39449
40528
|
return readdirSync5(SKILLS_DIR, { withFileTypes: true }).filter((entry) => entry.isDirectory()).flatMap((entry) => {
|
|
39450
40529
|
let content;
|
|
39451
40530
|
try {
|
|
39452
|
-
content = readFileSync19(
|
|
40531
|
+
content = readFileSync19(join30(SKILLS_DIR, entry.name, "SKILL.md"), "utf8");
|
|
39453
40532
|
} catch {
|
|
39454
40533
|
return [];
|
|
39455
40534
|
}
|
|
@@ -39600,11 +40679,11 @@ function resolveCreatedBy() {
|
|
|
39600
40679
|
}
|
|
39601
40680
|
}
|
|
39602
40681
|
function loadRubric() {
|
|
39603
|
-
const here =
|
|
39604
|
-
const shipped =
|
|
39605
|
-
if (
|
|
40682
|
+
const here = dirname9(fileURLToPath4(import.meta.url));
|
|
40683
|
+
const shipped = join31(here, "triage-rubric.md");
|
|
40684
|
+
if (existsSync13(shipped)) return readFileSync20(shipped, "utf8");
|
|
39606
40685
|
return readFileSync20(
|
|
39607
|
-
|
|
40686
|
+
join31(here, "..", "..", "..", "packages", "setup-wizard", "assets", "triage-rubric.md"),
|
|
39608
40687
|
"utf8"
|
|
39609
40688
|
);
|
|
39610
40689
|
}
|