@akasecurity/ai-tc-codex 0.9.14 → 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 +1828 -463
- package/scripts/backfill.js +2406 -518
- package/scripts/content-retention.js +1002 -275
- package/scripts/filescan.js +2323 -435
- package/scripts/firstrun.js +1643 -363
- package/scripts/history-sync.js +1024 -282
- package/scripts/intro.js +385 -178
- package/scripts/onboard.js +985 -260
- package/scripts/post-tool-use.js +2446 -439
- package/scripts/pre-tool-use.js +2350 -434
- package/scripts/query.js +1642 -362
- package/scripts/reconcile.js +2297 -413
- package/scripts/remediate.js +2281 -444
- package/scripts/scan-worker.js +514 -175
- package/scripts/session-start.js +2292 -421
- package/scripts/start-light.js +385 -178
- package/scripts/stop.js +481 -207
- package/scripts/sync.js +2322 -434
- package/scripts/user-prompt-submit.js +2392 -469
- 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 === SLASH3 ? `${source}$` : `${source}(?=$|\\/$)`;
|
|
@@ -418,17 +419,20 @@ 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 = "[^\\/]*";
|
|
429
|
+
var separatorAfter = (run, at) => {
|
|
430
|
+
let separator = EMPTY;
|
|
431
|
+
for (let index = at + 1; index < run.length && !run[index].wildcard; index++) {
|
|
432
|
+
separator += run[index].single;
|
|
433
|
+
}
|
|
434
|
+
return separator;
|
|
435
|
+
};
|
|
432
436
|
var pinWildcards = (source) => {
|
|
433
437
|
if (source.indexOf(WILDCARD) < 0) {
|
|
434
438
|
return source;
|
|
@@ -498,7 +502,7 @@ var require_ignore = __commonJS({
|
|
|
498
502
|
out += token.single;
|
|
499
503
|
return;
|
|
500
504
|
}
|
|
501
|
-
out += at === lastWildcard ? WILDCARD : `(?:(?!${run
|
|
505
|
+
out += at === lastWildcard ? WILDCARD : `(?:(?!${separatorAfter(run, at)})[^\\/])*`;
|
|
502
506
|
});
|
|
503
507
|
run = [];
|
|
504
508
|
};
|
|
@@ -536,6 +540,14 @@ var require_ignore = __commonJS({
|
|
|
536
540
|
(match, index) => sources[index]
|
|
537
541
|
) : replaced;
|
|
538
542
|
};
|
|
543
|
+
var checkSourceOf = (body, prefix) => {
|
|
544
|
+
if (body[body.length - 1] === SLASH3) {
|
|
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
|
+
};
|
|
539
551
|
var matchesBasename = (body) => {
|
|
540
552
|
const index = body.indexOf(SLASH3);
|
|
541
553
|
return index < 0 || index === body.length - 1;
|
|
@@ -596,11 +608,9 @@ var require_ignore = __commonJS({
|
|
|
596
608
|
return this._make(MODE_CHECK_IGNORE, key);
|
|
597
609
|
}
|
|
598
610
|
_make(mode, key) {
|
|
599
|
-
const str2 = pinWildcards(
|
|
600
|
-
REGEX_REPLACE_TRAILING_WILDCARD,
|
|
601
|
-
|
|
602
|
-
TRAILING_WILD_CARD_REPLACERS[mode]
|
|
603
|
-
));
|
|
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
|
+
);
|
|
604
614
|
const regex = this.ignoreCase ? new RegExp(str2, "i") : new RegExp(str2);
|
|
605
615
|
return define(this, key, regex);
|
|
606
616
|
}
|
|
@@ -659,8 +669,39 @@ var require_ignore = __commonJS({
|
|
|
659
669
|
makeArray(
|
|
660
670
|
isString(pattern) ? splitPattern(pattern) : pattern
|
|
661
671
|
).forEach(this._add, this);
|
|
672
|
+
if (this._added) {
|
|
673
|
+
this._literalRules = UNDEFINED;
|
|
674
|
+
}
|
|
662
675
|
return this._added;
|
|
663
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] === SLASH3 ? 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
|
+
}
|
|
664
705
|
// Test one single path without recursively checking parent directories
|
|
665
706
|
//
|
|
666
707
|
// - checkUnignored `boolean` whether should check if the path is unignored,
|
|
@@ -675,13 +716,13 @@ var require_ignore = __commonJS({
|
|
|
675
716
|
const rules = this._rules;
|
|
676
717
|
const { length } = rules;
|
|
677
718
|
const shortcut = this._basenameCount * 2 >= length;
|
|
678
|
-
const
|
|
719
|
+
const basename7 = shortcut ? basenameOf(path) : path;
|
|
679
720
|
for (let index = 0; index < length; index++) {
|
|
680
721
|
const rule = rules[index];
|
|
681
722
|
const { negative } = rule;
|
|
682
723
|
const skip = unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored;
|
|
683
724
|
if (!skip && rule[mode].test(
|
|
684
|
-
shortcut && rule._basenameOnly ?
|
|
725
|
+
shortcut && rule._basenameOnly ? basename7 : path
|
|
685
726
|
)) {
|
|
686
727
|
ignored = !negative;
|
|
687
728
|
unignored = negative;
|
|
@@ -781,14 +822,12 @@ var require_ignore = __commonJS({
|
|
|
781
822
|
if (path.charCodeAt(path.length - 1) !== SLASH_CODE) {
|
|
782
823
|
return this.test(path);
|
|
783
824
|
}
|
|
784
|
-
const
|
|
785
|
-
if (
|
|
786
|
-
|
|
787
|
-
if (parent.ignored) {
|
|
788
|
-
return parent;
|
|
789
|
-
}
|
|
825
|
+
const dir = this._t(path, this._testCache, true);
|
|
826
|
+
if (dir.ignored) {
|
|
827
|
+
return dir;
|
|
790
828
|
}
|
|
791
|
-
|
|
829
|
+
const literal2 = this._rules.testLiteral(path);
|
|
830
|
+
return literal2.ignored || literal2.unignored ? literal2 : dir;
|
|
792
831
|
}
|
|
793
832
|
_t(path, cache, checkUnignored) {
|
|
794
833
|
if (path in cache) {
|
|
@@ -995,6 +1034,14 @@ var SQLITE_MIGRATIONS = [
|
|
|
995
1034
|
{
|
|
996
1035
|
tag: "0035_share_destination_provider_id",
|
|
997
1036
|
sql: "ALTER TABLE `share_destination` ADD `provider_id` text;"
|
|
1037
|
+
},
|
|
1038
|
+
{
|
|
1039
|
+
tag: "0036_secret_vault_identity_fingerprint",
|
|
1040
|
+
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"
|
|
1041
|
+
},
|
|
1042
|
+
{
|
|
1043
|
+
tag: "0037_finding_location",
|
|
1044
|
+
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;"
|
|
998
1045
|
}
|
|
999
1046
|
];
|
|
1000
1047
|
|
|
@@ -6030,7 +6077,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
6030
6077
|
var NONE = 0;
|
|
6031
6078
|
var ASSUMED = 1;
|
|
6032
6079
|
var PROVEN = 2;
|
|
6033
|
-
function isRecursive(inst, stack,
|
|
6080
|
+
function isRecursive(inst, stack, resolve3) {
|
|
6034
6081
|
const cached2 = recursive.get(inst);
|
|
6035
6082
|
if (cached2 !== void 0)
|
|
6036
6083
|
return cached2 ? PROVEN : NONE;
|
|
@@ -6040,7 +6087,7 @@ function isRecursive(inst, stack, resolve2) {
|
|
|
6040
6087
|
let result = NONE;
|
|
6041
6088
|
const check2 = (child) => {
|
|
6042
6089
|
if (result !== PROVEN && child?._zod) {
|
|
6043
|
-
const answer = isRecursive(child, stack,
|
|
6090
|
+
const answer = isRecursive(child, stack, resolve3);
|
|
6044
6091
|
if (answer > result)
|
|
6045
6092
|
result = answer;
|
|
6046
6093
|
}
|
|
@@ -6051,7 +6098,7 @@ function isRecursive(inst, stack, resolve2) {
|
|
|
6051
6098
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
6052
6099
|
if (spread && !desc.enumerable)
|
|
6053
6100
|
continue;
|
|
6054
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
6101
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve3) : NONE;
|
|
6055
6102
|
if (child > answer)
|
|
6056
6103
|
answer = child;
|
|
6057
6104
|
}
|
|
@@ -6115,7 +6162,7 @@ function isRecursive(inst, stack, resolve2) {
|
|
|
6115
6162
|
break;
|
|
6116
6163
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
6117
6164
|
case "lazy": {
|
|
6118
|
-
const inner = def._cachedInner ?? (
|
|
6165
|
+
const inner = def._cachedInner ?? (resolve3 ? inst._zod.innerType : void 0);
|
|
6119
6166
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
6120
6167
|
break;
|
|
6121
6168
|
}
|
|
@@ -21888,11 +21935,33 @@ var ResolutionMethod = external_exports.enum([
|
|
|
21888
21935
|
"false-positive",
|
|
21889
21936
|
"redetected"
|
|
21890
21937
|
]).meta({ id: "ResolutionMethod" });
|
|
21938
|
+
var FindingContextBasis = external_exports.enum(["file", "excerpt"]).meta({ id: "FindingContextBasis" });
|
|
21939
|
+
var FindingContext = external_exports.object({
|
|
21940
|
+
basis: FindingContextBasis,
|
|
21941
|
+
// 1-based line number of `lines[0]`.
|
|
21942
|
+
firstLine: external_exports.number().int().positive(),
|
|
21943
|
+
lines: external_exports.array(external_exports.string()).min(1).max(5),
|
|
21944
|
+
match: external_exports.object({
|
|
21945
|
+
// 1-based line number, within [firstLine, firstLine + lines.length).
|
|
21946
|
+
line: external_exports.number().int().positive(),
|
|
21947
|
+
// Offsets into that entry of `lines`, end exclusive.
|
|
21948
|
+
start: external_exports.number().int().nonnegative(),
|
|
21949
|
+
end: external_exports.number().int().nonnegative()
|
|
21950
|
+
}).nullable()
|
|
21951
|
+
}).meta({ id: "FindingContext" });
|
|
21952
|
+
var FindingLocation = external_exports.object({
|
|
21953
|
+
line: external_exports.number().int().positive(),
|
|
21954
|
+
col: external_exports.number().int().positive(),
|
|
21955
|
+
context: FindingContext.nullable()
|
|
21956
|
+
});
|
|
21891
21957
|
var FindingMatch = external_exports.object({
|
|
21892
21958
|
// Masked preview of the matched value. Never raw content.
|
|
21893
21959
|
maskedValue: external_exports.string(),
|
|
21894
|
-
//
|
|
21895
|
-
contextPrefix: external_exports.string()
|
|
21960
|
+
// Deprecated: always empty. Superseded by `context`.
|
|
21961
|
+
contextPrefix: external_exports.string(),
|
|
21962
|
+
// The masked lines around the match. Absent when the finding predates
|
|
21963
|
+
// context capture or none could be built safely.
|
|
21964
|
+
context: FindingContext.optional()
|
|
21896
21965
|
}).meta({ id: "FindingMatch" });
|
|
21897
21966
|
var FindingDetectionRef = external_exports.object({
|
|
21898
21967
|
id: external_exports.string(),
|
|
@@ -21912,6 +21981,11 @@ var FindingInstance = external_exports.object({
|
|
|
21912
21981
|
provider: FindingProvider,
|
|
21913
21982
|
repo: external_exports.string(),
|
|
21914
21983
|
file: external_exports.string(),
|
|
21984
|
+
// 1-based line and column of the match start in the scanned text (the
|
|
21985
|
+
// column in UTF-16 code units). Absent for findings that predate location
|
|
21986
|
+
// capture or have no source text.
|
|
21987
|
+
line: external_exports.number().int().positive().optional(),
|
|
21988
|
+
col: external_exports.number().int().positive().optional(),
|
|
21915
21989
|
// Who the capturing event is attributed to. Optional: a single-user store
|
|
21916
21990
|
// has no one to attribute a finding to and never sets it.
|
|
21917
21991
|
user: FindingUser.optional(),
|
|
@@ -21973,6 +22047,13 @@ var FindingStats = external_exports.object({
|
|
|
21973
22047
|
low: external_exports.number().int().nonnegative()
|
|
21974
22048
|
})
|
|
21975
22049
|
}).meta({ id: "FindingStats" });
|
|
22050
|
+
var FindingsOverview = external_exports.object({
|
|
22051
|
+
findings: external_exports.number().int().nonnegative(),
|
|
22052
|
+
open: external_exports.number().int().nonnegative(),
|
|
22053
|
+
handled: external_exports.number().int().nonnegative(),
|
|
22054
|
+
resolved: external_exports.number().int().nonnegative(),
|
|
22055
|
+
dismissed: external_exports.number().int().nonnegative()
|
|
22056
|
+
}).meta({ id: "FindingsOverview" });
|
|
21976
22057
|
var FindingFacetItem = external_exports.object({
|
|
21977
22058
|
value: external_exports.string(),
|
|
21978
22059
|
count: external_exports.number().int().nonnegative()
|
|
@@ -22092,6 +22173,7 @@ var FindingInstanceDetail = FindingInstance.extend({
|
|
|
22092
22173
|
}).meta({ id: "FindingInstanceDetail" });
|
|
22093
22174
|
var DEFAULT_FLAT_FINDINGS_LIMIT = 50;
|
|
22094
22175
|
var MAX_FLAT_FINDINGS_LIMIT = 200;
|
|
22176
|
+
var FindingContextQuery = external_exports.object({ id: external_exports.string().min(1).max(256) });
|
|
22095
22177
|
var ListFindingInstancesQuery = external_exports.object({
|
|
22096
22178
|
severity: external_exports.array(Severity).optional(),
|
|
22097
22179
|
// Rule ids, the same vocabulary the types list's `subtype` carries. Pinning
|
|
@@ -22424,7 +22506,23 @@ var CaptureAttributes = external_exports.object({
|
|
|
22424
22506
|
// capture denied by another finding's own Block policy carries `block`
|
|
22425
22507
|
// here too. The full statement is on EventMetadata.redactDegradedTo; it is
|
|
22426
22508
|
// repeated rather than referenced because a store reader opens this file.
|
|
22427
|
-
redact_degraded_to: ActionTaken.optional()
|
|
22509
|
+
redact_degraded_to: ActionTaken.optional(),
|
|
22510
|
+
// The scope key this capture was stamped with: the canonical repository
|
|
22511
|
+
// (`host/owner/repo`) of the path the capture names (a relative path is read
|
|
22512
|
+
// against its working directory), else of its own working directory, or a
|
|
22513
|
+
// chat account's identity. The store's local `scope_key` column reads it, so
|
|
22514
|
+
// a scoped attachment has a per-row key to work from. Absent when no key
|
|
22515
|
+
// could be derived.
|
|
22516
|
+
//
|
|
22517
|
+
// LOCAL ONLY. That is the contract for every path that sends a row. Producers
|
|
22518
|
+
// stamp it in every attachment mode, and the two structural choke points strip
|
|
22519
|
+
// it: the attached gateway's `reKeyForForward` on the live path, and the
|
|
22520
|
+
// history drain's `rebuildAuditEvent`, which drops it through `withoutScopeKey`.
|
|
22521
|
+
// A capture row's bag reaches the wire through `rebuildCapture`, which builds
|
|
22522
|
+
// the metadata from named keys and never names this one; `toCaptureAttributes`,
|
|
22523
|
+
// which builds the bag from a wire event, never emits it. What a scoped
|
|
22524
|
+
// attachment does with the key is not part of this shape's contract.
|
|
22525
|
+
scope_key: external_exports.string().optional()
|
|
22428
22526
|
}).catchall(external_exports.unknown());
|
|
22429
22527
|
var CaptureStatusAttributes = external_exports.object({
|
|
22430
22528
|
source_tool: external_exports.string().optional(),
|
|
@@ -22454,6 +22552,12 @@ var ToolCallInspection = external_exports.object({
|
|
|
22454
22552
|
actionTaken: ActionTaken,
|
|
22455
22553
|
confidence: external_exports.number().min(0).max(1)
|
|
22456
22554
|
});
|
|
22555
|
+
var findingLocationFields = {
|
|
22556
|
+
line: external_exports.number().int().positive().optional(),
|
|
22557
|
+
col: external_exports.number().int().positive().optional(),
|
|
22558
|
+
context: FindingContext.nullable().optional()
|
|
22559
|
+
};
|
|
22560
|
+
var ToolCallInspectionInput = ToolCallInspection.extend(findingLocationFields);
|
|
22457
22561
|
var ToolCallInput = external_exports.object({
|
|
22458
22562
|
sessionId: external_exports.string().min(1),
|
|
22459
22563
|
toolUseId: external_exports.string().min(1),
|
|
@@ -22463,7 +22567,7 @@ var ToolCallInput = external_exports.object({
|
|
|
22463
22567
|
attributes: ToolCallAttributes,
|
|
22464
22568
|
// Secrets detected in the tool's (masked) target — written as linked
|
|
22465
22569
|
// `inspection_findings`. Empty for a clean tool call.
|
|
22466
|
-
inspections: external_exports.array(
|
|
22570
|
+
inspections: external_exports.array(ToolCallInspectionInput).default([])
|
|
22467
22571
|
});
|
|
22468
22572
|
var InventoryInput = external_exports.object({
|
|
22469
22573
|
objectType: InventoryObjectType,
|
|
@@ -22537,7 +22641,8 @@ var InspectionFindingInput = external_exports.object({
|
|
|
22537
22641
|
// same findingKey — mirrors the legacy `findings.first_detected_at`.
|
|
22538
22642
|
// Optional: when omitted, the writer derives it from the referenced audit
|
|
22539
22643
|
// event's startedAt on first insert (see SqliteInspectionFindingsRepository).
|
|
22540
|
-
firstDetectedAt: external_exports.iso.datetime().optional()
|
|
22644
|
+
firstDetectedAt: external_exports.iso.datetime().optional(),
|
|
22645
|
+
...findingLocationFields
|
|
22541
22646
|
});
|
|
22542
22647
|
var InventoryContext = external_exports.object({
|
|
22543
22648
|
host: InventoryInput.optional(),
|
|
@@ -23315,6 +23420,17 @@ var AttachedCredential = external_exports.object({
|
|
|
23315
23420
|
keyPrefix: external_exports.string().min(1).max(16).optional(),
|
|
23316
23421
|
mintedAt: external_exports.iso.datetime().optional()
|
|
23317
23422
|
});
|
|
23423
|
+
var AttachmentMode = external_exports.enum(["machine", "scoped"]);
|
|
23424
|
+
var ATTACHED_CREDENTIAL_SCOPED_SPEC_VERSION = 2;
|
|
23425
|
+
var AttachedCredentialV1 = AttachedCredential;
|
|
23426
|
+
var AttachedCredentialV2 = AttachedCredential.extend({
|
|
23427
|
+
specVersion: external_exports.literal(ATTACHED_CREDENTIAL_SCOPED_SPEC_VERSION),
|
|
23428
|
+
mode: external_exports.literal("scoped")
|
|
23429
|
+
});
|
|
23430
|
+
var AttachedCredentialAny = external_exports.discriminatedUnion("specVersion", [
|
|
23431
|
+
AttachedCredentialV1,
|
|
23432
|
+
AttachedCredentialV2
|
|
23433
|
+
]);
|
|
23318
23434
|
var MAX_DATE_MS = 253402300799999;
|
|
23319
23435
|
var MAX_INT4 = 2147483647;
|
|
23320
23436
|
var StorePosturePack = external_exports.object({
|
|
@@ -23371,7 +23487,29 @@ var StorePosturePlugin = external_exports.object({
|
|
|
23371
23487
|
*/
|
|
23372
23488
|
policyBundleVersion: external_exports.string().max(200).nullable(),
|
|
23373
23489
|
/** Epoch millis, on the CLIENT clock, of that fetch. */
|
|
23374
|
-
policyFetchedAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable()
|
|
23490
|
+
policyFetchedAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable(),
|
|
23491
|
+
/**
|
|
23492
|
+
* The newest version the host's own install record holds for this plugin —
|
|
23493
|
+
* what is on disk. After an update it leads `version` (the running copy) by
|
|
23494
|
+
* one launch. Null when no usable version can be read: no install record
|
|
23495
|
+
* (a plugin run from a checkout), no entry with a valid version, or every
|
|
23496
|
+
* such entry names an `installPath` that no longer exists; OPTIONAL, not
|
|
23497
|
+
* required, so a build that predates the member keeps getting its 200.
|
|
23498
|
+
* Bounded like `version`.
|
|
23499
|
+
*/
|
|
23500
|
+
installedVersion: external_exports.string().max(64).nullable().optional(),
|
|
23501
|
+
/**
|
|
23502
|
+
* The local-store schema version this running build migrates a store to:
|
|
23503
|
+
* the number of store migrations it carries, the count it stamps into
|
|
23504
|
+
* `PRAGMA user_version`. A snapshot whose `schemaVersion` is above it
|
|
23505
|
+
* usually describes a store a newer build migrated. It is a hint, not a
|
|
23506
|
+
* verdict: the stamp is write-only, so a store whose count ran past this
|
|
23507
|
+
* build's while this build knows every migration in its ledger reads above
|
|
23508
|
+
* it too, which is why describeStoreSkew decides skew on ledger tags and
|
|
23509
|
+
* never on the count. OPTIONAL for the same reason as `installedVersion`;
|
|
23510
|
+
* bounded like `schemaVersion`.
|
|
23511
|
+
*/
|
|
23512
|
+
buildSchemaVersion: external_exports.number().int().min(0).max(MAX_INT4).optional()
|
|
23375
23513
|
}).meta({ id: "StorePosturePlugin" });
|
|
23376
23514
|
var StorePostureSnapshot = external_exports.object({
|
|
23377
23515
|
deviceId: external_exports.guid(),
|
|
@@ -23574,6 +23712,130 @@ var PackId = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
|
23574
23712
|
var SemVer = external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?$/);
|
|
23575
23713
|
var PublisherKind = external_exports.enum(["labs", "user", "org"]);
|
|
23576
23714
|
|
|
23715
|
+
// ../../packages/schema/src/zod/builtin-policy-id.ts
|
|
23716
|
+
var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
|
|
23717
|
+
var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
|
|
23718
|
+
|
|
23719
|
+
// ../../packages/schema/src/zod/event.ts
|
|
23720
|
+
var EventKind = external_exports.enum(["prompt", "response", "code_change", "tool_use"]).meta({ id: "EventKind" });
|
|
23721
|
+
var CAPTURE_EVENT_TYPES_SQL = EventKind.options.map((k) => `'${k}'`).join(",");
|
|
23722
|
+
var EventMetadata = external_exports.object({
|
|
23723
|
+
sessionId: external_exports.string().optional(),
|
|
23724
|
+
repo: external_exports.string().optional(),
|
|
23725
|
+
filePath: external_exports.string().optional(),
|
|
23726
|
+
// The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
|
|
23727
|
+
// set by the tool-scanning hooks. The tool NAME only — never the tool's
|
|
23728
|
+
// arguments or output, which can carry the very value a finding masked
|
|
23729
|
+
// (metadata is stored unredacted). Gives findings on non-file captures a
|
|
23730
|
+
// display location ("via Bash") when no filePath exists.
|
|
23731
|
+
toolName: external_exports.string().optional(),
|
|
23732
|
+
// Set (true) by the worktree scanner when the file is excluded by the
|
|
23733
|
+
// repo's .gitignore. Gitignored files ARE still scanned — local scratch and
|
|
23734
|
+
// generated code can leak real secrets — but the provenance is recorded so
|
|
23735
|
+
// policy/dashboards can treat those findings as informational rather than
|
|
23736
|
+
// blocking. Omitted (not false) for tracked files and non-scan events.
|
|
23737
|
+
gitignored: external_exports.boolean().optional(),
|
|
23738
|
+
// Set (true) ONLY when the event's `content` is the COMPLETE file at
|
|
23739
|
+
// capture time (a worktree scan reading from disk). Hook-captured edits
|
|
23740
|
+
// (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
|
|
23741
|
+
// this. The resolver-on-ingest keys its fixed-at-source dropout
|
|
23742
|
+
// diff on this marker: only a whole-file snapshot can prove a previously
|
|
23743
|
+
// open finding is gone; a fragment's absence proves nothing (the secret
|
|
23744
|
+
// may live outside the hunk). Omitted (not false) for fragments and
|
|
23745
|
+
// non-scan events, so pre-marker clients safely default to the
|
|
23746
|
+
// non-authoritative path.
|
|
23747
|
+
wholeFile: external_exports.boolean().optional(),
|
|
23748
|
+
model: external_exports.string().optional(),
|
|
23749
|
+
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
23750
|
+
// Distributed-tracing correlation. `correlationId` ties a recorded event back
|
|
23751
|
+
// to the request that captured/ingested it (a UUID, generated independently of
|
|
23752
|
+
// the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
|
|
23753
|
+
// originating span when telemetry is enabled. Both optional + backward
|
|
23754
|
+
// compatible — populated by the plugin (see @akasecurity/plugin-sdk).
|
|
23755
|
+
correlationId: external_exports.uuid().optional(),
|
|
23756
|
+
traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
|
|
23757
|
+
// Ids of the detection exceptions that downgraded findings in this capture
|
|
23758
|
+
// to 'allow' — the enforcement audit trail's link back to the grant that
|
|
23759
|
+
// authorized the bypass. Absent on captures where no exception applied.
|
|
23760
|
+
exceptionIds: external_exports.array(external_exports.guid()).optional(),
|
|
23761
|
+
// The assistant message this capture belongs to, and the conversation it sits
|
|
23762
|
+
// in — set by the browser extension's network capture so a stored `response`
|
|
23763
|
+
// row can be joined to the `llm_call` leaf describing the same turn. Absent
|
|
23764
|
+
// on every other capture path, which has no such id.
|
|
23765
|
+
//
|
|
23766
|
+
// Non-empty for the reason WebExchange.messageId is: it is the join key, and
|
|
23767
|
+
// a blank one matches no `llm_call` leaf. That refusal reaches only the
|
|
23768
|
+
// places an event is PARSED; the local write path types the event and parses
|
|
23769
|
+
// nothing, which is why `toCaptureAttributes` omits a blank one separately.
|
|
23770
|
+
messageId: external_exports.string().min(1).optional(),
|
|
23771
|
+
conversationId: external_exports.string().optional(),
|
|
23772
|
+
// How long THIS capture's inspection blocked its caller, in whole
|
|
23773
|
+
// milliseconds — the plugin's own added latency, NOT the LLM call it sat in
|
|
23774
|
+
// front of. Measured inside `capture()` (@akasecurity/plugin-sdk) across
|
|
23775
|
+
// detection + redaction, the work the host session actually waits on.
|
|
23776
|
+
//
|
|
23777
|
+
// Stamped ONLY on live in-flight captures. A capture that carries its own
|
|
23778
|
+
// `occurredAt` is replaying past work (the transcript backfill, the worktree
|
|
23779
|
+
// scan), and its scan duration is not latency any host session experienced,
|
|
23780
|
+
// so those rows leave this ABSENT rather than reporting a misleading number.
|
|
23781
|
+
// Absent is also what every pre-measurement client writes, and what a
|
|
23782
|
+
// clock failure degrades to — a reader must treat absence as "not measured"
|
|
23783
|
+
// and never as a zero, which would read as "inspection is free".
|
|
23784
|
+
inspectionMs: external_exports.number().int().nonnegative().optional(),
|
|
23785
|
+
// What a `redact` this capture COULD NOT CARRY OUT became instead — the
|
|
23786
|
+
// workspace's `redactFallback`, applied because the field could not be
|
|
23787
|
+
// masked in place (a shell command, a URL, or any argument on a host whose
|
|
23788
|
+
// hook contract offers no rewrite channel).
|
|
23789
|
+
//
|
|
23790
|
+
// It exists because the action alone cannot say why. A finding recorded as
|
|
23791
|
+
// `warn` reads identically whether its detection was ASSIGNED Warn or was
|
|
23792
|
+
// assigned Redact on a field that could not take one — and those are
|
|
23793
|
+
// different facts about the same row: the first is a policy the user chose,
|
|
23794
|
+
// the second is a masking the host could not perform. Absent means no
|
|
23795
|
+
// degrade happened, which is every ordinary capture.
|
|
23796
|
+
//
|
|
23797
|
+
// TWO LIMITS a reader of a stored row has to know, because the grain here
|
|
23798
|
+
// is the CAPTURE while `actionTaken` is per FINDING:
|
|
23799
|
+
//
|
|
23800
|
+
// - It does not say WHICH finding degraded. A capture carrying a degraded
|
|
23801
|
+
// `redact` alongside a finding ASSIGNED the same action stores both
|
|
23802
|
+
// identically and one reason for the pair; attributing it to both
|
|
23803
|
+
// describes the assigned one wrongly, and to neither loses the degrade.
|
|
23804
|
+
// - PRESENCE IS NOT CAUSATION. The value is the action the lost redact
|
|
23805
|
+
// became, not the reason the capture ended as it did — a capture denied
|
|
23806
|
+
// by some other finding's own Block policy still carries `block` here,
|
|
23807
|
+
// and clearing the workspace's fallback would not have let it through.
|
|
23808
|
+
// Gate on the value against what a fallback can produce; never read the
|
|
23809
|
+
// field's presence as "this was the fallback's doing".
|
|
23810
|
+
//
|
|
23811
|
+
// Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
|
|
23812
|
+
// Closing either means moving the reason onto the finding row, which
|
|
23813
|
+
// already carries its own action.
|
|
23814
|
+
redactDegradedTo: ActionTaken.optional()
|
|
23815
|
+
}).meta({ id: "EventMetadata" });
|
|
23816
|
+
var Event = external_exports.object({
|
|
23817
|
+
id: external_exports.guid(),
|
|
23818
|
+
sourceTool: SourceTool,
|
|
23819
|
+
kind: EventKind,
|
|
23820
|
+
occurredAt: external_exports.iso.datetime(),
|
|
23821
|
+
contentHash: external_exports.string(),
|
|
23822
|
+
content: external_exports.string(),
|
|
23823
|
+
metadata: EventMetadata.optional()
|
|
23824
|
+
}).meta({ id: "Event" });
|
|
23825
|
+
var IngestEvent = Event.meta({ id: "IngestEvent" });
|
|
23826
|
+
var INGEST_BATCH_MAX = 100;
|
|
23827
|
+
var IngestBatch = external_exports.object({
|
|
23828
|
+
events: external_exports.array(IngestEvent).min(1).max(INGEST_BATCH_MAX),
|
|
23829
|
+
// Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
|
|
23830
|
+
// additionally rejects any event whose contentHash the store has already
|
|
23831
|
+
// recorded — for re-runnable bulk ingest (worktree scan, transcript
|
|
23832
|
+
// backfill), where a re-run mints fresh event ids for identical content and
|
|
23833
|
+
// would otherwise accumulate duplicates. Live hook traffic must NOT set it:
|
|
23834
|
+
// two genuinely separate prompts can be byte-identical and both belong on
|
|
23835
|
+
// the timeline.
|
|
23836
|
+
dedupe: external_exports.literal("content-hash").optional()
|
|
23837
|
+
}).meta({ id: "IngestBatch" });
|
|
23838
|
+
|
|
23577
23839
|
// ../../packages/schema/src/zod/rule.ts
|
|
23578
23840
|
var MatcherType = external_exports.enum(["keyword", "regex"]).meta({ id: "MatcherType" });
|
|
23579
23841
|
var RuleProbeVerdict = external_exports.enum(["safe", "quarantined"]).meta({ id: "RuleProbeVerdict" });
|
|
@@ -23642,7 +23904,10 @@ var Matcher = external_exports.discriminatedUnion("type", [KeywordMatcher, Regex
|
|
|
23642
23904
|
var MATCHER_TYPES = MatcherType.options;
|
|
23643
23905
|
var AppliesTo = external_exports.strictObject({
|
|
23644
23906
|
// Dot-prefixed, e.g. ".py" — matches the scanner's SOURCE_EXTENSIONS shape.
|
|
23645
|
-
extensions: external_exports.array(external_exports.string().regex(/^\.[A-Za-z0-9]+$/)).min(1)
|
|
23907
|
+
extensions: external_exports.array(external_exports.string().regex(/^\.[A-Za-z0-9]+$/)).min(1).optional(),
|
|
23908
|
+
eventKinds: external_exports.array(EventKind).min(1).optional()
|
|
23909
|
+
}).refine((v) => v.extensions !== void 0 || v.eventKinds !== void 0, {
|
|
23910
|
+
message: "appliesTo needs extensions, eventKinds, or both"
|
|
23646
23911
|
}).meta({ id: "AppliesTo" });
|
|
23647
23912
|
var PostValidatorName = external_exports.enum(["entropy", "luhn"]).meta({ id: "PostValidatorName" });
|
|
23648
23913
|
var PostValidatorRef = external_exports.union(
|
|
@@ -23665,6 +23930,7 @@ var PostValidatorRef = external_exports.union(
|
|
|
23665
23930
|
)}) or { "name": ..., "config": { ... } }. An unrecognized name would be a false-positive guard that never runs.`
|
|
23666
23931
|
}
|
|
23667
23932
|
).meta({ id: "PostValidatorRef" });
|
|
23933
|
+
var RuleEvidence = external_exports.enum(["code", "value"]).meta({ id: "RuleEvidence" });
|
|
23668
23934
|
var RequiresNearby = external_exports.strictObject({
|
|
23669
23935
|
// Each array, when present, must be non-empty and contain non-empty strings —
|
|
23670
23936
|
// an empty/blank criterion would either never fire or (for labels) match
|
|
@@ -23687,6 +23953,8 @@ var RuleFixture = external_exports.strictObject({
|
|
|
23687
23953
|
// Simulated file context for the scan, so fixtures can assert `appliesTo`
|
|
23688
23954
|
// gating (e.g. a Python-only pattern must NOT fire in a .ts file).
|
|
23689
23955
|
filePath: external_exports.string().optional(),
|
|
23956
|
+
// Simulated capture kind, so fixtures can assert `appliesTo.eventKinds`.
|
|
23957
|
+
eventKind: EventKind.optional(),
|
|
23690
23958
|
expectedSpans: external_exports.array(external_exports.strictObject({ start: external_exports.number(), end: external_exports.number() })).optional()
|
|
23691
23959
|
}).meta({ id: "RuleFixture" });
|
|
23692
23960
|
var Rule = external_exports.strictObject({
|
|
@@ -23712,7 +23980,9 @@ var Rule = external_exports.strictObject({
|
|
|
23712
23980
|
appliesTo: AppliesTo.optional(),
|
|
23713
23981
|
postValidators: external_exports.array(PostValidatorRef).optional(),
|
|
23714
23982
|
requiresNearby: RequiresNearby.optional(),
|
|
23715
|
-
examples: external_exports.array(external_exports.string()).optional()
|
|
23983
|
+
examples: external_exports.array(external_exports.string()).optional(),
|
|
23984
|
+
// Whether the matched text is itself sensitive. Absent means 'value'.
|
|
23985
|
+
evidence: RuleEvidence.optional()
|
|
23716
23986
|
}).meta({ id: "Rule" });
|
|
23717
23987
|
var Author = external_exports.object({
|
|
23718
23988
|
name: external_exports.string(),
|
|
@@ -23729,7 +23999,11 @@ var PackManifest = external_exports.object({
|
|
|
23729
23999
|
description: external_exports.string().optional(),
|
|
23730
24000
|
author: Author.optional(),
|
|
23731
24001
|
license: external_exports.string().optional(),
|
|
23732
|
-
sourceUrl: external_exports.url().optional()
|
|
24002
|
+
sourceUrl: external_exports.url().optional(),
|
|
24003
|
+
// The built-in policy a FIRST install of this pack assigns
|
|
24004
|
+
// (installed_packs.policy_id). Absent leaves the pack unassigned, so its
|
|
24005
|
+
// rules follow the category policies. An existing install never takes it.
|
|
24006
|
+
defaultPolicy: BuiltinPolicyId.optional()
|
|
23733
24007
|
}).meta({ id: "PackManifest" });
|
|
23734
24008
|
|
|
23735
24009
|
// ../../packages/schema/src/zod/detection.ts
|
|
@@ -23757,10 +24031,12 @@ var DetectionListItem = external_exports.object({
|
|
|
23757
24031
|
// Per-pack enforcement-policy assignment. Holds a BuiltinPolicyId ARCHETYPE
|
|
23758
24032
|
// (monitor|warn|redact|block) — NOT a policies-table Policy.id guid; a
|
|
23759
24033
|
// detection is a PACK, and its policy is the archetype applied to all its
|
|
23760
|
-
// rules. Absent == unassigned, which resolves to Monitor
|
|
23761
|
-
// (DEFAULT_PACK_POLICY_ID)
|
|
23762
|
-
//
|
|
23763
|
-
//
|
|
24034
|
+
// rules. Absent == unassigned, which resolves to Monitor by default
|
|
24035
|
+
// (DEFAULT_PACK_POLICY_ID); a host may resolve it to a policy of its own
|
|
24036
|
+
// (see the dashboard's `unassignedPolicy`). Every enforcement surface
|
|
24037
|
+
// expands it into per-rule policies (see policyIdToAction). Typed
|
|
24038
|
+
// z.string() (not the enum) to keep the OpenAPI response tolerant of a
|
|
24039
|
+
// future custom id.
|
|
23764
24040
|
policyId: external_exports.string().optional(),
|
|
23765
24041
|
// Set ONLY when a newer snapshot is available for this pack (OSS: the
|
|
23766
24042
|
// bundled inventory recorded in available_packs differs from the installed
|
|
@@ -23829,10 +24105,12 @@ var DetectionDetail = external_exports.object({
|
|
|
23829
24105
|
// Per-pack enforcement-policy assignment. Holds a BuiltinPolicyId ARCHETYPE
|
|
23830
24106
|
// (monitor|warn|redact|block) — NOT a policies-table Policy.id guid; a
|
|
23831
24107
|
// detection is a PACK, and its policy is the archetype applied to all its
|
|
23832
|
-
// rules. Absent == unassigned, which resolves to Monitor
|
|
23833
|
-
// (DEFAULT_PACK_POLICY_ID)
|
|
23834
|
-
//
|
|
23835
|
-
//
|
|
24108
|
+
// rules. Absent == unassigned, which resolves to Monitor by default
|
|
24109
|
+
// (DEFAULT_PACK_POLICY_ID); a host may resolve it to a policy of its own
|
|
24110
|
+
// (see the dashboard's `unassignedPolicy`). Every enforcement surface
|
|
24111
|
+
// expands it into per-rule policies (see policyIdToAction). Typed
|
|
24112
|
+
// z.string() (not the enum) to keep the OpenAPI response tolerant of a
|
|
24113
|
+
// future custom id.
|
|
23836
24114
|
policyId: external_exports.string().optional()
|
|
23837
24115
|
}).meta({ id: "DetectionDetail" });
|
|
23838
24116
|
var LibraryItem = external_exports.object({
|
|
@@ -23979,126 +24257,6 @@ function buildDetectionsList(summaries, query) {
|
|
|
23979
24257
|
return { counts, items: filtered.map(summaryToDetectionListItem) };
|
|
23980
24258
|
}
|
|
23981
24259
|
|
|
23982
|
-
// ../../packages/schema/src/zod/event.ts
|
|
23983
|
-
var EventKind = external_exports.enum(["prompt", "response", "code_change", "tool_use"]).meta({ id: "EventKind" });
|
|
23984
|
-
var CAPTURE_EVENT_TYPES_SQL = EventKind.options.map((k) => `'${k}'`).join(",");
|
|
23985
|
-
var EventMetadata = external_exports.object({
|
|
23986
|
-
sessionId: external_exports.string().optional(),
|
|
23987
|
-
repo: external_exports.string().optional(),
|
|
23988
|
-
filePath: external_exports.string().optional(),
|
|
23989
|
-
// The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
|
|
23990
|
-
// set by the tool-scanning hooks. The tool NAME only — never the tool's
|
|
23991
|
-
// arguments or output, which can carry the very value a finding masked
|
|
23992
|
-
// (metadata is stored unredacted). Gives findings on non-file captures a
|
|
23993
|
-
// display location ("via Bash") when no filePath exists.
|
|
23994
|
-
toolName: external_exports.string().optional(),
|
|
23995
|
-
// Set (true) by the worktree scanner when the file is excluded by the
|
|
23996
|
-
// repo's .gitignore. Gitignored files ARE still scanned — local scratch and
|
|
23997
|
-
// generated code can leak real secrets — but the provenance is recorded so
|
|
23998
|
-
// policy/dashboards can treat those findings as informational rather than
|
|
23999
|
-
// blocking. Omitted (not false) for tracked files and non-scan events.
|
|
24000
|
-
gitignored: external_exports.boolean().optional(),
|
|
24001
|
-
// Set (true) ONLY when the event's `content` is the COMPLETE file at
|
|
24002
|
-
// capture time (a worktree scan reading from disk). Hook-captured edits
|
|
24003
|
-
// (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
|
|
24004
|
-
// this. The resolver-on-ingest keys its fixed-at-source dropout
|
|
24005
|
-
// diff on this marker: only a whole-file snapshot can prove a previously
|
|
24006
|
-
// open finding is gone; a fragment's absence proves nothing (the secret
|
|
24007
|
-
// may live outside the hunk). Omitted (not false) for fragments and
|
|
24008
|
-
// non-scan events, so pre-marker clients safely default to the
|
|
24009
|
-
// non-authoritative path.
|
|
24010
|
-
wholeFile: external_exports.boolean().optional(),
|
|
24011
|
-
model: external_exports.string().optional(),
|
|
24012
|
-
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
24013
|
-
// Distributed-tracing correlation. `correlationId` ties a recorded event back
|
|
24014
|
-
// to the request that captured/ingested it (a UUID, generated independently of
|
|
24015
|
-
// the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
|
|
24016
|
-
// originating span when telemetry is enabled. Both optional + backward
|
|
24017
|
-
// compatible — populated by the plugin (see @akasecurity/plugin-sdk).
|
|
24018
|
-
correlationId: external_exports.uuid().optional(),
|
|
24019
|
-
traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
|
|
24020
|
-
// Ids of the detection exceptions that downgraded findings in this capture
|
|
24021
|
-
// to 'allow' — the enforcement audit trail's link back to the grant that
|
|
24022
|
-
// authorized the bypass. Absent on captures where no exception applied.
|
|
24023
|
-
exceptionIds: external_exports.array(external_exports.guid()).optional(),
|
|
24024
|
-
// The assistant message this capture belongs to, and the conversation it sits
|
|
24025
|
-
// in — set by the browser extension's network capture so a stored `response`
|
|
24026
|
-
// row can be joined to the `llm_call` leaf describing the same turn. Absent
|
|
24027
|
-
// on every other capture path, which has no such id.
|
|
24028
|
-
//
|
|
24029
|
-
// Non-empty for the reason WebExchange.messageId is: it is the join key, and
|
|
24030
|
-
// a blank one matches no `llm_call` leaf. That refusal reaches only the
|
|
24031
|
-
// places an event is PARSED; the local write path types the event and parses
|
|
24032
|
-
// nothing, which is why `toCaptureAttributes` omits a blank one separately.
|
|
24033
|
-
messageId: external_exports.string().min(1).optional(),
|
|
24034
|
-
conversationId: external_exports.string().optional(),
|
|
24035
|
-
// How long THIS capture's inspection blocked its caller, in whole
|
|
24036
|
-
// milliseconds — the plugin's own added latency, NOT the LLM call it sat in
|
|
24037
|
-
// front of. Measured inside `capture()` (@akasecurity/plugin-sdk) across
|
|
24038
|
-
// detection + redaction, the work the host session actually waits on.
|
|
24039
|
-
//
|
|
24040
|
-
// Stamped ONLY on live in-flight captures. A capture that carries its own
|
|
24041
|
-
// `occurredAt` is replaying past work (the transcript backfill, the worktree
|
|
24042
|
-
// scan), and its scan duration is not latency any host session experienced,
|
|
24043
|
-
// so those rows leave this ABSENT rather than reporting a misleading number.
|
|
24044
|
-
// Absent is also what every pre-measurement client writes, and what a
|
|
24045
|
-
// clock failure degrades to — a reader must treat absence as "not measured"
|
|
24046
|
-
// and never as a zero, which would read as "inspection is free".
|
|
24047
|
-
inspectionMs: external_exports.number().int().nonnegative().optional(),
|
|
24048
|
-
// What a `redact` this capture COULD NOT CARRY OUT became instead — the
|
|
24049
|
-
// workspace's `redactFallback`, applied because the field could not be
|
|
24050
|
-
// masked in place (a shell command, a URL, or any argument on a host whose
|
|
24051
|
-
// hook contract offers no rewrite channel).
|
|
24052
|
-
//
|
|
24053
|
-
// It exists because the action alone cannot say why. A finding recorded as
|
|
24054
|
-
// `warn` reads identically whether its detection was ASSIGNED Warn or was
|
|
24055
|
-
// assigned Redact on a field that could not take one — and those are
|
|
24056
|
-
// different facts about the same row: the first is a policy the user chose,
|
|
24057
|
-
// the second is a masking the host could not perform. Absent means no
|
|
24058
|
-
// degrade happened, which is every ordinary capture.
|
|
24059
|
-
//
|
|
24060
|
-
// TWO LIMITS a reader of a stored row has to know, because the grain here
|
|
24061
|
-
// is the CAPTURE while `actionTaken` is per FINDING:
|
|
24062
|
-
//
|
|
24063
|
-
// - It does not say WHICH finding degraded. A capture carrying a degraded
|
|
24064
|
-
// `redact` alongside a finding ASSIGNED the same action stores both
|
|
24065
|
-
// identically and one reason for the pair; attributing it to both
|
|
24066
|
-
// describes the assigned one wrongly, and to neither loses the degrade.
|
|
24067
|
-
// - PRESENCE IS NOT CAUSATION. The value is the action the lost redact
|
|
24068
|
-
// became, not the reason the capture ended as it did — a capture denied
|
|
24069
|
-
// by some other finding's own Block policy still carries `block` here,
|
|
24070
|
-
// and clearing the workspace's fallback would not have let it through.
|
|
24071
|
-
// Gate on the value against what a fallback can produce; never read the
|
|
24072
|
-
// field's presence as "this was the fallback's doing".
|
|
24073
|
-
//
|
|
24074
|
-
// Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
|
|
24075
|
-
// Closing either means moving the reason onto the finding row, which
|
|
24076
|
-
// already carries its own action.
|
|
24077
|
-
redactDegradedTo: ActionTaken.optional()
|
|
24078
|
-
}).meta({ id: "EventMetadata" });
|
|
24079
|
-
var Event = external_exports.object({
|
|
24080
|
-
id: external_exports.guid(),
|
|
24081
|
-
sourceTool: SourceTool,
|
|
24082
|
-
kind: EventKind,
|
|
24083
|
-
occurredAt: external_exports.iso.datetime(),
|
|
24084
|
-
contentHash: external_exports.string(),
|
|
24085
|
-
content: external_exports.string(),
|
|
24086
|
-
metadata: EventMetadata.optional()
|
|
24087
|
-
}).meta({ id: "Event" });
|
|
24088
|
-
var IngestEvent = Event.meta({ id: "IngestEvent" });
|
|
24089
|
-
var INGEST_BATCH_MAX = 100;
|
|
24090
|
-
var IngestBatch = external_exports.object({
|
|
24091
|
-
events: external_exports.array(IngestEvent).min(1).max(INGEST_BATCH_MAX),
|
|
24092
|
-
// Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
|
|
24093
|
-
// additionally rejects any event whose contentHash the store has already
|
|
24094
|
-
// recorded — for re-runnable bulk ingest (worktree scan, transcript
|
|
24095
|
-
// backfill), where a re-run mints fresh event ids for identical content and
|
|
24096
|
-
// would otherwise accumulate duplicates. Live hook traffic must NOT set it:
|
|
24097
|
-
// two genuinely separate prompts can be byte-identical and both belong on
|
|
24098
|
-
// the timeline.
|
|
24099
|
-
dedupe: external_exports.literal("content-hash").optional()
|
|
24100
|
-
}).meta({ id: "IngestBatch" });
|
|
24101
|
-
|
|
24102
24260
|
// ../../packages/schema/src/zod/exception.ts
|
|
24103
24261
|
var ExceptionScope = external_exports.enum(["once", "temporary", "permanent"]);
|
|
24104
24262
|
var ExceptionConditions = external_exports.object({
|
|
@@ -24566,6 +24724,8 @@ function toInstanceDetail(row) {
|
|
|
24566
24724
|
provider: toApiProvider(row.sourceTool),
|
|
24567
24725
|
repo: row.repo,
|
|
24568
24726
|
file: row.file,
|
|
24727
|
+
...row.line === void 0 ? {} : { line: row.line },
|
|
24728
|
+
...row.col === void 0 ? {} : { col: row.col },
|
|
24569
24729
|
...row.toolName === void 0 ? {} : { toolName: row.toolName },
|
|
24570
24730
|
eventId: row.eventId,
|
|
24571
24731
|
...row.sessionId === void 0 ? {} : { sessionId: row.sessionId },
|
|
@@ -24579,7 +24739,11 @@ function toInstanceDetail(row) {
|
|
|
24579
24739
|
category,
|
|
24580
24740
|
subtype: row.ruleId,
|
|
24581
24741
|
severity: row.severity,
|
|
24582
|
-
match: {
|
|
24742
|
+
match: {
|
|
24743
|
+
maskedValue: row.maskedMatch,
|
|
24744
|
+
contextPrefix: "",
|
|
24745
|
+
...row.context === void 0 ? {} : { context: row.context }
|
|
24746
|
+
},
|
|
24583
24747
|
detection: { id: row.ruleId, name: null },
|
|
24584
24748
|
policy: { id: `category:${category}`, name: category }
|
|
24585
24749
|
};
|
|
@@ -24691,8 +24855,6 @@ var Policy = external_exports.object({
|
|
|
24691
24855
|
// test `prohibitedModels` passes and `reversibleRuleIds` fails.
|
|
24692
24856
|
provenance: PolicyProvenance.optional()
|
|
24693
24857
|
}).meta({ id: "Policy" });
|
|
24694
|
-
var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
|
|
24695
|
-
var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
|
|
24696
24858
|
var RedactFallback = BuiltinPolicyId.extract(["monitor", "warn", "block"]).meta({
|
|
24697
24859
|
id: "RedactFallback"
|
|
24698
24860
|
});
|
|
@@ -24927,10 +25089,15 @@ var ParsedPointer = external_exports.object({
|
|
|
24927
25089
|
});
|
|
24928
25090
|
var VaultEntry = external_exports.object({
|
|
24929
25091
|
pointerId: external_exports.string(),
|
|
24930
|
-
// The keyed HMAC of the raw
|
|
24931
|
-
// derived under.
|
|
24932
|
-
// independently of the vault encryption
|
|
25092
|
+
// The keyed HMAC of the EXACT raw bytes under `exception.key`, and the epoch it
|
|
25093
|
+
// was derived under. The vault's own dedupe key: a value and its invisibly
|
|
25094
|
+
// padded twin are two rows. It rotates independently of the vault encryption
|
|
25095
|
+
// key below. Never matched against an exception or grant.
|
|
24933
25096
|
valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
25097
|
+
// The same HMAC over the raw with invisible padding removed: the identity a
|
|
25098
|
+
// reveal-to-model grant and every exception match on. Shared by a value and
|
|
25099
|
+
// its padded twin.
|
|
25100
|
+
valueIdentityFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
24934
25101
|
fingerprintKeyVersion: external_exports.number().int().positive(),
|
|
24935
25102
|
// The vault-key epoch this row's ciphertext was sealed under.
|
|
24936
25103
|
keyVersion: external_exports.number().int().positive(),
|
|
@@ -25074,7 +25241,7 @@ var VaultConsent = external_exports.object({
|
|
|
25074
25241
|
});
|
|
25075
25242
|
|
|
25076
25243
|
// ../../packages/schema/src/zod/local.ts
|
|
25077
|
-
var WORKSPACE_SETTINGS_SPEC_VERSION =
|
|
25244
|
+
var WORKSPACE_SETTINGS_SPEC_VERSION = 9;
|
|
25078
25245
|
var MODEL_JUDGE_PAYLOAD_VERSION = 1;
|
|
25079
25246
|
var RunMode = external_exports.enum(["standalone", "attached"]);
|
|
25080
25247
|
var ControlPlaneConnection = external_exports.object({
|
|
@@ -25094,6 +25261,18 @@ var HistorySyncConsent = external_exports.object({
|
|
|
25094
25261
|
payloadVersion: external_exports.number().int().positive(),
|
|
25095
25262
|
endpoint: external_exports.string()
|
|
25096
25263
|
});
|
|
25264
|
+
var ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH = 512;
|
|
25265
|
+
var AttachmentScopeEntry = external_exports.object({
|
|
25266
|
+
kind: external_exports.enum(["repo", "account"]),
|
|
25267
|
+
identity: printable(ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH).min(1),
|
|
25268
|
+
label: printable(80).optional(),
|
|
25269
|
+
enrolledAt: external_exports.iso.datetime()
|
|
25270
|
+
});
|
|
25271
|
+
var AttachmentScope = external_exports.object({
|
|
25272
|
+
endpoint: external_exports.string().min(1),
|
|
25273
|
+
entries: external_exports.array(AttachmentScopeEntry)
|
|
25274
|
+
});
|
|
25275
|
+
var AttachmentScopeEnvelope = AttachmentScope.extend({ entries: external_exports.array(external_exports.unknown()) });
|
|
25097
25276
|
var WebChatCaptureConsent = external_exports.object({
|
|
25098
25277
|
acknowledgedAt: external_exports.iso.datetime(),
|
|
25099
25278
|
version: external_exports.number().int().positive()
|
|
@@ -25164,6 +25343,23 @@ var WorkspaceSettings = external_exports.object({
|
|
|
25164
25343
|
// both widenings. Absent until granted, and a grant for a different endpoint
|
|
25165
25344
|
// or an older payload no longer counts.
|
|
25166
25345
|
historySyncConsent: HistorySyncConsent.optional(),
|
|
25346
|
+
// The identities a SCOPED attachment forwards and the deployment they were
|
|
25347
|
+
// enrolled for (see AttachmentScope). Absent until something is enrolled.
|
|
25348
|
+
//
|
|
25349
|
+
// `z.unknown()`, NOT `AttachmentScope`, and the difference is this field's
|
|
25350
|
+
// whole failure mode. A settings.json that fails this schema reads as the
|
|
25351
|
+
// unonboarded defaults (readUserSettings in @akasecurity/persistence), and the
|
|
25352
|
+
// next save writes those defaults back over it. Typed, one entry with an
|
|
25353
|
+
// unknown `kind`, a control character or a bad timestamp would cost the
|
|
25354
|
+
// attachment, every consent and onboardedAt, permanently. Untyped, the value
|
|
25355
|
+
// is kept exactly as found and validated where it is used: parseAttachmentScope
|
|
25356
|
+
// drops a bad entry by itself, and on a scoped attachment resolveScope reads a
|
|
25357
|
+
// bad envelope as no entries, which keeps every event local.
|
|
25358
|
+
//
|
|
25359
|
+
// No default: absent must stay absent, so defaultWorkspaceSettings() and a
|
|
25360
|
+
// fresh settings.json do not change. No `.meta({ id })`, like every field
|
|
25361
|
+
// here. Not a ManagedSettingKey.
|
|
25362
|
+
attachmentScope: external_exports.unknown().optional(),
|
|
25167
25363
|
// What the browser extension may record from a web chat, and the grant that
|
|
25168
25364
|
// authorizes it. Absent until the user answers: recording something that was
|
|
25169
25365
|
// never recorded before is never an assumed grant on upgrade, so the whole
|
|
@@ -25261,7 +25457,10 @@ function toInspectionFindingRow(input2) {
|
|
|
25261
25457
|
actionTaken: input2.actionTaken,
|
|
25262
25458
|
confidence: input2.confidence,
|
|
25263
25459
|
findingKey: input2.findingKey ?? null,
|
|
25264
|
-
firstDetectedAt: input2.firstDetectedAt ? isoToEpochMillis(input2.firstDetectedAt) : null
|
|
25460
|
+
firstDetectedAt: input2.firstDetectedAt ? isoToEpochMillis(input2.firstDetectedAt) : null,
|
|
25461
|
+
line: input2.line ?? null,
|
|
25462
|
+
col: input2.col ?? null,
|
|
25463
|
+
context: input2.context ? JSON.stringify(input2.context) : null
|
|
25265
25464
|
};
|
|
25266
25465
|
}
|
|
25267
25466
|
function toCaptureAttributes(event) {
|
|
@@ -25506,10 +25705,18 @@ var SeveritySummaryItem = external_exports.object({
|
|
|
25506
25705
|
count: external_exports.number().int().nonnegative(),
|
|
25507
25706
|
// Resolution-aware breakdown (optional, additive). Populated once findings
|
|
25508
25707
|
// carry lifecycle state: `caught` = handled in-flight (enforced); `openAtRest`
|
|
25509
|
-
// = still open with no in-flight enforcement (needs remediation)
|
|
25510
|
-
//
|
|
25708
|
+
// = still open with no in-flight enforcement (needs remediation); `dismissed`
|
|
25709
|
+
// = closed by a human judgement rather than a fix — visible, but not counted as
|
|
25710
|
+
// needing remediation. The three are disjoint. Absent on the legacy count-only
|
|
25711
|
+
// response until the resolution feature lands.
|
|
25511
25712
|
caught: external_exports.number().int().nonnegative().optional(),
|
|
25512
|
-
openAtRest: external_exports.number().int().nonnegative().optional()
|
|
25713
|
+
openAtRest: external_exports.number().int().nonnegative().optional(),
|
|
25714
|
+
dismissed: external_exports.number().int().nonnegative().optional(),
|
|
25715
|
+
// The two halves of `caught`, for a reader that wants them apart: `handled` =
|
|
25716
|
+
// in-flight findings an enforcement action already contained; `resolved` =
|
|
25717
|
+
// at-rest findings closed out by fixing them. `handled + resolved === caught`.
|
|
25718
|
+
handled: external_exports.number().int().nonnegative().optional(),
|
|
25719
|
+
resolved: external_exports.number().int().nonnegative().optional()
|
|
25513
25720
|
}).meta({ id: "SeveritySummaryItem" });
|
|
25514
25721
|
var SeveritySummaryResponse = external_exports.object({
|
|
25515
25722
|
// Sum of bySeverity[].count.
|
|
@@ -25517,6 +25724,9 @@ var SeveritySummaryResponse = external_exports.object({
|
|
|
25517
25724
|
// Findings still open at rest (sum of bySeverity[].openAtRest). Optional and
|
|
25518
25725
|
// additive — absent on the legacy response until the resolution feature lands.
|
|
25519
25726
|
needsRemediation: external_exports.number().int().nonnegative().optional(),
|
|
25727
|
+
// Findings a user dismissed (sum of bySeverity[].dismissed). Excluded from
|
|
25728
|
+
// needsRemediation, and kept visible here so an accepted risk is not erased.
|
|
25729
|
+
dismissed: external_exports.number().int().nonnegative().optional(),
|
|
25520
25730
|
// All four severity levels are always present (count may be 0).
|
|
25521
25731
|
bySeverity: external_exports.array(SeveritySummaryItem)
|
|
25522
25732
|
}).meta({ id: "SeveritySummaryResponse" });
|
|
@@ -26402,6 +26612,15 @@ var COUNTED_SCOPE = `
|
|
|
26402
26612
|
OR outbox_owed = 1
|
|
26403
26613
|
)`;
|
|
26404
26614
|
var SKIPPED = -1;
|
|
26615
|
+
function inScope(column) {
|
|
26616
|
+
return `${column} IN (SELECT value FROM json_each(:scopeKeys))`;
|
|
26617
|
+
}
|
|
26618
|
+
function scopeKeysParam(scopeKeys) {
|
|
26619
|
+
return JSON.stringify(scopeKeys);
|
|
26620
|
+
}
|
|
26621
|
+
var ROOT_SCOPE_KEY = `(SELECT session_root.scope_key
|
|
26622
|
+
FROM audit_events AS session_root
|
|
26623
|
+
WHERE session_root.id = COALESCE(audit_events.root_session_id, audit_events.id))`;
|
|
26405
26624
|
var ROW_COLUMNS = `id,
|
|
26406
26625
|
parent_id AS parentId,
|
|
26407
26626
|
root_session_id AS rootSessionId,
|
|
@@ -26430,6 +26649,18 @@ var SqliteHistorySyncRepository = class {
|
|
|
26430
26649
|
ORDER BY earliest
|
|
26431
26650
|
LIMIT :limit`
|
|
26432
26651
|
);
|
|
26652
|
+
this.scopedSessionsStmt = db.prepare(
|
|
26653
|
+
`SELECT COALESCE(root_session_id, id) AS sessionId, MIN(started_at) AS earliest
|
|
26654
|
+
FROM audit_events
|
|
26655
|
+
WHERE synced_at IS NULL
|
|
26656
|
+
AND event_type IN (${TYPE_LIST})
|
|
26657
|
+
AND started_at < :before
|
|
26658
|
+
AND ${inScope("scope_key")}
|
|
26659
|
+
AND ${inScope(ROOT_SCOPE_KEY)}
|
|
26660
|
+
GROUP BY sessionId
|
|
26661
|
+
ORDER BY earliest
|
|
26662
|
+
LIMIT :limit`
|
|
26663
|
+
);
|
|
26433
26664
|
this.rowsStmt = db.prepare(
|
|
26434
26665
|
`SELECT ${ROW_COLUMNS}
|
|
26435
26666
|
FROM audit_events
|
|
@@ -26440,6 +26671,18 @@ var SqliteHistorySyncRepository = class {
|
|
|
26440
26671
|
ORDER BY (event_type = 'session') DESC, started_at
|
|
26441
26672
|
LIMIT :limit`
|
|
26442
26673
|
);
|
|
26674
|
+
this.scopedRowsStmt = db.prepare(
|
|
26675
|
+
`SELECT ${ROW_COLUMNS}
|
|
26676
|
+
FROM audit_events
|
|
26677
|
+
WHERE synced_at IS NULL
|
|
26678
|
+
AND event_type IN (${TYPE_LIST})
|
|
26679
|
+
AND started_at < :before
|
|
26680
|
+
AND COALESCE(root_session_id, id) = :sessionId
|
|
26681
|
+
AND ${inScope("scope_key")}
|
|
26682
|
+
AND ${inScope(ROOT_SCOPE_KEY)}
|
|
26683
|
+
ORDER BY (event_type = 'session') DESC, started_at
|
|
26684
|
+
LIMIT :limit`
|
|
26685
|
+
);
|
|
26443
26686
|
this.captureRowsStmt = db.prepare(
|
|
26444
26687
|
`SELECT ${ROW_COLUMNS}
|
|
26445
26688
|
FROM audit_events
|
|
@@ -26451,6 +26694,18 @@ var SqliteHistorySyncRepository = class {
|
|
|
26451
26694
|
ORDER BY started_at
|
|
26452
26695
|
LIMIT :limit`
|
|
26453
26696
|
);
|
|
26697
|
+
this.scopedCaptureRowsStmt = db.prepare(
|
|
26698
|
+
`SELECT ${ROW_COLUMNS}
|
|
26699
|
+
FROM audit_events
|
|
26700
|
+
WHERE synced_at IS NULL
|
|
26701
|
+
AND sync_claimed_at IS NULL
|
|
26702
|
+
AND outbox_owed = 1
|
|
26703
|
+
AND event_type IN (${CAPTURE_TYPE_LIST})
|
|
26704
|
+
AND started_at < :before
|
|
26705
|
+
AND ${inScope("scope_key")}
|
|
26706
|
+
ORDER BY started_at
|
|
26707
|
+
LIMIT :limit`
|
|
26708
|
+
);
|
|
26454
26709
|
this.markOwedStmt = db.prepare(
|
|
26455
26710
|
`UPDATE audit_events SET outbox_owed = 1 WHERE id = :id AND synced_at IS NULL`
|
|
26456
26711
|
);
|
|
@@ -26460,6 +26715,20 @@ var SqliteHistorySyncRepository = class {
|
|
|
26460
26715
|
AND event_type IN (${CAPTURE_TYPE_LIST})
|
|
26461
26716
|
AND started_at < :before`
|
|
26462
26717
|
);
|
|
26718
|
+
this.scopedCaptureBacklogOwedStmt = db.prepare(
|
|
26719
|
+
`UPDATE audit_events SET outbox_owed = 1
|
|
26720
|
+
WHERE synced_at IS NULL
|
|
26721
|
+
AND event_type IN (${CAPTURE_TYPE_LIST})
|
|
26722
|
+
AND started_at < :before
|
|
26723
|
+
AND ${inScope("scope_key")}`
|
|
26724
|
+
);
|
|
26725
|
+
this.markScopeCapturesOwedStmt = db.prepare(
|
|
26726
|
+
`UPDATE audit_events SET outbox_owed = 1
|
|
26727
|
+
WHERE synced_at IS NULL
|
|
26728
|
+
AND outbox_owed IS NULL
|
|
26729
|
+
AND event_type IN (${CAPTURE_TYPE_LIST})
|
|
26730
|
+
AND ${inScope("scope_key")}`
|
|
26731
|
+
);
|
|
26463
26732
|
this.stampStmt = db.prepare(
|
|
26464
26733
|
`UPDATE audit_events
|
|
26465
26734
|
SET synced_at = :at,
|
|
@@ -26618,6 +26887,15 @@ var SqliteHistorySyncRepository = class {
|
|
|
26618
26887
|
claimRowStmt;
|
|
26619
26888
|
releaseRowStmt;
|
|
26620
26889
|
releaseStaleClaimsStmt;
|
|
26890
|
+
// The SCOPED twins, for a scoped attachment: the same reads and seeds with the
|
|
26891
|
+
// scope clause added, prepared once here beside the machine statements, so a
|
|
26892
|
+
// machine attachment's statements are untouched and neither form is compiled
|
|
26893
|
+
// per call.
|
|
26894
|
+
scopedSessionsStmt;
|
|
26895
|
+
scopedRowsStmt;
|
|
26896
|
+
scopedCaptureRowsStmt;
|
|
26897
|
+
scopedCaptureBacklogOwedStmt;
|
|
26898
|
+
markScopeCapturesOwedStmt;
|
|
26621
26899
|
/**
|
|
26622
26900
|
* The masked detections recorded against one tool call.
|
|
26623
26901
|
*
|
|
@@ -26637,15 +26915,33 @@ var SqliteHistorySyncRepository = class {
|
|
|
26637
26915
|
* path's to deliver; this drain exists for what was recorded before it, and a
|
|
26638
26916
|
* row both paths send is at best a duplicate request and at worst — for a
|
|
26639
26917
|
* session root — an overwrite of the inventory ids the live path resolved.
|
|
26918
|
+
*
|
|
26919
|
+
* `scopeKeys` is a scoped attachment's filter: a session is offered only while
|
|
26920
|
+
* its root's key is one of them AND at least one of its unsent rows' keys is
|
|
26921
|
+
* (see scopedSessionsStmt). Omitted, this runs the machine statement,
|
|
26922
|
+
* unchanged; an empty list offers nothing.
|
|
26640
26923
|
*/
|
|
26641
|
-
pendingSessions(limit, before) {
|
|
26642
|
-
|
|
26643
|
-
|
|
26644
|
-
|
|
26924
|
+
pendingSessions(limit, before, scopeKeys) {
|
|
26925
|
+
const rows = scopeKeys === void 0 ? allRows(this.sessionsStmt, { limit, before }) : allRows(this.scopedSessionsStmt, {
|
|
26926
|
+
limit,
|
|
26927
|
+
before,
|
|
26928
|
+
scopeKeys: scopeKeysParam(scopeKeys)
|
|
26929
|
+
});
|
|
26930
|
+
return rows.map((r) => r.sessionId);
|
|
26645
26931
|
}
|
|
26646
|
-
/**
|
|
26647
|
-
|
|
26648
|
-
|
|
26932
|
+
/**
|
|
26933
|
+
* One session's undelivered structural rows within the backlog, root first.
|
|
26934
|
+
*
|
|
26935
|
+
* With `scopeKeys`, only the rows whose own key AND whose session root's key
|
|
26936
|
+
* are among them, whichever session id is passed.
|
|
26937
|
+
*/
|
|
26938
|
+
pendingRows(sessionId, limit, before, scopeKeys) {
|
|
26939
|
+
return scopeKeys === void 0 ? allRows(this.rowsStmt, { sessionId, limit, before }) : allRows(this.scopedRowsStmt, {
|
|
26940
|
+
sessionId,
|
|
26941
|
+
limit,
|
|
26942
|
+
before,
|
|
26943
|
+
scopeKeys: scopeKeysParam(scopeKeys)
|
|
26944
|
+
});
|
|
26649
26945
|
}
|
|
26650
26946
|
/**
|
|
26651
26947
|
* Captures this machine still owes the deployment, oldest first.
|
|
@@ -26654,9 +26950,17 @@ var SqliteHistorySyncRepository = class {
|
|
|
26654
26950
|
* by a time window — see captureRowsStmt for why a window could not express
|
|
26655
26951
|
* this. `before` is the grace window that leaves a just-recorded capture to
|
|
26656
26952
|
* the live path.
|
|
26953
|
+
*
|
|
26954
|
+
* With `scopeKeys`, only captures stamped with one of them, decided per
|
|
26955
|
+
* capture: /v1/events stubs a missing root, so a capture never waits on its
|
|
26956
|
+
* session's scope. An empty list reads nothing.
|
|
26657
26957
|
*/
|
|
26658
|
-
pendingCaptureRows(limit, before) {
|
|
26659
|
-
return allRows(this.captureRowsStmt, { limit, before })
|
|
26958
|
+
pendingCaptureRows(limit, before, scopeKeys) {
|
|
26959
|
+
return scopeKeys === void 0 ? allRows(this.captureRowsStmt, { limit, before }) : allRows(this.scopedCaptureRowsStmt, {
|
|
26960
|
+
limit,
|
|
26961
|
+
before,
|
|
26962
|
+
scopeKeys: scopeKeysParam(scopeKeys)
|
|
26963
|
+
});
|
|
26660
26964
|
}
|
|
26661
26965
|
/**
|
|
26662
26966
|
* Record that a capture is OWED to the deployment.
|
|
@@ -26688,9 +26992,37 @@ var SqliteHistorySyncRepository = class {
|
|
|
26688
26992
|
* Returns how many rows matched, for the caller to log or test against. Not a
|
|
26689
26993
|
* count of NEWLY marked rows — a row still unsynced from an earlier call
|
|
26690
26994
|
* matches again and is counted again, the same as `UPDATE`'s own `changes`.
|
|
26995
|
+
*
|
|
26996
|
+
* `scopeKeys` scopes it for a scoped attachment: only captures stamped with one
|
|
26997
|
+
* of the keys are marked, and an empty list marks none. The scoped capture read
|
|
26998
|
+
* is what keeps a personal capture out of a batch; this keeps the marker to
|
|
26999
|
+
* what the grant covers. Omitted, it runs the machine statement, unchanged.
|
|
27000
|
+
*/
|
|
27001
|
+
markCaptureBacklogOwed(before, scopeKeys) {
|
|
27002
|
+
const result = scopeKeys === void 0 ? this.markCaptureBacklogOwedStmt.run({ before }) : this.scopedCaptureBacklogOwedStmt.run({ before, scopeKeys: scopeKeysParam(scopeKeys) });
|
|
27003
|
+
return Number(result.changes);
|
|
27004
|
+
}
|
|
27005
|
+
/**
|
|
27006
|
+
* Mark owed every unsent capture stamped with one of `scopeKeys`: the re-seed
|
|
27007
|
+
* an enrollment runs.
|
|
27008
|
+
*
|
|
27009
|
+
* This ASSUMES the contract a scoped caller keeps, and cannot check it: nothing
|
|
27010
|
+
* else marks an out-of-scope capture owed (the live forward must refuse it
|
|
27011
|
+
* before its owed branch, and the consent-time seed must be handed the key
|
|
27012
|
+
* list). Under that contract, an enrolled repository's unsent captures are
|
|
27013
|
+
* reachable only if this runs when the repository is enrolled. Like the
|
|
27014
|
+
* consent seed it is one explicit human action, never something a pass infers,
|
|
27015
|
+
* and its caller must know the history grant is in force: this method cannot
|
|
27016
|
+
* check consent and must not be called without it.
|
|
27017
|
+
*
|
|
27018
|
+
* No time bound. Delivered and skipped rows are never re-opened, and a row
|
|
27019
|
+
* already owed is not counted, so the return value is how many rows this call
|
|
27020
|
+
* newly marked. An empty list marks nothing.
|
|
26691
27021
|
*/
|
|
26692
|
-
|
|
26693
|
-
return Number(
|
|
27022
|
+
markScopeCapturesOwed(scopeKeys) {
|
|
27023
|
+
return Number(
|
|
27024
|
+
this.markScopeCapturesOwedStmt.run({ scopeKeys: scopeKeysParam(scopeKeys) }).changes
|
|
27025
|
+
);
|
|
26694
27026
|
}
|
|
26695
27027
|
/**
|
|
26696
27028
|
* Record delivery. Called only AFTER the far side has accepted the rows.
|
|
@@ -26895,8 +27227,12 @@ var SqliteHistorySyncRepository = class {
|
|
|
26895
27227
|
* disown from eating THIS SAME CALL's own re-mark is the order, not the
|
|
26896
27228
|
* bound — disown runs first, re-mark second, both inside the one
|
|
26897
27229
|
* transaction above.
|
|
27230
|
+
*
|
|
27231
|
+
* `scopeKeys` scopes the re-mark exactly as `markCaptureBacklogOwed` is scoped.
|
|
27232
|
+
* The disown before it is not scoped, and must not be: it clears the previous
|
|
27233
|
+
* deployment's markers whatever their scope.
|
|
26898
27234
|
*/
|
|
26899
|
-
rearmFor(fingerprint, backlogBefore, backfillCapturesBefore) {
|
|
27235
|
+
rearmFor(fingerprint, backlogBefore, backfillCapturesBefore, scopeKeys) {
|
|
26900
27236
|
this.ensureRowStmt.run();
|
|
26901
27237
|
withTransaction(
|
|
26902
27238
|
this.db,
|
|
@@ -26907,7 +27243,7 @@ var SqliteHistorySyncRepository = class {
|
|
|
26907
27243
|
this.disownCapturesStmt.run({ attachedAt: backlogBefore });
|
|
26908
27244
|
}
|
|
26909
27245
|
if (backfillCapturesBefore !== void 0) {
|
|
26910
|
-
this.
|
|
27246
|
+
this.markCaptureBacklogOwed(backfillCapturesBefore, scopeKeys);
|
|
26911
27247
|
}
|
|
26912
27248
|
this.setFingerprintStmt.run({ fingerprint, backlogBefore });
|
|
26913
27249
|
},
|
|
@@ -27073,6 +27409,7 @@ function applyMigrations(db, file2, options = {}) {
|
|
|
27073
27409
|
db.exec(`PRAGMA user_version = ${String(SQLITE_MIGRATIONS.length)}`);
|
|
27074
27410
|
}
|
|
27075
27411
|
ensureSyncedAtColumn(db, "audit_events");
|
|
27412
|
+
ensureScopeKeyColumn(db);
|
|
27076
27413
|
ensureScanLedgerTable(db);
|
|
27077
27414
|
ensureHistorySyncTable(db);
|
|
27078
27415
|
ensureBlockedDetectionsTable(db);
|
|
@@ -27498,6 +27835,21 @@ function ensureSyncedAtColumn(db, table) {
|
|
|
27498
27835
|
ON audit_events (sync_claimed_at) WHERE sync_claimed_at IS NOT NULL`
|
|
27499
27836
|
);
|
|
27500
27837
|
}
|
|
27838
|
+
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";
|
|
27839
|
+
function ensureScopeKeyColumn(db) {
|
|
27840
|
+
if (!schemaObjectExists(db, "table", "audit_events")) return;
|
|
27841
|
+
if (hasScopeKeyColumn(db)) return;
|
|
27842
|
+
withTransaction(
|
|
27843
|
+
db,
|
|
27844
|
+
() => {
|
|
27845
|
+
if (!hasScopeKeyColumn(db)) db.exec(SCOPE_KEY_COLUMN_DDL);
|
|
27846
|
+
},
|
|
27847
|
+
"IMMEDIATE"
|
|
27848
|
+
);
|
|
27849
|
+
}
|
|
27850
|
+
function hasScopeKeyColumn(db) {
|
|
27851
|
+
return columnNames(db, "audit_events", { includeGenerated: true }).includes("scope_key");
|
|
27852
|
+
}
|
|
27501
27853
|
function ensureScanLedgerTable(db) {
|
|
27502
27854
|
db.exec(`CREATE TABLE IF NOT EXISTS scan_ledger (
|
|
27503
27855
|
path TEXT PRIMARY KEY,
|
|
@@ -28375,6 +28727,19 @@ var SqliteAuditEventsRepository = class {
|
|
|
28375
28727
|
if (typeof provider === "string") return provider;
|
|
28376
28728
|
return void 0;
|
|
28377
28729
|
}
|
|
28730
|
+
// The `scope_key` stored on a session root's attributes: the key the history
|
|
28731
|
+
// drain decides that root by. It is NOT necessarily the key of the root event a
|
|
28732
|
+
// caller just wrote, because roots are first-write-wins (see the session-root
|
|
28733
|
+
// upsert above) and the root event that arrives second leaves the stored row as
|
|
28734
|
+
// it was. Returns undefined when the id is not a session root, when the root is
|
|
28735
|
+
// a stub or carries no key, and when the stored value is not a string, which is
|
|
28736
|
+
// what the drain's scoped reads would not match either.
|
|
28737
|
+
sessionScopeKey(sessionId) {
|
|
28738
|
+
const row = this.findById(sessionId);
|
|
28739
|
+
if (row?.event_type !== "session" || !row.attributes) return void 0;
|
|
28740
|
+
const key = parseJsonObject(row.attributes)?.scope_key;
|
|
28741
|
+
return typeof key === "string" ? key : void 0;
|
|
28742
|
+
}
|
|
28378
28743
|
// Every `llm_call` leaf's session id + raw attribute bag, for the read-time token
|
|
28379
28744
|
// rollups. The caller parses each bag and prices it via the
|
|
28380
28745
|
// cost model — we stay a thin reader here (no business logic, no cost). `root_session_id`
|
|
@@ -28395,6 +28760,8 @@ var SqliteAuditEventsRepository = class {
|
|
|
28395
28760
|
var DEFAULT_BATCH_SIZE = 500;
|
|
28396
28761
|
var DEFAULT_MAX_ROWS = 5e4;
|
|
28397
28762
|
var SYNC_LANE_TYPES_SQL = OUTBOX_CAPTURE_TYPE_LIST;
|
|
28763
|
+
var SWEEP = { kind: "sweep" };
|
|
28764
|
+
var HOLD_ALL = { kind: "hold-all" };
|
|
28398
28765
|
var SqliteBodyRetentionRepository = class {
|
|
28399
28766
|
constructor(db) {
|
|
28400
28767
|
this.db = db;
|
|
@@ -28411,6 +28778,14 @@ var SqliteBodyRetentionRepository = class {
|
|
|
28411
28778
|
this.candidatesSyncSafeStmt = this.db.prepare(
|
|
28412
28779
|
select(`AND (event_type NOT IN (${SYNC_LANE_TYPES_SQL}) OR synced_at IS NOT NULL)`)
|
|
28413
28780
|
);
|
|
28781
|
+
this.candidatesScopedStmt = this.db.prepare(
|
|
28782
|
+
select(
|
|
28783
|
+
`AND (event_type NOT IN (${SYNC_LANE_TYPES_SQL}) OR synced_at IS NOT NULL
|
|
28784
|
+
OR (outbox_owed IS NOT 1
|
|
28785
|
+
AND (scope_key IS NULL
|
|
28786
|
+
OR scope_key NOT IN (SELECT value FROM json_each(:scopeKeys)))))`
|
|
28787
|
+
)
|
|
28788
|
+
);
|
|
28414
28789
|
this.heldBySyncStmt = this.db.prepare(`
|
|
28415
28790
|
SELECT COUNT(*) AS n
|
|
28416
28791
|
FROM audit_events
|
|
@@ -28418,37 +28793,63 @@ var SqliteBodyRetentionRepository = class {
|
|
|
28418
28793
|
AND started_at < :cutoff
|
|
28419
28794
|
AND event_type IN (${SYNC_LANE_TYPES_SQL})
|
|
28420
28795
|
AND synced_at IS NULL`);
|
|
28796
|
+
this.heldByScopeStmt = this.db.prepare(`
|
|
28797
|
+
SELECT COUNT(*) AS n
|
|
28798
|
+
FROM audit_events
|
|
28799
|
+
WHERE content IS NOT NULL
|
|
28800
|
+
AND started_at < :cutoff
|
|
28801
|
+
AND event_type IN (${SYNC_LANE_TYPES_SQL})
|
|
28802
|
+
AND synced_at IS NULL
|
|
28803
|
+
AND (outbox_owed = 1
|
|
28804
|
+
OR scope_key IN (SELECT value FROM json_each(:scopeKeys)))`);
|
|
28421
28805
|
this.expireStmt = this.db.prepare(
|
|
28422
28806
|
`UPDATE audit_events SET content = NULL, content_expired_at = :now WHERE id = :id`
|
|
28423
28807
|
);
|
|
28808
|
+
this.expireContextsStmt = this.db.prepare(
|
|
28809
|
+
`UPDATE inspection_findings SET context = NULL
|
|
28810
|
+
WHERE id IN (
|
|
28811
|
+
SELECT f.id
|
|
28812
|
+
FROM inspection_findings f INDEXED BY idx_inspection_findings_context
|
|
28813
|
+
JOIN audit_events e ON e.id = f.audit_event_id
|
|
28814
|
+
WHERE f.context IS NOT NULL
|
|
28815
|
+
AND f.first_detected_at < :cutoff
|
|
28816
|
+
AND e.content IS NULL
|
|
28817
|
+
AND e.started_at < :cutoff
|
|
28818
|
+
LIMIT :limit)`
|
|
28819
|
+
);
|
|
28424
28820
|
}
|
|
28425
28821
|
db;
|
|
28426
28822
|
candidatesStmt;
|
|
28427
28823
|
candidatesSyncSafeStmt;
|
|
28824
|
+
candidatesScopedStmt;
|
|
28428
28825
|
heldBySyncStmt;
|
|
28826
|
+
heldByScopeStmt;
|
|
28429
28827
|
expireStmt;
|
|
28430
|
-
|
|
28828
|
+
expireContextsStmt;
|
|
28829
|
+
/**
|
|
28830
|
+
* How many body bytes a pass with these options would free, changing
|
|
28831
|
+
* nothing. Finding excerpts are not counted (see `bytesFreed`).
|
|
28832
|
+
*/
|
|
28431
28833
|
preview(opts) {
|
|
28432
|
-
const
|
|
28433
|
-
const
|
|
28434
|
-
const rows = stmt.all({ cutoff: opts.cutoff, limit });
|
|
28834
|
+
const lane = laneOf(opts.sweepSyncLane);
|
|
28835
|
+
const rows = this.candidates(lane, opts.cutoff, opts.maxRows ?? DEFAULT_MAX_ROWS);
|
|
28435
28836
|
return {
|
|
28436
28837
|
rowsExpired: rows.length,
|
|
28437
28838
|
bytesFreed: rows.reduce((sum, r) => sum + r.bytes, 0),
|
|
28438
|
-
rowsHeldBySync: this.countHeldBySync(opts)
|
|
28839
|
+
rowsHeldBySync: this.countHeldBySync(lane, opts.cutoff)
|
|
28439
28840
|
};
|
|
28440
28841
|
}
|
|
28441
28842
|
/** Clear eligible bodies, in bounded batches. */
|
|
28442
28843
|
expire(opts) {
|
|
28443
28844
|
const batchSize = opts.batchSize ?? DEFAULT_BATCH_SIZE;
|
|
28444
28845
|
const maxRows = opts.maxRows ?? DEFAULT_MAX_ROWS;
|
|
28445
|
-
const
|
|
28846
|
+
const lane = laneOf(opts.sweepSyncLane);
|
|
28446
28847
|
let rowsExpired = 0;
|
|
28447
28848
|
let bytesFreed = 0;
|
|
28448
28849
|
let done = true;
|
|
28449
28850
|
while (rowsExpired < maxRows) {
|
|
28450
28851
|
const remaining = Math.min(batchSize, maxRows - rowsExpired);
|
|
28451
|
-
const batch =
|
|
28852
|
+
const batch = this.candidates(lane, opts.cutoff, remaining);
|
|
28452
28853
|
if (batch.length === 0) break;
|
|
28453
28854
|
withTransaction(
|
|
28454
28855
|
this.db,
|
|
@@ -28461,17 +28862,60 @@ var SqliteBodyRetentionRepository = class {
|
|
|
28461
28862
|
bytesFreed += batch.reduce((sum, r) => sum + r.bytes, 0);
|
|
28462
28863
|
if (batch.length < remaining) break;
|
|
28463
28864
|
if (rowsExpired >= maxRows) {
|
|
28464
|
-
done =
|
|
28865
|
+
done = this.candidates(lane, opts.cutoff, 1).length === 0;
|
|
28465
28866
|
}
|
|
28466
28867
|
}
|
|
28467
|
-
|
|
28868
|
+
this.expireContexts(opts.cutoff, batchSize, maxRows);
|
|
28869
|
+
return {
|
|
28870
|
+
rowsExpired,
|
|
28871
|
+
bytesFreed,
|
|
28872
|
+
rowsHeldBySync: this.countHeldBySync(lane, opts.cutoff),
|
|
28873
|
+
done
|
|
28874
|
+
};
|
|
28875
|
+
}
|
|
28876
|
+
// Clear the excerpts that outlived their body, one bounded transaction per
|
|
28877
|
+
// batch for the same reason the body sweep batches, and at most `maxRows` of
|
|
28878
|
+
// them per pass under the same cap: the next pass picks up the rest.
|
|
28879
|
+
expireContexts(cutoff, batchSize, maxRows) {
|
|
28880
|
+
let total = 0;
|
|
28881
|
+
while (total < maxRows) {
|
|
28882
|
+
const limit = Math.min(batchSize, maxRows - total);
|
|
28883
|
+
let cleared = 0;
|
|
28884
|
+
withTransaction(
|
|
28885
|
+
this.db,
|
|
28886
|
+
() => {
|
|
28887
|
+
cleared = Number(this.expireContextsStmt.run({ cutoff, limit }).changes);
|
|
28888
|
+
},
|
|
28889
|
+
"IMMEDIATE"
|
|
28890
|
+
);
|
|
28891
|
+
total += cleared;
|
|
28892
|
+
if (cleared < limit) return;
|
|
28893
|
+
}
|
|
28894
|
+
}
|
|
28895
|
+
/**
|
|
28896
|
+
* One batch of candidates under `lane`, bound with exactly the parameters its
|
|
28897
|
+
* statement names — node:sqlite refuses a named parameter a statement does not
|
|
28898
|
+
* declare, so the key list goes to the scoped statements only.
|
|
28899
|
+
*
|
|
28900
|
+
* Anything that is not `sweep` or `hold-keys` takes the hold-all statement.
|
|
28901
|
+
* The type admits no fourth kind, but this decides what is destroyed, and the
|
|
28902
|
+
* direction an unforeseen value falls has to be holding.
|
|
28903
|
+
*/
|
|
28904
|
+
candidates(lane, cutoff, limit) {
|
|
28905
|
+
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 });
|
|
28906
|
+
return rows;
|
|
28468
28907
|
}
|
|
28469
|
-
countHeldBySync(
|
|
28470
|
-
if (
|
|
28471
|
-
const row = this.
|
|
28908
|
+
countHeldBySync(lane, cutoff) {
|
|
28909
|
+
if (lane.kind === "sweep") return 0;
|
|
28910
|
+
const row = lane.kind === "hold-keys" ? this.heldByScopeStmt.get({ cutoff, scopeKeys: JSON.stringify(lane.keys) }) : this.heldBySyncStmt.get({ cutoff });
|
|
28472
28911
|
return row.n;
|
|
28473
28912
|
}
|
|
28474
28913
|
};
|
|
28914
|
+
function laneOf(gate) {
|
|
28915
|
+
if (gate === true) return SWEEP;
|
|
28916
|
+
if (gate === false) return HOLD_ALL;
|
|
28917
|
+
return gate;
|
|
28918
|
+
}
|
|
28475
28919
|
|
|
28476
28920
|
// ../../packages/persistence/src/repositories/capture-status.ts
|
|
28477
28921
|
var STATUS_LOOKBACK_ROWS = 128;
|
|
@@ -29380,6 +29824,8 @@ function toFlatFindingRow(r) {
|
|
|
29380
29824
|
repo: r.repo ?? "",
|
|
29381
29825
|
file: r.file ?? "",
|
|
29382
29826
|
...r.tool_name === null ? {} : { toolName: r.tool_name },
|
|
29827
|
+
...r.line === null ? {} : { line: r.line },
|
|
29828
|
+
...r.col === null ? {} : { col: r.col },
|
|
29383
29829
|
eventId: r.event_id,
|
|
29384
29830
|
...r.session_id === null ? {} : { sessionId: r.session_id },
|
|
29385
29831
|
status: deriveInstanceStatus(r),
|
|
@@ -29457,7 +29903,8 @@ var FINDING_ROW_COLUMNS_SQL = `f.id AS id, d.rule_id AS rule_id, d.category AS c
|
|
|
29457
29903
|
${latestResolutionStatusSql("f")} AS latest_status,
|
|
29458
29904
|
e.synced_at AS synced_at, e.sync_claimed_at AS sync_claimed_at,
|
|
29459
29905
|
e.sync_failed_at AS sync_failed_at, e.sync_failure AS sync_failure,
|
|
29460
|
-
e.outbox_owed AS outbox_owed
|
|
29906
|
+
e.outbox_owed AS outbox_owed,
|
|
29907
|
+
f.line AS line, f.col AS col`;
|
|
29461
29908
|
var DAY_MS3 = 864e5;
|
|
29462
29909
|
var SqliteFindingsRepository = class {
|
|
29463
29910
|
constructor(db) {
|
|
@@ -29880,6 +30327,27 @@ var SqliteFindingsRepository = class {
|
|
|
29880
30327
|
).get(id);
|
|
29881
30328
|
return Promise.resolve(row === void 0 ? null : toInstanceDetail(toFlatFindingRow(row)));
|
|
29882
30329
|
}
|
|
30330
|
+
/**
|
|
30331
|
+
* One finding's excerpt source (see FindingContextSource). A primary-key
|
|
30332
|
+
* seek, like `findingInstance`, and the only findings read that touches the
|
|
30333
|
+
* event's text — which is why the list never projects the excerpt and the
|
|
30334
|
+
* drawer asks for it here, one finding at a time.
|
|
30335
|
+
*/
|
|
30336
|
+
findingContextSource(id) {
|
|
30337
|
+
const row = this.db.prepare(
|
|
30338
|
+
`SELECT f.context AS context, e.content AS content,
|
|
30339
|
+
f.span_start AS spanStart, f.span_end AS spanEnd,
|
|
30340
|
+
d.rule_id AS ruleId, d.category AS category,
|
|
30341
|
+
json_extract(e.attributes, '$.whole_file') AS wholeFile,
|
|
30342
|
+
e.tool_name AS toolName, e.event_type AS eventType
|
|
30343
|
+
FROM inspection_findings f
|
|
30344
|
+
JOIN audit_events e ON e.id = f.audit_event_id
|
|
30345
|
+
JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
30346
|
+
WHERE f.id = ?`
|
|
30347
|
+
).get(id);
|
|
30348
|
+
if (row === void 0) return null;
|
|
30349
|
+
return { ...row, wholeFile: row.wholeFile === 1 };
|
|
30350
|
+
}
|
|
29883
30351
|
/**
|
|
29884
30352
|
* The one statement both instance-level scans run: every finding in scope,
|
|
29885
30353
|
* joined to its event and definition, newest first.
|
|
@@ -30016,6 +30484,61 @@ var SqliteFindingsRepository = class {
|
|
|
30016
30484
|
])
|
|
30017
30485
|
);
|
|
30018
30486
|
}
|
|
30487
|
+
/**
|
|
30488
|
+
* The Findings page's summary strip: whole-store counts over exactly the rows
|
|
30489
|
+
* the instance reads list (the four capture kinds), each equal to what
|
|
30490
|
+
* listFindingInstances totals for the same filters — see FindingsOverview.
|
|
30491
|
+
*
|
|
30492
|
+
* ONE grouped aggregate whose keys are the raw classifier inputs, not the
|
|
30493
|
+
* answers: the statement groups by the three inputs deriveFindingStatus
|
|
30494
|
+
* reads, and each group is then classified here by that same function. So
|
|
30495
|
+
* SQL never restates the status rule, and the strip cannot disagree with the
|
|
30496
|
+
* list about which status a finding has. The group count is bounded by a
|
|
30497
|
+
* handful of status inputs, not by the store, so only the scan grows with it
|
|
30498
|
+
* — the same linear cost every other unscoped read on the page already pays.
|
|
30499
|
+
*
|
|
30500
|
+
* The definitions join selects nothing. It is there because the list's scan
|
|
30501
|
+
* joins it too, so a finding whose definition row is missing is left out of
|
|
30502
|
+
* both rather than counted here and absent there.
|
|
30503
|
+
*
|
|
30504
|
+
* The latest-resolution join is the derived-table form, which
|
|
30505
|
+
* resolution-sql.ts recommends for an aggregate over many findings.
|
|
30506
|
+
*/
|
|
30507
|
+
findingsOverview() {
|
|
30508
|
+
const rows = allRows(
|
|
30509
|
+
this.db.prepare(
|
|
30510
|
+
`SELECT e.event_type AS kind, (f.finding_key IS NOT NULL) AS keyed,
|
|
30511
|
+
latest.status AS latest_status, count(*) AS c
|
|
30512
|
+
FROM inspection_findings f
|
|
30513
|
+
JOIN audit_events e ON e.id = f.audit_event_id
|
|
30514
|
+
JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
30515
|
+
LEFT JOIN ${LATEST_RESOLUTION_BY_KEY_SQL} latest
|
|
30516
|
+
ON latest.finding_key = f.finding_key
|
|
30517
|
+
WHERE e.event_type IN (${CAPTURE_EVENT_TYPES_SQL})
|
|
30518
|
+
GROUP BY e.event_type, keyed, latest.status`
|
|
30519
|
+
)
|
|
30520
|
+
);
|
|
30521
|
+
const byStatus = {
|
|
30522
|
+
open: 0,
|
|
30523
|
+
handled: 0,
|
|
30524
|
+
resolved: 0,
|
|
30525
|
+
dismissed: 0
|
|
30526
|
+
};
|
|
30527
|
+
let findings = 0;
|
|
30528
|
+
for (const row of rows) {
|
|
30529
|
+
const status = deriveFindingStatus({
|
|
30530
|
+
kind: row.kind,
|
|
30531
|
+
// The classifier only asks whether a key exists, never what it is. The
|
|
30532
|
+
// stand-in is non-empty so a truthiness test of the key reads it as
|
|
30533
|
+
// present, exactly as it would a real one.
|
|
30534
|
+
findingKey: row.keyed ? "keyed" : null,
|
|
30535
|
+
latestResolutionStatus: row.latest_status
|
|
30536
|
+
});
|
|
30537
|
+
findings += row.c;
|
|
30538
|
+
byStatus[status] += row.c;
|
|
30539
|
+
}
|
|
30540
|
+
return Promise.resolve({ findings, ...byStatus });
|
|
30541
|
+
}
|
|
30019
30542
|
healthSummary() {
|
|
30020
30543
|
const total = countScalar(
|
|
30021
30544
|
this.db,
|
|
@@ -30143,12 +30666,13 @@ var SqliteInspectionFindingsRepository = class {
|
|
|
30143
30666
|
`INSERT INTO inspection_findings
|
|
30144
30667
|
(id, audit_event_id, inspection_definition_id, classified_data_id,
|
|
30145
30668
|
span_start, span_end, masked_match, action_taken, confidence,
|
|
30146
|
-
finding_key, first_detected_at)
|
|
30669
|
+
finding_key, first_detected_at, line, col, context)
|
|
30147
30670
|
VALUES
|
|
30148
30671
|
(:id, :auditEventId, :inspectionDefinitionId, :classifiedDataId,
|
|
30149
30672
|
:spanStart, :spanEnd, :maskedMatch, :actionTaken, :confidence,
|
|
30150
30673
|
:findingKey,
|
|
30151
|
-
COALESCE(:firstDetectedAt, (SELECT started_at FROM audit_events WHERE id = :auditEventId))
|
|
30674
|
+
COALESCE(:firstDetectedAt, (SELECT started_at FROM audit_events WHERE id = :auditEventId)),
|
|
30675
|
+
:line, :col, :context)
|
|
30152
30676
|
ON CONFLICT(id) DO UPDATE SET
|
|
30153
30677
|
inspection_definition_id = excluded.inspection_definition_id
|
|
30154
30678
|
ON CONFLICT (finding_key) DO UPDATE SET
|
|
@@ -30159,7 +30683,10 @@ var SqliteInspectionFindingsRepository = class {
|
|
|
30159
30683
|
span_end = excluded.span_end,
|
|
30160
30684
|
masked_match = excluded.masked_match,
|
|
30161
30685
|
action_taken = excluded.action_taken,
|
|
30162
|
-
confidence = excluded.confidence
|
|
30686
|
+
confidence = excluded.confidence,
|
|
30687
|
+
line = excluded.line,
|
|
30688
|
+
col = excluded.col,
|
|
30689
|
+
context = excluded.context`
|
|
30163
30690
|
);
|
|
30164
30691
|
this.sessionDupStmt = db.prepare(
|
|
30165
30692
|
`SELECT 1 FROM inspection_findings f
|
|
@@ -30209,7 +30736,10 @@ var SqliteInspectionFindingsRepository = class {
|
|
|
30209
30736
|
actionTaken: row.actionTaken,
|
|
30210
30737
|
confidence: row.confidence,
|
|
30211
30738
|
findingKey: row.findingKey,
|
|
30212
|
-
firstDetectedAt: row.firstDetectedAt
|
|
30739
|
+
firstDetectedAt: row.firstDetectedAt,
|
|
30740
|
+
line: row.line,
|
|
30741
|
+
col: row.col,
|
|
30742
|
+
context: row.context
|
|
30213
30743
|
})
|
|
30214
30744
|
);
|
|
30215
30745
|
}
|
|
@@ -30550,8 +31080,8 @@ var SqliteInstalledPacksRepository = class {
|
|
|
30550
31080
|
this.db = db;
|
|
30551
31081
|
this.baseDir = baseDir;
|
|
30552
31082
|
this.insertMissingStmt = db.prepare(
|
|
30553
|
-
`INSERT INTO installed_packs (id, namespace, pack_id, version, name, rules_json, enabled, created_at, updated_at)
|
|
30554
|
-
VALUES (:id, :namespace, :packId, :version, :name, :rulesJson, 1, :now, :now)
|
|
31083
|
+
`INSERT INTO installed_packs (id, namespace, pack_id, version, name, rules_json, enabled, policy_id, created_at, updated_at)
|
|
31084
|
+
VALUES (:id, :namespace, :packId, :version, :name, :rulesJson, 1, :policyId, :now, :now)
|
|
30555
31085
|
ON CONFLICT (namespace, pack_id) DO NOTHING`
|
|
30556
31086
|
);
|
|
30557
31087
|
this.upsertAvailableStmt = db.prepare(
|
|
@@ -30611,7 +31141,10 @@ var SqliteInstalledPacksRepository = class {
|
|
|
30611
31141
|
version: pack.version,
|
|
30612
31142
|
name: pack.name,
|
|
30613
31143
|
rulesJson: JSON.stringify(pack.rules),
|
|
30614
|
-
ruleIds: new Set(pack.rules.map((r) => r.id))
|
|
31144
|
+
ruleIds: new Set(pack.rules.map((r) => r.id)),
|
|
31145
|
+
// Only a first install takes it: an existing row is never modified here,
|
|
31146
|
+
// so a policy the user chose (or cleared) is never overwritten.
|
|
31147
|
+
defaultPolicyId: pack.defaultPolicyId ?? null
|
|
30615
31148
|
}));
|
|
30616
31149
|
if (this.storedSignature() === inventorySignature(rows)) return;
|
|
30617
31150
|
const now = Date.now();
|
|
@@ -30640,7 +31173,7 @@ var SqliteInstalledPacksRepository = class {
|
|
|
30640
31173
|
} else {
|
|
30641
31174
|
behind = true;
|
|
30642
31175
|
}
|
|
30643
|
-
this.insertMissingStmt.run(params);
|
|
31176
|
+
this.insertMissingStmt.run({ ...params, policyId: row.defaultPolicyId });
|
|
30644
31177
|
}
|
|
30645
31178
|
if (!behind) this.pruneAvailable(rows.map((r) => `${r.namespace}/${r.packId}`));
|
|
30646
31179
|
},
|
|
@@ -30758,7 +31291,8 @@ var SqliteInstalledPacksRepository = class {
|
|
|
30758
31291
|
rejectedRules: [],
|
|
30759
31292
|
ruleActions: /* @__PURE__ */ new Map(),
|
|
30760
31293
|
ruleVersions: /* @__PURE__ */ new Map(),
|
|
30761
|
-
reversibleRules: /* @__PURE__ */ new Set()
|
|
31294
|
+
reversibleRules: /* @__PURE__ */ new Set(),
|
|
31295
|
+
assignedRules: /* @__PURE__ */ new Set()
|
|
30762
31296
|
};
|
|
30763
31297
|
const reject = (pack, ruleId, reason) => {
|
|
30764
31298
|
if (out.rejectedRules.length >= REJECTED_RULE_DETAIL_CAP) return;
|
|
@@ -30791,6 +31325,8 @@ var SqliteInstalledPacksRepository = class {
|
|
|
30791
31325
|
out.ruleVersions.set(parsed.data.id, row.version);
|
|
30792
31326
|
if (reversible) out.reversibleRules.add(parsed.data.id);
|
|
30793
31327
|
else out.reversibleRules.delete(parsed.data.id);
|
|
31328
|
+
if (row.policyId !== null) out.assignedRules.add(parsed.data.id);
|
|
31329
|
+
else out.assignedRules.delete(parsed.data.id);
|
|
30794
31330
|
} else {
|
|
30795
31331
|
out.invalidRules += 1;
|
|
30796
31332
|
reject(pack, printableRuleId(entry), firstIssueReason(parsed.error));
|
|
@@ -31877,6 +32413,7 @@ var SqliteInventoryAssetsRepository = class {
|
|
|
31877
32413
|
|
|
31878
32414
|
// ../../packages/persistence/src/repositories/policies.ts
|
|
31879
32415
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
32416
|
+
var SEED_BATCH_WINDOW_MS = 6e4;
|
|
31880
32417
|
var SqlitePoliciesRepository = class {
|
|
31881
32418
|
constructor(db) {
|
|
31882
32419
|
this.db = db;
|
|
@@ -31898,39 +32435,123 @@ var SqlitePoliciesRepository = class {
|
|
|
31898
32435
|
});
|
|
31899
32436
|
return Promise.resolve(policies);
|
|
31900
32437
|
}
|
|
31901
|
-
// Seed one policy per bundled category
|
|
31902
|
-
//
|
|
31903
|
-
//
|
|
32438
|
+
// Seed one policy per bundled category at Monitor so the detection-type config
|
|
32439
|
+
// exists from first run. An unassigned pack's rules follow these rows, so
|
|
32440
|
+
// Monitor here is the posture of every pack that ships no defaultPolicy; a pack
|
|
32441
|
+
// that ships one carries its own assignment instead. Only when the
|
|
32442
|
+
// table is empty, so a user's edits are never clobbered.
|
|
31904
32443
|
seedDefaults() {
|
|
31905
32444
|
const count = countScalar(this.db, "SELECT count(*) AS n FROM policies");
|
|
31906
|
-
if (count > 0)
|
|
32445
|
+
if (count > 0) {
|
|
32446
|
+
this.markEarlierChoices();
|
|
32447
|
+
this.monitorUntouchedSeeds();
|
|
32448
|
+
return;
|
|
32449
|
+
}
|
|
31907
32450
|
const stmt = this.db.prepare(
|
|
31908
32451
|
`INSERT INTO policies (id, scope, target, action, enabled, created_at, updated_at)
|
|
31909
32452
|
VALUES (:id, 'global', :target, :action, 1, :now, :now)`
|
|
31910
32453
|
);
|
|
31911
32454
|
failOpenTransaction(this.db, () => {
|
|
31912
|
-
for (const
|
|
32455
|
+
for (const category of Object.keys(DEFAULT_ACTIONS)) {
|
|
31913
32456
|
stmt.run({
|
|
31914
32457
|
id: randomUUID6(),
|
|
31915
32458
|
target: JSON.stringify({ category }),
|
|
31916
|
-
action,
|
|
32459
|
+
action: "log",
|
|
31917
32460
|
now: Date.now()
|
|
31918
32461
|
});
|
|
31919
32462
|
}
|
|
31920
32463
|
});
|
|
31921
32464
|
}
|
|
32465
|
+
// Before this build, upsertCategoryAction INSERTed a new row with updated_at
|
|
32466
|
+
// equal to created_at, so a choice made for a category that had no row yet
|
|
32467
|
+
// (one added in a release after the store was seeded) looks exactly like a
|
|
32468
|
+
// seed. Left alone, fill-gaps would overwrite it and monitorUntouchedSeeds
|
|
32469
|
+
// could reset it. This pass marks such rows as chosen (updated_at =
|
|
32470
|
+
// created_at + 1) before either can read them. A row is an earlier build's
|
|
32471
|
+
// choice, not its seed, when either:
|
|
32472
|
+
// - its action is neither the old seed value (DEFAULT_ACTIONS) nor Monitor,
|
|
32473
|
+
// which no seed of any build ever wrote; or
|
|
32474
|
+
// - it was created well after the seed batch. Every build seeds all of its
|
|
32475
|
+
// categories in one transaction, and only into an empty table, so a row
|
|
32476
|
+
// created later came from upsertCategoryAction.
|
|
32477
|
+
// It needs no marker of its own: every row this build writes has updated_at >
|
|
32478
|
+
// created_at, and the seeds it leaves equal (fresh 'log' seeds, and seeds
|
|
32479
|
+
// moved to Monitor below, which keep their created_at) match neither test, so
|
|
32480
|
+
// after one pass it finds nothing and stays a read. What it cannot tell apart
|
|
32481
|
+
// is an earlier build's choice that equals the seed value AND was made within
|
|
32482
|
+
// the seed batch window; that row is read as a seed.
|
|
32483
|
+
markEarlierChoices() {
|
|
32484
|
+
const rows = allRows(
|
|
32485
|
+
this.db.prepare(
|
|
32486
|
+
`SELECT id, json_extract(target, '$.category') AS category, action,
|
|
32487
|
+
created_at AS c, updated_at AS u
|
|
32488
|
+
FROM policies
|
|
32489
|
+
WHERE scope = 'global' AND json_extract(target, '$.category') IS NOT NULL`
|
|
32490
|
+
)
|
|
32491
|
+
);
|
|
32492
|
+
if (rows.length === 0) return;
|
|
32493
|
+
const seedBatchStart = Math.min(...rows.map((row) => row.c));
|
|
32494
|
+
const seeded = DEFAULT_ACTIONS;
|
|
32495
|
+
const choices = rows.filter(
|
|
32496
|
+
(row) => row.u === row.c && (row.action !== "log" && row.action !== seeded[row.category] || row.c > seedBatchStart + SEED_BATCH_WINDOW_MS)
|
|
32497
|
+
);
|
|
32498
|
+
if (choices.length === 0) return;
|
|
32499
|
+
const stmt = this.db.prepare(
|
|
32500
|
+
`UPDATE policies SET updated_at = created_at + 1 WHERE id = :id AND updated_at = created_at`
|
|
32501
|
+
);
|
|
32502
|
+
failOpenTransaction(this.db, () => {
|
|
32503
|
+
for (const row of choices) stmt.run({ id: row.id });
|
|
32504
|
+
});
|
|
32505
|
+
}
|
|
32506
|
+
// Stores seeded by an earlier build hold DEFAULT_ACTIONS in their category
|
|
32507
|
+
// rows. Those rows used to be shadowed by the Monitor every unassigned pack
|
|
32508
|
+
// emitted; now that unassigned packs defer to them, an untouched one would
|
|
32509
|
+
// turn Monitor into Warn on upgrade with nobody having asked. So a row still
|
|
32510
|
+
// exactly as seeded — the seeded action, never updated since it was created —
|
|
32511
|
+
// is moved to Monitor. A row the user, the setup wizard or the warn-era cap
|
|
32512
|
+
// ever wrote has a later updated_at and is left alone. updated_at is NOT
|
|
32513
|
+
// advanced, so a moved row still reads as an untouched seed (see
|
|
32514
|
+
// isCategoryChosen); it never matches again because it is no longer off 'log'.
|
|
32515
|
+
// One knock-on: when the installed snapshot is unusable (corrupt rules_json)
|
|
32516
|
+
// the gateway falls back to the bundled packs with no per-rule policies, so
|
|
32517
|
+
// every rule follows these rows. On an upgraded store that fallback now
|
|
32518
|
+
// monitors where the earlier build warned.
|
|
32519
|
+
monitorUntouchedSeeds() {
|
|
32520
|
+
const untouched = allRows(
|
|
32521
|
+
this.db.prepare(
|
|
32522
|
+
`SELECT json_extract(target, '$.category') AS category, action FROM policies
|
|
32523
|
+
WHERE scope = 'global' AND json_extract(target, '$.category') IS NOT NULL
|
|
32524
|
+
AND action <> 'log' AND updated_at = created_at`
|
|
32525
|
+
)
|
|
32526
|
+
).filter(
|
|
32527
|
+
(row) => DEFAULT_ACTIONS[row.category] === row.action
|
|
32528
|
+
);
|
|
32529
|
+
if (untouched.length === 0) return;
|
|
32530
|
+
const stmt = this.db.prepare(
|
|
32531
|
+
`UPDATE policies SET action = 'log'
|
|
32532
|
+
WHERE scope = 'global' AND json_extract(target, '$.category') = :category
|
|
32533
|
+
AND action = :seeded AND action <> 'log' AND updated_at = created_at`
|
|
32534
|
+
);
|
|
32535
|
+
failOpenTransaction(this.db, () => {
|
|
32536
|
+
for (const row of untouched) {
|
|
32537
|
+
stmt.run({ category: row.category, seeded: row.action });
|
|
32538
|
+
}
|
|
32539
|
+
});
|
|
32540
|
+
}
|
|
31922
32541
|
// Insert-or-update the single global per-category policy row, keyed on the
|
|
31923
32542
|
// existing uq_policies_scope_target unique index (scope, target). `action`
|
|
31924
32543
|
// uses the SAME vocabulary seedDefaults writes (DEFAULT_ACTIONS' ActionTaken
|
|
31925
32544
|
// values), so the runtime's resolveAction reads rows written by either path
|
|
31926
32545
|
// identically. On conflict, `action`, `enabled`, and `updated_at` are updated;
|
|
31927
|
-
// `id` and `created_at` are left exactly as they were.
|
|
32546
|
+
// `id` and `created_at` are left exactly as they were. Either way updated_at
|
|
32547
|
+
// ends up later than created_at, which is what marks the row as chosen.
|
|
31928
32548
|
upsertCategoryAction(category, action) {
|
|
31929
32549
|
const now = Date.now();
|
|
31930
32550
|
this.db.prepare(
|
|
31931
32551
|
`INSERT INTO policies (id, scope, target, action, enabled, created_at, updated_at)
|
|
31932
|
-
VALUES (:id, 'global', :target, :action, 1, :now, :now)
|
|
31933
|
-
ON CONFLICT(scope, target) DO UPDATE SET action = excluded.action, enabled = 1,
|
|
32552
|
+
VALUES (:id, 'global', :target, :action, 1, :now, :now + 1)
|
|
32553
|
+
ON CONFLICT(scope, target) DO UPDATE SET action = excluded.action, enabled = 1,
|
|
32554
|
+
updated_at = MAX(excluded.updated_at, policies.created_at + 1)`
|
|
31934
32555
|
).run({ id: randomUUID6(), target: JSON.stringify({ category }), action, now });
|
|
31935
32556
|
}
|
|
31936
32557
|
// Caps every global per-category policy currently set to block/redact down
|
|
@@ -31944,6 +32565,16 @@ var SqlitePoliciesRepository = class {
|
|
|
31944
32565
|
).run({ now: Date.now() });
|
|
31945
32566
|
return Number(info.changes);
|
|
31946
32567
|
}
|
|
32568
|
+
// Whether the category's row was ever written after it was created — by the
|
|
32569
|
+
// user, the setup wizard or a cap. A row still as seeded (updated_at equal to
|
|
32570
|
+
// created_at) is not a choice, so a posture filling gaps may replace it.
|
|
32571
|
+
isCategoryChosen(category) {
|
|
32572
|
+
const row = this.db.prepare(
|
|
32573
|
+
`SELECT created_at AS c, updated_at AS u FROM policies
|
|
32574
|
+
WHERE scope='global' AND json_extract(target,'$.category') = :category`
|
|
32575
|
+
).get({ category });
|
|
32576
|
+
return row !== void 0 && row.u !== row.c;
|
|
32577
|
+
}
|
|
31947
32578
|
// Read the current action for a single global per-category policy row, mirroring
|
|
31948
32579
|
// upsertCategoryAction's category-lookup predicate. Returns undefined when no
|
|
31949
32580
|
// row exists yet, so callers can distinguish an unset category from a set one.
|
|
@@ -32115,7 +32746,10 @@ var SqliteResolutionsRepository = class {
|
|
|
32115
32746
|
* Insert many dispositions as ONE transaction — all of them or none.
|
|
32116
32747
|
*
|
|
32117
32748
|
* A dashboard dismissal closes every open finding of a rule, which is one
|
|
32118
|
-
* write per key
|
|
32749
|
+
* write per key. It reaches this through
|
|
32750
|
+
* `LocalDatabase.dismissOpenFindingsForRule`, which calls it inside the
|
|
32751
|
+
* transaction that selected the keys, so there it runs as a SAVEPOINT of
|
|
32752
|
+
* that transaction. Run loose, a fault partway leaves half a rule closed with
|
|
32119
32753
|
* nothing recording that the other half was meant to be. The caller then has
|
|
32120
32754
|
* no way to tell a partial run from a complete one, because the card it
|
|
32121
32755
|
* refreshes into just shows a smaller number either way.
|
|
@@ -32335,6 +32969,7 @@ function toSighting(row) {
|
|
|
32335
32969
|
var SELECT_COLUMNS = `
|
|
32336
32970
|
pointer_id AS pointerId,
|
|
32337
32971
|
value_fingerprint AS valueFingerprint,
|
|
32972
|
+
value_identity_fingerprint AS valueIdentityFingerprint,
|
|
32338
32973
|
fingerprint_key_version AS fingerprintKeyVersion,
|
|
32339
32974
|
key_version AS keyVersion,
|
|
32340
32975
|
format_version AS formatVersion,
|
|
@@ -32359,13 +32994,13 @@ var SqliteSecretVaultRepository = class {
|
|
|
32359
32994
|
this.db = db;
|
|
32360
32995
|
this.insertStmt = db.prepare(
|
|
32361
32996
|
`INSERT INTO secret_vault (
|
|
32362
|
-
pointer_id, value_fingerprint,
|
|
32363
|
-
format_version, category, rule_id, masked_match, provider,
|
|
32997
|
+
pointer_id, value_fingerprint, value_identity_fingerprint,
|
|
32998
|
+
fingerprint_key_version, key_version, format_version, category, rule_id, masked_match, provider,
|
|
32364
32999
|
ciphertext, nonce, auth_tag,
|
|
32365
33000
|
user_authorized, occurrence_count, first_seen, last_seen
|
|
32366
33001
|
) VALUES (
|
|
32367
|
-
:pointerId, :valueFingerprint, :
|
|
32368
|
-
:formatVersion, :category, :ruleId, :maskedMatch, :provider,
|
|
33002
|
+
:pointerId, :valueFingerprint, :valueIdentityFingerprint,
|
|
33003
|
+
:fingerprintKeyVersion, :keyVersion, :formatVersion, :category, :ruleId, :maskedMatch, :provider,
|
|
32369
33004
|
:ciphertext, :nonce, :authTag,
|
|
32370
33005
|
:userAuthorized, 1, :now, :now
|
|
32371
33006
|
)`
|
|
@@ -32390,7 +33025,13 @@ var SqliteSecretVaultRepository = class {
|
|
|
32390
33025
|
);
|
|
32391
33026
|
this.refreshFingerprintStmt = db.prepare(
|
|
32392
33027
|
`UPDATE secret_vault
|
|
32393
|
-
SET value_fingerprint = :valueFingerprint,
|
|
33028
|
+
SET value_fingerprint = :valueFingerprint,
|
|
33029
|
+
value_identity_fingerprint = :valueIdentityFingerprint,
|
|
33030
|
+
fingerprint_key_version = :fingerprintKeyVersion
|
|
33031
|
+
WHERE pointer_id = :pointerId`
|
|
33032
|
+
);
|
|
33033
|
+
this.setIdentityStmt = db.prepare(
|
|
33034
|
+
`UPDATE secret_vault SET value_identity_fingerprint = :valueIdentityFingerprint
|
|
32394
33035
|
WHERE pointer_id = :pointerId`
|
|
32395
33036
|
);
|
|
32396
33037
|
this.deleteByPointerStmt = db.prepare(`DELETE FROM secret_vault WHERE pointer_id = :pointerId`);
|
|
@@ -32407,6 +33048,7 @@ var SqliteSecretVaultRepository = class {
|
|
|
32407
33048
|
listStmt;
|
|
32408
33049
|
replaceCiphertextStmt;
|
|
32409
33050
|
refreshFingerprintStmt;
|
|
33051
|
+
setIdentityStmt;
|
|
32410
33052
|
deleteByPointerStmt;
|
|
32411
33053
|
derefStmt;
|
|
32412
33054
|
/**
|
|
@@ -32437,6 +33079,7 @@ var SqliteSecretVaultRepository = class {
|
|
|
32437
33079
|
bindParams({
|
|
32438
33080
|
pointerId: input2.pointerId,
|
|
32439
33081
|
valueFingerprint: input2.valueFingerprint,
|
|
33082
|
+
valueIdentityFingerprint: input2.valueIdentityFingerprint,
|
|
32440
33083
|
fingerprintKeyVersion: input2.fingerprintKeyVersion,
|
|
32441
33084
|
keyVersion: input2.keyVersion,
|
|
32442
33085
|
formatVersion: input2.formatVersion ?? POINTER_FORMAT_VERSION,
|
|
@@ -32498,7 +33141,15 @@ var SqliteSecretVaultRepository = class {
|
|
|
32498
33141
|
replaceCiphertext(pointerId, next) {
|
|
32499
33142
|
this.replaceCiphertextStmt.run({ pointerId, ...next });
|
|
32500
33143
|
}
|
|
32501
|
-
/**
|
|
33144
|
+
/**
|
|
33145
|
+
* Correct an entry's identity fingerprint in place, leaving its exact
|
|
33146
|
+
* fingerprint and key epoch alone. For a row whose identity column still holds
|
|
33147
|
+
* the exact value copied in by the migration that added it.
|
|
33148
|
+
*/
|
|
33149
|
+
setIdentityFingerprint(pointerId, valueIdentityFingerprint) {
|
|
33150
|
+
this.setIdentityStmt.run({ pointerId, valueIdentityFingerprint });
|
|
33151
|
+
}
|
|
33152
|
+
/** Re-derive an entry's fingerprints under a new fingerprint-key epoch. */
|
|
32502
33153
|
refreshFingerprint(pointerId, next) {
|
|
32503
33154
|
this.refreshFingerprintStmt.run({ pointerId, ...next });
|
|
32504
33155
|
}
|
|
@@ -32629,7 +33280,7 @@ var SqliteSecretVaultRepository = class {
|
|
|
32629
33280
|
`SELECT ${INVENTORY_COLUMNS},
|
|
32630
33281
|
(SELECT e.id FROM exceptions e
|
|
32631
33282
|
WHERE e.rule_id = v.rule_id
|
|
32632
|
-
AND e.value_fingerprint = v.
|
|
33283
|
+
AND e.value_fingerprint = v.value_identity_fingerprint
|
|
32633
33284
|
AND e.key_version = v.fingerprint_key_version
|
|
32634
33285
|
AND ${ACTIVE_REVEAL_GRANT_PREDICATE}
|
|
32635
33286
|
LIMIT 1) AS grant_id
|
|
@@ -32672,7 +33323,7 @@ var SqliteSecretVaultRepository = class {
|
|
|
32672
33323
|
`SELECT ${INVENTORY_COLUMNS},
|
|
32673
33324
|
(SELECT e.id FROM exceptions e
|
|
32674
33325
|
WHERE e.rule_id = v.rule_id
|
|
32675
|
-
AND e.value_fingerprint = v.
|
|
33326
|
+
AND e.value_fingerprint = v.value_identity_fingerprint
|
|
32676
33327
|
AND e.key_version = v.fingerprint_key_version
|
|
32677
33328
|
AND ${ACTIVE_REVEAL_GRANT_PREDICATE}
|
|
32678
33329
|
LIMIT 1) AS grant_id
|
|
@@ -32776,6 +33427,18 @@ var OPEN_AT_REST_FINDINGS_SQL = `FROM inspection_findings f
|
|
|
32776
33427
|
OR latest.status IS NULL
|
|
32777
33428
|
OR latest.status NOT IN ('resolved', 'dismissed')
|
|
32778
33429
|
)`;
|
|
33430
|
+
function selectOpenFindingKeysForRule(db, ruleId) {
|
|
33431
|
+
const rows = allRows(
|
|
33432
|
+
db.prepare(
|
|
33433
|
+
`SELECT DISTINCT f.finding_key AS finding_key
|
|
33434
|
+
${OPEN_AT_REST_FINDINGS_SQL}
|
|
33435
|
+
AND d.rule_id = :ruleId
|
|
33436
|
+
AND f.finding_key IS NOT NULL`
|
|
33437
|
+
),
|
|
33438
|
+
{ ruleId }
|
|
33439
|
+
);
|
|
33440
|
+
return rows.map((r) => r.finding_key);
|
|
33441
|
+
}
|
|
32779
33442
|
var SEVERITIES = ["critical", "high", "medium", "low"];
|
|
32780
33443
|
var ACTION_TO_KIND = {
|
|
32781
33444
|
block: "blocked",
|
|
@@ -32832,16 +33495,16 @@ var SqliteSecurityRepository = class {
|
|
|
32832
33495
|
// findings are caught only once their latest disposition is resolved,
|
|
32833
33496
|
// otherwise they are open-at-rest.
|
|
32834
33497
|
//
|
|
32835
|
-
//
|
|
32836
|
-
//
|
|
32837
|
-
//
|
|
32838
|
-
//
|
|
32839
|
-
// be bucketed as caught
|
|
33498
|
+
// Only latest status 'resolved' counts as caught above. 'dismissed' is its
|
|
33499
|
+
// own bucket: a judgement rather than a fix, so it is neither caught nor
|
|
33500
|
+
// needing remediation, and stays countable. A further manual disposition
|
|
33501
|
+
// (acknowledged, false-positive) must be placed deliberately — 'acknowledged'
|
|
33502
|
+
// is accepted risk, not a fix, and must NOT be bucketed as caught.
|
|
32840
33503
|
//
|
|
32841
33504
|
// Legacy at-rest findings from pre-branch scans carry finding_key = NULL —
|
|
32842
33505
|
// the resolution lifecycle is keyed by finding_key, so it can never attach a
|
|
32843
33506
|
// disposition to (or clear) one of these on re-scan. They are excluded from
|
|
32844
|
-
//
|
|
33507
|
+
// all three buckets (untracked, not "needs remediation forever"),
|
|
32845
33508
|
// but still counted in total/count below — this keeps this predicate
|
|
32846
33509
|
// consistent with SqliteResolutionsRepository.openAtRestKeysForPath, which
|
|
32847
33510
|
// already filters `finding_key IS NOT NULL`.
|
|
@@ -32864,12 +33527,25 @@ var SqliteSecurityRepository = class {
|
|
|
32864
33527
|
WHEN latest.status = 'resolved' THEN 1
|
|
32865
33528
|
ELSE 0
|
|
32866
33529
|
END) AS caught,
|
|
33530
|
+
SUM(CASE WHEN e.event_type != 'code_change' THEN 1 ELSE 0 END) AS handled,
|
|
32867
33531
|
SUM(CASE
|
|
32868
33532
|
WHEN e.event_type = 'code_change'
|
|
32869
33533
|
AND f.finding_key IS NOT NULL
|
|
32870
|
-
AND
|
|
33534
|
+
AND latest.status = 'resolved' THEN 1
|
|
32871
33535
|
ELSE 0
|
|
32872
|
-
END) AS
|
|
33536
|
+
END) AS resolved,
|
|
33537
|
+
SUM(CASE
|
|
33538
|
+
WHEN e.event_type = 'code_change'
|
|
33539
|
+
AND f.finding_key IS NOT NULL
|
|
33540
|
+
AND (latest.status IS NULL
|
|
33541
|
+
OR latest.status NOT IN ('resolved', 'dismissed')) THEN 1
|
|
33542
|
+
ELSE 0
|
|
33543
|
+
END) AS open_at_rest,
|
|
33544
|
+
SUM(CASE
|
|
33545
|
+
WHEN e.event_type = 'code_change'
|
|
33546
|
+
AND latest.status = 'dismissed' THEN 1
|
|
33547
|
+
ELSE 0
|
|
33548
|
+
END) AS dismissed
|
|
32873
33549
|
FROM inspection_findings f
|
|
32874
33550
|
JOIN audit_events e INDEXED BY idx_audit_capture_rollup ON e.id = f.audit_event_id
|
|
32875
33551
|
JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
@@ -32884,11 +33560,15 @@ var SqliteSecurityRepository = class {
|
|
|
32884
33560
|
severity,
|
|
32885
33561
|
count: byRow.get(severity)?.count ?? 0,
|
|
32886
33562
|
caught: byRow.get(severity)?.caught ?? 0,
|
|
32887
|
-
|
|
33563
|
+
handled: byRow.get(severity)?.handled ?? 0,
|
|
33564
|
+
resolved: byRow.get(severity)?.resolved ?? 0,
|
|
33565
|
+
openAtRest: byRow.get(severity)?.open_at_rest ?? 0,
|
|
33566
|
+
dismissed: byRow.get(severity)?.dismissed ?? 0
|
|
32888
33567
|
}));
|
|
32889
33568
|
const total = bySeverity.reduce((sum, s) => sum + s.count, 0);
|
|
32890
33569
|
const needsRemediation = bySeverity.reduce((sum, s) => sum + s.openAtRest, 0);
|
|
32891
|
-
|
|
33570
|
+
const dismissed = bySeverity.reduce((sum, s) => sum + s.dismissed, 0);
|
|
33571
|
+
return Promise.resolve({ total, needsRemediation, dismissed, bySeverity });
|
|
32892
33572
|
}
|
|
32893
33573
|
// Range is echoed but does not change the result today — coverage is a constant
|
|
32894
33574
|
// business fact (see SCAN_COVERAGE), not a measured per-window metric. Order
|
|
@@ -33205,10 +33885,10 @@ var SqliteSecurityRepository = class {
|
|
|
33205
33885
|
* machine, and the second reported "no recommendations" over live exposure.
|
|
33206
33886
|
*
|
|
33207
33887
|
* `open` mirrors `deriveFindingStatus` — at-rest, minus resolved and dismissed —
|
|
33208
|
-
* so a row's count is exactly what `?status=open&type=<rule>` returns.
|
|
33209
|
-
*
|
|
33210
|
-
*
|
|
33211
|
-
*
|
|
33888
|
+
* so a row's count is exactly what `?status=open&type=<rule>` returns. It
|
|
33889
|
+
* differs from `severitySummary`'s `openAtRest` only in including untracked
|
|
33890
|
+
* legacy rows, which that bucket leaves out; dismissed is excluded from both.
|
|
33891
|
+
* Only this one has to match a link.
|
|
33212
33892
|
*
|
|
33213
33893
|
* Aggregated in SQL: the result is O(distinct rule × category × severity), so a
|
|
33214
33894
|
* whole-store scope costs a grouped scan rather than a row per finding.
|
|
@@ -33236,6 +33916,8 @@ var SqliteSecurityRepository = class {
|
|
|
33236
33916
|
/**
|
|
33237
33917
|
* The distinct `finding_key`s behind ONE rule's {@link recommendationInputs}
|
|
33238
33918
|
* tally — what a dashboard dismissal of that row writes a disposition for.
|
|
33919
|
+
* The dismissal itself does not call this: it reads the same set through
|
|
33920
|
+
* {@link selectOpenFindingKeysForRule}, inside its own write transaction.
|
|
33239
33921
|
*
|
|
33240
33922
|
* It shares {@link OPEN_AT_REST_FINDINGS_SQL} with the count rather than
|
|
33241
33923
|
* restating the predicate, because a dismissal has to act on exactly the set
|
|
@@ -33252,16 +33934,7 @@ var SqliteSecurityRepository = class {
|
|
|
33252
33934
|
* this set SMALLER than the tally, never larger.
|
|
33253
33935
|
*/
|
|
33254
33936
|
openFindingKeysForRule(ruleId) {
|
|
33255
|
-
|
|
33256
|
-
this.db.prepare(
|
|
33257
|
-
`SELECT DISTINCT f.finding_key AS finding_key
|
|
33258
|
-
${OPEN_AT_REST_FINDINGS_SQL}
|
|
33259
|
-
AND d.rule_id = :ruleId
|
|
33260
|
-
AND f.finding_key IS NOT NULL`
|
|
33261
|
-
),
|
|
33262
|
-
{ ruleId }
|
|
33263
|
-
);
|
|
33264
|
-
return Promise.resolve(rows.map((r) => r.finding_key));
|
|
33937
|
+
return Promise.resolve(selectOpenFindingKeysForRule(this.db, ruleId));
|
|
33265
33938
|
}
|
|
33266
33939
|
// Findings whose parent event occurred in [fromMs, toMs), with the parent's
|
|
33267
33940
|
// epoch-millis timestamp. started_at is an INTEGER column, so the bounds stay
|
|
@@ -34147,6 +34820,11 @@ var UNSAFE_TEST_ONLY_RAW_HANDLE = /* @__PURE__ */ Symbol(
|
|
|
34147
34820
|
function linkHost(input2, hostId) {
|
|
34148
34821
|
return hostId ? { ...input2, hostId } : input2;
|
|
34149
34822
|
}
|
|
34823
|
+
function captureAttributesOf(event, scopeKey) {
|
|
34824
|
+
const attributes = toCaptureAttributes(event);
|
|
34825
|
+
if (scopeKey === void 0 || scopeKey === "") return attributes;
|
|
34826
|
+
return { ...attributes, scope_key: scopeKey };
|
|
34827
|
+
}
|
|
34150
34828
|
function closeQuietly(db) {
|
|
34151
34829
|
try {
|
|
34152
34830
|
db.close();
|
|
@@ -34307,7 +34985,32 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
34307
34985
|
);
|
|
34308
34986
|
});
|
|
34309
34987
|
}
|
|
34310
|
-
function
|
|
34988
|
+
function dismissOpenFindingsForRule(ruleId, disposition) {
|
|
34989
|
+
let dismissed = 0;
|
|
34990
|
+
withTransaction(
|
|
34991
|
+
db,
|
|
34992
|
+
() => {
|
|
34993
|
+
const keys = selectOpenFindingKeysForRule(db, ruleId);
|
|
34994
|
+
resolutions.insertResolutions(
|
|
34995
|
+
keys.map((findingKey) => ({
|
|
34996
|
+
findingKey,
|
|
34997
|
+
status: "dismissed",
|
|
34998
|
+
method: disposition.method,
|
|
34999
|
+
resolvedAt: disposition.resolvedAt,
|
|
35000
|
+
evidence: disposition.evidence
|
|
35001
|
+
}))
|
|
35002
|
+
);
|
|
35003
|
+
dismissed = keys.length;
|
|
35004
|
+
},
|
|
35005
|
+
// IMMEDIATE takes the write lock at BEGIN, before the select, which is
|
|
35006
|
+
// what keeps a concurrent resolve out of the gap. It also makes waiting
|
|
35007
|
+
// on a busy writer an ordinary busy_timeout wait rather than a
|
|
35008
|
+
// read-to-write upgrade SQLite refuses to retry.
|
|
35009
|
+
"IMMEDIATE"
|
|
35010
|
+
);
|
|
35011
|
+
return dismissed;
|
|
35012
|
+
}
|
|
35013
|
+
function recordCapture(event, detected, scopeKey) {
|
|
34311
35014
|
failOpenTransaction(db, () => {
|
|
34312
35015
|
const sessionId = event.metadata?.sessionId;
|
|
34313
35016
|
if (sessionId) {
|
|
@@ -34322,7 +35025,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
34322
35025
|
rootSessionId: sessionId,
|
|
34323
35026
|
content: event.content,
|
|
34324
35027
|
contentHash: event.contentHash,
|
|
34325
|
-
attributes:
|
|
35028
|
+
attributes: captureAttributesOf(event, scopeKey)
|
|
34326
35029
|
});
|
|
34327
35030
|
const definitionIds = /* @__PURE__ */ new Map();
|
|
34328
35031
|
for (const finding of detected) {
|
|
@@ -34352,7 +35055,12 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
34352
35055
|
maskedMatch: finding.maskedMatch,
|
|
34353
35056
|
actionTaken: finding.actionTaken,
|
|
34354
35057
|
confidence: finding.confidence,
|
|
34355
|
-
findingKey: finding.findingKey ?? void 0
|
|
35058
|
+
findingKey: finding.findingKey ?? void 0,
|
|
35059
|
+
...finding.location === void 0 ? {} : {
|
|
35060
|
+
line: finding.location.line,
|
|
35061
|
+
col: finding.location.col,
|
|
35062
|
+
context: finding.location.context
|
|
35063
|
+
}
|
|
34356
35064
|
});
|
|
34357
35065
|
}
|
|
34358
35066
|
});
|
|
@@ -34490,6 +35198,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
34490
35198
|
inspectionDefinitions,
|
|
34491
35199
|
inspectionFindings,
|
|
34492
35200
|
recordCapture,
|
|
35201
|
+
dismissOpenFindingsForRule,
|
|
34493
35202
|
markCaptureDelivered,
|
|
34494
35203
|
markCaptureOwed,
|
|
34495
35204
|
markAuditEventsDelivered,
|
|
@@ -34514,6 +35223,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
34514
35223
|
// ../../packages/persistence/src/egress-wire.ts
|
|
34515
35224
|
import { createHash as createHash3 } from "crypto";
|
|
34516
35225
|
var SLASH = "/".charCodeAt(0);
|
|
35226
|
+
var SCOPE_KEY = printable(ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH);
|
|
34517
35227
|
|
|
34518
35228
|
// ../../packages/persistence/src/finding-key.ts
|
|
34519
35229
|
import { createHash as createHash4 } from "crypto";
|
|
@@ -34575,14 +35285,17 @@ var MAX_RESPONSE_BYTES = 8 * 1024 * 1024;
|
|
|
34575
35285
|
// ../../packages/remote/src/client.ts
|
|
34576
35286
|
var SLASH2 = "/".charCodeAt(0);
|
|
34577
35287
|
|
|
35288
|
+
// ../../packages/plugin-runtime/src/attached/with-timeout.ts
|
|
35289
|
+
var REQUEST_TIMEOUT_MS = 2e3;
|
|
35290
|
+
|
|
34578
35291
|
// ../../packages/plugin-runtime/src/attached/forward-drops.ts
|
|
34579
35292
|
import { readFileSync as readFileSync10 } from "fs";
|
|
34580
35293
|
import { join as join16 } from "path";
|
|
34581
35294
|
|
|
34582
35295
|
// ../../packages/plugin-runtime/src/attached/forward-policy.ts
|
|
34583
|
-
import { randomUUID as
|
|
35296
|
+
import { randomUUID as randomUUID16 } from "crypto";
|
|
34584
35297
|
import { readFile, rename, writeFile } from "fs/promises";
|
|
34585
|
-
import { join as
|
|
35298
|
+
import { join as join28 } from "path";
|
|
34586
35299
|
|
|
34587
35300
|
// ../../packages/plugin-sdk/src/config.ts
|
|
34588
35301
|
import { existsSync as existsSync8 } from "fs";
|
|
@@ -35207,6 +35920,10 @@ function escapeRegExp2(value) {
|
|
|
35207
35920
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
35208
35921
|
}
|
|
35209
35922
|
|
|
35923
|
+
// ../../packages/detections/src/format-chars.ts
|
|
35924
|
+
var HAS_FORMAT_CHAR = new RegExp("\\p{Cf}", "u");
|
|
35925
|
+
var FORMAT_CHAR_GLOBAL = new RegExp("\\p{Cf}", "gu");
|
|
35926
|
+
|
|
35210
35927
|
// ../../packages/detections/src/regex-cache.ts
|
|
35211
35928
|
var singles = /* @__PURE__ */ new WeakMap();
|
|
35212
35929
|
var keywordLists = /* @__PURE__ */ new WeakMap();
|
|
@@ -35443,6 +36160,7 @@ var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
|
|
|
35443
36160
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
35444
36161
|
import { existsSync as existsSync9, readFileSync as readFileSync11, statSync as statSync6 } from "fs";
|
|
35445
36162
|
import { basename as basename2, dirname as dirname4, isAbsolute, join as join18, sep as sep2 } from "path";
|
|
36163
|
+
var NO_ATTRIBUTION = Object.freeze({});
|
|
35446
36164
|
|
|
35447
36165
|
// ../../packages/plugin-sdk/src/events.ts
|
|
35448
36166
|
import { createHash as createHash5, randomUUID as randomUUID13 } from "crypto";
|
|
@@ -35517,6 +36235,9 @@ import { join as join24 } from "path";
|
|
|
35517
36235
|
import { readdirSync as readdirSync3, realpathSync as realpathSync3 } from "fs";
|
|
35518
36236
|
import { basename as basename4, dirname as dirname5, sep as sep3 } from "path";
|
|
35519
36237
|
|
|
36238
|
+
// ../../packages/plugin-sdk/src/policy-resolver.ts
|
|
36239
|
+
import { randomUUID as randomUUID14 } from "crypto";
|
|
36240
|
+
|
|
35520
36241
|
// ../../packages/plugin-sdk/src/project-files.ts
|
|
35521
36242
|
import { existsSync as existsSync11, readdirSync as readdirSync4 } from "fs";
|
|
35522
36243
|
import { basename as basename5, join as join25 } from "path";
|
|
@@ -35548,14 +36269,18 @@ var codexProviderEnvShape = {
|
|
|
35548
36269
|
var CodexProviderEnvSchema = external_exports.object(codexProviderEnvShape);
|
|
35549
36270
|
|
|
35550
36271
|
// ../../packages/plugin-sdk/src/runtime.ts
|
|
35551
|
-
import { randomUUID as
|
|
36272
|
+
import { randomUUID as randomUUID15 } from "crypto";
|
|
36273
|
+
|
|
36274
|
+
// ../../packages/plugin-sdk/src/scope-key.ts
|
|
36275
|
+
import { existsSync as existsSync12 } from "fs";
|
|
36276
|
+
import { dirname as dirname6, isAbsolute as isAbsolute2, join as join26, normalize } from "path";
|
|
35552
36277
|
|
|
35553
36278
|
// ../../packages/plugin-sdk/src/suppressions.ts
|
|
35554
36279
|
var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
35555
36280
|
|
|
35556
36281
|
// ../../packages/plugin-sdk/src/throttle.ts
|
|
35557
36282
|
import { mkdirSync as mkdirSync4, statSync as statSync8, writeFileSync as writeFileSync7 } from "fs";
|
|
35558
|
-
import { join as
|
|
36283
|
+
import { join as join27 } from "path";
|
|
35559
36284
|
|
|
35560
36285
|
// ../../packages/plugin-runtime/src/attached/history-sync.ts
|
|
35561
36286
|
import { createHash as createHash6 } from "crypto";
|
|
@@ -35575,13 +36300,18 @@ import { spawn } from "child_process";
|
|
|
35575
36300
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
35576
36301
|
var HISTORY_SYNC_THROTTLE_MS = 5 * 60 * 1e3;
|
|
35577
36302
|
|
|
36303
|
+
// ../../packages/plugin-runtime/src/attached/install-record.ts
|
|
36304
|
+
import { readFile as readFile2, stat } from "fs/promises";
|
|
36305
|
+
import { basename as basename6, dirname as dirname7, join as join29, resolve as resolve2 } from "path";
|
|
36306
|
+
|
|
35578
36307
|
// ../../packages/plugin-runtime/src/attached/plugin-block.ts
|
|
35579
36308
|
import { readFileSync as readFileSync18 } from "fs";
|
|
36309
|
+
var INSTALL_RECORD_READ_TIMEOUT_MS = REQUEST_TIMEOUT_MS / 2;
|
|
35580
36310
|
|
|
35581
36311
|
// ../../packages/plugin-runtime/src/attached/policy-store.ts
|
|
35582
|
-
import { randomUUID as
|
|
35583
|
-
import { readFile as
|
|
35584
|
-
import { join as
|
|
36312
|
+
import { randomUUID as randomUUID17 } from "crypto";
|
|
36313
|
+
import { readFile as readFile3, rm, writeFile as writeFile2 } from "fs/promises";
|
|
36314
|
+
import { join as join30 } from "path";
|
|
35585
36315
|
|
|
35586
36316
|
// ../../packages/plugin-runtime/src/attached/atomic-publish.ts
|
|
35587
36317
|
import { rename as rename2 } from "fs/promises";
|
|
@@ -35591,7 +36321,7 @@ var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
|
|
|
35591
36321
|
|
|
35592
36322
|
// ../../packages/plugin-runtime/src/attached/posture-report-state.ts
|
|
35593
36323
|
import { readFileSync as readFileSync19 } from "fs";
|
|
35594
|
-
import { join as
|
|
36324
|
+
import { join as join31 } from "path";
|
|
35595
36325
|
var OUTCOME_KEYS = {
|
|
35596
36326
|
ok: true,
|
|
35597
36327
|
unauthorized: true,
|
|
@@ -35612,13 +36342,13 @@ import { statSync as statSync9 } from "fs";
|
|
|
35612
36342
|
import { DatabaseSync as DatabaseSync4 } from "node:sqlite";
|
|
35613
36343
|
|
|
35614
36344
|
// ../../packages/plugin-runtime/src/attached/posture-store.ts
|
|
35615
|
-
import { randomUUID as
|
|
35616
|
-
import { readFile as
|
|
35617
|
-
import { join as
|
|
36345
|
+
import { randomUUID as randomUUID18 } from "crypto";
|
|
36346
|
+
import { readFile as readFile4, rm as rm2, writeFile as writeFile3 } from "fs/promises";
|
|
36347
|
+
import { join as join32 } from "path";
|
|
35618
36348
|
|
|
35619
36349
|
// ../../packages/plugin-runtime/src/attached/sync-state.ts
|
|
35620
36350
|
import { readFileSync as readFileSync20 } from "fs";
|
|
35621
|
-
import { join as
|
|
36351
|
+
import { join as join33 } from "path";
|
|
35622
36352
|
|
|
35623
36353
|
// ../../packages/plugin-runtime/src/attached/status.ts
|
|
35624
36354
|
var REFUSAL_LINES = {
|
|
@@ -35670,9 +36400,6 @@ var CONTENT_RETENTION_THROTTLE_MS = 60 * 60 * 1e3;
|
|
|
35670
36400
|
// ../../packages/plugin-runtime/src/attached/factory.ts
|
|
35671
36401
|
import { hostname as hostname6 } from "os";
|
|
35672
36402
|
|
|
35673
|
-
// ../../packages/plugin-runtime/src/standalone-gateway.ts
|
|
35674
|
-
import { randomUUID as randomUUID18 } from "crypto";
|
|
35675
|
-
|
|
35676
36403
|
// ../../packages/plugin-runtime/src/handle-session-start.ts
|
|
35677
36404
|
import { randomUUID as randomUUID19 } from "crypto";
|
|
35678
36405
|
var EXCEPTION_RETENTION_MS = 90 * 24 * 60 * 60 * 1e3;
|