@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
package/scripts/onboard.js
CHANGED
|
@@ -32,9 +32,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
32
32
|
mod
|
|
33
33
|
));
|
|
34
34
|
|
|
35
|
-
// ../../node_modules/.pnpm/ignore@7.0.
|
|
35
|
+
// ../../node_modules/.pnpm/ignore@7.0.11/node_modules/ignore/index.js
|
|
36
36
|
var require_ignore = __commonJS({
|
|
37
|
-
"../../node_modules/.pnpm/ignore@7.0.
|
|
37
|
+
"../../node_modules/.pnpm/ignore@7.0.11/node_modules/ignore/index.js"(exports, module) {
|
|
38
38
|
"use strict";
|
|
39
39
|
function makeArray(subject) {
|
|
40
40
|
return Array.isArray(subject) ? subject : [subject];
|
|
@@ -169,6 +169,7 @@ var require_ignore = __commonJS({
|
|
|
169
169
|
"g"
|
|
170
170
|
);
|
|
171
171
|
var TRAILING_WILDCARD = "\uE000";
|
|
172
|
+
var TRAILING_DOUBLESTAR = "\uE001";
|
|
172
173
|
var extractBrackets = (pattern) => {
|
|
173
174
|
const sources = [];
|
|
174
175
|
const hold = (source) => `${PLACEHOLDER}${sources.push(source) - 1}${PLACEHOLDER}`;
|
|
@@ -329,7 +330,7 @@ var require_ignore = __commonJS({
|
|
|
329
330
|
// Zero, one or several directories
|
|
330
331
|
// should not use '*', or it will be replaced by the next replacer
|
|
331
332
|
// Check if it is not the last `'/**'`
|
|
332
|
-
(_, index, str2) => index + 6 < str2.length ? str2.slice(index + 6) === "\\/" ? "(?:\\/[^\\/]+)+" : "(?:\\/[^\\/]+)*" :
|
|
333
|
+
(_, index, str2) => index + 6 < str2.length ? str2.slice(index + 6) === "\\/" ? "(?:\\/[^\\/]+)+" : "(?:\\/[^\\/]+)*" : `\\/${TRAILING_DOUBLESTAR}`,
|
|
333
334
|
"*"
|
|
334
335
|
],
|
|
335
336
|
// normal intermediate wildcards
|
|
@@ -407,7 +408,7 @@ var require_ignore = __commonJS({
|
|
|
407
408
|
// 'js' will match 'a.js' and 'a.js/'
|
|
408
409
|
(source) => {
|
|
409
410
|
const last = source[source.length - 1];
|
|
410
|
-
if (!last || last === TRAILING_WILDCARD) {
|
|
411
|
+
if (!last || last === TRAILING_WILDCARD || last === TRAILING_DOUBLESTAR) {
|
|
411
412
|
return source;
|
|
412
413
|
}
|
|
413
414
|
return last === SLASH2 ? `${source}$` : `${source}(?=$|\\/$)`;
|
|
@@ -418,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] === SLASH2) {
|
|
545
|
+
prefix = makeRegexPrefix(body.slice(0, -1));
|
|
546
|
+
}
|
|
547
|
+
const head = prefix.slice(0, -1);
|
|
548
|
+
const last = prefix[prefix.length - 1];
|
|
549
|
+
return last === TRAILING_WILDCARD ? `${head}$` : last === TRAILING_DOUBLESTAR ? `${head}.*$` : NEVER_MATCH;
|
|
550
|
+
};
|
|
539
551
|
var matchesBasename = (body) => {
|
|
540
552
|
const index = body.indexOf(SLASH2);
|
|
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] === SLASH2 ? 2 : 1)] === "*"
|
|
683
|
+
));
|
|
684
|
+
let ignored = false;
|
|
685
|
+
let unignored = false;
|
|
686
|
+
let matchedRule;
|
|
687
|
+
for (let index = rules.length - 1; index >= 0; index--) {
|
|
688
|
+
const rule = rules[index];
|
|
689
|
+
if (rule.checkRegex.test(path)) {
|
|
690
|
+
ignored = !rule.negative;
|
|
691
|
+
unignored = rule.negative;
|
|
692
|
+
matchedRule = rule.negative ? UNDEFINED : rule;
|
|
693
|
+
break;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
const ret = {
|
|
697
|
+
ignored,
|
|
698
|
+
unignored
|
|
699
|
+
};
|
|
700
|
+
if (matchedRule) {
|
|
701
|
+
ret.rule = matchedRule;
|
|
702
|
+
}
|
|
703
|
+
return ret;
|
|
704
|
+
}
|
|
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,
|
|
@@ -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
|
|
|
@@ -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
|
});
|
|
@@ -24932,10 +25094,15 @@ var ParsedPointer = external_exports.object({
|
|
|
24932
25094
|
});
|
|
24933
25095
|
var VaultEntry = external_exports.object({
|
|
24934
25096
|
pointerId: external_exports.string(),
|
|
24935
|
-
// The keyed HMAC of the raw
|
|
24936
|
-
// derived under.
|
|
24937
|
-
// independently of the vault encryption
|
|
25097
|
+
// The keyed HMAC of the EXACT raw bytes under `exception.key`, and the epoch it
|
|
25098
|
+
// was derived under. The vault's own dedupe key: a value and its invisibly
|
|
25099
|
+
// padded twin are two rows. It rotates independently of the vault encryption
|
|
25100
|
+
// key below. Never matched against an exception or grant.
|
|
24938
25101
|
valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
25102
|
+
// The same HMAC over the raw with invisible padding removed: the identity a
|
|
25103
|
+
// reveal-to-model grant and every exception match on. Shared by a value and
|
|
25104
|
+
// its padded twin.
|
|
25105
|
+
valueIdentityFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
24939
25106
|
fingerprintKeyVersion: external_exports.number().int().positive(),
|
|
24940
25107
|
// The vault-key epoch this row's ciphertext was sealed under.
|
|
24941
25108
|
keyVersion: external_exports.number().int().positive(),
|
|
@@ -25082,7 +25249,7 @@ function isVaultConsentValid(consent) {
|
|
|
25082
25249
|
}
|
|
25083
25250
|
|
|
25084
25251
|
// ../../packages/schema/src/zod/local.ts
|
|
25085
|
-
var WORKSPACE_SETTINGS_SPEC_VERSION =
|
|
25252
|
+
var WORKSPACE_SETTINGS_SPEC_VERSION = 9;
|
|
25086
25253
|
var MODEL_JUDGE_PAYLOAD_VERSION = 1;
|
|
25087
25254
|
var RunMode = external_exports.enum(["standalone", "attached"]);
|
|
25088
25255
|
var ControlPlaneConnection = external_exports.object({
|
|
@@ -25105,6 +25272,18 @@ var HistorySyncConsent = external_exports.object({
|
|
|
25105
25272
|
payloadVersion: external_exports.number().int().positive(),
|
|
25106
25273
|
endpoint: external_exports.string()
|
|
25107
25274
|
});
|
|
25275
|
+
var ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH = 512;
|
|
25276
|
+
var AttachmentScopeEntry = external_exports.object({
|
|
25277
|
+
kind: external_exports.enum(["repo", "account"]),
|
|
25278
|
+
identity: printable(ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH).min(1),
|
|
25279
|
+
label: printable(80).optional(),
|
|
25280
|
+
enrolledAt: external_exports.iso.datetime()
|
|
25281
|
+
});
|
|
25282
|
+
var AttachmentScope = external_exports.object({
|
|
25283
|
+
endpoint: external_exports.string().min(1),
|
|
25284
|
+
entries: external_exports.array(AttachmentScopeEntry)
|
|
25285
|
+
});
|
|
25286
|
+
var AttachmentScopeEnvelope = AttachmentScope.extend({ entries: external_exports.array(external_exports.unknown()) });
|
|
25108
25287
|
var WebChatCaptureConsent = external_exports.object({
|
|
25109
25288
|
acknowledgedAt: external_exports.iso.datetime(),
|
|
25110
25289
|
version: external_exports.number().int().positive()
|
|
@@ -25175,6 +25354,23 @@ var WorkspaceSettings = external_exports.object({
|
|
|
25175
25354
|
// both widenings. Absent until granted, and a grant for a different endpoint
|
|
25176
25355
|
// or an older payload no longer counts.
|
|
25177
25356
|
historySyncConsent: HistorySyncConsent.optional(),
|
|
25357
|
+
// The identities a SCOPED attachment forwards and the deployment they were
|
|
25358
|
+
// enrolled for (see AttachmentScope). Absent until something is enrolled.
|
|
25359
|
+
//
|
|
25360
|
+
// `z.unknown()`, NOT `AttachmentScope`, and the difference is this field's
|
|
25361
|
+
// whole failure mode. A settings.json that fails this schema reads as the
|
|
25362
|
+
// unonboarded defaults (readUserSettings in @akasecurity/persistence), and the
|
|
25363
|
+
// next save writes those defaults back over it. Typed, one entry with an
|
|
25364
|
+
// unknown `kind`, a control character or a bad timestamp would cost the
|
|
25365
|
+
// attachment, every consent and onboardedAt, permanently. Untyped, the value
|
|
25366
|
+
// is kept exactly as found and validated where it is used: parseAttachmentScope
|
|
25367
|
+
// drops a bad entry by itself, and on a scoped attachment resolveScope reads a
|
|
25368
|
+
// bad envelope as no entries, which keeps every event local.
|
|
25369
|
+
//
|
|
25370
|
+
// No default: absent must stay absent, so defaultWorkspaceSettings() and a
|
|
25371
|
+
// fresh settings.json do not change. No `.meta({ id })`, like every field
|
|
25372
|
+
// here. Not a ManagedSettingKey.
|
|
25373
|
+
attachmentScope: external_exports.unknown().optional(),
|
|
25178
25374
|
// What the browser extension may record from a web chat, and the grant that
|
|
25179
25375
|
// authorizes it. Absent until the user answers: recording something that was
|
|
25180
25376
|
// never recorded before is never an assumed grant on upgrade, so the whole
|
|
@@ -25269,7 +25465,10 @@ function toInspectionFindingRow(input2) {
|
|
|
25269
25465
|
actionTaken: input2.actionTaken,
|
|
25270
25466
|
confidence: input2.confidence,
|
|
25271
25467
|
findingKey: input2.findingKey ?? null,
|
|
25272
|
-
firstDetectedAt: input2.firstDetectedAt ? isoToEpochMillis(input2.firstDetectedAt) : null
|
|
25468
|
+
firstDetectedAt: input2.firstDetectedAt ? isoToEpochMillis(input2.firstDetectedAt) : null,
|
|
25469
|
+
line: input2.line ?? null,
|
|
25470
|
+
col: input2.col ?? null,
|
|
25471
|
+
context: input2.context ? JSON.stringify(input2.context) : null
|
|
25273
25472
|
};
|
|
25274
25473
|
}
|
|
25275
25474
|
function toCaptureAttributes(event) {
|
|
@@ -25515,10 +25714,18 @@ var SeveritySummaryItem = external_exports.object({
|
|
|
25515
25714
|
count: external_exports.number().int().nonnegative(),
|
|
25516
25715
|
// Resolution-aware breakdown (optional, additive). Populated once findings
|
|
25517
25716
|
// carry lifecycle state: `caught` = handled in-flight (enforced); `openAtRest`
|
|
25518
|
-
// = still open with no in-flight enforcement (needs remediation)
|
|
25519
|
-
//
|
|
25717
|
+
// = still open with no in-flight enforcement (needs remediation); `dismissed`
|
|
25718
|
+
// = closed by a human judgement rather than a fix — visible, but not counted as
|
|
25719
|
+
// needing remediation. The three are disjoint. Absent on the legacy count-only
|
|
25720
|
+
// response until the resolution feature lands.
|
|
25520
25721
|
caught: external_exports.number().int().nonnegative().optional(),
|
|
25521
|
-
openAtRest: external_exports.number().int().nonnegative().optional()
|
|
25722
|
+
openAtRest: external_exports.number().int().nonnegative().optional(),
|
|
25723
|
+
dismissed: external_exports.number().int().nonnegative().optional(),
|
|
25724
|
+
// The two halves of `caught`, for a reader that wants them apart: `handled` =
|
|
25725
|
+
// in-flight findings an enforcement action already contained; `resolved` =
|
|
25726
|
+
// at-rest findings closed out by fixing them. `handled + resolved === caught`.
|
|
25727
|
+
handled: external_exports.number().int().nonnegative().optional(),
|
|
25728
|
+
resolved: external_exports.number().int().nonnegative().optional()
|
|
25522
25729
|
}).meta({ id: "SeveritySummaryItem" });
|
|
25523
25730
|
var SeveritySummaryResponse = external_exports.object({
|
|
25524
25731
|
// Sum of bySeverity[].count.
|
|
@@ -25526,6 +25733,9 @@ var SeveritySummaryResponse = external_exports.object({
|
|
|
25526
25733
|
// Findings still open at rest (sum of bySeverity[].openAtRest). Optional and
|
|
25527
25734
|
// additive — absent on the legacy response until the resolution feature lands.
|
|
25528
25735
|
needsRemediation: external_exports.number().int().nonnegative().optional(),
|
|
25736
|
+
// Findings a user dismissed (sum of bySeverity[].dismissed). Excluded from
|
|
25737
|
+
// needsRemediation, and kept visible here so an accepted risk is not erased.
|
|
25738
|
+
dismissed: external_exports.number().int().nonnegative().optional(),
|
|
25529
25739
|
// All four severity levels are always present (count may be 0).
|
|
25530
25740
|
bySeverity: external_exports.array(SeveritySummaryItem)
|
|
25531
25741
|
}).meta({ id: "SeveritySummaryResponse" });
|
|
@@ -26431,6 +26641,15 @@ var COUNTED_SCOPE = `
|
|
|
26431
26641
|
OR outbox_owed = 1
|
|
26432
26642
|
)`;
|
|
26433
26643
|
var SKIPPED = -1;
|
|
26644
|
+
function inScope(column) {
|
|
26645
|
+
return `${column} IN (SELECT value FROM json_each(:scopeKeys))`;
|
|
26646
|
+
}
|
|
26647
|
+
function scopeKeysParam(scopeKeys) {
|
|
26648
|
+
return JSON.stringify(scopeKeys);
|
|
26649
|
+
}
|
|
26650
|
+
var ROOT_SCOPE_KEY = `(SELECT session_root.scope_key
|
|
26651
|
+
FROM audit_events AS session_root
|
|
26652
|
+
WHERE session_root.id = COALESCE(audit_events.root_session_id, audit_events.id))`;
|
|
26434
26653
|
var ROW_COLUMNS = `id,
|
|
26435
26654
|
parent_id AS parentId,
|
|
26436
26655
|
root_session_id AS rootSessionId,
|
|
@@ -26459,6 +26678,18 @@ var SqliteHistorySyncRepository = class {
|
|
|
26459
26678
|
ORDER BY earliest
|
|
26460
26679
|
LIMIT :limit`
|
|
26461
26680
|
);
|
|
26681
|
+
this.scopedSessionsStmt = db.prepare(
|
|
26682
|
+
`SELECT COALESCE(root_session_id, id) AS sessionId, MIN(started_at) AS earliest
|
|
26683
|
+
FROM audit_events
|
|
26684
|
+
WHERE synced_at IS NULL
|
|
26685
|
+
AND event_type IN (${TYPE_LIST})
|
|
26686
|
+
AND started_at < :before
|
|
26687
|
+
AND ${inScope("scope_key")}
|
|
26688
|
+
AND ${inScope(ROOT_SCOPE_KEY)}
|
|
26689
|
+
GROUP BY sessionId
|
|
26690
|
+
ORDER BY earliest
|
|
26691
|
+
LIMIT :limit`
|
|
26692
|
+
);
|
|
26462
26693
|
this.rowsStmt = db.prepare(
|
|
26463
26694
|
`SELECT ${ROW_COLUMNS}
|
|
26464
26695
|
FROM audit_events
|
|
@@ -26469,6 +26700,18 @@ var SqliteHistorySyncRepository = class {
|
|
|
26469
26700
|
ORDER BY (event_type = 'session') DESC, started_at
|
|
26470
26701
|
LIMIT :limit`
|
|
26471
26702
|
);
|
|
26703
|
+
this.scopedRowsStmt = db.prepare(
|
|
26704
|
+
`SELECT ${ROW_COLUMNS}
|
|
26705
|
+
FROM audit_events
|
|
26706
|
+
WHERE synced_at IS NULL
|
|
26707
|
+
AND event_type IN (${TYPE_LIST})
|
|
26708
|
+
AND started_at < :before
|
|
26709
|
+
AND COALESCE(root_session_id, id) = :sessionId
|
|
26710
|
+
AND ${inScope("scope_key")}
|
|
26711
|
+
AND ${inScope(ROOT_SCOPE_KEY)}
|
|
26712
|
+
ORDER BY (event_type = 'session') DESC, started_at
|
|
26713
|
+
LIMIT :limit`
|
|
26714
|
+
);
|
|
26472
26715
|
this.captureRowsStmt = db.prepare(
|
|
26473
26716
|
`SELECT ${ROW_COLUMNS}
|
|
26474
26717
|
FROM audit_events
|
|
@@ -26480,6 +26723,18 @@ var SqliteHistorySyncRepository = class {
|
|
|
26480
26723
|
ORDER BY started_at
|
|
26481
26724
|
LIMIT :limit`
|
|
26482
26725
|
);
|
|
26726
|
+
this.scopedCaptureRowsStmt = db.prepare(
|
|
26727
|
+
`SELECT ${ROW_COLUMNS}
|
|
26728
|
+
FROM audit_events
|
|
26729
|
+
WHERE synced_at IS NULL
|
|
26730
|
+
AND sync_claimed_at IS NULL
|
|
26731
|
+
AND outbox_owed = 1
|
|
26732
|
+
AND event_type IN (${CAPTURE_TYPE_LIST})
|
|
26733
|
+
AND started_at < :before
|
|
26734
|
+
AND ${inScope("scope_key")}
|
|
26735
|
+
ORDER BY started_at
|
|
26736
|
+
LIMIT :limit`
|
|
26737
|
+
);
|
|
26483
26738
|
this.markOwedStmt = db.prepare(
|
|
26484
26739
|
`UPDATE audit_events SET outbox_owed = 1 WHERE id = :id AND synced_at IS NULL`
|
|
26485
26740
|
);
|
|
@@ -26489,6 +26744,20 @@ var SqliteHistorySyncRepository = class {
|
|
|
26489
26744
|
AND event_type IN (${CAPTURE_TYPE_LIST})
|
|
26490
26745
|
AND started_at < :before`
|
|
26491
26746
|
);
|
|
26747
|
+
this.scopedCaptureBacklogOwedStmt = db.prepare(
|
|
26748
|
+
`UPDATE audit_events SET outbox_owed = 1
|
|
26749
|
+
WHERE synced_at IS NULL
|
|
26750
|
+
AND event_type IN (${CAPTURE_TYPE_LIST})
|
|
26751
|
+
AND started_at < :before
|
|
26752
|
+
AND ${inScope("scope_key")}`
|
|
26753
|
+
);
|
|
26754
|
+
this.markScopeCapturesOwedStmt = db.prepare(
|
|
26755
|
+
`UPDATE audit_events SET outbox_owed = 1
|
|
26756
|
+
WHERE synced_at IS NULL
|
|
26757
|
+
AND outbox_owed IS NULL
|
|
26758
|
+
AND event_type IN (${CAPTURE_TYPE_LIST})
|
|
26759
|
+
AND ${inScope("scope_key")}`
|
|
26760
|
+
);
|
|
26492
26761
|
this.stampStmt = db.prepare(
|
|
26493
26762
|
`UPDATE audit_events
|
|
26494
26763
|
SET synced_at = :at,
|
|
@@ -26647,6 +26916,15 @@ var SqliteHistorySyncRepository = class {
|
|
|
26647
26916
|
claimRowStmt;
|
|
26648
26917
|
releaseRowStmt;
|
|
26649
26918
|
releaseStaleClaimsStmt;
|
|
26919
|
+
// The SCOPED twins, for a scoped attachment: the same reads and seeds with the
|
|
26920
|
+
// scope clause added, prepared once here beside the machine statements, so a
|
|
26921
|
+
// machine attachment's statements are untouched and neither form is compiled
|
|
26922
|
+
// per call.
|
|
26923
|
+
scopedSessionsStmt;
|
|
26924
|
+
scopedRowsStmt;
|
|
26925
|
+
scopedCaptureRowsStmt;
|
|
26926
|
+
scopedCaptureBacklogOwedStmt;
|
|
26927
|
+
markScopeCapturesOwedStmt;
|
|
26650
26928
|
/**
|
|
26651
26929
|
* The masked detections recorded against one tool call.
|
|
26652
26930
|
*
|
|
@@ -26666,15 +26944,33 @@ var SqliteHistorySyncRepository = class {
|
|
|
26666
26944
|
* path's to deliver; this drain exists for what was recorded before it, and a
|
|
26667
26945
|
* row both paths send is at best a duplicate request and at worst — for a
|
|
26668
26946
|
* session root — an overwrite of the inventory ids the live path resolved.
|
|
26947
|
+
*
|
|
26948
|
+
* `scopeKeys` is a scoped attachment's filter: a session is offered only while
|
|
26949
|
+
* its root's key is one of them AND at least one of its unsent rows' keys is
|
|
26950
|
+
* (see scopedSessionsStmt). Omitted, this runs the machine statement,
|
|
26951
|
+
* unchanged; an empty list offers nothing.
|
|
26669
26952
|
*/
|
|
26670
|
-
pendingSessions(limit, before) {
|
|
26671
|
-
|
|
26672
|
-
|
|
26673
|
-
|
|
26953
|
+
pendingSessions(limit, before, scopeKeys) {
|
|
26954
|
+
const rows = scopeKeys === void 0 ? allRows(this.sessionsStmt, { limit, before }) : allRows(this.scopedSessionsStmt, {
|
|
26955
|
+
limit,
|
|
26956
|
+
before,
|
|
26957
|
+
scopeKeys: scopeKeysParam(scopeKeys)
|
|
26958
|
+
});
|
|
26959
|
+
return rows.map((r) => r.sessionId);
|
|
26674
26960
|
}
|
|
26675
|
-
/**
|
|
26676
|
-
|
|
26677
|
-
|
|
26961
|
+
/**
|
|
26962
|
+
* One session's undelivered structural rows within the backlog, root first.
|
|
26963
|
+
*
|
|
26964
|
+
* With `scopeKeys`, only the rows whose own key AND whose session root's key
|
|
26965
|
+
* are among them, whichever session id is passed.
|
|
26966
|
+
*/
|
|
26967
|
+
pendingRows(sessionId, limit, before, scopeKeys) {
|
|
26968
|
+
return scopeKeys === void 0 ? allRows(this.rowsStmt, { sessionId, limit, before }) : allRows(this.scopedRowsStmt, {
|
|
26969
|
+
sessionId,
|
|
26970
|
+
limit,
|
|
26971
|
+
before,
|
|
26972
|
+
scopeKeys: scopeKeysParam(scopeKeys)
|
|
26973
|
+
});
|
|
26678
26974
|
}
|
|
26679
26975
|
/**
|
|
26680
26976
|
* Captures this machine still owes the deployment, oldest first.
|
|
@@ -26683,9 +26979,17 @@ var SqliteHistorySyncRepository = class {
|
|
|
26683
26979
|
* by a time window — see captureRowsStmt for why a window could not express
|
|
26684
26980
|
* this. `before` is the grace window that leaves a just-recorded capture to
|
|
26685
26981
|
* the live path.
|
|
26982
|
+
*
|
|
26983
|
+
* With `scopeKeys`, only captures stamped with one of them, decided per
|
|
26984
|
+
* capture: /v1/events stubs a missing root, so a capture never waits on its
|
|
26985
|
+
* session's scope. An empty list reads nothing.
|
|
26686
26986
|
*/
|
|
26687
|
-
pendingCaptureRows(limit, before) {
|
|
26688
|
-
return allRows(this.captureRowsStmt, { limit, before })
|
|
26987
|
+
pendingCaptureRows(limit, before, scopeKeys) {
|
|
26988
|
+
return scopeKeys === void 0 ? allRows(this.captureRowsStmt, { limit, before }) : allRows(this.scopedCaptureRowsStmt, {
|
|
26989
|
+
limit,
|
|
26990
|
+
before,
|
|
26991
|
+
scopeKeys: scopeKeysParam(scopeKeys)
|
|
26992
|
+
});
|
|
26689
26993
|
}
|
|
26690
26994
|
/**
|
|
26691
26995
|
* Record that a capture is OWED to the deployment.
|
|
@@ -26717,9 +27021,37 @@ var SqliteHistorySyncRepository = class {
|
|
|
26717
27021
|
* Returns how many rows matched, for the caller to log or test against. Not a
|
|
26718
27022
|
* count of NEWLY marked rows — a row still unsynced from an earlier call
|
|
26719
27023
|
* matches again and is counted again, the same as `UPDATE`'s own `changes`.
|
|
27024
|
+
*
|
|
27025
|
+
* `scopeKeys` scopes it for a scoped attachment: only captures stamped with one
|
|
27026
|
+
* of the keys are marked, and an empty list marks none. The scoped capture read
|
|
27027
|
+
* is what keeps a personal capture out of a batch; this keeps the marker to
|
|
27028
|
+
* what the grant covers. Omitted, it runs the machine statement, unchanged.
|
|
27029
|
+
*/
|
|
27030
|
+
markCaptureBacklogOwed(before, scopeKeys) {
|
|
27031
|
+
const result = scopeKeys === void 0 ? this.markCaptureBacklogOwedStmt.run({ before }) : this.scopedCaptureBacklogOwedStmt.run({ before, scopeKeys: scopeKeysParam(scopeKeys) });
|
|
27032
|
+
return Number(result.changes);
|
|
27033
|
+
}
|
|
27034
|
+
/**
|
|
27035
|
+
* Mark owed every unsent capture stamped with one of `scopeKeys`: the re-seed
|
|
27036
|
+
* an enrollment runs.
|
|
27037
|
+
*
|
|
27038
|
+
* This ASSUMES the contract a scoped caller keeps, and cannot check it: nothing
|
|
27039
|
+
* else marks an out-of-scope capture owed (the live forward must refuse it
|
|
27040
|
+
* before its owed branch, and the consent-time seed must be handed the key
|
|
27041
|
+
* list). Under that contract, an enrolled repository's unsent captures are
|
|
27042
|
+
* reachable only if this runs when the repository is enrolled. Like the
|
|
27043
|
+
* consent seed it is one explicit human action, never something a pass infers,
|
|
27044
|
+
* and its caller must know the history grant is in force: this method cannot
|
|
27045
|
+
* check consent and must not be called without it.
|
|
27046
|
+
*
|
|
27047
|
+
* No time bound. Delivered and skipped rows are never re-opened, and a row
|
|
27048
|
+
* already owed is not counted, so the return value is how many rows this call
|
|
27049
|
+
* newly marked. An empty list marks nothing.
|
|
26720
27050
|
*/
|
|
26721
|
-
|
|
26722
|
-
return Number(
|
|
27051
|
+
markScopeCapturesOwed(scopeKeys) {
|
|
27052
|
+
return Number(
|
|
27053
|
+
this.markScopeCapturesOwedStmt.run({ scopeKeys: scopeKeysParam(scopeKeys) }).changes
|
|
27054
|
+
);
|
|
26723
27055
|
}
|
|
26724
27056
|
/**
|
|
26725
27057
|
* Record delivery. Called only AFTER the far side has accepted the rows.
|
|
@@ -26924,8 +27256,12 @@ var SqliteHistorySyncRepository = class {
|
|
|
26924
27256
|
* disown from eating THIS SAME CALL's own re-mark is the order, not the
|
|
26925
27257
|
* bound — disown runs first, re-mark second, both inside the one
|
|
26926
27258
|
* transaction above.
|
|
27259
|
+
*
|
|
27260
|
+
* `scopeKeys` scopes the re-mark exactly as `markCaptureBacklogOwed` is scoped.
|
|
27261
|
+
* The disown before it is not scoped, and must not be: it clears the previous
|
|
27262
|
+
* deployment's markers whatever their scope.
|
|
26927
27263
|
*/
|
|
26928
|
-
rearmFor(fingerprint, backlogBefore, backfillCapturesBefore) {
|
|
27264
|
+
rearmFor(fingerprint, backlogBefore, backfillCapturesBefore, scopeKeys) {
|
|
26929
27265
|
this.ensureRowStmt.run();
|
|
26930
27266
|
withTransaction(
|
|
26931
27267
|
this.db,
|
|
@@ -26936,7 +27272,7 @@ var SqliteHistorySyncRepository = class {
|
|
|
26936
27272
|
this.disownCapturesStmt.run({ attachedAt: backlogBefore });
|
|
26937
27273
|
}
|
|
26938
27274
|
if (backfillCapturesBefore !== void 0) {
|
|
26939
|
-
this.
|
|
27275
|
+
this.markCaptureBacklogOwed(backfillCapturesBefore, scopeKeys);
|
|
26940
27276
|
}
|
|
26941
27277
|
this.setFingerprintStmt.run({ fingerprint, backlogBefore });
|
|
26942
27278
|
},
|
|
@@ -27102,6 +27438,7 @@ function applyMigrations(db, file2, options = {}) {
|
|
|
27102
27438
|
db.exec(`PRAGMA user_version = ${String(SQLITE_MIGRATIONS.length)}`);
|
|
27103
27439
|
}
|
|
27104
27440
|
ensureSyncedAtColumn(db, "audit_events");
|
|
27441
|
+
ensureScopeKeyColumn(db);
|
|
27105
27442
|
ensureScanLedgerTable(db);
|
|
27106
27443
|
ensureHistorySyncTable(db);
|
|
27107
27444
|
ensureBlockedDetectionsTable(db);
|
|
@@ -27527,6 +27864,21 @@ function ensureSyncedAtColumn(db, table2) {
|
|
|
27527
27864
|
ON audit_events (sync_claimed_at) WHERE sync_claimed_at IS NOT NULL`
|
|
27528
27865
|
);
|
|
27529
27866
|
}
|
|
27867
|
+
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";
|
|
27868
|
+
function ensureScopeKeyColumn(db) {
|
|
27869
|
+
if (!schemaObjectExists(db, "table", "audit_events")) return;
|
|
27870
|
+
if (hasScopeKeyColumn(db)) return;
|
|
27871
|
+
withTransaction(
|
|
27872
|
+
db,
|
|
27873
|
+
() => {
|
|
27874
|
+
if (!hasScopeKeyColumn(db)) db.exec(SCOPE_KEY_COLUMN_DDL);
|
|
27875
|
+
},
|
|
27876
|
+
"IMMEDIATE"
|
|
27877
|
+
);
|
|
27878
|
+
}
|
|
27879
|
+
function hasScopeKeyColumn(db) {
|
|
27880
|
+
return columnNames(db, "audit_events", { includeGenerated: true }).includes("scope_key");
|
|
27881
|
+
}
|
|
27530
27882
|
function ensureScanLedgerTable(db) {
|
|
27531
27883
|
db.exec(`CREATE TABLE IF NOT EXISTS scan_ledger (
|
|
27532
27884
|
path TEXT PRIMARY KEY,
|
|
@@ -28404,6 +28756,19 @@ var SqliteAuditEventsRepository = class {
|
|
|
28404
28756
|
if (typeof provider === "string") return provider;
|
|
28405
28757
|
return void 0;
|
|
28406
28758
|
}
|
|
28759
|
+
// The `scope_key` stored on a session root's attributes: the key the history
|
|
28760
|
+
// drain decides that root by. It is NOT necessarily the key of the root event a
|
|
28761
|
+
// caller just wrote, because roots are first-write-wins (see the session-root
|
|
28762
|
+
// upsert above) and the root event that arrives second leaves the stored row as
|
|
28763
|
+
// it was. Returns undefined when the id is not a session root, when the root is
|
|
28764
|
+
// a stub or carries no key, and when the stored value is not a string, which is
|
|
28765
|
+
// what the drain's scoped reads would not match either.
|
|
28766
|
+
sessionScopeKey(sessionId) {
|
|
28767
|
+
const row = this.findById(sessionId);
|
|
28768
|
+
if (row?.event_type !== "session" || !row.attributes) return void 0;
|
|
28769
|
+
const key = parseJsonObject(row.attributes)?.scope_key;
|
|
28770
|
+
return typeof key === "string" ? key : void 0;
|
|
28771
|
+
}
|
|
28407
28772
|
// Every `llm_call` leaf's session id + raw attribute bag, for the read-time token
|
|
28408
28773
|
// rollups. The caller parses each bag and prices it via the
|
|
28409
28774
|
// cost model — we stay a thin reader here (no business logic, no cost). `root_session_id`
|
|
@@ -28424,6 +28789,8 @@ var SqliteAuditEventsRepository = class {
|
|
|
28424
28789
|
var DEFAULT_BATCH_SIZE = 500;
|
|
28425
28790
|
var DEFAULT_MAX_ROWS = 5e4;
|
|
28426
28791
|
var SYNC_LANE_TYPES_SQL = OUTBOX_CAPTURE_TYPE_LIST;
|
|
28792
|
+
var SWEEP = { kind: "sweep" };
|
|
28793
|
+
var HOLD_ALL = { kind: "hold-all" };
|
|
28427
28794
|
var SqliteBodyRetentionRepository = class {
|
|
28428
28795
|
constructor(db) {
|
|
28429
28796
|
this.db = db;
|
|
@@ -28440,6 +28807,14 @@ var SqliteBodyRetentionRepository = class {
|
|
|
28440
28807
|
this.candidatesSyncSafeStmt = this.db.prepare(
|
|
28441
28808
|
select(`AND (event_type NOT IN (${SYNC_LANE_TYPES_SQL}) OR synced_at IS NOT NULL)`)
|
|
28442
28809
|
);
|
|
28810
|
+
this.candidatesScopedStmt = this.db.prepare(
|
|
28811
|
+
select(
|
|
28812
|
+
`AND (event_type NOT IN (${SYNC_LANE_TYPES_SQL}) OR synced_at IS NOT NULL
|
|
28813
|
+
OR (outbox_owed IS NOT 1
|
|
28814
|
+
AND (scope_key IS NULL
|
|
28815
|
+
OR scope_key NOT IN (SELECT value FROM json_each(:scopeKeys)))))`
|
|
28816
|
+
)
|
|
28817
|
+
);
|
|
28443
28818
|
this.heldBySyncStmt = this.db.prepare(`
|
|
28444
28819
|
SELECT COUNT(*) AS n
|
|
28445
28820
|
FROM audit_events
|
|
@@ -28447,37 +28822,63 @@ var SqliteBodyRetentionRepository = class {
|
|
|
28447
28822
|
AND started_at < :cutoff
|
|
28448
28823
|
AND event_type IN (${SYNC_LANE_TYPES_SQL})
|
|
28449
28824
|
AND synced_at IS NULL`);
|
|
28825
|
+
this.heldByScopeStmt = this.db.prepare(`
|
|
28826
|
+
SELECT COUNT(*) AS n
|
|
28827
|
+
FROM audit_events
|
|
28828
|
+
WHERE content IS NOT NULL
|
|
28829
|
+
AND started_at < :cutoff
|
|
28830
|
+
AND event_type IN (${SYNC_LANE_TYPES_SQL})
|
|
28831
|
+
AND synced_at IS NULL
|
|
28832
|
+
AND (outbox_owed = 1
|
|
28833
|
+
OR scope_key IN (SELECT value FROM json_each(:scopeKeys)))`);
|
|
28450
28834
|
this.expireStmt = this.db.prepare(
|
|
28451
28835
|
`UPDATE audit_events SET content = NULL, content_expired_at = :now WHERE id = :id`
|
|
28452
28836
|
);
|
|
28837
|
+
this.expireContextsStmt = this.db.prepare(
|
|
28838
|
+
`UPDATE inspection_findings SET context = NULL
|
|
28839
|
+
WHERE id IN (
|
|
28840
|
+
SELECT f.id
|
|
28841
|
+
FROM inspection_findings f INDEXED BY idx_inspection_findings_context
|
|
28842
|
+
JOIN audit_events e ON e.id = f.audit_event_id
|
|
28843
|
+
WHERE f.context IS NOT NULL
|
|
28844
|
+
AND f.first_detected_at < :cutoff
|
|
28845
|
+
AND e.content IS NULL
|
|
28846
|
+
AND e.started_at < :cutoff
|
|
28847
|
+
LIMIT :limit)`
|
|
28848
|
+
);
|
|
28453
28849
|
}
|
|
28454
28850
|
db;
|
|
28455
28851
|
candidatesStmt;
|
|
28456
28852
|
candidatesSyncSafeStmt;
|
|
28853
|
+
candidatesScopedStmt;
|
|
28457
28854
|
heldBySyncStmt;
|
|
28855
|
+
heldByScopeStmt;
|
|
28458
28856
|
expireStmt;
|
|
28459
|
-
|
|
28857
|
+
expireContextsStmt;
|
|
28858
|
+
/**
|
|
28859
|
+
* How many body bytes a pass with these options would free, changing
|
|
28860
|
+
* nothing. Finding excerpts are not counted (see `bytesFreed`).
|
|
28861
|
+
*/
|
|
28460
28862
|
preview(opts) {
|
|
28461
|
-
const
|
|
28462
|
-
const
|
|
28463
|
-
const rows = stmt.all({ cutoff: opts.cutoff, limit });
|
|
28863
|
+
const lane = laneOf(opts.sweepSyncLane);
|
|
28864
|
+
const rows = this.candidates(lane, opts.cutoff, opts.maxRows ?? DEFAULT_MAX_ROWS);
|
|
28464
28865
|
return {
|
|
28465
28866
|
rowsExpired: rows.length,
|
|
28466
28867
|
bytesFreed: rows.reduce((sum, r) => sum + r.bytes, 0),
|
|
28467
|
-
rowsHeldBySync: this.countHeldBySync(opts)
|
|
28868
|
+
rowsHeldBySync: this.countHeldBySync(lane, opts.cutoff)
|
|
28468
28869
|
};
|
|
28469
28870
|
}
|
|
28470
28871
|
/** Clear eligible bodies, in bounded batches. */
|
|
28471
28872
|
expire(opts) {
|
|
28472
28873
|
const batchSize = opts.batchSize ?? DEFAULT_BATCH_SIZE;
|
|
28473
28874
|
const maxRows = opts.maxRows ?? DEFAULT_MAX_ROWS;
|
|
28474
|
-
const
|
|
28875
|
+
const lane = laneOf(opts.sweepSyncLane);
|
|
28475
28876
|
let rowsExpired = 0;
|
|
28476
28877
|
let bytesFreed = 0;
|
|
28477
28878
|
let done = true;
|
|
28478
28879
|
while (rowsExpired < maxRows) {
|
|
28479
28880
|
const remaining = Math.min(batchSize, maxRows - rowsExpired);
|
|
28480
|
-
const batch =
|
|
28881
|
+
const batch = this.candidates(lane, opts.cutoff, remaining);
|
|
28481
28882
|
if (batch.length === 0) break;
|
|
28482
28883
|
withTransaction(
|
|
28483
28884
|
this.db,
|
|
@@ -28490,17 +28891,60 @@ var SqliteBodyRetentionRepository = class {
|
|
|
28490
28891
|
bytesFreed += batch.reduce((sum, r) => sum + r.bytes, 0);
|
|
28491
28892
|
if (batch.length < remaining) break;
|
|
28492
28893
|
if (rowsExpired >= maxRows) {
|
|
28493
|
-
done =
|
|
28894
|
+
done = this.candidates(lane, opts.cutoff, 1).length === 0;
|
|
28494
28895
|
}
|
|
28495
28896
|
}
|
|
28496
|
-
|
|
28897
|
+
this.expireContexts(opts.cutoff, batchSize, maxRows);
|
|
28898
|
+
return {
|
|
28899
|
+
rowsExpired,
|
|
28900
|
+
bytesFreed,
|
|
28901
|
+
rowsHeldBySync: this.countHeldBySync(lane, opts.cutoff),
|
|
28902
|
+
done
|
|
28903
|
+
};
|
|
28904
|
+
}
|
|
28905
|
+
// Clear the excerpts that outlived their body, one bounded transaction per
|
|
28906
|
+
// batch for the same reason the body sweep batches, and at most `maxRows` of
|
|
28907
|
+
// them per pass under the same cap: the next pass picks up the rest.
|
|
28908
|
+
expireContexts(cutoff, batchSize, maxRows) {
|
|
28909
|
+
let total = 0;
|
|
28910
|
+
while (total < maxRows) {
|
|
28911
|
+
const limit = Math.min(batchSize, maxRows - total);
|
|
28912
|
+
let cleared = 0;
|
|
28913
|
+
withTransaction(
|
|
28914
|
+
this.db,
|
|
28915
|
+
() => {
|
|
28916
|
+
cleared = Number(this.expireContextsStmt.run({ cutoff, limit }).changes);
|
|
28917
|
+
},
|
|
28918
|
+
"IMMEDIATE"
|
|
28919
|
+
);
|
|
28920
|
+
total += cleared;
|
|
28921
|
+
if (cleared < limit) return;
|
|
28922
|
+
}
|
|
28497
28923
|
}
|
|
28498
|
-
|
|
28499
|
-
|
|
28500
|
-
|
|
28924
|
+
/**
|
|
28925
|
+
* One batch of candidates under `lane`, bound with exactly the parameters its
|
|
28926
|
+
* statement names — node:sqlite refuses a named parameter a statement does not
|
|
28927
|
+
* declare, so the key list goes to the scoped statements only.
|
|
28928
|
+
*
|
|
28929
|
+
* Anything that is not `sweep` or `hold-keys` takes the hold-all statement.
|
|
28930
|
+
* The type admits no fourth kind, but this decides what is destroyed, and the
|
|
28931
|
+
* direction an unforeseen value falls has to be holding.
|
|
28932
|
+
*/
|
|
28933
|
+
candidates(lane, cutoff, limit) {
|
|
28934
|
+
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 });
|
|
28935
|
+
return rows;
|
|
28936
|
+
}
|
|
28937
|
+
countHeldBySync(lane, cutoff) {
|
|
28938
|
+
if (lane.kind === "sweep") return 0;
|
|
28939
|
+
const row = lane.kind === "hold-keys" ? this.heldByScopeStmt.get({ cutoff, scopeKeys: JSON.stringify(lane.keys) }) : this.heldBySyncStmt.get({ cutoff });
|
|
28501
28940
|
return row.n;
|
|
28502
28941
|
}
|
|
28503
28942
|
};
|
|
28943
|
+
function laneOf(gate) {
|
|
28944
|
+
if (gate === true) return SWEEP;
|
|
28945
|
+
if (gate === false) return HOLD_ALL;
|
|
28946
|
+
return gate;
|
|
28947
|
+
}
|
|
28504
28948
|
|
|
28505
28949
|
// ../../packages/persistence/src/repositories/capture-status.ts
|
|
28506
28950
|
var STATUS_LOOKBACK_ROWS = 128;
|
|
@@ -29409,6 +29853,8 @@ function toFlatFindingRow(r) {
|
|
|
29409
29853
|
repo: r.repo ?? "",
|
|
29410
29854
|
file: r.file ?? "",
|
|
29411
29855
|
...r.tool_name === null ? {} : { toolName: r.tool_name },
|
|
29856
|
+
...r.line === null ? {} : { line: r.line },
|
|
29857
|
+
...r.col === null ? {} : { col: r.col },
|
|
29412
29858
|
eventId: r.event_id,
|
|
29413
29859
|
...r.session_id === null ? {} : { sessionId: r.session_id },
|
|
29414
29860
|
status: deriveInstanceStatus(r),
|
|
@@ -29486,7 +29932,8 @@ var FINDING_ROW_COLUMNS_SQL = `f.id AS id, d.rule_id AS rule_id, d.category AS c
|
|
|
29486
29932
|
${latestResolutionStatusSql("f")} AS latest_status,
|
|
29487
29933
|
e.synced_at AS synced_at, e.sync_claimed_at AS sync_claimed_at,
|
|
29488
29934
|
e.sync_failed_at AS sync_failed_at, e.sync_failure AS sync_failure,
|
|
29489
|
-
e.outbox_owed AS outbox_owed
|
|
29935
|
+
e.outbox_owed AS outbox_owed,
|
|
29936
|
+
f.line AS line, f.col AS col`;
|
|
29490
29937
|
var DAY_MS3 = 864e5;
|
|
29491
29938
|
var SqliteFindingsRepository = class {
|
|
29492
29939
|
constructor(db) {
|
|
@@ -29909,6 +30356,27 @@ var SqliteFindingsRepository = class {
|
|
|
29909
30356
|
).get(id);
|
|
29910
30357
|
return Promise.resolve(row === void 0 ? null : toInstanceDetail(toFlatFindingRow(row)));
|
|
29911
30358
|
}
|
|
30359
|
+
/**
|
|
30360
|
+
* One finding's excerpt source (see FindingContextSource). A primary-key
|
|
30361
|
+
* seek, like `findingInstance`, and the only findings read that touches the
|
|
30362
|
+
* event's text — which is why the list never projects the excerpt and the
|
|
30363
|
+
* drawer asks for it here, one finding at a time.
|
|
30364
|
+
*/
|
|
30365
|
+
findingContextSource(id) {
|
|
30366
|
+
const row = this.db.prepare(
|
|
30367
|
+
`SELECT f.context AS context, e.content AS content,
|
|
30368
|
+
f.span_start AS spanStart, f.span_end AS spanEnd,
|
|
30369
|
+
d.rule_id AS ruleId, d.category AS category,
|
|
30370
|
+
json_extract(e.attributes, '$.whole_file') AS wholeFile,
|
|
30371
|
+
e.tool_name AS toolName, e.event_type AS eventType
|
|
30372
|
+
FROM inspection_findings f
|
|
30373
|
+
JOIN audit_events e ON e.id = f.audit_event_id
|
|
30374
|
+
JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
30375
|
+
WHERE f.id = ?`
|
|
30376
|
+
).get(id);
|
|
30377
|
+
if (row === void 0) return null;
|
|
30378
|
+
return { ...row, wholeFile: row.wholeFile === 1 };
|
|
30379
|
+
}
|
|
29912
30380
|
/**
|
|
29913
30381
|
* The one statement both instance-level scans run: every finding in scope,
|
|
29914
30382
|
* joined to its event and definition, newest first.
|
|
@@ -30045,6 +30513,61 @@ var SqliteFindingsRepository = class {
|
|
|
30045
30513
|
])
|
|
30046
30514
|
);
|
|
30047
30515
|
}
|
|
30516
|
+
/**
|
|
30517
|
+
* The Findings page's summary strip: whole-store counts over exactly the rows
|
|
30518
|
+
* the instance reads list (the four capture kinds), each equal to what
|
|
30519
|
+
* listFindingInstances totals for the same filters — see FindingsOverview.
|
|
30520
|
+
*
|
|
30521
|
+
* ONE grouped aggregate whose keys are the raw classifier inputs, not the
|
|
30522
|
+
* answers: the statement groups by the three inputs deriveFindingStatus
|
|
30523
|
+
* reads, and each group is then classified here by that same function. So
|
|
30524
|
+
* SQL never restates the status rule, and the strip cannot disagree with the
|
|
30525
|
+
* list about which status a finding has. The group count is bounded by a
|
|
30526
|
+
* handful of status inputs, not by the store, so only the scan grows with it
|
|
30527
|
+
* — the same linear cost every other unscoped read on the page already pays.
|
|
30528
|
+
*
|
|
30529
|
+
* The definitions join selects nothing. It is there because the list's scan
|
|
30530
|
+
* joins it too, so a finding whose definition row is missing is left out of
|
|
30531
|
+
* both rather than counted here and absent there.
|
|
30532
|
+
*
|
|
30533
|
+
* The latest-resolution join is the derived-table form, which
|
|
30534
|
+
* resolution-sql.ts recommends for an aggregate over many findings.
|
|
30535
|
+
*/
|
|
30536
|
+
findingsOverview() {
|
|
30537
|
+
const rows = allRows(
|
|
30538
|
+
this.db.prepare(
|
|
30539
|
+
`SELECT e.event_type AS kind, (f.finding_key IS NOT NULL) AS keyed,
|
|
30540
|
+
latest.status AS latest_status, count(*) AS c
|
|
30541
|
+
FROM inspection_findings f
|
|
30542
|
+
JOIN audit_events e ON e.id = f.audit_event_id
|
|
30543
|
+
JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
30544
|
+
LEFT JOIN ${LATEST_RESOLUTION_BY_KEY_SQL} latest
|
|
30545
|
+
ON latest.finding_key = f.finding_key
|
|
30546
|
+
WHERE e.event_type IN (${CAPTURE_EVENT_TYPES_SQL})
|
|
30547
|
+
GROUP BY e.event_type, keyed, latest.status`
|
|
30548
|
+
)
|
|
30549
|
+
);
|
|
30550
|
+
const byStatus = {
|
|
30551
|
+
open: 0,
|
|
30552
|
+
handled: 0,
|
|
30553
|
+
resolved: 0,
|
|
30554
|
+
dismissed: 0
|
|
30555
|
+
};
|
|
30556
|
+
let findings = 0;
|
|
30557
|
+
for (const row of rows) {
|
|
30558
|
+
const status = deriveFindingStatus({
|
|
30559
|
+
kind: row.kind,
|
|
30560
|
+
// The classifier only asks whether a key exists, never what it is. The
|
|
30561
|
+
// stand-in is non-empty so a truthiness test of the key reads it as
|
|
30562
|
+
// present, exactly as it would a real one.
|
|
30563
|
+
findingKey: row.keyed ? "keyed" : null,
|
|
30564
|
+
latestResolutionStatus: row.latest_status
|
|
30565
|
+
});
|
|
30566
|
+
findings += row.c;
|
|
30567
|
+
byStatus[status] += row.c;
|
|
30568
|
+
}
|
|
30569
|
+
return Promise.resolve({ findings, ...byStatus });
|
|
30570
|
+
}
|
|
30048
30571
|
healthSummary() {
|
|
30049
30572
|
const total = countScalar(
|
|
30050
30573
|
this.db,
|
|
@@ -30172,12 +30695,13 @@ var SqliteInspectionFindingsRepository = class {
|
|
|
30172
30695
|
`INSERT INTO inspection_findings
|
|
30173
30696
|
(id, audit_event_id, inspection_definition_id, classified_data_id,
|
|
30174
30697
|
span_start, span_end, masked_match, action_taken, confidence,
|
|
30175
|
-
finding_key, first_detected_at)
|
|
30698
|
+
finding_key, first_detected_at, line, col, context)
|
|
30176
30699
|
VALUES
|
|
30177
30700
|
(:id, :auditEventId, :inspectionDefinitionId, :classifiedDataId,
|
|
30178
30701
|
:spanStart, :spanEnd, :maskedMatch, :actionTaken, :confidence,
|
|
30179
30702
|
:findingKey,
|
|
30180
|
-
COALESCE(:firstDetectedAt, (SELECT started_at FROM audit_events WHERE id = :auditEventId))
|
|
30703
|
+
COALESCE(:firstDetectedAt, (SELECT started_at FROM audit_events WHERE id = :auditEventId)),
|
|
30704
|
+
:line, :col, :context)
|
|
30181
30705
|
ON CONFLICT(id) DO UPDATE SET
|
|
30182
30706
|
inspection_definition_id = excluded.inspection_definition_id
|
|
30183
30707
|
ON CONFLICT (finding_key) DO UPDATE SET
|
|
@@ -30188,7 +30712,10 @@ var SqliteInspectionFindingsRepository = class {
|
|
|
30188
30712
|
span_end = excluded.span_end,
|
|
30189
30713
|
masked_match = excluded.masked_match,
|
|
30190
30714
|
action_taken = excluded.action_taken,
|
|
30191
|
-
confidence = excluded.confidence
|
|
30715
|
+
confidence = excluded.confidence,
|
|
30716
|
+
line = excluded.line,
|
|
30717
|
+
col = excluded.col,
|
|
30718
|
+
context = excluded.context`
|
|
30192
30719
|
);
|
|
30193
30720
|
this.sessionDupStmt = db.prepare(
|
|
30194
30721
|
`SELECT 1 FROM inspection_findings f
|
|
@@ -30238,7 +30765,10 @@ var SqliteInspectionFindingsRepository = class {
|
|
|
30238
30765
|
actionTaken: row.actionTaken,
|
|
30239
30766
|
confidence: row.confidence,
|
|
30240
30767
|
findingKey: row.findingKey,
|
|
30241
|
-
firstDetectedAt: row.firstDetectedAt
|
|
30768
|
+
firstDetectedAt: row.firstDetectedAt,
|
|
30769
|
+
line: row.line,
|
|
30770
|
+
col: row.col,
|
|
30771
|
+
context: row.context
|
|
30242
30772
|
})
|
|
30243
30773
|
);
|
|
30244
30774
|
}
|
|
@@ -30918,8 +31448,8 @@ var SqliteInstalledPacksRepository = class {
|
|
|
30918
31448
|
this.db = db;
|
|
30919
31449
|
this.baseDir = baseDir;
|
|
30920
31450
|
this.insertMissingStmt = db.prepare(
|
|
30921
|
-
`INSERT INTO installed_packs (id, namespace, pack_id, version, name, rules_json, enabled, created_at, updated_at)
|
|
30922
|
-
VALUES (:id, :namespace, :packId, :version, :name, :rulesJson, 1, :now, :now)
|
|
31451
|
+
`INSERT INTO installed_packs (id, namespace, pack_id, version, name, rules_json, enabled, policy_id, created_at, updated_at)
|
|
31452
|
+
VALUES (:id, :namespace, :packId, :version, :name, :rulesJson, 1, :policyId, :now, :now)
|
|
30923
31453
|
ON CONFLICT (namespace, pack_id) DO NOTHING`
|
|
30924
31454
|
);
|
|
30925
31455
|
this.upsertAvailableStmt = db.prepare(
|
|
@@ -30979,7 +31509,10 @@ var SqliteInstalledPacksRepository = class {
|
|
|
30979
31509
|
version: pack.version,
|
|
30980
31510
|
name: pack.name,
|
|
30981
31511
|
rulesJson: JSON.stringify(pack.rules),
|
|
30982
|
-
ruleIds: new Set(pack.rules.map((r) => r.id))
|
|
31512
|
+
ruleIds: new Set(pack.rules.map((r) => r.id)),
|
|
31513
|
+
// Only a first install takes it: an existing row is never modified here,
|
|
31514
|
+
// so a policy the user chose (or cleared) is never overwritten.
|
|
31515
|
+
defaultPolicyId: pack.defaultPolicyId ?? null
|
|
30983
31516
|
}));
|
|
30984
31517
|
if (this.storedSignature() === inventorySignature(rows)) return;
|
|
30985
31518
|
const now = Date.now();
|
|
@@ -31008,7 +31541,7 @@ var SqliteInstalledPacksRepository = class {
|
|
|
31008
31541
|
} else {
|
|
31009
31542
|
behind = true;
|
|
31010
31543
|
}
|
|
31011
|
-
this.insertMissingStmt.run(params);
|
|
31544
|
+
this.insertMissingStmt.run({ ...params, policyId: row.defaultPolicyId });
|
|
31012
31545
|
}
|
|
31013
31546
|
if (!behind) this.pruneAvailable(rows.map((r) => `${r.namespace}/${r.packId}`));
|
|
31014
31547
|
},
|
|
@@ -31126,7 +31659,8 @@ var SqliteInstalledPacksRepository = class {
|
|
|
31126
31659
|
rejectedRules: [],
|
|
31127
31660
|
ruleActions: /* @__PURE__ */ new Map(),
|
|
31128
31661
|
ruleVersions: /* @__PURE__ */ new Map(),
|
|
31129
|
-
reversibleRules: /* @__PURE__ */ new Set()
|
|
31662
|
+
reversibleRules: /* @__PURE__ */ new Set(),
|
|
31663
|
+
assignedRules: /* @__PURE__ */ new Set()
|
|
31130
31664
|
};
|
|
31131
31665
|
const reject = (pack, ruleId, reason) => {
|
|
31132
31666
|
if (out.rejectedRules.length >= REJECTED_RULE_DETAIL_CAP) return;
|
|
@@ -31159,6 +31693,8 @@ var SqliteInstalledPacksRepository = class {
|
|
|
31159
31693
|
out.ruleVersions.set(parsed.data.id, row.version);
|
|
31160
31694
|
if (reversible) out.reversibleRules.add(parsed.data.id);
|
|
31161
31695
|
else out.reversibleRules.delete(parsed.data.id);
|
|
31696
|
+
if (row.policyId !== null) out.assignedRules.add(parsed.data.id);
|
|
31697
|
+
else out.assignedRules.delete(parsed.data.id);
|
|
31162
31698
|
} else {
|
|
31163
31699
|
out.invalidRules += 1;
|
|
31164
31700
|
reject(pack, printableRuleId(entry), firstIssueReason(parsed.error));
|
|
@@ -32245,6 +32781,7 @@ var SqliteInventoryAssetsRepository = class {
|
|
|
32245
32781
|
|
|
32246
32782
|
// ../../packages/persistence/src/repositories/policies.ts
|
|
32247
32783
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
32784
|
+
var SEED_BATCH_WINDOW_MS = 6e4;
|
|
32248
32785
|
var SqlitePoliciesRepository = class {
|
|
32249
32786
|
constructor(db) {
|
|
32250
32787
|
this.db = db;
|
|
@@ -32266,39 +32803,123 @@ var SqlitePoliciesRepository = class {
|
|
|
32266
32803
|
});
|
|
32267
32804
|
return Promise.resolve(policies);
|
|
32268
32805
|
}
|
|
32269
|
-
// Seed one policy per bundled category
|
|
32270
|
-
//
|
|
32271
|
-
//
|
|
32806
|
+
// Seed one policy per bundled category at Monitor so the detection-type config
|
|
32807
|
+
// exists from first run. An unassigned pack's rules follow these rows, so
|
|
32808
|
+
// Monitor here is the posture of every pack that ships no defaultPolicy; a pack
|
|
32809
|
+
// that ships one carries its own assignment instead. Only when the
|
|
32810
|
+
// table is empty, so a user's edits are never clobbered.
|
|
32272
32811
|
seedDefaults() {
|
|
32273
32812
|
const count = countScalar(this.db, "SELECT count(*) AS n FROM policies");
|
|
32274
|
-
if (count > 0)
|
|
32813
|
+
if (count > 0) {
|
|
32814
|
+
this.markEarlierChoices();
|
|
32815
|
+
this.monitorUntouchedSeeds();
|
|
32816
|
+
return;
|
|
32817
|
+
}
|
|
32275
32818
|
const stmt = this.db.prepare(
|
|
32276
32819
|
`INSERT INTO policies (id, scope, target, action, enabled, created_at, updated_at)
|
|
32277
32820
|
VALUES (:id, 'global', :target, :action, 1, :now, :now)`
|
|
32278
32821
|
);
|
|
32279
32822
|
failOpenTransaction(this.db, () => {
|
|
32280
|
-
for (const
|
|
32823
|
+
for (const category of Object.keys(DEFAULT_ACTIONS)) {
|
|
32281
32824
|
stmt.run({
|
|
32282
32825
|
id: randomUUID6(),
|
|
32283
32826
|
target: JSON.stringify({ category }),
|
|
32284
|
-
action,
|
|
32827
|
+
action: "log",
|
|
32285
32828
|
now: Date.now()
|
|
32286
32829
|
});
|
|
32287
32830
|
}
|
|
32288
32831
|
});
|
|
32289
32832
|
}
|
|
32833
|
+
// Before this build, upsertCategoryAction INSERTed a new row with updated_at
|
|
32834
|
+
// equal to created_at, so a choice made for a category that had no row yet
|
|
32835
|
+
// (one added in a release after the store was seeded) looks exactly like a
|
|
32836
|
+
// seed. Left alone, fill-gaps would overwrite it and monitorUntouchedSeeds
|
|
32837
|
+
// could reset it. This pass marks such rows as chosen (updated_at =
|
|
32838
|
+
// created_at + 1) before either can read them. A row is an earlier build's
|
|
32839
|
+
// choice, not its seed, when either:
|
|
32840
|
+
// - its action is neither the old seed value (DEFAULT_ACTIONS) nor Monitor,
|
|
32841
|
+
// which no seed of any build ever wrote; or
|
|
32842
|
+
// - it was created well after the seed batch. Every build seeds all of its
|
|
32843
|
+
// categories in one transaction, and only into an empty table, so a row
|
|
32844
|
+
// created later came from upsertCategoryAction.
|
|
32845
|
+
// It needs no marker of its own: every row this build writes has updated_at >
|
|
32846
|
+
// created_at, and the seeds it leaves equal (fresh 'log' seeds, and seeds
|
|
32847
|
+
// moved to Monitor below, which keep their created_at) match neither test, so
|
|
32848
|
+
// after one pass it finds nothing and stays a read. What it cannot tell apart
|
|
32849
|
+
// is an earlier build's choice that equals the seed value AND was made within
|
|
32850
|
+
// the seed batch window; that row is read as a seed.
|
|
32851
|
+
markEarlierChoices() {
|
|
32852
|
+
const rows = allRows(
|
|
32853
|
+
this.db.prepare(
|
|
32854
|
+
`SELECT id, json_extract(target, '$.category') AS category, action,
|
|
32855
|
+
created_at AS c, updated_at AS u
|
|
32856
|
+
FROM policies
|
|
32857
|
+
WHERE scope = 'global' AND json_extract(target, '$.category') IS NOT NULL`
|
|
32858
|
+
)
|
|
32859
|
+
);
|
|
32860
|
+
if (rows.length === 0) return;
|
|
32861
|
+
const seedBatchStart = Math.min(...rows.map((row) => row.c));
|
|
32862
|
+
const seeded = DEFAULT_ACTIONS;
|
|
32863
|
+
const choices = rows.filter(
|
|
32864
|
+
(row) => row.u === row.c && (row.action !== "log" && row.action !== seeded[row.category] || row.c > seedBatchStart + SEED_BATCH_WINDOW_MS)
|
|
32865
|
+
);
|
|
32866
|
+
if (choices.length === 0) return;
|
|
32867
|
+
const stmt = this.db.prepare(
|
|
32868
|
+
`UPDATE policies SET updated_at = created_at + 1 WHERE id = :id AND updated_at = created_at`
|
|
32869
|
+
);
|
|
32870
|
+
failOpenTransaction(this.db, () => {
|
|
32871
|
+
for (const row of choices) stmt.run({ id: row.id });
|
|
32872
|
+
});
|
|
32873
|
+
}
|
|
32874
|
+
// Stores seeded by an earlier build hold DEFAULT_ACTIONS in their category
|
|
32875
|
+
// rows. Those rows used to be shadowed by the Monitor every unassigned pack
|
|
32876
|
+
// emitted; now that unassigned packs defer to them, an untouched one would
|
|
32877
|
+
// turn Monitor into Warn on upgrade with nobody having asked. So a row still
|
|
32878
|
+
// exactly as seeded — the seeded action, never updated since it was created —
|
|
32879
|
+
// is moved to Monitor. A row the user, the setup wizard or the warn-era cap
|
|
32880
|
+
// ever wrote has a later updated_at and is left alone. updated_at is NOT
|
|
32881
|
+
// advanced, so a moved row still reads as an untouched seed (see
|
|
32882
|
+
// isCategoryChosen); it never matches again because it is no longer off 'log'.
|
|
32883
|
+
// One knock-on: when the installed snapshot is unusable (corrupt rules_json)
|
|
32884
|
+
// the gateway falls back to the bundled packs with no per-rule policies, so
|
|
32885
|
+
// every rule follows these rows. On an upgraded store that fallback now
|
|
32886
|
+
// monitors where the earlier build warned.
|
|
32887
|
+
monitorUntouchedSeeds() {
|
|
32888
|
+
const untouched = allRows(
|
|
32889
|
+
this.db.prepare(
|
|
32890
|
+
`SELECT json_extract(target, '$.category') AS category, action FROM policies
|
|
32891
|
+
WHERE scope = 'global' AND json_extract(target, '$.category') IS NOT NULL
|
|
32892
|
+
AND action <> 'log' AND updated_at = created_at`
|
|
32893
|
+
)
|
|
32894
|
+
).filter(
|
|
32895
|
+
(row) => DEFAULT_ACTIONS[row.category] === row.action
|
|
32896
|
+
);
|
|
32897
|
+
if (untouched.length === 0) return;
|
|
32898
|
+
const stmt = this.db.prepare(
|
|
32899
|
+
`UPDATE policies SET action = 'log'
|
|
32900
|
+
WHERE scope = 'global' AND json_extract(target, '$.category') = :category
|
|
32901
|
+
AND action = :seeded AND action <> 'log' AND updated_at = created_at`
|
|
32902
|
+
);
|
|
32903
|
+
failOpenTransaction(this.db, () => {
|
|
32904
|
+
for (const row of untouched) {
|
|
32905
|
+
stmt.run({ category: row.category, seeded: row.action });
|
|
32906
|
+
}
|
|
32907
|
+
});
|
|
32908
|
+
}
|
|
32290
32909
|
// Insert-or-update the single global per-category policy row, keyed on the
|
|
32291
32910
|
// existing uq_policies_scope_target unique index (scope, target). `action`
|
|
32292
32911
|
// uses the SAME vocabulary seedDefaults writes (DEFAULT_ACTIONS' ActionTaken
|
|
32293
32912
|
// values), so the runtime's resolveAction reads rows written by either path
|
|
32294
32913
|
// identically. On conflict, `action`, `enabled`, and `updated_at` are updated;
|
|
32295
|
-
// `id` and `created_at` are left exactly as they were.
|
|
32914
|
+
// `id` and `created_at` are left exactly as they were. Either way updated_at
|
|
32915
|
+
// ends up later than created_at, which is what marks the row as chosen.
|
|
32296
32916
|
upsertCategoryAction(category, action) {
|
|
32297
32917
|
const now = Date.now();
|
|
32298
32918
|
this.db.prepare(
|
|
32299
32919
|
`INSERT INTO policies (id, scope, target, action, enabled, created_at, updated_at)
|
|
32300
|
-
VALUES (:id, 'global', :target, :action, 1, :now, :now)
|
|
32301
|
-
ON CONFLICT(scope, target) DO UPDATE SET action = excluded.action, enabled = 1,
|
|
32920
|
+
VALUES (:id, 'global', :target, :action, 1, :now, :now + 1)
|
|
32921
|
+
ON CONFLICT(scope, target) DO UPDATE SET action = excluded.action, enabled = 1,
|
|
32922
|
+
updated_at = MAX(excluded.updated_at, policies.created_at + 1)`
|
|
32302
32923
|
).run({ id: randomUUID6(), target: JSON.stringify({ category }), action, now });
|
|
32303
32924
|
}
|
|
32304
32925
|
// Caps every global per-category policy currently set to block/redact down
|
|
@@ -32312,6 +32933,16 @@ var SqlitePoliciesRepository = class {
|
|
|
32312
32933
|
).run({ now: Date.now() });
|
|
32313
32934
|
return Number(info.changes);
|
|
32314
32935
|
}
|
|
32936
|
+
// Whether the category's row was ever written after it was created — by the
|
|
32937
|
+
// user, the setup wizard or a cap. A row still as seeded (updated_at equal to
|
|
32938
|
+
// created_at) is not a choice, so a posture filling gaps may replace it.
|
|
32939
|
+
isCategoryChosen(category) {
|
|
32940
|
+
const row = this.db.prepare(
|
|
32941
|
+
`SELECT created_at AS c, updated_at AS u FROM policies
|
|
32942
|
+
WHERE scope='global' AND json_extract(target,'$.category') = :category`
|
|
32943
|
+
).get({ category });
|
|
32944
|
+
return row !== void 0 && row.u !== row.c;
|
|
32945
|
+
}
|
|
32315
32946
|
// Read the current action for a single global per-category policy row, mirroring
|
|
32316
32947
|
// upsertCategoryAction's category-lookup predicate. Returns undefined when no
|
|
32317
32948
|
// row exists yet, so callers can distinguish an unset category from a set one.
|
|
@@ -32483,7 +33114,10 @@ var SqliteResolutionsRepository = class {
|
|
|
32483
33114
|
* Insert many dispositions as ONE transaction — all of them or none.
|
|
32484
33115
|
*
|
|
32485
33116
|
* A dashboard dismissal closes every open finding of a rule, which is one
|
|
32486
|
-
* write per key
|
|
33117
|
+
* write per key. It reaches this through
|
|
33118
|
+
* `LocalDatabase.dismissOpenFindingsForRule`, which calls it inside the
|
|
33119
|
+
* transaction that selected the keys, so there it runs as a SAVEPOINT of
|
|
33120
|
+
* that transaction. Run loose, a fault partway leaves half a rule closed with
|
|
32487
33121
|
* nothing recording that the other half was meant to be. The caller then has
|
|
32488
33122
|
* no way to tell a partial run from a complete one, because the card it
|
|
32489
33123
|
* refreshes into just shows a smaller number either way.
|
|
@@ -32703,6 +33337,7 @@ function toSighting(row) {
|
|
|
32703
33337
|
var SELECT_COLUMNS = `
|
|
32704
33338
|
pointer_id AS pointerId,
|
|
32705
33339
|
value_fingerprint AS valueFingerprint,
|
|
33340
|
+
value_identity_fingerprint AS valueIdentityFingerprint,
|
|
32706
33341
|
fingerprint_key_version AS fingerprintKeyVersion,
|
|
32707
33342
|
key_version AS keyVersion,
|
|
32708
33343
|
format_version AS formatVersion,
|
|
@@ -32727,13 +33362,13 @@ var SqliteSecretVaultRepository = class {
|
|
|
32727
33362
|
this.db = db;
|
|
32728
33363
|
this.insertStmt = db.prepare(
|
|
32729
33364
|
`INSERT INTO secret_vault (
|
|
32730
|
-
pointer_id, value_fingerprint,
|
|
32731
|
-
format_version, category, rule_id, masked_match, provider,
|
|
33365
|
+
pointer_id, value_fingerprint, value_identity_fingerprint,
|
|
33366
|
+
fingerprint_key_version, key_version, format_version, category, rule_id, masked_match, provider,
|
|
32732
33367
|
ciphertext, nonce, auth_tag,
|
|
32733
33368
|
user_authorized, occurrence_count, first_seen, last_seen
|
|
32734
33369
|
) VALUES (
|
|
32735
|
-
:pointerId, :valueFingerprint, :
|
|
32736
|
-
:formatVersion, :category, :ruleId, :maskedMatch, :provider,
|
|
33370
|
+
:pointerId, :valueFingerprint, :valueIdentityFingerprint,
|
|
33371
|
+
:fingerprintKeyVersion, :keyVersion, :formatVersion, :category, :ruleId, :maskedMatch, :provider,
|
|
32737
33372
|
:ciphertext, :nonce, :authTag,
|
|
32738
33373
|
:userAuthorized, 1, :now, :now
|
|
32739
33374
|
)`
|
|
@@ -32758,7 +33393,13 @@ var SqliteSecretVaultRepository = class {
|
|
|
32758
33393
|
);
|
|
32759
33394
|
this.refreshFingerprintStmt = db.prepare(
|
|
32760
33395
|
`UPDATE secret_vault
|
|
32761
|
-
SET value_fingerprint = :valueFingerprint,
|
|
33396
|
+
SET value_fingerprint = :valueFingerprint,
|
|
33397
|
+
value_identity_fingerprint = :valueIdentityFingerprint,
|
|
33398
|
+
fingerprint_key_version = :fingerprintKeyVersion
|
|
33399
|
+
WHERE pointer_id = :pointerId`
|
|
33400
|
+
);
|
|
33401
|
+
this.setIdentityStmt = db.prepare(
|
|
33402
|
+
`UPDATE secret_vault SET value_identity_fingerprint = :valueIdentityFingerprint
|
|
32762
33403
|
WHERE pointer_id = :pointerId`
|
|
32763
33404
|
);
|
|
32764
33405
|
this.deleteByPointerStmt = db.prepare(`DELETE FROM secret_vault WHERE pointer_id = :pointerId`);
|
|
@@ -32775,6 +33416,7 @@ var SqliteSecretVaultRepository = class {
|
|
|
32775
33416
|
listStmt;
|
|
32776
33417
|
replaceCiphertextStmt;
|
|
32777
33418
|
refreshFingerprintStmt;
|
|
33419
|
+
setIdentityStmt;
|
|
32778
33420
|
deleteByPointerStmt;
|
|
32779
33421
|
derefStmt;
|
|
32780
33422
|
/**
|
|
@@ -32805,6 +33447,7 @@ var SqliteSecretVaultRepository = class {
|
|
|
32805
33447
|
bindParams({
|
|
32806
33448
|
pointerId: input2.pointerId,
|
|
32807
33449
|
valueFingerprint: input2.valueFingerprint,
|
|
33450
|
+
valueIdentityFingerprint: input2.valueIdentityFingerprint,
|
|
32808
33451
|
fingerprintKeyVersion: input2.fingerprintKeyVersion,
|
|
32809
33452
|
keyVersion: input2.keyVersion,
|
|
32810
33453
|
formatVersion: input2.formatVersion ?? POINTER_FORMAT_VERSION,
|
|
@@ -32866,7 +33509,15 @@ var SqliteSecretVaultRepository = class {
|
|
|
32866
33509
|
replaceCiphertext(pointerId, next) {
|
|
32867
33510
|
this.replaceCiphertextStmt.run({ pointerId, ...next });
|
|
32868
33511
|
}
|
|
32869
|
-
/**
|
|
33512
|
+
/**
|
|
33513
|
+
* Correct an entry's identity fingerprint in place, leaving its exact
|
|
33514
|
+
* fingerprint and key epoch alone. For a row whose identity column still holds
|
|
33515
|
+
* the exact value copied in by the migration that added it.
|
|
33516
|
+
*/
|
|
33517
|
+
setIdentityFingerprint(pointerId, valueIdentityFingerprint) {
|
|
33518
|
+
this.setIdentityStmt.run({ pointerId, valueIdentityFingerprint });
|
|
33519
|
+
}
|
|
33520
|
+
/** Re-derive an entry's fingerprints under a new fingerprint-key epoch. */
|
|
32870
33521
|
refreshFingerprint(pointerId, next) {
|
|
32871
33522
|
this.refreshFingerprintStmt.run({ pointerId, ...next });
|
|
32872
33523
|
}
|
|
@@ -32997,7 +33648,7 @@ var SqliteSecretVaultRepository = class {
|
|
|
32997
33648
|
`SELECT ${INVENTORY_COLUMNS},
|
|
32998
33649
|
(SELECT e.id FROM exceptions e
|
|
32999
33650
|
WHERE e.rule_id = v.rule_id
|
|
33000
|
-
AND e.value_fingerprint = v.
|
|
33651
|
+
AND e.value_fingerprint = v.value_identity_fingerprint
|
|
33001
33652
|
AND e.key_version = v.fingerprint_key_version
|
|
33002
33653
|
AND ${ACTIVE_REVEAL_GRANT_PREDICATE}
|
|
33003
33654
|
LIMIT 1) AS grant_id
|
|
@@ -33040,7 +33691,7 @@ var SqliteSecretVaultRepository = class {
|
|
|
33040
33691
|
`SELECT ${INVENTORY_COLUMNS},
|
|
33041
33692
|
(SELECT e.id FROM exceptions e
|
|
33042
33693
|
WHERE e.rule_id = v.rule_id
|
|
33043
|
-
AND e.value_fingerprint = v.
|
|
33694
|
+
AND e.value_fingerprint = v.value_identity_fingerprint
|
|
33044
33695
|
AND e.key_version = v.fingerprint_key_version
|
|
33045
33696
|
AND ${ACTIVE_REVEAL_GRANT_PREDICATE}
|
|
33046
33697
|
LIMIT 1) AS grant_id
|
|
@@ -33144,6 +33795,18 @@ var OPEN_AT_REST_FINDINGS_SQL = `FROM inspection_findings f
|
|
|
33144
33795
|
OR latest.status IS NULL
|
|
33145
33796
|
OR latest.status NOT IN ('resolved', 'dismissed')
|
|
33146
33797
|
)`;
|
|
33798
|
+
function selectOpenFindingKeysForRule(db, ruleId) {
|
|
33799
|
+
const rows = allRows(
|
|
33800
|
+
db.prepare(
|
|
33801
|
+
`SELECT DISTINCT f.finding_key AS finding_key
|
|
33802
|
+
${OPEN_AT_REST_FINDINGS_SQL}
|
|
33803
|
+
AND d.rule_id = :ruleId
|
|
33804
|
+
AND f.finding_key IS NOT NULL`
|
|
33805
|
+
),
|
|
33806
|
+
{ ruleId }
|
|
33807
|
+
);
|
|
33808
|
+
return rows.map((r) => r.finding_key);
|
|
33809
|
+
}
|
|
33147
33810
|
var SEVERITIES = ["critical", "high", "medium", "low"];
|
|
33148
33811
|
var ACTION_TO_KIND = {
|
|
33149
33812
|
block: "blocked",
|
|
@@ -33200,16 +33863,16 @@ var SqliteSecurityRepository = class {
|
|
|
33200
33863
|
// findings are caught only once their latest disposition is resolved,
|
|
33201
33864
|
// otherwise they are open-at-rest.
|
|
33202
33865
|
//
|
|
33203
|
-
//
|
|
33204
|
-
//
|
|
33205
|
-
//
|
|
33206
|
-
//
|
|
33207
|
-
// be bucketed as caught
|
|
33866
|
+
// Only latest status 'resolved' counts as caught above. 'dismissed' is its
|
|
33867
|
+
// own bucket: a judgement rather than a fix, so it is neither caught nor
|
|
33868
|
+
// needing remediation, and stays countable. A further manual disposition
|
|
33869
|
+
// (acknowledged, false-positive) must be placed deliberately — 'acknowledged'
|
|
33870
|
+
// is accepted risk, not a fix, and must NOT be bucketed as caught.
|
|
33208
33871
|
//
|
|
33209
33872
|
// Legacy at-rest findings from pre-branch scans carry finding_key = NULL —
|
|
33210
33873
|
// the resolution lifecycle is keyed by finding_key, so it can never attach a
|
|
33211
33874
|
// disposition to (or clear) one of these on re-scan. They are excluded from
|
|
33212
|
-
//
|
|
33875
|
+
// all three buckets (untracked, not "needs remediation forever"),
|
|
33213
33876
|
// but still counted in total/count below — this keeps this predicate
|
|
33214
33877
|
// consistent with SqliteResolutionsRepository.openAtRestKeysForPath, which
|
|
33215
33878
|
// already filters `finding_key IS NOT NULL`.
|
|
@@ -33232,12 +33895,25 @@ var SqliteSecurityRepository = class {
|
|
|
33232
33895
|
WHEN latest.status = 'resolved' THEN 1
|
|
33233
33896
|
ELSE 0
|
|
33234
33897
|
END) AS caught,
|
|
33898
|
+
SUM(CASE WHEN e.event_type != 'code_change' THEN 1 ELSE 0 END) AS handled,
|
|
33235
33899
|
SUM(CASE
|
|
33236
33900
|
WHEN e.event_type = 'code_change'
|
|
33237
33901
|
AND f.finding_key IS NOT NULL
|
|
33238
|
-
AND
|
|
33902
|
+
AND latest.status = 'resolved' THEN 1
|
|
33239
33903
|
ELSE 0
|
|
33240
|
-
END) AS
|
|
33904
|
+
END) AS resolved,
|
|
33905
|
+
SUM(CASE
|
|
33906
|
+
WHEN e.event_type = 'code_change'
|
|
33907
|
+
AND f.finding_key IS NOT NULL
|
|
33908
|
+
AND (latest.status IS NULL
|
|
33909
|
+
OR latest.status NOT IN ('resolved', 'dismissed')) THEN 1
|
|
33910
|
+
ELSE 0
|
|
33911
|
+
END) AS open_at_rest,
|
|
33912
|
+
SUM(CASE
|
|
33913
|
+
WHEN e.event_type = 'code_change'
|
|
33914
|
+
AND latest.status = 'dismissed' THEN 1
|
|
33915
|
+
ELSE 0
|
|
33916
|
+
END) AS dismissed
|
|
33241
33917
|
FROM inspection_findings f
|
|
33242
33918
|
JOIN audit_events e INDEXED BY idx_audit_capture_rollup ON e.id = f.audit_event_id
|
|
33243
33919
|
JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
@@ -33252,11 +33928,15 @@ var SqliteSecurityRepository = class {
|
|
|
33252
33928
|
severity,
|
|
33253
33929
|
count: byRow.get(severity)?.count ?? 0,
|
|
33254
33930
|
caught: byRow.get(severity)?.caught ?? 0,
|
|
33255
|
-
|
|
33931
|
+
handled: byRow.get(severity)?.handled ?? 0,
|
|
33932
|
+
resolved: byRow.get(severity)?.resolved ?? 0,
|
|
33933
|
+
openAtRest: byRow.get(severity)?.open_at_rest ?? 0,
|
|
33934
|
+
dismissed: byRow.get(severity)?.dismissed ?? 0
|
|
33256
33935
|
}));
|
|
33257
33936
|
const total = bySeverity.reduce((sum, s) => sum + s.count, 0);
|
|
33258
33937
|
const needsRemediation = bySeverity.reduce((sum, s) => sum + s.openAtRest, 0);
|
|
33259
|
-
|
|
33938
|
+
const dismissed = bySeverity.reduce((sum, s) => sum + s.dismissed, 0);
|
|
33939
|
+
return Promise.resolve({ total, needsRemediation, dismissed, bySeverity });
|
|
33260
33940
|
}
|
|
33261
33941
|
// Range is echoed but does not change the result today — coverage is a constant
|
|
33262
33942
|
// business fact (see SCAN_COVERAGE), not a measured per-window metric. Order
|
|
@@ -33573,10 +34253,10 @@ var SqliteSecurityRepository = class {
|
|
|
33573
34253
|
* machine, and the second reported "no recommendations" over live exposure.
|
|
33574
34254
|
*
|
|
33575
34255
|
* `open` mirrors `deriveFindingStatus` — at-rest, minus resolved and dismissed —
|
|
33576
|
-
* so a row's count is exactly what `?status=open&type=<rule>` returns.
|
|
33577
|
-
*
|
|
33578
|
-
*
|
|
33579
|
-
*
|
|
34256
|
+
* so a row's count is exactly what `?status=open&type=<rule>` returns. It
|
|
34257
|
+
* differs from `severitySummary`'s `openAtRest` only in including untracked
|
|
34258
|
+
* legacy rows, which that bucket leaves out; dismissed is excluded from both.
|
|
34259
|
+
* Only this one has to match a link.
|
|
33580
34260
|
*
|
|
33581
34261
|
* Aggregated in SQL: the result is O(distinct rule × category × severity), so a
|
|
33582
34262
|
* whole-store scope costs a grouped scan rather than a row per finding.
|
|
@@ -33604,6 +34284,8 @@ var SqliteSecurityRepository = class {
|
|
|
33604
34284
|
/**
|
|
33605
34285
|
* The distinct `finding_key`s behind ONE rule's {@link recommendationInputs}
|
|
33606
34286
|
* tally — what a dashboard dismissal of that row writes a disposition for.
|
|
34287
|
+
* The dismissal itself does not call this: it reads the same set through
|
|
34288
|
+
* {@link selectOpenFindingKeysForRule}, inside its own write transaction.
|
|
33607
34289
|
*
|
|
33608
34290
|
* It shares {@link OPEN_AT_REST_FINDINGS_SQL} with the count rather than
|
|
33609
34291
|
* restating the predicate, because a dismissal has to act on exactly the set
|
|
@@ -33620,16 +34302,7 @@ var SqliteSecurityRepository = class {
|
|
|
33620
34302
|
* this set SMALLER than the tally, never larger.
|
|
33621
34303
|
*/
|
|
33622
34304
|
openFindingKeysForRule(ruleId) {
|
|
33623
|
-
|
|
33624
|
-
this.db.prepare(
|
|
33625
|
-
`SELECT DISTINCT f.finding_key AS finding_key
|
|
33626
|
-
${OPEN_AT_REST_FINDINGS_SQL}
|
|
33627
|
-
AND d.rule_id = :ruleId
|
|
33628
|
-
AND f.finding_key IS NOT NULL`
|
|
33629
|
-
),
|
|
33630
|
-
{ ruleId }
|
|
33631
|
-
);
|
|
33632
|
-
return Promise.resolve(rows.map((r) => r.finding_key));
|
|
34305
|
+
return Promise.resolve(selectOpenFindingKeysForRule(this.db, ruleId));
|
|
33633
34306
|
}
|
|
33634
34307
|
// Findings whose parent event occurred in [fromMs, toMs), with the parent's
|
|
33635
34308
|
// epoch-millis timestamp. started_at is an INTEGER column, so the bounds stay
|
|
@@ -34515,6 +35188,11 @@ var UNSAFE_TEST_ONLY_RAW_HANDLE = /* @__PURE__ */ Symbol(
|
|
|
34515
35188
|
function linkHost(input2, hostId) {
|
|
34516
35189
|
return hostId ? { ...input2, hostId } : input2;
|
|
34517
35190
|
}
|
|
35191
|
+
function captureAttributesOf(event, scopeKey) {
|
|
35192
|
+
const attributes = toCaptureAttributes(event);
|
|
35193
|
+
if (scopeKey === void 0 || scopeKey === "") return attributes;
|
|
35194
|
+
return { ...attributes, scope_key: scopeKey };
|
|
35195
|
+
}
|
|
34518
35196
|
function closeQuietly(db) {
|
|
34519
35197
|
try {
|
|
34520
35198
|
db.close();
|
|
@@ -34675,7 +35353,32 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
34675
35353
|
);
|
|
34676
35354
|
});
|
|
34677
35355
|
}
|
|
34678
|
-
function
|
|
35356
|
+
function dismissOpenFindingsForRule(ruleId, disposition) {
|
|
35357
|
+
let dismissed = 0;
|
|
35358
|
+
withTransaction(
|
|
35359
|
+
db,
|
|
35360
|
+
() => {
|
|
35361
|
+
const keys = selectOpenFindingKeysForRule(db, ruleId);
|
|
35362
|
+
resolutions.insertResolutions(
|
|
35363
|
+
keys.map((findingKey) => ({
|
|
35364
|
+
findingKey,
|
|
35365
|
+
status: "dismissed",
|
|
35366
|
+
method: disposition.method,
|
|
35367
|
+
resolvedAt: disposition.resolvedAt,
|
|
35368
|
+
evidence: disposition.evidence
|
|
35369
|
+
}))
|
|
35370
|
+
);
|
|
35371
|
+
dismissed = keys.length;
|
|
35372
|
+
},
|
|
35373
|
+
// IMMEDIATE takes the write lock at BEGIN, before the select, which is
|
|
35374
|
+
// what keeps a concurrent resolve out of the gap. It also makes waiting
|
|
35375
|
+
// on a busy writer an ordinary busy_timeout wait rather than a
|
|
35376
|
+
// read-to-write upgrade SQLite refuses to retry.
|
|
35377
|
+
"IMMEDIATE"
|
|
35378
|
+
);
|
|
35379
|
+
return dismissed;
|
|
35380
|
+
}
|
|
35381
|
+
function recordCapture(event, detected, scopeKey) {
|
|
34679
35382
|
failOpenTransaction(db, () => {
|
|
34680
35383
|
const sessionId = event.metadata?.sessionId;
|
|
34681
35384
|
if (sessionId) {
|
|
@@ -34690,7 +35393,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
34690
35393
|
rootSessionId: sessionId,
|
|
34691
35394
|
content: event.content,
|
|
34692
35395
|
contentHash: event.contentHash,
|
|
34693
|
-
attributes:
|
|
35396
|
+
attributes: captureAttributesOf(event, scopeKey)
|
|
34694
35397
|
});
|
|
34695
35398
|
const definitionIds = /* @__PURE__ */ new Map();
|
|
34696
35399
|
for (const finding of detected) {
|
|
@@ -34720,7 +35423,12 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
34720
35423
|
maskedMatch: finding.maskedMatch,
|
|
34721
35424
|
actionTaken: finding.actionTaken,
|
|
34722
35425
|
confidence: finding.confidence,
|
|
34723
|
-
findingKey: finding.findingKey ?? void 0
|
|
35426
|
+
findingKey: finding.findingKey ?? void 0,
|
|
35427
|
+
...finding.location === void 0 ? {} : {
|
|
35428
|
+
line: finding.location.line,
|
|
35429
|
+
col: finding.location.col,
|
|
35430
|
+
context: finding.location.context
|
|
35431
|
+
}
|
|
34724
35432
|
});
|
|
34725
35433
|
}
|
|
34726
35434
|
});
|
|
@@ -34858,6 +35566,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
34858
35566
|
inspectionDefinitions,
|
|
34859
35567
|
inspectionFindings,
|
|
34860
35568
|
recordCapture,
|
|
35569
|
+
dismissOpenFindingsForRule,
|
|
34861
35570
|
markCaptureDelivered,
|
|
34862
35571
|
markCaptureOwed,
|
|
34863
35572
|
markAuditEventsDelivered,
|
|
@@ -34882,6 +35591,7 @@ function openLocalDatabase(dir, options = {}) {
|
|
|
34882
35591
|
// ../../packages/persistence/src/egress-wire.ts
|
|
34883
35592
|
import { createHash as createHash3 } from "crypto";
|
|
34884
35593
|
var SLASH = "/".charCodeAt(0);
|
|
35594
|
+
var SCOPE_KEY = printable(ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH);
|
|
34885
35595
|
|
|
34886
35596
|
// ../../packages/persistence/src/finding-key.ts
|
|
34887
35597
|
import { createHash as createHash4 } from "crypto";
|
|
@@ -35625,6 +36335,10 @@ function escapeRegExp2(value) {
|
|
|
35625
36335
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
35626
36336
|
}
|
|
35627
36337
|
|
|
36338
|
+
// ../../packages/detections/src/format-chars.ts
|
|
36339
|
+
var HAS_FORMAT_CHAR = new RegExp("\\p{Cf}", "u");
|
|
36340
|
+
var FORMAT_CHAR_GLOBAL = new RegExp("\\p{Cf}", "gu");
|
|
36341
|
+
|
|
35628
36342
|
// ../../packages/detections/src/regex-cache.ts
|
|
35629
36343
|
var singles = /* @__PURE__ */ new WeakMap();
|
|
35630
36344
|
var keywordLists = /* @__PURE__ */ new WeakMap();
|
|
@@ -35861,6 +36575,7 @@ var CORROBORATION_FLOOR_MS = BUDGET_MS * CPU_CORROBORATION_SHARE;
|
|
|
35861
36575
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
35862
36576
|
import { existsSync as existsSync9, readFileSync as readFileSync10, statSync as statSync6 } from "fs";
|
|
35863
36577
|
import { basename as basename2, dirname as dirname4, isAbsolute, join as join17, sep as sep2 } from "path";
|
|
36578
|
+
var NO_ATTRIBUTION = Object.freeze({});
|
|
35864
36579
|
|
|
35865
36580
|
// ../../packages/plugin-sdk/src/events.ts
|
|
35866
36581
|
import { createHash as createHash5, randomUUID as randomUUID13 } from "crypto";
|
|
@@ -35935,12 +36650,18 @@ import { join as join23 } from "path";
|
|
|
35935
36650
|
import { readdirSync as readdirSync3, realpathSync as realpathSync3 } from "fs";
|
|
35936
36651
|
import { basename as basename4, dirname as dirname5, sep as sep3 } from "path";
|
|
35937
36652
|
|
|
36653
|
+
// ../../packages/plugin-sdk/src/policy-resolver.ts
|
|
36654
|
+
import { randomUUID as randomUUID14 } from "crypto";
|
|
36655
|
+
|
|
35938
36656
|
// ../../packages/plugin-sdk/src/posture.ts
|
|
35939
36657
|
function applyCategoryPosture(posture, repo, mode = "fill-gaps") {
|
|
35940
36658
|
for (const category of Object.keys(posture)) {
|
|
35941
36659
|
const policyId = posture[category];
|
|
35942
36660
|
if (!policyId) continue;
|
|
35943
|
-
if (mode === "fill-gaps"
|
|
36661
|
+
if (mode === "fill-gaps") {
|
|
36662
|
+
const chosen = repo.isCategoryChosen ? repo.isCategoryChosen(category) : repo.getCategoryAction(category) !== void 0;
|
|
36663
|
+
if (chosen) continue;
|
|
36664
|
+
}
|
|
35944
36665
|
repo.upsertCategoryAction(category, builtinPolicyToAction(policyId));
|
|
35945
36666
|
}
|
|
35946
36667
|
}
|
|
@@ -35976,14 +36697,18 @@ var codexProviderEnvShape = {
|
|
|
35976
36697
|
var CodexProviderEnvSchema = external_exports.object(codexProviderEnvShape);
|
|
35977
36698
|
|
|
35978
36699
|
// ../../packages/plugin-sdk/src/runtime.ts
|
|
35979
|
-
import { randomUUID as
|
|
36700
|
+
import { randomUUID as randomUUID15 } from "crypto";
|
|
36701
|
+
|
|
36702
|
+
// ../../packages/plugin-sdk/src/scope-key.ts
|
|
36703
|
+
import { existsSync as existsSync12 } from "fs";
|
|
36704
|
+
import { dirname as dirname6, isAbsolute as isAbsolute2, join as join25, normalize } from "path";
|
|
35980
36705
|
|
|
35981
36706
|
// ../../packages/plugin-sdk/src/suppressions.ts
|
|
35982
36707
|
var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
35983
36708
|
|
|
35984
36709
|
// ../../packages/plugin-sdk/src/throttle.ts
|
|
35985
36710
|
import { mkdirSync as mkdirSync4, statSync as statSync8, writeFileSync as writeFileSync7 } from "fs";
|
|
35986
|
-
import { join as
|
|
36711
|
+
import { join as join26 } from "path";
|
|
35987
36712
|
|
|
35988
36713
|
// ../../packages/setup-wizard/src/onboard-posture.ts
|
|
35989
36714
|
function parsePosture(json2) {
|
|
@@ -36006,7 +36731,7 @@ function parsePosture(json2) {
|
|
|
36006
36731
|
|
|
36007
36732
|
// ../../packages/setup-wizard/src/remediation/rotation-checklist.ts
|
|
36008
36733
|
import { writeFileSync as writeFileSync8 } from "fs";
|
|
36009
|
-
import { join as
|
|
36734
|
+
import { join as join27 } from "path";
|
|
36010
36735
|
|
|
36011
36736
|
// ../../packages/setup-wizard/src/triage/merge.ts
|
|
36012
36737
|
var RANK = Object.fromEntries(
|
|
@@ -36016,7 +36741,7 @@ var RANK = Object.fromEntries(
|
|
|
36016
36741
|
// ../../packages/setup-wizard/src/triage/plan-file.ts
|
|
36017
36742
|
import { mkdtempSync, readFileSync as readFileSync17, rmdirSync, rmSync as rmSync7, writeFileSync as writeFileSync9 } from "fs";
|
|
36018
36743
|
import { tmpdir } from "os";
|
|
36019
|
-
import { basename as basename6, dirname as
|
|
36744
|
+
import { basename as basename6, dirname as dirname7, join as join28 } from "path";
|
|
36020
36745
|
var SuppressionEntrySchema = external_exports.object({
|
|
36021
36746
|
ruleId: external_exports.string(),
|
|
36022
36747
|
category: DetectionCategory,
|
|
@@ -36104,7 +36829,7 @@ function show(body) {
|
|
|
36104
36829
|
|
|
36105
36830
|
// src/skills-registry.ts
|
|
36106
36831
|
import { readdirSync as readdirSync5, readFileSync as readFileSync18 } from "fs";
|
|
36107
|
-
import { join as
|
|
36832
|
+
import { join as join29 } from "path";
|
|
36108
36833
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
36109
36834
|
var SKILLS_DIR = fileURLToPath2(new URL("../skills", import.meta.url));
|
|
36110
36835
|
|