@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/scan-worker.js
CHANGED
|
@@ -603,6 +603,82 @@ function escapeRegExp2(value) {
|
|
|
603
603
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
604
604
|
}
|
|
605
605
|
|
|
606
|
+
// ../../packages/detections/src/format-chars.ts
|
|
607
|
+
var HAS_FORMAT_CHAR = new RegExp("\\p{Cf}", "u");
|
|
608
|
+
var FORMAT_CHAR_GLOBAL = new RegExp("\\p{Cf}", "gu");
|
|
609
|
+
function normalizeFormatChars(text) {
|
|
610
|
+
if (!HAS_FORMAT_CHAR.test(text)) return void 0;
|
|
611
|
+
const normalizedParts = [];
|
|
612
|
+
const segments = [];
|
|
613
|
+
let cursor = 0;
|
|
614
|
+
let normLength = 0;
|
|
615
|
+
for (const match of text.matchAll(FORMAT_CHAR_GLOBAL)) {
|
|
616
|
+
const matchStart = match.index;
|
|
617
|
+
if (matchStart > cursor) {
|
|
618
|
+
const length = matchStart - cursor;
|
|
619
|
+
normalizedParts.push(text.slice(cursor, matchStart));
|
|
620
|
+
segments.push({ normStart: normLength, origStart: cursor, length });
|
|
621
|
+
normLength += length;
|
|
622
|
+
}
|
|
623
|
+
cursor = matchStart + match[0].length;
|
|
624
|
+
}
|
|
625
|
+
if (cursor < text.length) {
|
|
626
|
+
const length = text.length - cursor;
|
|
627
|
+
normalizedParts.push(text.slice(cursor));
|
|
628
|
+
segments.push({ normStart: normLength, origStart: cursor, length });
|
|
629
|
+
}
|
|
630
|
+
return { normalized: normalizedParts.join(""), segments };
|
|
631
|
+
}
|
|
632
|
+
function segmentAt(segments, normPos) {
|
|
633
|
+
let lo = 0;
|
|
634
|
+
let hi = segments.length - 1;
|
|
635
|
+
while (lo < hi) {
|
|
636
|
+
const mid = lo + hi >> 1;
|
|
637
|
+
const segment = segments[mid];
|
|
638
|
+
if (segment !== void 0 && normPos >= segment.normStart + segment.length) {
|
|
639
|
+
lo = mid + 1;
|
|
640
|
+
} else {
|
|
641
|
+
hi = mid;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
const found = segments[lo];
|
|
645
|
+
if (found === void 0) {
|
|
646
|
+
throw new Error(`normPos ${String(normPos)} has no covering segment`);
|
|
647
|
+
}
|
|
648
|
+
return found;
|
|
649
|
+
}
|
|
650
|
+
function mapSpanToOriginal(span, normalization) {
|
|
651
|
+
const { segments } = normalization;
|
|
652
|
+
const startSegment = segmentAt(segments, span.start);
|
|
653
|
+
const start = startSegment.origStart + (span.start - startSegment.normStart);
|
|
654
|
+
const endSegment = segmentAt(segments, span.end - 1);
|
|
655
|
+
const end = endSegment.origStart + (span.end - 1 - endSegment.normStart) + 1;
|
|
656
|
+
return { start, end };
|
|
657
|
+
}
|
|
658
|
+
function normalizedOffset(origPos, segments) {
|
|
659
|
+
let lo = 0;
|
|
660
|
+
let hi = segments.length;
|
|
661
|
+
while (lo < hi) {
|
|
662
|
+
const mid = lo + hi >> 1;
|
|
663
|
+
const segment = segments[mid];
|
|
664
|
+
if (segment !== void 0 && segment.origStart + segment.length <= origPos) {
|
|
665
|
+
lo = mid + 1;
|
|
666
|
+
} else {
|
|
667
|
+
hi = mid;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
const found = segments[Math.min(lo, segments.length - 1)];
|
|
671
|
+
if (found === void 0) return 0;
|
|
672
|
+
return found.normStart + Math.min(Math.max(0, origPos - found.origStart), found.length);
|
|
673
|
+
}
|
|
674
|
+
function mapSpanToNormalized(span, normalization) {
|
|
675
|
+
const { segments } = normalization;
|
|
676
|
+
return {
|
|
677
|
+
start: normalizedOffset(span.start, segments),
|
|
678
|
+
end: normalizedOffset(span.end, segments)
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
|
|
606
682
|
// ../../packages/detections/src/regex-cache.ts
|
|
607
683
|
var singles = /* @__PURE__ */ new WeakMap();
|
|
608
684
|
var keywordLists = /* @__PURE__ */ new WeakMap();
|
|
@@ -761,29 +837,35 @@ function passesPostValidators(rule, value) {
|
|
|
761
837
|
function getLoadedRules() {
|
|
762
838
|
return [...packs.values()].flatMap((p) => p.rules);
|
|
763
839
|
}
|
|
764
|
-
function
|
|
840
|
+
function spansOverlap(a, b) {
|
|
841
|
+
return a.start < b.end && a.end > b.start;
|
|
842
|
+
}
|
|
843
|
+
function isCorroborated(candidate, candidates, text, normalization) {
|
|
765
844
|
const req = candidate.rule.requiresNearby;
|
|
766
845
|
if (!req) return true;
|
|
767
846
|
const halfWindow = req.windowChars;
|
|
768
|
-
const
|
|
769
|
-
const winStart = start - halfWindow;
|
|
770
|
-
const winEnd = end + halfWindow;
|
|
847
|
+
const ns = candidate.normSpan;
|
|
848
|
+
const winStart = ns.start - halfWindow;
|
|
849
|
+
const winEnd = ns.end + halfWindow;
|
|
771
850
|
const categories = req.categories;
|
|
772
851
|
const ruleIds = req.ruleIds;
|
|
773
852
|
if (categories?.length || ruleIds?.length) {
|
|
774
853
|
for (const other of candidates) {
|
|
775
854
|
if (other === candidate) continue;
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
if (
|
|
779
|
-
|
|
855
|
+
if (other.normSpan.end < winStart || other.normSpan.start > winEnd) continue;
|
|
856
|
+
const relevant = other.match.ruleId !== candidate.match.ruleId && categories?.includes(other.match.category) === true || ruleIds?.includes(other.match.ruleId) === true;
|
|
857
|
+
if (!relevant) continue;
|
|
858
|
+
if (other.match.ruleId === candidate.match.ruleId && spansOverlap(other.match.span, candidate.match.span)) {
|
|
859
|
+
continue;
|
|
780
860
|
}
|
|
781
|
-
|
|
861
|
+
return true;
|
|
782
862
|
}
|
|
783
863
|
}
|
|
784
864
|
const labels = req.labels;
|
|
785
865
|
if (labels && labels.length > 0) {
|
|
786
|
-
const
|
|
866
|
+
const { start, end } = candidate.match.span;
|
|
867
|
+
const haystack = text.slice(Math.max(0, start - halfWindow), end + halfWindow);
|
|
868
|
+
const normalizedHaystack = normalization === void 0 ? void 0 : normalization.normalized.slice(Math.max(0, winStart), winEnd);
|
|
787
869
|
for (const re of memoizedRegExpList(
|
|
788
870
|
"label",
|
|
789
871
|
req,
|
|
@@ -792,29 +874,20 @@ function isCorroborated(candidate, candidates, text) {
|
|
|
792
874
|
return trimmed.length === 0 ? void 0 : new RegExp(`(?<![A-Za-z0-9])${escapeRegExp2(trimmed)}(?![A-Za-z0-9])`, "i");
|
|
793
875
|
})
|
|
794
876
|
)) {
|
|
795
|
-
if (re
|
|
877
|
+
if (!re) continue;
|
|
878
|
+
if (re.test(haystack)) return true;
|
|
879
|
+
if (normalizedHaystack !== void 0 && re.test(normalizedHaystack)) return true;
|
|
796
880
|
}
|
|
797
881
|
}
|
|
798
882
|
return false;
|
|
799
883
|
}
|
|
800
|
-
function
|
|
801
|
-
const base = filePath.slice(Math.max(filePath.lastIndexOf("/"), filePath.lastIndexOf("\\")) + 1);
|
|
802
|
-
const dot = base.lastIndexOf(".");
|
|
803
|
-
return dot > 0 ? base.slice(dot).toLowerCase() : void 0;
|
|
804
|
-
}
|
|
805
|
-
function ruleApplies(rule, extension) {
|
|
806
|
-
if (!rule.appliesTo || extension === void 0) return true;
|
|
807
|
-
return rule.appliesTo.extensions.some((e) => e.toLowerCase() === extension);
|
|
808
|
-
}
|
|
809
|
-
function scan(text, rules, context) {
|
|
810
|
-
const ruleset2 = rules ?? getLoadedRules();
|
|
811
|
-
const extension = context?.filePath ? extensionOf(context.filePath) : void 0;
|
|
884
|
+
function buildCandidates(matchText, ruleset2, extension, eventKind) {
|
|
812
885
|
const candidates = [];
|
|
813
886
|
for (const rule of ruleset2) {
|
|
814
|
-
if (!ruleApplies(rule, extension)) continue;
|
|
815
|
-
const spans = MATCHERS[rule.matcher.type](
|
|
887
|
+
if (!ruleApplies(rule, extension, eventKind)) continue;
|
|
888
|
+
const spans = MATCHERS[rule.matcher.type](matchText, rule);
|
|
816
889
|
for (const span of spans) {
|
|
817
|
-
const rawMatch =
|
|
890
|
+
const rawMatch = matchText.slice(span.start, span.end);
|
|
818
891
|
if (!passesPostValidators(rule, rawMatch)) continue;
|
|
819
892
|
candidates.push({
|
|
820
893
|
rule,
|
|
@@ -825,10 +898,31 @@ function scan(text, rules, context) {
|
|
|
825
898
|
span,
|
|
826
899
|
rawMatch,
|
|
827
900
|
confidence: 0.9
|
|
828
|
-
}
|
|
901
|
+
},
|
|
902
|
+
// In `matchText`'s own coordinates, which is the normalized text for
|
|
903
|
+
// a normalized-pass candidate and so already right; an original-pass
|
|
904
|
+
// candidate on the slow path is re-derived by withNormalizedSpan.
|
|
905
|
+
normSpan: span
|
|
829
906
|
});
|
|
830
907
|
}
|
|
831
908
|
}
|
|
909
|
+
return candidates;
|
|
910
|
+
}
|
|
911
|
+
function mapCandidateToOriginal(candidate, normalization, text) {
|
|
912
|
+
const span = mapSpanToOriginal(candidate.match.span, normalization);
|
|
913
|
+
return {
|
|
914
|
+
rule: candidate.rule,
|
|
915
|
+
match: { ...candidate.match, span, rawMatch: text.slice(span.start, span.end) },
|
|
916
|
+
// Deliberately NOT remapped: `normSpan` is the span the primitive match
|
|
917
|
+
// was found at in the normalized text, which is exactly the coordinate
|
|
918
|
+
// space windows are measured in. See the `Candidate` comment.
|
|
919
|
+
normSpan: candidate.normSpan
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
function withNormalizedSpan(candidate, normalization) {
|
|
923
|
+
return { ...candidate, normSpan: mapSpanToNormalized(candidate.match.span, normalization) };
|
|
924
|
+
}
|
|
925
|
+
function gate(candidates, text, normalization) {
|
|
832
926
|
const findings = [];
|
|
833
927
|
for (const candidate of candidates) {
|
|
834
928
|
const req = candidate.rule.requiresNearby;
|
|
@@ -836,7 +930,7 @@ function scan(text, rules, context) {
|
|
|
836
930
|
findings.push(candidate.match);
|
|
837
931
|
continue;
|
|
838
932
|
}
|
|
839
|
-
if (!isCorroborated(candidate, candidates, text)) continue;
|
|
933
|
+
if (!isCorroborated(candidate, candidates, text, normalization)) continue;
|
|
840
934
|
const boost = req.confidenceBoost;
|
|
841
935
|
findings.push(
|
|
842
936
|
boost ? { ...candidate.match, confidence: Math.min(0.99, candidate.match.confidence + boost) } : candidate.match
|
|
@@ -844,6 +938,89 @@ function scan(text, rules, context) {
|
|
|
844
938
|
}
|
|
845
939
|
return findings;
|
|
846
940
|
}
|
|
941
|
+
function closeRegion(open2, text) {
|
|
942
|
+
const span = { start: open2.start, end: open2.end };
|
|
943
|
+
return {
|
|
944
|
+
ruleId: open2.ruleId,
|
|
945
|
+
category: open2.category,
|
|
946
|
+
severity: open2.severity,
|
|
947
|
+
span,
|
|
948
|
+
rawMatch: text.slice(span.start, span.end),
|
|
949
|
+
confidence: open2.confidence
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
function mergeOverlappingSameRule(findings, text) {
|
|
953
|
+
if (findings.length === 0) return findings;
|
|
954
|
+
const groups = /* @__PURE__ */ new Map();
|
|
955
|
+
const ruleOrder = [];
|
|
956
|
+
for (const finding of findings) {
|
|
957
|
+
const group = groups.get(finding.ruleId);
|
|
958
|
+
if (group) {
|
|
959
|
+
group.push(finding);
|
|
960
|
+
} else {
|
|
961
|
+
groups.set(finding.ruleId, [finding]);
|
|
962
|
+
ruleOrder.push(finding.ruleId);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
const merged = [];
|
|
966
|
+
for (const ruleId of ruleOrder) {
|
|
967
|
+
const group = groups.get(ruleId) ?? [];
|
|
968
|
+
const sorted = [...group].sort(
|
|
969
|
+
(a, b) => a.span.start - b.span.start || a.span.end - b.span.end
|
|
970
|
+
);
|
|
971
|
+
let open2;
|
|
972
|
+
for (const finding of sorted) {
|
|
973
|
+
if (open2 && finding.span.start < open2.end) {
|
|
974
|
+
open2.end = Math.max(open2.end, finding.span.end);
|
|
975
|
+
open2.confidence = Math.max(open2.confidence, finding.confidence);
|
|
976
|
+
continue;
|
|
977
|
+
}
|
|
978
|
+
if (open2) merged.push(closeRegion(open2, text));
|
|
979
|
+
open2 = {
|
|
980
|
+
start: finding.span.start,
|
|
981
|
+
end: finding.span.end,
|
|
982
|
+
confidence: finding.confidence,
|
|
983
|
+
ruleId: finding.ruleId,
|
|
984
|
+
category: finding.category,
|
|
985
|
+
severity: finding.severity
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
if (open2) merged.push(closeRegion(open2, text));
|
|
989
|
+
}
|
|
990
|
+
return merged;
|
|
991
|
+
}
|
|
992
|
+
function extensionOf(filePath) {
|
|
993
|
+
const base = filePath.slice(Math.max(filePath.lastIndexOf("/"), filePath.lastIndexOf("\\")) + 1);
|
|
994
|
+
const dot = base.lastIndexOf(".");
|
|
995
|
+
return dot > 0 ? base.slice(dot).toLowerCase() : void 0;
|
|
996
|
+
}
|
|
997
|
+
function ruleApplies(rule, extension, eventKind) {
|
|
998
|
+
const scope = rule.appliesTo;
|
|
999
|
+
if (!scope) return true;
|
|
1000
|
+
if (scope.eventKinds && (eventKind === void 0 || !scope.eventKinds.some((k) => k === eventKind))) {
|
|
1001
|
+
return false;
|
|
1002
|
+
}
|
|
1003
|
+
if (!scope.extensions || extension === void 0) return true;
|
|
1004
|
+
return scope.extensions.some((e) => e.toLowerCase() === extension);
|
|
1005
|
+
}
|
|
1006
|
+
function scan(text, rules, context) {
|
|
1007
|
+
const ruleset2 = rules ?? getLoadedRules();
|
|
1008
|
+
const extension = context?.filePath ? extensionOf(context.filePath) : void 0;
|
|
1009
|
+
const normalization = normalizeFormatChars(text);
|
|
1010
|
+
const originalCandidates = buildCandidates(text, ruleset2, extension, context?.eventKind);
|
|
1011
|
+
if (!normalization) return gate(originalCandidates, text, void 0);
|
|
1012
|
+
const pooledOriginal = originalCandidates.map(
|
|
1013
|
+
(candidate) => withNormalizedSpan(candidate, normalization)
|
|
1014
|
+
);
|
|
1015
|
+
const normalizedCandidates = buildCandidates(
|
|
1016
|
+
normalization.normalized,
|
|
1017
|
+
ruleset2,
|
|
1018
|
+
extension,
|
|
1019
|
+
context?.eventKind
|
|
1020
|
+
).map((candidate) => mapCandidateToOriginal(candidate, normalization, text));
|
|
1021
|
+
const findings = gate([...pooledOriginal, ...normalizedCandidates], text, normalization);
|
|
1022
|
+
return mergeOverlappingSameRule(findings, text);
|
|
1023
|
+
}
|
|
847
1024
|
|
|
848
1025
|
// ../../packages/schema/src/exception-scope.ts
|
|
849
1026
|
var MINUTE_MS = 6e4;
|
|
@@ -21500,11 +21677,33 @@ var ResolutionMethod = external_exports.enum([
|
|
|
21500
21677
|
"false-positive",
|
|
21501
21678
|
"redetected"
|
|
21502
21679
|
]).meta({ id: "ResolutionMethod" });
|
|
21680
|
+
var FindingContextBasis = external_exports.enum(["file", "excerpt"]).meta({ id: "FindingContextBasis" });
|
|
21681
|
+
var FindingContext = external_exports.object({
|
|
21682
|
+
basis: FindingContextBasis,
|
|
21683
|
+
// 1-based line number of `lines[0]`.
|
|
21684
|
+
firstLine: external_exports.number().int().positive(),
|
|
21685
|
+
lines: external_exports.array(external_exports.string()).min(1).max(5),
|
|
21686
|
+
match: external_exports.object({
|
|
21687
|
+
// 1-based line number, within [firstLine, firstLine + lines.length).
|
|
21688
|
+
line: external_exports.number().int().positive(),
|
|
21689
|
+
// Offsets into that entry of `lines`, end exclusive.
|
|
21690
|
+
start: external_exports.number().int().nonnegative(),
|
|
21691
|
+
end: external_exports.number().int().nonnegative()
|
|
21692
|
+
}).nullable()
|
|
21693
|
+
}).meta({ id: "FindingContext" });
|
|
21694
|
+
var FindingLocation = external_exports.object({
|
|
21695
|
+
line: external_exports.number().int().positive(),
|
|
21696
|
+
col: external_exports.number().int().positive(),
|
|
21697
|
+
context: FindingContext.nullable()
|
|
21698
|
+
});
|
|
21503
21699
|
var FindingMatch = external_exports.object({
|
|
21504
21700
|
// Masked preview of the matched value. Never raw content.
|
|
21505
21701
|
maskedValue: external_exports.string(),
|
|
21506
|
-
//
|
|
21507
|
-
contextPrefix: external_exports.string()
|
|
21702
|
+
// Deprecated: always empty. Superseded by `context`.
|
|
21703
|
+
contextPrefix: external_exports.string(),
|
|
21704
|
+
// The masked lines around the match. Absent when the finding predates
|
|
21705
|
+
// context capture or none could be built safely.
|
|
21706
|
+
context: FindingContext.optional()
|
|
21508
21707
|
}).meta({ id: "FindingMatch" });
|
|
21509
21708
|
var FindingDetectionRef = external_exports.object({
|
|
21510
21709
|
id: external_exports.string(),
|
|
@@ -21524,6 +21723,11 @@ var FindingInstance = external_exports.object({
|
|
|
21524
21723
|
provider: FindingProvider,
|
|
21525
21724
|
repo: external_exports.string(),
|
|
21526
21725
|
file: external_exports.string(),
|
|
21726
|
+
// 1-based line and column of the match start in the scanned text (the
|
|
21727
|
+
// column in UTF-16 code units). Absent for findings that predate location
|
|
21728
|
+
// capture or have no source text.
|
|
21729
|
+
line: external_exports.number().int().positive().optional(),
|
|
21730
|
+
col: external_exports.number().int().positive().optional(),
|
|
21527
21731
|
// Who the capturing event is attributed to. Optional: a single-user store
|
|
21528
21732
|
// has no one to attribute a finding to and never sets it.
|
|
21529
21733
|
user: FindingUser.optional(),
|
|
@@ -21585,6 +21789,13 @@ var FindingStats = external_exports.object({
|
|
|
21585
21789
|
low: external_exports.number().int().nonnegative()
|
|
21586
21790
|
})
|
|
21587
21791
|
}).meta({ id: "FindingStats" });
|
|
21792
|
+
var FindingsOverview = external_exports.object({
|
|
21793
|
+
findings: external_exports.number().int().nonnegative(),
|
|
21794
|
+
open: external_exports.number().int().nonnegative(),
|
|
21795
|
+
handled: external_exports.number().int().nonnegative(),
|
|
21796
|
+
resolved: external_exports.number().int().nonnegative(),
|
|
21797
|
+
dismissed: external_exports.number().int().nonnegative()
|
|
21798
|
+
}).meta({ id: "FindingsOverview" });
|
|
21588
21799
|
var FindingFacetItem = external_exports.object({
|
|
21589
21800
|
value: external_exports.string(),
|
|
21590
21801
|
count: external_exports.number().int().nonnegative()
|
|
@@ -21702,6 +21913,7 @@ var FindingInstanceDetail = FindingInstance.extend({
|
|
|
21702
21913
|
policy: FindingPolicyRef
|
|
21703
21914
|
}).meta({ id: "FindingInstanceDetail" });
|
|
21704
21915
|
var MAX_FLAT_FINDINGS_LIMIT = 200;
|
|
21916
|
+
var FindingContextQuery = external_exports.object({ id: external_exports.string().min(1).max(256) });
|
|
21705
21917
|
var ListFindingInstancesQuery = external_exports.object({
|
|
21706
21918
|
severity: external_exports.array(Severity).optional(),
|
|
21707
21919
|
// Rule ids, the same vocabulary the types list's `subtype` carries. Pinning
|
|
@@ -22033,7 +22245,23 @@ var CaptureAttributes = external_exports.object({
|
|
|
22033
22245
|
// capture denied by another finding's own Block policy carries `block`
|
|
22034
22246
|
// here too. The full statement is on EventMetadata.redactDegradedTo; it is
|
|
22035
22247
|
// repeated rather than referenced because a store reader opens this file.
|
|
22036
|
-
redact_degraded_to: ActionTaken.optional()
|
|
22248
|
+
redact_degraded_to: ActionTaken.optional(),
|
|
22249
|
+
// The scope key this capture was stamped with: the canonical repository
|
|
22250
|
+
// (`host/owner/repo`) of the path the capture names (a relative path is read
|
|
22251
|
+
// against its working directory), else of its own working directory, or a
|
|
22252
|
+
// chat account's identity. The store's local `scope_key` column reads it, so
|
|
22253
|
+
// a scoped attachment has a per-row key to work from. Absent when no key
|
|
22254
|
+
// could be derived.
|
|
22255
|
+
//
|
|
22256
|
+
// LOCAL ONLY. That is the contract for every path that sends a row. Producers
|
|
22257
|
+
// stamp it in every attachment mode, and the two structural choke points strip
|
|
22258
|
+
// it: the attached gateway's `reKeyForForward` on the live path, and the
|
|
22259
|
+
// history drain's `rebuildAuditEvent`, which drops it through `withoutScopeKey`.
|
|
22260
|
+
// A capture row's bag reaches the wire through `rebuildCapture`, which builds
|
|
22261
|
+
// the metadata from named keys and never names this one; `toCaptureAttributes`,
|
|
22262
|
+
// which builds the bag from a wire event, never emits it. What a scoped
|
|
22263
|
+
// attachment does with the key is not part of this shape's contract.
|
|
22264
|
+
scope_key: external_exports.string().optional()
|
|
22037
22265
|
}).catchall(external_exports.unknown());
|
|
22038
22266
|
var CaptureStatusAttributes = external_exports.object({
|
|
22039
22267
|
source_tool: external_exports.string().optional(),
|
|
@@ -22063,6 +22291,12 @@ var ToolCallInspection = external_exports.object({
|
|
|
22063
22291
|
actionTaken: ActionTaken,
|
|
22064
22292
|
confidence: external_exports.number().min(0).max(1)
|
|
22065
22293
|
});
|
|
22294
|
+
var findingLocationFields = {
|
|
22295
|
+
line: external_exports.number().int().positive().optional(),
|
|
22296
|
+
col: external_exports.number().int().positive().optional(),
|
|
22297
|
+
context: FindingContext.nullable().optional()
|
|
22298
|
+
};
|
|
22299
|
+
var ToolCallInspectionInput = ToolCallInspection.extend(findingLocationFields);
|
|
22066
22300
|
var ToolCallInput = external_exports.object({
|
|
22067
22301
|
sessionId: external_exports.string().min(1),
|
|
22068
22302
|
toolUseId: external_exports.string().min(1),
|
|
@@ -22072,7 +22306,7 @@ var ToolCallInput = external_exports.object({
|
|
|
22072
22306
|
attributes: ToolCallAttributes,
|
|
22073
22307
|
// Secrets detected in the tool's (masked) target — written as linked
|
|
22074
22308
|
// `inspection_findings`. Empty for a clean tool call.
|
|
22075
|
-
inspections: external_exports.array(
|
|
22309
|
+
inspections: external_exports.array(ToolCallInspectionInput).default([])
|
|
22076
22310
|
});
|
|
22077
22311
|
var InventoryInput = external_exports.object({
|
|
22078
22312
|
objectType: InventoryObjectType,
|
|
@@ -22146,7 +22380,8 @@ var InspectionFindingInput = external_exports.object({
|
|
|
22146
22380
|
// same findingKey — mirrors the legacy `findings.first_detected_at`.
|
|
22147
22381
|
// Optional: when omitted, the writer derives it from the referenced audit
|
|
22148
22382
|
// event's startedAt on first insert (see SqliteInspectionFindingsRepository).
|
|
22149
|
-
firstDetectedAt: external_exports.iso.datetime().optional()
|
|
22383
|
+
firstDetectedAt: external_exports.iso.datetime().optional(),
|
|
22384
|
+
...findingLocationFields
|
|
22150
22385
|
});
|
|
22151
22386
|
var InventoryContext = external_exports.object({
|
|
22152
22387
|
host: InventoryInput.optional(),
|
|
@@ -22921,6 +23156,17 @@ var AttachedCredential = external_exports.object({
|
|
|
22921
23156
|
keyPrefix: external_exports.string().min(1).max(16).optional(),
|
|
22922
23157
|
mintedAt: external_exports.iso.datetime().optional()
|
|
22923
23158
|
});
|
|
23159
|
+
var AttachmentMode = external_exports.enum(["machine", "scoped"]);
|
|
23160
|
+
var ATTACHED_CREDENTIAL_SCOPED_SPEC_VERSION = 2;
|
|
23161
|
+
var AttachedCredentialV1 = AttachedCredential;
|
|
23162
|
+
var AttachedCredentialV2 = AttachedCredential.extend({
|
|
23163
|
+
specVersion: external_exports.literal(ATTACHED_CREDENTIAL_SCOPED_SPEC_VERSION),
|
|
23164
|
+
mode: external_exports.literal("scoped")
|
|
23165
|
+
});
|
|
23166
|
+
var AttachedCredentialAny = external_exports.discriminatedUnion("specVersion", [
|
|
23167
|
+
AttachedCredentialV1,
|
|
23168
|
+
AttachedCredentialV2
|
|
23169
|
+
]);
|
|
22924
23170
|
var MAX_DATE_MS = 253402300799999;
|
|
22925
23171
|
var MAX_INT4 = 2147483647;
|
|
22926
23172
|
var StorePosturePack = external_exports.object({
|
|
@@ -22977,7 +23223,29 @@ var StorePosturePlugin = external_exports.object({
|
|
|
22977
23223
|
*/
|
|
22978
23224
|
policyBundleVersion: external_exports.string().max(200).nullable(),
|
|
22979
23225
|
/** Epoch millis, on the CLIENT clock, of that fetch. */
|
|
22980
|
-
policyFetchedAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable()
|
|
23226
|
+
policyFetchedAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable(),
|
|
23227
|
+
/**
|
|
23228
|
+
* The newest version the host's own install record holds for this plugin —
|
|
23229
|
+
* what is on disk. After an update it leads `version` (the running copy) by
|
|
23230
|
+
* one launch. Null when no usable version can be read: no install record
|
|
23231
|
+
* (a plugin run from a checkout), no entry with a valid version, or every
|
|
23232
|
+
* such entry names an `installPath` that no longer exists; OPTIONAL, not
|
|
23233
|
+
* required, so a build that predates the member keeps getting its 200.
|
|
23234
|
+
* Bounded like `version`.
|
|
23235
|
+
*/
|
|
23236
|
+
installedVersion: external_exports.string().max(64).nullable().optional(),
|
|
23237
|
+
/**
|
|
23238
|
+
* The local-store schema version this running build migrates a store to:
|
|
23239
|
+
* the number of store migrations it carries, the count it stamps into
|
|
23240
|
+
* `PRAGMA user_version`. A snapshot whose `schemaVersion` is above it
|
|
23241
|
+
* usually describes a store a newer build migrated. It is a hint, not a
|
|
23242
|
+
* verdict: the stamp is write-only, so a store whose count ran past this
|
|
23243
|
+
* build's while this build knows every migration in its ledger reads above
|
|
23244
|
+
* it too, which is why describeStoreSkew decides skew on ledger tags and
|
|
23245
|
+
* never on the count. OPTIONAL for the same reason as `installedVersion`;
|
|
23246
|
+
* bounded like `schemaVersion`.
|
|
23247
|
+
*/
|
|
23248
|
+
buildSchemaVersion: external_exports.number().int().min(0).max(MAX_INT4).optional()
|
|
22981
23249
|
}).meta({ id: "StorePosturePlugin" });
|
|
22982
23250
|
var StorePostureSnapshot = external_exports.object({
|
|
22983
23251
|
deviceId: external_exports.guid(),
|
|
@@ -23180,6 +23448,130 @@ var PackId = external_exports.string().regex(/^[a-z][a-z0-9-]*$/);
|
|
|
23180
23448
|
var SemVer = external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?$/);
|
|
23181
23449
|
var PublisherKind = external_exports.enum(["labs", "user", "org"]);
|
|
23182
23450
|
|
|
23451
|
+
// ../../packages/schema/src/zod/builtin-policy-id.ts
|
|
23452
|
+
var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
|
|
23453
|
+
var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
|
|
23454
|
+
|
|
23455
|
+
// ../../packages/schema/src/zod/event.ts
|
|
23456
|
+
var EventKind = external_exports.enum(["prompt", "response", "code_change", "tool_use"]).meta({ id: "EventKind" });
|
|
23457
|
+
var CAPTURE_EVENT_TYPES_SQL = EventKind.options.map((k) => `'${k}'`).join(",");
|
|
23458
|
+
var EventMetadata = external_exports.object({
|
|
23459
|
+
sessionId: external_exports.string().optional(),
|
|
23460
|
+
repo: external_exports.string().optional(),
|
|
23461
|
+
filePath: external_exports.string().optional(),
|
|
23462
|
+
// The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
|
|
23463
|
+
// set by the tool-scanning hooks. The tool NAME only — never the tool's
|
|
23464
|
+
// arguments or output, which can carry the very value a finding masked
|
|
23465
|
+
// (metadata is stored unredacted). Gives findings on non-file captures a
|
|
23466
|
+
// display location ("via Bash") when no filePath exists.
|
|
23467
|
+
toolName: external_exports.string().optional(),
|
|
23468
|
+
// Set (true) by the worktree scanner when the file is excluded by the
|
|
23469
|
+
// repo's .gitignore. Gitignored files ARE still scanned — local scratch and
|
|
23470
|
+
// generated code can leak real secrets — but the provenance is recorded so
|
|
23471
|
+
// policy/dashboards can treat those findings as informational rather than
|
|
23472
|
+
// blocking. Omitted (not false) for tracked files and non-scan events.
|
|
23473
|
+
gitignored: external_exports.boolean().optional(),
|
|
23474
|
+
// Set (true) ONLY when the event's `content` is the COMPLETE file at
|
|
23475
|
+
// capture time (a worktree scan reading from disk). Hook-captured edits
|
|
23476
|
+
// (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
|
|
23477
|
+
// this. The resolver-on-ingest keys its fixed-at-source dropout
|
|
23478
|
+
// diff on this marker: only a whole-file snapshot can prove a previously
|
|
23479
|
+
// open finding is gone; a fragment's absence proves nothing (the secret
|
|
23480
|
+
// may live outside the hunk). Omitted (not false) for fragments and
|
|
23481
|
+
// non-scan events, so pre-marker clients safely default to the
|
|
23482
|
+
// non-authoritative path.
|
|
23483
|
+
wholeFile: external_exports.boolean().optional(),
|
|
23484
|
+
model: external_exports.string().optional(),
|
|
23485
|
+
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
23486
|
+
// Distributed-tracing correlation. `correlationId` ties a recorded event back
|
|
23487
|
+
// to the request that captured/ingested it (a UUID, generated independently of
|
|
23488
|
+
// the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
|
|
23489
|
+
// originating span when telemetry is enabled. Both optional + backward
|
|
23490
|
+
// compatible — populated by the plugin (see @akasecurity/plugin-sdk).
|
|
23491
|
+
correlationId: external_exports.uuid().optional(),
|
|
23492
|
+
traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
|
|
23493
|
+
// Ids of the detection exceptions that downgraded findings in this capture
|
|
23494
|
+
// to 'allow' — the enforcement audit trail's link back to the grant that
|
|
23495
|
+
// authorized the bypass. Absent on captures where no exception applied.
|
|
23496
|
+
exceptionIds: external_exports.array(external_exports.guid()).optional(),
|
|
23497
|
+
// The assistant message this capture belongs to, and the conversation it sits
|
|
23498
|
+
// in — set by the browser extension's network capture so a stored `response`
|
|
23499
|
+
// row can be joined to the `llm_call` leaf describing the same turn. Absent
|
|
23500
|
+
// on every other capture path, which has no such id.
|
|
23501
|
+
//
|
|
23502
|
+
// Non-empty for the reason WebExchange.messageId is: it is the join key, and
|
|
23503
|
+
// a blank one matches no `llm_call` leaf. That refusal reaches only the
|
|
23504
|
+
// places an event is PARSED; the local write path types the event and parses
|
|
23505
|
+
// nothing, which is why `toCaptureAttributes` omits a blank one separately.
|
|
23506
|
+
messageId: external_exports.string().min(1).optional(),
|
|
23507
|
+
conversationId: external_exports.string().optional(),
|
|
23508
|
+
// How long THIS capture's inspection blocked its caller, in whole
|
|
23509
|
+
// milliseconds — the plugin's own added latency, NOT the LLM call it sat in
|
|
23510
|
+
// front of. Measured inside `capture()` (@akasecurity/plugin-sdk) across
|
|
23511
|
+
// detection + redaction, the work the host session actually waits on.
|
|
23512
|
+
//
|
|
23513
|
+
// Stamped ONLY on live in-flight captures. A capture that carries its own
|
|
23514
|
+
// `occurredAt` is replaying past work (the transcript backfill, the worktree
|
|
23515
|
+
// scan), and its scan duration is not latency any host session experienced,
|
|
23516
|
+
// so those rows leave this ABSENT rather than reporting a misleading number.
|
|
23517
|
+
// Absent is also what every pre-measurement client writes, and what a
|
|
23518
|
+
// clock failure degrades to — a reader must treat absence as "not measured"
|
|
23519
|
+
// and never as a zero, which would read as "inspection is free".
|
|
23520
|
+
inspectionMs: external_exports.number().int().nonnegative().optional(),
|
|
23521
|
+
// What a `redact` this capture COULD NOT CARRY OUT became instead — the
|
|
23522
|
+
// workspace's `redactFallback`, applied because the field could not be
|
|
23523
|
+
// masked in place (a shell command, a URL, or any argument on a host whose
|
|
23524
|
+
// hook contract offers no rewrite channel).
|
|
23525
|
+
//
|
|
23526
|
+
// It exists because the action alone cannot say why. A finding recorded as
|
|
23527
|
+
// `warn` reads identically whether its detection was ASSIGNED Warn or was
|
|
23528
|
+
// assigned Redact on a field that could not take one — and those are
|
|
23529
|
+
// different facts about the same row: the first is a policy the user chose,
|
|
23530
|
+
// the second is a masking the host could not perform. Absent means no
|
|
23531
|
+
// degrade happened, which is every ordinary capture.
|
|
23532
|
+
//
|
|
23533
|
+
// TWO LIMITS a reader of a stored row has to know, because the grain here
|
|
23534
|
+
// is the CAPTURE while `actionTaken` is per FINDING:
|
|
23535
|
+
//
|
|
23536
|
+
// - It does not say WHICH finding degraded. A capture carrying a degraded
|
|
23537
|
+
// `redact` alongside a finding ASSIGNED the same action stores both
|
|
23538
|
+
// identically and one reason for the pair; attributing it to both
|
|
23539
|
+
// describes the assigned one wrongly, and to neither loses the degrade.
|
|
23540
|
+
// - PRESENCE IS NOT CAUSATION. The value is the action the lost redact
|
|
23541
|
+
// became, not the reason the capture ended as it did — a capture denied
|
|
23542
|
+
// by some other finding's own Block policy still carries `block` here,
|
|
23543
|
+
// and clearing the workspace's fallback would not have let it through.
|
|
23544
|
+
// Gate on the value against what a fallback can produce; never read the
|
|
23545
|
+
// field's presence as "this was the fallback's doing".
|
|
23546
|
+
//
|
|
23547
|
+
// Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
|
|
23548
|
+
// Closing either means moving the reason onto the finding row, which
|
|
23549
|
+
// already carries its own action.
|
|
23550
|
+
redactDegradedTo: ActionTaken.optional()
|
|
23551
|
+
}).meta({ id: "EventMetadata" });
|
|
23552
|
+
var Event = external_exports.object({
|
|
23553
|
+
id: external_exports.guid(),
|
|
23554
|
+
sourceTool: SourceTool,
|
|
23555
|
+
kind: EventKind,
|
|
23556
|
+
occurredAt: external_exports.iso.datetime(),
|
|
23557
|
+
contentHash: external_exports.string(),
|
|
23558
|
+
content: external_exports.string(),
|
|
23559
|
+
metadata: EventMetadata.optional()
|
|
23560
|
+
}).meta({ id: "Event" });
|
|
23561
|
+
var IngestEvent = Event.meta({ id: "IngestEvent" });
|
|
23562
|
+
var INGEST_BATCH_MAX = 100;
|
|
23563
|
+
var IngestBatch = external_exports.object({
|
|
23564
|
+
events: external_exports.array(IngestEvent).min(1).max(INGEST_BATCH_MAX),
|
|
23565
|
+
// Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
|
|
23566
|
+
// additionally rejects any event whose contentHash the store has already
|
|
23567
|
+
// recorded — for re-runnable bulk ingest (worktree scan, transcript
|
|
23568
|
+
// backfill), where a re-run mints fresh event ids for identical content and
|
|
23569
|
+
// would otherwise accumulate duplicates. Live hook traffic must NOT set it:
|
|
23570
|
+
// two genuinely separate prompts can be byte-identical and both belong on
|
|
23571
|
+
// the timeline.
|
|
23572
|
+
dedupe: external_exports.literal("content-hash").optional()
|
|
23573
|
+
}).meta({ id: "IngestBatch" });
|
|
23574
|
+
|
|
23183
23575
|
// ../../packages/schema/src/zod/rule.ts
|
|
23184
23576
|
var MatcherType = external_exports.enum(["keyword", "regex"]).meta({ id: "MatcherType" });
|
|
23185
23577
|
var RuleProbeVerdict = external_exports.enum(["safe", "quarantined"]).meta({ id: "RuleProbeVerdict" });
|
|
@@ -23248,7 +23640,10 @@ var Matcher = external_exports.discriminatedUnion("type", [KeywordMatcher2, Rege
|
|
|
23248
23640
|
var MATCHER_TYPES = MatcherType.options;
|
|
23249
23641
|
var AppliesTo = external_exports.strictObject({
|
|
23250
23642
|
// Dot-prefixed, e.g. ".py" — matches the scanner's SOURCE_EXTENSIONS shape.
|
|
23251
|
-
extensions: external_exports.array(external_exports.string().regex(/^\.[A-Za-z0-9]+$/)).min(1)
|
|
23643
|
+
extensions: external_exports.array(external_exports.string().regex(/^\.[A-Za-z0-9]+$/)).min(1).optional(),
|
|
23644
|
+
eventKinds: external_exports.array(EventKind).min(1).optional()
|
|
23645
|
+
}).refine((v) => v.extensions !== void 0 || v.eventKinds !== void 0, {
|
|
23646
|
+
message: "appliesTo needs extensions, eventKinds, or both"
|
|
23252
23647
|
}).meta({ id: "AppliesTo" });
|
|
23253
23648
|
var PostValidatorName = external_exports.enum(["entropy", "luhn"]).meta({ id: "PostValidatorName" });
|
|
23254
23649
|
var PostValidatorRef = external_exports.union(
|
|
@@ -23271,6 +23666,7 @@ var PostValidatorRef = external_exports.union(
|
|
|
23271
23666
|
)}) or { "name": ..., "config": { ... } }. An unrecognized name would be a false-positive guard that never runs.`
|
|
23272
23667
|
}
|
|
23273
23668
|
).meta({ id: "PostValidatorRef" });
|
|
23669
|
+
var RuleEvidence = external_exports.enum(["code", "value"]).meta({ id: "RuleEvidence" });
|
|
23274
23670
|
var RequiresNearby = external_exports.strictObject({
|
|
23275
23671
|
// Each array, when present, must be non-empty and contain non-empty strings —
|
|
23276
23672
|
// an empty/blank criterion would either never fire or (for labels) match
|
|
@@ -23293,6 +23689,8 @@ var RuleFixture = external_exports.strictObject({
|
|
|
23293
23689
|
// Simulated file context for the scan, so fixtures can assert `appliesTo`
|
|
23294
23690
|
// gating (e.g. a Python-only pattern must NOT fire in a .ts file).
|
|
23295
23691
|
filePath: external_exports.string().optional(),
|
|
23692
|
+
// Simulated capture kind, so fixtures can assert `appliesTo.eventKinds`.
|
|
23693
|
+
eventKind: EventKind.optional(),
|
|
23296
23694
|
expectedSpans: external_exports.array(external_exports.strictObject({ start: external_exports.number(), end: external_exports.number() })).optional()
|
|
23297
23695
|
}).meta({ id: "RuleFixture" });
|
|
23298
23696
|
var Rule = external_exports.strictObject({
|
|
@@ -23318,7 +23716,9 @@ var Rule = external_exports.strictObject({
|
|
|
23318
23716
|
appliesTo: AppliesTo.optional(),
|
|
23319
23717
|
postValidators: external_exports.array(PostValidatorRef).optional(),
|
|
23320
23718
|
requiresNearby: RequiresNearby.optional(),
|
|
23321
|
-
examples: external_exports.array(external_exports.string()).optional()
|
|
23719
|
+
examples: external_exports.array(external_exports.string()).optional(),
|
|
23720
|
+
// Whether the matched text is itself sensitive. Absent means 'value'.
|
|
23721
|
+
evidence: RuleEvidence.optional()
|
|
23322
23722
|
}).meta({ id: "Rule" });
|
|
23323
23723
|
var Author = external_exports.object({
|
|
23324
23724
|
name: external_exports.string(),
|
|
@@ -23335,7 +23735,11 @@ var PackManifest = external_exports.object({
|
|
|
23335
23735
|
description: external_exports.string().optional(),
|
|
23336
23736
|
author: Author.optional(),
|
|
23337
23737
|
license: external_exports.string().optional(),
|
|
23338
|
-
sourceUrl: external_exports.url().optional()
|
|
23738
|
+
sourceUrl: external_exports.url().optional(),
|
|
23739
|
+
// The built-in policy a FIRST install of this pack assigns
|
|
23740
|
+
// (installed_packs.policy_id). Absent leaves the pack unassigned, so its
|
|
23741
|
+
// rules follow the category policies. An existing install never takes it.
|
|
23742
|
+
defaultPolicy: BuiltinPolicyId.optional()
|
|
23339
23743
|
}).meta({ id: "PackManifest" });
|
|
23340
23744
|
|
|
23341
23745
|
// ../../packages/schema/src/zod/detection.ts
|
|
@@ -23363,10 +23767,12 @@ var DetectionListItem = external_exports.object({
|
|
|
23363
23767
|
// Per-pack enforcement-policy assignment. Holds a BuiltinPolicyId ARCHETYPE
|
|
23364
23768
|
// (monitor|warn|redact|block) — NOT a policies-table Policy.id guid; a
|
|
23365
23769
|
// detection is a PACK, and its policy is the archetype applied to all its
|
|
23366
|
-
// rules. Absent == unassigned, which resolves to Monitor
|
|
23367
|
-
// (DEFAULT_PACK_POLICY_ID)
|
|
23368
|
-
//
|
|
23369
|
-
//
|
|
23770
|
+
// rules. Absent == unassigned, which resolves to Monitor by default
|
|
23771
|
+
// (DEFAULT_PACK_POLICY_ID); a host may resolve it to a policy of its own
|
|
23772
|
+
// (see the dashboard's `unassignedPolicy`). Every enforcement surface
|
|
23773
|
+
// expands it into per-rule policies (see policyIdToAction). Typed
|
|
23774
|
+
// z.string() (not the enum) to keep the OpenAPI response tolerant of a
|
|
23775
|
+
// future custom id.
|
|
23370
23776
|
policyId: external_exports.string().optional(),
|
|
23371
23777
|
// Set ONLY when a newer snapshot is available for this pack (OSS: the
|
|
23372
23778
|
// bundled inventory recorded in available_packs differs from the installed
|
|
@@ -23435,10 +23841,12 @@ var DetectionDetail = external_exports.object({
|
|
|
23435
23841
|
// Per-pack enforcement-policy assignment. Holds a BuiltinPolicyId ARCHETYPE
|
|
23436
23842
|
// (monitor|warn|redact|block) — NOT a policies-table Policy.id guid; a
|
|
23437
23843
|
// detection is a PACK, and its policy is the archetype applied to all its
|
|
23438
|
-
// rules. Absent == unassigned, which resolves to Monitor
|
|
23439
|
-
// (DEFAULT_PACK_POLICY_ID)
|
|
23440
|
-
//
|
|
23441
|
-
//
|
|
23844
|
+
// rules. Absent == unassigned, which resolves to Monitor by default
|
|
23845
|
+
// (DEFAULT_PACK_POLICY_ID); a host may resolve it to a policy of its own
|
|
23846
|
+
// (see the dashboard's `unassignedPolicy`). Every enforcement surface
|
|
23847
|
+
// expands it into per-rule policies (see policyIdToAction). Typed
|
|
23848
|
+
// z.string() (not the enum) to keep the OpenAPI response tolerant of a
|
|
23849
|
+
// future custom id.
|
|
23442
23850
|
policyId: external_exports.string().optional()
|
|
23443
23851
|
}).meta({ id: "DetectionDetail" });
|
|
23444
23852
|
var LibraryItem = external_exports.object({
|
|
@@ -23468,126 +23876,6 @@ var ImportDetectionRequest = external_exports.object({
|
|
|
23468
23876
|
})
|
|
23469
23877
|
}).meta({ id: "ImportDetectionRequest" });
|
|
23470
23878
|
|
|
23471
|
-
// ../../packages/schema/src/zod/event.ts
|
|
23472
|
-
var EventKind = external_exports.enum(["prompt", "response", "code_change", "tool_use"]).meta({ id: "EventKind" });
|
|
23473
|
-
var CAPTURE_EVENT_TYPES_SQL = EventKind.options.map((k) => `'${k}'`).join(",");
|
|
23474
|
-
var EventMetadata = external_exports.object({
|
|
23475
|
-
sessionId: external_exports.string().optional(),
|
|
23476
|
-
repo: external_exports.string().optional(),
|
|
23477
|
-
filePath: external_exports.string().optional(),
|
|
23478
|
-
// The host tool whose input/output was scanned (e.g. 'Bash', 'WebFetch'),
|
|
23479
|
-
// set by the tool-scanning hooks. The tool NAME only — never the tool's
|
|
23480
|
-
// arguments or output, which can carry the very value a finding masked
|
|
23481
|
-
// (metadata is stored unredacted). Gives findings on non-file captures a
|
|
23482
|
-
// display location ("via Bash") when no filePath exists.
|
|
23483
|
-
toolName: external_exports.string().optional(),
|
|
23484
|
-
// Set (true) by the worktree scanner when the file is excluded by the
|
|
23485
|
-
// repo's .gitignore. Gitignored files ARE still scanned — local scratch and
|
|
23486
|
-
// generated code can leak real secrets — but the provenance is recorded so
|
|
23487
|
-
// policy/dashboards can treat those findings as informational rather than
|
|
23488
|
-
// blocking. Omitted (not false) for tracked files and non-scan events.
|
|
23489
|
-
gitignored: external_exports.boolean().optional(),
|
|
23490
|
-
// Set (true) ONLY when the event's `content` is the COMPLETE file at
|
|
23491
|
-
// capture time (a worktree scan reading from disk). Hook-captured edits
|
|
23492
|
-
// (e.g. an Edit tool's new_string) are partial fragments and MUST NOT set
|
|
23493
|
-
// this. The resolver-on-ingest keys its fixed-at-source dropout
|
|
23494
|
-
// diff on this marker: only a whole-file snapshot can prove a previously
|
|
23495
|
-
// open finding is gone; a fragment's absence proves nothing (the secret
|
|
23496
|
-
// may live outside the hunk). Omitted (not false) for fragments and
|
|
23497
|
-
// non-scan events, so pre-marker clients safely default to the
|
|
23498
|
-
// non-authoritative path.
|
|
23499
|
-
wholeFile: external_exports.boolean().optional(),
|
|
23500
|
-
model: external_exports.string().optional(),
|
|
23501
|
-
turnIndex: external_exports.number().int().nonnegative().optional(),
|
|
23502
|
-
// Distributed-tracing correlation. `correlationId` ties a recorded event back
|
|
23503
|
-
// to the request that captured/ingested it (a UUID, generated independently of
|
|
23504
|
-
// the trace id); `traceId` is the W3C trace id (32 lowercase hex chars) of the
|
|
23505
|
-
// originating span when telemetry is enabled. Both optional + backward
|
|
23506
|
-
// compatible — populated by the plugin (see @akasecurity/plugin-sdk).
|
|
23507
|
-
correlationId: external_exports.uuid().optional(),
|
|
23508
|
-
traceId: external_exports.string().regex(/^[0-9a-f]{32}$/).optional(),
|
|
23509
|
-
// Ids of the detection exceptions that downgraded findings in this capture
|
|
23510
|
-
// to 'allow' — the enforcement audit trail's link back to the grant that
|
|
23511
|
-
// authorized the bypass. Absent on captures where no exception applied.
|
|
23512
|
-
exceptionIds: external_exports.array(external_exports.guid()).optional(),
|
|
23513
|
-
// The assistant message this capture belongs to, and the conversation it sits
|
|
23514
|
-
// in — set by the browser extension's network capture so a stored `response`
|
|
23515
|
-
// row can be joined to the `llm_call` leaf describing the same turn. Absent
|
|
23516
|
-
// on every other capture path, which has no such id.
|
|
23517
|
-
//
|
|
23518
|
-
// Non-empty for the reason WebExchange.messageId is: it is the join key, and
|
|
23519
|
-
// a blank one matches no `llm_call` leaf. That refusal reaches only the
|
|
23520
|
-
// places an event is PARSED; the local write path types the event and parses
|
|
23521
|
-
// nothing, which is why `toCaptureAttributes` omits a blank one separately.
|
|
23522
|
-
messageId: external_exports.string().min(1).optional(),
|
|
23523
|
-
conversationId: external_exports.string().optional(),
|
|
23524
|
-
// How long THIS capture's inspection blocked its caller, in whole
|
|
23525
|
-
// milliseconds — the plugin's own added latency, NOT the LLM call it sat in
|
|
23526
|
-
// front of. Measured inside `capture()` (@akasecurity/plugin-sdk) across
|
|
23527
|
-
// detection + redaction, the work the host session actually waits on.
|
|
23528
|
-
//
|
|
23529
|
-
// Stamped ONLY on live in-flight captures. A capture that carries its own
|
|
23530
|
-
// `occurredAt` is replaying past work (the transcript backfill, the worktree
|
|
23531
|
-
// scan), and its scan duration is not latency any host session experienced,
|
|
23532
|
-
// so those rows leave this ABSENT rather than reporting a misleading number.
|
|
23533
|
-
// Absent is also what every pre-measurement client writes, and what a
|
|
23534
|
-
// clock failure degrades to — a reader must treat absence as "not measured"
|
|
23535
|
-
// and never as a zero, which would read as "inspection is free".
|
|
23536
|
-
inspectionMs: external_exports.number().int().nonnegative().optional(),
|
|
23537
|
-
// What a `redact` this capture COULD NOT CARRY OUT became instead — the
|
|
23538
|
-
// workspace's `redactFallback`, applied because the field could not be
|
|
23539
|
-
// masked in place (a shell command, a URL, or any argument on a host whose
|
|
23540
|
-
// hook contract offers no rewrite channel).
|
|
23541
|
-
//
|
|
23542
|
-
// It exists because the action alone cannot say why. A finding recorded as
|
|
23543
|
-
// `warn` reads identically whether its detection was ASSIGNED Warn or was
|
|
23544
|
-
// assigned Redact on a field that could not take one — and those are
|
|
23545
|
-
// different facts about the same row: the first is a policy the user chose,
|
|
23546
|
-
// the second is a masking the host could not perform. Absent means no
|
|
23547
|
-
// degrade happened, which is every ordinary capture.
|
|
23548
|
-
//
|
|
23549
|
-
// TWO LIMITS a reader of a stored row has to know, because the grain here
|
|
23550
|
-
// is the CAPTURE while `actionTaken` is per FINDING:
|
|
23551
|
-
//
|
|
23552
|
-
// - It does not say WHICH finding degraded. A capture carrying a degraded
|
|
23553
|
-
// `redact` alongside a finding ASSIGNED the same action stores both
|
|
23554
|
-
// identically and one reason for the pair; attributing it to both
|
|
23555
|
-
// describes the assigned one wrongly, and to neither loses the degrade.
|
|
23556
|
-
// - PRESENCE IS NOT CAUSATION. The value is the action the lost redact
|
|
23557
|
-
// became, not the reason the capture ended as it did — a capture denied
|
|
23558
|
-
// by some other finding's own Block policy still carries `block` here,
|
|
23559
|
-
// and clearing the workspace's fallback would not have let it through.
|
|
23560
|
-
// Gate on the value against what a fallback can produce; never read the
|
|
23561
|
-
// field's presence as "this was the fallback's doing".
|
|
23562
|
-
//
|
|
23563
|
-
// Both are pinned as behaviour in @akasecurity/plugin-sdk's runtime suite.
|
|
23564
|
-
// Closing either means moving the reason onto the finding row, which
|
|
23565
|
-
// already carries its own action.
|
|
23566
|
-
redactDegradedTo: ActionTaken.optional()
|
|
23567
|
-
}).meta({ id: "EventMetadata" });
|
|
23568
|
-
var Event = external_exports.object({
|
|
23569
|
-
id: external_exports.guid(),
|
|
23570
|
-
sourceTool: SourceTool,
|
|
23571
|
-
kind: EventKind,
|
|
23572
|
-
occurredAt: external_exports.iso.datetime(),
|
|
23573
|
-
contentHash: external_exports.string(),
|
|
23574
|
-
content: external_exports.string(),
|
|
23575
|
-
metadata: EventMetadata.optional()
|
|
23576
|
-
}).meta({ id: "Event" });
|
|
23577
|
-
var IngestEvent = Event.meta({ id: "IngestEvent" });
|
|
23578
|
-
var INGEST_BATCH_MAX = 100;
|
|
23579
|
-
var IngestBatch = external_exports.object({
|
|
23580
|
-
events: external_exports.array(IngestEvent).min(1).max(INGEST_BATCH_MAX),
|
|
23581
|
-
// Dedup policy for this batch. Id-dedup ALWAYS applies. 'content-hash'
|
|
23582
|
-
// additionally rejects any event whose contentHash the store has already
|
|
23583
|
-
// recorded — for re-runnable bulk ingest (worktree scan, transcript
|
|
23584
|
-
// backfill), where a re-run mints fresh event ids for identical content and
|
|
23585
|
-
// would otherwise accumulate duplicates. Live hook traffic must NOT set it:
|
|
23586
|
-
// two genuinely separate prompts can be byte-identical and both belong on
|
|
23587
|
-
// the timeline.
|
|
23588
|
-
dedupe: external_exports.literal("content-hash").optional()
|
|
23589
|
-
}).meta({ id: "IngestBatch" });
|
|
23590
|
-
|
|
23591
23879
|
// ../../packages/schema/src/zod/exception.ts
|
|
23592
23880
|
var ExceptionScope = external_exports.enum(["once", "temporary", "permanent"]);
|
|
23593
23881
|
var ExceptionConditions = external_exports.object({
|
|
@@ -23748,8 +24036,6 @@ var Policy = external_exports.object({
|
|
|
23748
24036
|
// test `prohibitedModels` passes and `reversibleRuleIds` fails.
|
|
23749
24037
|
provenance: PolicyProvenance.optional()
|
|
23750
24038
|
}).meta({ id: "Policy" });
|
|
23751
|
-
var KNOWN_BUILTIN_IDS = ["monitor", "warn", "redact", "vault", "block"];
|
|
23752
|
-
var BuiltinPolicyId = external_exports.enum(KNOWN_BUILTIN_IDS).meta({ id: "BuiltinPolicyId" });
|
|
23753
24039
|
var RedactFallback = BuiltinPolicyId.extract(["monitor", "warn", "block"]).meta({
|
|
23754
24040
|
id: "RedactFallback"
|
|
23755
24041
|
});
|
|
@@ -23956,10 +24242,15 @@ var ParsedPointer = external_exports.object({
|
|
|
23956
24242
|
});
|
|
23957
24243
|
var VaultEntry = external_exports.object({
|
|
23958
24244
|
pointerId: external_exports.string(),
|
|
23959
|
-
// The keyed HMAC of the raw
|
|
23960
|
-
// derived under.
|
|
23961
|
-
// independently of the vault encryption
|
|
24245
|
+
// The keyed HMAC of the EXACT raw bytes under `exception.key`, and the epoch it
|
|
24246
|
+
// was derived under. The vault's own dedupe key: a value and its invisibly
|
|
24247
|
+
// padded twin are two rows. It rotates independently of the vault encryption
|
|
24248
|
+
// key below. Never matched against an exception or grant.
|
|
23962
24249
|
valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
24250
|
+
// The same HMAC over the raw with invisible padding removed: the identity a
|
|
24251
|
+
// reveal-to-model grant and every exception match on. Shared by a value and
|
|
24252
|
+
// its padded twin.
|
|
24253
|
+
valueIdentityFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
23963
24254
|
fingerprintKeyVersion: external_exports.number().int().positive(),
|
|
23964
24255
|
// The vault-key epoch this row's ciphertext was sealed under.
|
|
23965
24256
|
keyVersion: external_exports.number().int().positive(),
|
|
@@ -24100,7 +24391,7 @@ var VaultConsent = external_exports.object({
|
|
|
24100
24391
|
});
|
|
24101
24392
|
|
|
24102
24393
|
// ../../packages/schema/src/zod/local.ts
|
|
24103
|
-
var WORKSPACE_SETTINGS_SPEC_VERSION =
|
|
24394
|
+
var WORKSPACE_SETTINGS_SPEC_VERSION = 9;
|
|
24104
24395
|
var RunMode = external_exports.enum(["standalone", "attached"]);
|
|
24105
24396
|
var ControlPlaneConnection = external_exports.object({
|
|
24106
24397
|
endpoint: external_exports.string().min(1),
|
|
@@ -24119,6 +24410,18 @@ var HistorySyncConsent = external_exports.object({
|
|
|
24119
24410
|
payloadVersion: external_exports.number().int().positive(),
|
|
24120
24411
|
endpoint: external_exports.string()
|
|
24121
24412
|
});
|
|
24413
|
+
var ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH = 512;
|
|
24414
|
+
var AttachmentScopeEntry = external_exports.object({
|
|
24415
|
+
kind: external_exports.enum(["repo", "account"]),
|
|
24416
|
+
identity: printable(ATTACHMENT_SCOPE_IDENTITY_MAX_LENGTH).min(1),
|
|
24417
|
+
label: printable(80).optional(),
|
|
24418
|
+
enrolledAt: external_exports.iso.datetime()
|
|
24419
|
+
});
|
|
24420
|
+
var AttachmentScope = external_exports.object({
|
|
24421
|
+
endpoint: external_exports.string().min(1),
|
|
24422
|
+
entries: external_exports.array(AttachmentScopeEntry)
|
|
24423
|
+
});
|
|
24424
|
+
var AttachmentScopeEnvelope = AttachmentScope.extend({ entries: external_exports.array(external_exports.unknown()) });
|
|
24122
24425
|
var WebChatCaptureConsent = external_exports.object({
|
|
24123
24426
|
acknowledgedAt: external_exports.iso.datetime(),
|
|
24124
24427
|
version: external_exports.number().int().positive()
|
|
@@ -24189,6 +24492,23 @@ var WorkspaceSettings = external_exports.object({
|
|
|
24189
24492
|
// both widenings. Absent until granted, and a grant for a different endpoint
|
|
24190
24493
|
// or an older payload no longer counts.
|
|
24191
24494
|
historySyncConsent: HistorySyncConsent.optional(),
|
|
24495
|
+
// The identities a SCOPED attachment forwards and the deployment they were
|
|
24496
|
+
// enrolled for (see AttachmentScope). Absent until something is enrolled.
|
|
24497
|
+
//
|
|
24498
|
+
// `z.unknown()`, NOT `AttachmentScope`, and the difference is this field's
|
|
24499
|
+
// whole failure mode. A settings.json that fails this schema reads as the
|
|
24500
|
+
// unonboarded defaults (readUserSettings in @akasecurity/persistence), and the
|
|
24501
|
+
// next save writes those defaults back over it. Typed, one entry with an
|
|
24502
|
+
// unknown `kind`, a control character or a bad timestamp would cost the
|
|
24503
|
+
// attachment, every consent and onboardedAt, permanently. Untyped, the value
|
|
24504
|
+
// is kept exactly as found and validated where it is used: parseAttachmentScope
|
|
24505
|
+
// drops a bad entry by itself, and on a scoped attachment resolveScope reads a
|
|
24506
|
+
// bad envelope as no entries, which keeps every event local.
|
|
24507
|
+
//
|
|
24508
|
+
// No default: absent must stay absent, so defaultWorkspaceSettings() and a
|
|
24509
|
+
// fresh settings.json do not change. No `.meta({ id })`, like every field
|
|
24510
|
+
// here. Not a ManagedSettingKey.
|
|
24511
|
+
attachmentScope: external_exports.unknown().optional(),
|
|
24192
24512
|
// What the browser extension may record from a web chat, and the grant that
|
|
24193
24513
|
// authorizes it. Absent until the user answers: recording something that was
|
|
24194
24514
|
// never recorded before is never an assumed grant on upgrade, so the whole
|
|
@@ -24401,10 +24721,18 @@ var SeveritySummaryItem = external_exports.object({
|
|
|
24401
24721
|
count: external_exports.number().int().nonnegative(),
|
|
24402
24722
|
// Resolution-aware breakdown (optional, additive). Populated once findings
|
|
24403
24723
|
// carry lifecycle state: `caught` = handled in-flight (enforced); `openAtRest`
|
|
24404
|
-
// = still open with no in-flight enforcement (needs remediation)
|
|
24405
|
-
//
|
|
24724
|
+
// = still open with no in-flight enforcement (needs remediation); `dismissed`
|
|
24725
|
+
// = closed by a human judgement rather than a fix — visible, but not counted as
|
|
24726
|
+
// needing remediation. The three are disjoint. Absent on the legacy count-only
|
|
24727
|
+
// response until the resolution feature lands.
|
|
24406
24728
|
caught: external_exports.number().int().nonnegative().optional(),
|
|
24407
|
-
openAtRest: external_exports.number().int().nonnegative().optional()
|
|
24729
|
+
openAtRest: external_exports.number().int().nonnegative().optional(),
|
|
24730
|
+
dismissed: external_exports.number().int().nonnegative().optional(),
|
|
24731
|
+
// The two halves of `caught`, for a reader that wants them apart: `handled` =
|
|
24732
|
+
// in-flight findings an enforcement action already contained; `resolved` =
|
|
24733
|
+
// at-rest findings closed out by fixing them. `handled + resolved === caught`.
|
|
24734
|
+
handled: external_exports.number().int().nonnegative().optional(),
|
|
24735
|
+
resolved: external_exports.number().int().nonnegative().optional()
|
|
24408
24736
|
}).meta({ id: "SeveritySummaryItem" });
|
|
24409
24737
|
var SeveritySummaryResponse = external_exports.object({
|
|
24410
24738
|
// Sum of bySeverity[].count.
|
|
@@ -24412,6 +24740,9 @@ var SeveritySummaryResponse = external_exports.object({
|
|
|
24412
24740
|
// Findings still open at rest (sum of bySeverity[].openAtRest). Optional and
|
|
24413
24741
|
// additive — absent on the legacy response until the resolution feature lands.
|
|
24414
24742
|
needsRemediation: external_exports.number().int().nonnegative().optional(),
|
|
24743
|
+
// Findings a user dismissed (sum of bySeverity[].dismissed). Excluded from
|
|
24744
|
+
// needsRemediation, and kept visible here so an accepted risk is not erased.
|
|
24745
|
+
dismissed: external_exports.number().int().nonnegative().optional(),
|
|
24415
24746
|
// All four severity levels are always present (count may be 0).
|
|
24416
24747
|
bySeverity: external_exports.array(SeveritySummaryItem)
|
|
24417
24748
|
}).meta({ id: "SeveritySummaryResponse" });
|
|
@@ -25066,7 +25397,15 @@ port.on("message", (job) => {
|
|
|
25066
25397
|
post({ kind: "probed", id: job.id, verdict, worstMs, corroboratedMs });
|
|
25067
25398
|
return;
|
|
25068
25399
|
}
|
|
25069
|
-
|
|
25400
|
+
if (job.eventKind !== void 0 && !EventKind.safeParse(job.eventKind).success) {
|
|
25401
|
+
post({
|
|
25402
|
+
kind: "failed",
|
|
25403
|
+
id: job.id,
|
|
25404
|
+
message: `unknown event kind ${JSON.stringify(job.eventKind)}`
|
|
25405
|
+
});
|
|
25406
|
+
return;
|
|
25407
|
+
}
|
|
25408
|
+
const context = job.filePath === void 0 && job.eventKind === void 0 ? void 0 : { filePath: job.filePath, eventKind: job.eventKind };
|
|
25070
25409
|
if (job.attribute) {
|
|
25071
25410
|
for (const [index, rule] of unverified.entries()) {
|
|
25072
25411
|
post({ kind: "progress", index });
|