@akasecurity/ai-tc-codex 0.9.10 → 0.9.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/package.json +4 -4
- package/scripts/apply-suppressions.js +627 -435
- package/scripts/backfill.js +727 -497
- package/scripts/filescan.js +726 -496
- package/scripts/firstrun.js +775 -519
- package/scripts/history-sync.js +611 -418
- package/scripts/intro.js +242 -92
- package/scripts/onboard.js +603 -410
- package/scripts/post-tool-use.js +711 -483
- package/scripts/pre-tool-use.js +715 -485
- package/scripts/query.js +780 -524
- package/scripts/reconcile.js +707 -485
- package/scripts/remediate.js +725 -495
- package/scripts/scan-worker.js +153 -58
- package/scripts/session-start.js +755 -535
- package/scripts/start-light.js +240 -90
- package/scripts/stop.js +264 -116
- package/scripts/sync.js +722 -494
- package/scripts/user-prompt-submit.js +719 -489
package/scripts/session-start.js
CHANGED
|
@@ -492,10 +492,7 @@ var require_ignore = __commonJS({
|
|
|
492
492
|
});
|
|
493
493
|
|
|
494
494
|
// src/hooks/session-start.ts
|
|
495
|
-
import { readFileSync as
|
|
496
|
-
|
|
497
|
-
// ../../packages/plugin-runtime/src/attached/egress-wire.ts
|
|
498
|
-
import { createHash as createHash4 } from "crypto";
|
|
495
|
+
import { readFileSync as readFileSync22 } from "fs";
|
|
499
496
|
|
|
500
497
|
// ../../packages/persistence/src/attached-derived.ts
|
|
501
498
|
import { rmSync } from "fs";
|
|
@@ -20748,13 +20745,11 @@ var FindingGroup = external_exports.object({
|
|
|
20748
20745
|
latestDetectedAt: external_exports.iso.datetime(),
|
|
20749
20746
|
instances: external_exports.array(FindingInstance),
|
|
20750
20747
|
// Derived from instances' statuses with open-dominates precedence (see
|
|
20751
|
-
//
|
|
20748
|
+
// foldGroupStatus). Undefined only when no instance carries a status.
|
|
20752
20749
|
status: FindingStatus.optional(),
|
|
20753
|
-
// The distinct people across the WHOLE group, not just the
|
|
20754
|
-
//
|
|
20755
|
-
//
|
|
20756
|
-
// instance carries a user, or when the store supplied whole-group folds
|
|
20757
|
-
// without one.
|
|
20750
|
+
// The distinct people across the WHOLE group, not just the instances
|
|
20751
|
+
// carried here. Undefined when no instance carries a user, or when the
|
|
20752
|
+
// store supplied whole-group folds without one.
|
|
20758
20753
|
users: external_exports.array(FindingUser).optional()
|
|
20759
20754
|
}).meta({ id: "FindingGroup" });
|
|
20760
20755
|
var FindingStats = external_exports.object({
|
|
@@ -20783,21 +20778,31 @@ var FindingFacets = external_exports.object({
|
|
|
20783
20778
|
// counted under no value.
|
|
20784
20779
|
status: external_exports.array(FindingFacetItem),
|
|
20785
20780
|
// Host tool (attributes.tool_name). Present only on the instance-level
|
|
20786
|
-
// reads, which can filter by it; the
|
|
20781
|
+
// reads, which can filter by it; the type-level read omits the dimension
|
|
20787
20782
|
// because a group spans tools.
|
|
20788
20783
|
tool: external_exports.array(FindingFacetItem).optional()
|
|
20789
20784
|
}).meta({ id: "FindingFacets" });
|
|
20790
|
-
var
|
|
20791
|
-
|
|
20785
|
+
var FindingTypeSummary = FindingGroup.omit({ instances: true, match: true }).meta({
|
|
20786
|
+
id: "FindingTypeSummary"
|
|
20787
|
+
});
|
|
20788
|
+
var DEFAULT_FINDING_TYPES_LIMIT = 50;
|
|
20789
|
+
var MAX_FINDING_TYPES_LIMIT = 100;
|
|
20790
|
+
var ListFindingTypesQuery = external_exports.object({
|
|
20792
20791
|
// NOTE: severity filters by Severity (critical/high/medium/low), not by
|
|
20793
|
-
// FindingAction.
|
|
20792
|
+
// FindingAction. It narrows TYPES: a type's severity is the one its newest
|
|
20793
|
+
// firing version carries, and this list pages types.
|
|
20794
|
+
//
|
|
20795
|
+
// That is NOT a claim the findings of a type share it. A rule can hold several
|
|
20796
|
+
// definition versions at different severities, so a type kept by this filter
|
|
20797
|
+
// can hold findings that individually do not match — see totals.findings on
|
|
20798
|
+
// ListFindingTypesResponse, which counts them all.
|
|
20794
20799
|
severity: external_exports.array(Severity).optional(),
|
|
20795
20800
|
subtype: external_exports.array(external_exports.string()).optional(),
|
|
20796
20801
|
provider: external_exports.array(FindingProvider).optional(),
|
|
20797
20802
|
action: external_exports.array(FindingAction).optional(),
|
|
20798
|
-
// Matches a
|
|
20799
|
-
// individual
|
|
20800
|
-
//
|
|
20803
|
+
// Matches a type's DERIVED status (see FindingGroup.status), not its
|
|
20804
|
+
// individual findings' — so a filtered row's status always reads one of the
|
|
20805
|
+
// requested values.
|
|
20801
20806
|
status: external_exports.array(FindingStatus).optional(),
|
|
20802
20807
|
q: external_exports.string().optional(),
|
|
20803
20808
|
// Scope to findings whose event carries this session id (the Activity page's
|
|
@@ -20807,23 +20812,37 @@ var ListGroupedFindingsQuery = external_exports.object({
|
|
|
20807
20812
|
// from a time-scoped page (Activity's range) can carry that scope. Absent
|
|
20808
20813
|
// means all time — this list has no default window.
|
|
20809
20814
|
from: external_exports.iso.datetime().optional(),
|
|
20810
|
-
// A
|
|
20811
|
-
//
|
|
20812
|
-
//
|
|
20813
|
-
//
|
|
20814
|
-
//
|
|
20815
|
+
// A RULE id that must appear in the page even when the cursor has already
|
|
20816
|
+
// advanced past its sort position. This is what keeps the selected type
|
|
20817
|
+
// visible in the list once it paginates: the target is appended out of sort
|
|
20818
|
+
// order rather than scanned forward for. Never affects totals, facets or the
|
|
20819
|
+
// cursor. Unlike the grouped read this replaces, it names a rule only — an
|
|
20820
|
+
// instance id is resolved by `findingInstance`, which is a primary-key seek
|
|
20821
|
+
// and so is not bounded by what any page happens to hold.
|
|
20815
20822
|
includeId: external_exports.string().optional(),
|
|
20816
|
-
|
|
20817
|
-
limit: external_exports.coerce.number().int().min(1).max(100).optional(),
|
|
20823
|
+
limit: external_exports.coerce.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
|
|
20818
20824
|
cursor: external_exports.string().optional()
|
|
20819
20825
|
});
|
|
20820
|
-
var
|
|
20826
|
+
var ListFindingTypesResponse = external_exports.object({
|
|
20821
20827
|
totals: external_exports.object({
|
|
20828
|
+
// Findings belonging to the matching TYPES — not findings that each match
|
|
20829
|
+
// the filters. The filters here select types, so a type that survives
|
|
20830
|
+
// contributes its whole instanceCount.
|
|
20831
|
+
//
|
|
20832
|
+
// `status` is the one exception, narrowed per finding via
|
|
20833
|
+
// countInstancesByStatus. `severity`, `provider` and `action` are not, so
|
|
20834
|
+
// this can exceed what the instance read reports for the same filters: a
|
|
20835
|
+
// rule whose severity moved between versions is kept on its newest and
|
|
20836
|
+
// still counts its older findings. Narrowing the other three needs
|
|
20837
|
+
// per-dimension counts the aggregate does not carry today.
|
|
20822
20838
|
findings: external_exports.number().int().nonnegative(),
|
|
20823
|
-
|
|
20839
|
+
// Counts TYPES, which is the unit this read pages. The instance read's
|
|
20840
|
+
// own totals count findings; the two deliberately answer different
|
|
20841
|
+
// questions and are never summed.
|
|
20842
|
+
types: external_exports.number().int().nonnegative()
|
|
20824
20843
|
}),
|
|
20825
20844
|
facets: FindingFacets,
|
|
20826
|
-
items: external_exports.array(
|
|
20845
|
+
items: external_exports.array(FindingTypeSummary),
|
|
20827
20846
|
nextCursor: external_exports.string().nullable(),
|
|
20828
20847
|
// Present only on session-scoped queries (`sessionId` set): per ruleId, how
|
|
20829
20848
|
// many times that rule fired in the session's persisted transcript. Findings
|
|
@@ -20831,7 +20850,7 @@ var ListGroupedFindingsResponse = external_exports.object({
|
|
|
20831
20850
|
// every firing, so the two numbers legitimately differ — this map lets a
|
|
20832
20851
|
// session-scoped view show both.
|
|
20833
20852
|
sessionFirings: external_exports.record(external_exports.string(), external_exports.number().int().nonnegative()).optional()
|
|
20834
|
-
}).meta({ id: "
|
|
20853
|
+
}).meta({ id: "ListFindingTypesResponse" });
|
|
20835
20854
|
var ApplyFindingActionRequest = external_exports.object({
|
|
20836
20855
|
// 'quarantined' is system-assigned (see FindingAction) — clients may not set
|
|
20837
20856
|
// it, so it is excluded from the request contract. The mapping helper
|
|
@@ -20861,12 +20880,13 @@ var DEFAULT_FLAT_FINDINGS_LIMIT = 50;
|
|
|
20861
20880
|
var MAX_FLAT_FINDINGS_LIMIT = 200;
|
|
20862
20881
|
var ListFindingInstancesQuery = external_exports.object({
|
|
20863
20882
|
severity: external_exports.array(Severity).optional(),
|
|
20864
|
-
// Rule ids, the same vocabulary the
|
|
20883
|
+
// Rule ids, the same vocabulary the types list's `subtype` carries. Pinning
|
|
20884
|
+
// ONE of them is how the master/detail view scopes its right-hand panel.
|
|
20865
20885
|
subtype: external_exports.array(external_exports.string()).optional(),
|
|
20866
20886
|
provider: external_exports.array(FindingProvider).optional(),
|
|
20867
20887
|
action: external_exports.array(FindingAction).optional(),
|
|
20868
20888
|
// Matches each instance's OWN derived status (deriveFindingStatus), unlike
|
|
20869
|
-
// the
|
|
20889
|
+
// the types query's type-level fold.
|
|
20870
20890
|
status: external_exports.array(FindingStatus).optional(),
|
|
20871
20891
|
// Exact host-tool names (attributes.tool_name, e.g. 'Bash'). A real filter,
|
|
20872
20892
|
// where the free-text `q` can only match the rendered "via Bash" label.
|
|
@@ -20883,37 +20903,47 @@ var ListFindingInstancesQuery = external_exports.object({
|
|
|
20883
20903
|
});
|
|
20884
20904
|
var ListFindingInstancesResponse = external_exports.object({
|
|
20885
20905
|
// Instances matching the filters across the whole scope, not just this
|
|
20886
|
-
// page — cursor-independent, like the
|
|
20906
|
+
// page — cursor-independent, like the types list's totals.
|
|
20887
20907
|
totals: external_exports.object({ findings: external_exports.number().int().nonnegative() }),
|
|
20888
|
-
// Counts in INSTANCES here, where the
|
|
20908
|
+
// Counts in INSTANCES here, where the types response counts types. Each
|
|
20889
20909
|
// dimension still excludes its own filter.
|
|
20890
20910
|
facets: FindingFacets,
|
|
20891
20911
|
items: external_exports.array(FindingInstanceDetail),
|
|
20892
20912
|
nextCursor: external_exports.string().nullable()
|
|
20893
20913
|
}).meta({ id: "ListFindingInstancesResponse" });
|
|
20894
|
-
var
|
|
20895
|
-
//
|
|
20896
|
-
//
|
|
20897
|
-
|
|
20898
|
-
|
|
20899
|
-
|
|
20900
|
-
|
|
20901
|
-
// Folded from the instances' derived statuses with the same
|
|
20902
|
-
// open-dominates precedence a group uses.
|
|
20903
|
-
status: FindingStatus.optional(),
|
|
20904
|
-
// Distinct rules seen at this location, capped — the row shows them as
|
|
20905
|
-
// chips, and the count is what conveys scale.
|
|
20906
|
-
ruleIds: external_exports.array(external_exports.string())
|
|
20907
|
-
}).meta({ id: "FindingLocationFile" });
|
|
20908
|
-
var FindingLocationRepo = external_exports.object({
|
|
20914
|
+
var FindingLocationSummary = external_exports.object({
|
|
20915
|
+
// Opaque, stable, minted from the pair by encodeLocationId. It exists
|
|
20916
|
+
// because a location's identity is two values and a URL param carries one:
|
|
20917
|
+
// `?loc=` names a location the way `?rule=` names a type. Only ever compared
|
|
20918
|
+
// for EQUALITY — the page's selection check, this read's `includeId`, the
|
|
20919
|
+
// client's page dedupe — never decoded, and never a sort key.
|
|
20920
|
+
id: external_exports.string(),
|
|
20909
20921
|
/** Empty when the instances carried no repo attribute. */
|
|
20910
20922
|
repo: external_exports.string(),
|
|
20923
|
+
// Empty when the instances carried no file path (a prompt, or a tool call
|
|
20924
|
+
// with no file attribution). Both halves empty is a real location — usually
|
|
20925
|
+
// the largest one in a store — and is selectable like any other.
|
|
20926
|
+
file: external_exports.string(),
|
|
20911
20927
|
instanceCount: external_exports.number().int().nonnegative(),
|
|
20928
|
+
// The WORST severity present, not the first row's. It is this list's primary
|
|
20929
|
+
// sort key, so it is also what explains why a row is where it is, and it is
|
|
20930
|
+
// how a reader decides what to open without opening everything.
|
|
20912
20931
|
maxSeverity: Severity,
|
|
20913
20932
|
latestDetectedAt: external_exports.iso.datetime(),
|
|
20933
|
+
// Folded from the instances' derived statuses with the same open-dominates
|
|
20934
|
+
// precedence a group uses, so it answers "is anything left to do here" and
|
|
20935
|
+
// not much more: a location holding 1 open among 40 resolved reads like one
|
|
20936
|
+
// holding 40 open. That loss is accepted — the panel beside this list
|
|
20937
|
+
// carries each finding's own status, and instanceCount sits next to the
|
|
20938
|
+
// badge.
|
|
20914
20939
|
status: FindingStatus.optional(),
|
|
20915
|
-
|
|
20916
|
-
|
|
20940
|
+
// Every distinct rule seen at this location, UNCAPPED — so the length is a
|
|
20941
|
+
// tally rather than a sample and a row can say how many there are. Bounded
|
|
20942
|
+
// by the ruleset, not by the store. The view bounds what it DISPLAYS.
|
|
20943
|
+
ruleIds: external_exports.array(external_exports.string())
|
|
20944
|
+
}).meta({ id: "FindingLocationSummary" });
|
|
20945
|
+
var DEFAULT_FINDING_LOCATIONS_LIMIT = 50;
|
|
20946
|
+
var MAX_FINDING_LOCATIONS_LIMIT = 100;
|
|
20917
20947
|
var ListFindingLocationsQuery = external_exports.object({
|
|
20918
20948
|
severity: external_exports.array(Severity).optional(),
|
|
20919
20949
|
subtype: external_exports.array(external_exports.string()).optional(),
|
|
@@ -20926,18 +20956,42 @@ var ListFindingLocationsQuery = external_exports.object({
|
|
|
20926
20956
|
q: external_exports.string().optional(),
|
|
20927
20957
|
sessionId: external_exports.string().optional(),
|
|
20928
20958
|
from: external_exports.iso.datetime().optional(),
|
|
20929
|
-
|
|
20959
|
+
// A LOCATION id (see FindingLocationSummary.id) that must appear in the page
|
|
20960
|
+
// even when the cursor has already advanced past its sort position — the
|
|
20961
|
+
// counterpart of ListFindingTypesQuery.includeId, and needed far more often
|
|
20962
|
+
// here. Selecting a row pushes the URL, which re-renders the server and resets
|
|
20963
|
+
// the client's page cache to page 0; with distinct (repo, file) pairs running
|
|
20964
|
+
// into the thousands, a selection sitting off page 0 is the ordinary case
|
|
20965
|
+
// rather than a deep-link corner. Never affects totals, facets or the cursor.
|
|
20966
|
+
includeId: external_exports.string().optional(),
|
|
20967
|
+
limit: external_exports.coerce.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
|
|
20968
|
+
cursor: external_exports.string().optional()
|
|
20930
20969
|
});
|
|
20931
20970
|
var ListFindingLocationsResponse = external_exports.object({
|
|
20932
20971
|
totals: external_exports.object({
|
|
20972
|
+
// Findings matching the filters across the whole scope. Unlike the types
|
|
20973
|
+
// read's same-named field this needs no caveat: the filters here narrow
|
|
20974
|
+
// per finding, so this is the sum of every row's instanceCount.
|
|
20933
20975
|
findings: external_exports.number().int().nonnegative(),
|
|
20934
|
-
|
|
20935
|
-
|
|
20976
|
+
// Counts LOCATIONS, the unit this read pages — the number the paginator
|
|
20977
|
+
// states. The facets beside it count FINDINGS (see below); a surface
|
|
20978
|
+
// showing both says which is which.
|
|
20979
|
+
locations: external_exports.number().int().nonnegative()
|
|
20936
20980
|
}),
|
|
20937
|
-
|
|
20938
|
-
|
|
20939
|
-
|
|
20940
|
-
|
|
20981
|
+
// Counts in FINDINGS, where the types response counts types, each dimension
|
|
20982
|
+
// still excluding its own filter. Deliberately not locations: counting those
|
|
20983
|
+
// needs a set of location keys per dimension per value — memory tracking the
|
|
20984
|
+
// store times the vocabulary, in a read whose scan promises flat memory —
|
|
20985
|
+
// and the cheap per-location version is not an approximation but WRONG. A
|
|
20986
|
+
// location holding {claudecode, block} and {codex, warn} would survive
|
|
20987
|
+
// provider=claudecode AND action=warn, under which no single finding
|
|
20988
|
+
// matches, so the facet would contradict the instanceCount this whole view
|
|
20989
|
+
// rests on. Findings also keep the toolbar in the same unit as the page
|
|
20990
|
+
// tally and the panel it sits above.
|
|
20991
|
+
facets: FindingFacets,
|
|
20992
|
+
/** Sorted by max severity, then most recent, then (repo, file). */
|
|
20993
|
+
items: external_exports.array(FindingLocationSummary),
|
|
20994
|
+
nextCursor: external_exports.string().nullable()
|
|
20941
20995
|
}).meta({ id: "ListFindingLocationsResponse" });
|
|
20942
20996
|
|
|
20943
20997
|
// ../../packages/schema/src/zod/meta.ts
|
|
@@ -22220,6 +22274,14 @@ var ControlPlaneErrorBody = external_exports.object({
|
|
|
22220
22274
|
message: external_exports.string().optional()
|
|
22221
22275
|
}).optional()
|
|
22222
22276
|
});
|
|
22277
|
+
var RemoteFailureKind = external_exports.enum([
|
|
22278
|
+
"unauthorized",
|
|
22279
|
+
"forbidden",
|
|
22280
|
+
"route-absent",
|
|
22281
|
+
"invalid-request",
|
|
22282
|
+
"rejected",
|
|
22283
|
+
"unreachable"
|
|
22284
|
+
]);
|
|
22223
22285
|
var AttachDeviceRequest = external_exports.object({
|
|
22224
22286
|
// This machine's own continuity id, so re-attaching ROTATES the credential
|
|
22225
22287
|
// on one machine record instead of producing a second one. Client-minted
|
|
@@ -22913,139 +22975,62 @@ function deriveFindingStatus(row) {
|
|
|
22913
22975
|
if (row.latestResolutionStatus === "dismissed") return "dismissed";
|
|
22914
22976
|
return "open";
|
|
22915
22977
|
}
|
|
22916
|
-
function distinctUsers(instances) {
|
|
22917
|
-
const seen = /* @__PURE__ */ new Set();
|
|
22918
|
-
const users = [];
|
|
22919
|
-
for (const i of instances) {
|
|
22920
|
-
if (i.user === void 0 || seen.has(i.user.id)) continue;
|
|
22921
|
-
seen.add(i.user.id);
|
|
22922
|
-
users.push(i.user);
|
|
22923
|
-
}
|
|
22924
|
-
return users;
|
|
22925
|
-
}
|
|
22926
22978
|
function sortUsers(users) {
|
|
22927
22979
|
return [...users].sort((a, b) => a.name.localeCompare(b.name) || a.id.localeCompare(b.id));
|
|
22928
22980
|
}
|
|
22929
|
-
function
|
|
22930
|
-
const overrides = opts.overrides;
|
|
22981
|
+
function buildFindingTypes(aggregates, opts = {}) {
|
|
22931
22982
|
const packNames = opts.packNames;
|
|
22932
|
-
const
|
|
22933
|
-
const
|
|
22934
|
-
|
|
22935
|
-
const
|
|
22936
|
-
|
|
22937
|
-
else byRuleId.set(row.ruleId, [row]);
|
|
22938
|
-
}
|
|
22939
|
-
const groups = [];
|
|
22940
|
-
for (const [ruleId, ruleRows] of byRuleId) {
|
|
22941
|
-
const instances = ruleRows.map((r) => {
|
|
22942
|
-
const effectiveDbAction = overrides?.get(r.id) ?? r.actionTaken;
|
|
22943
|
-
return {
|
|
22944
|
-
id: r.id,
|
|
22945
|
-
provider: toApiProvider(r.sourceTool),
|
|
22946
|
-
repo: r.repo,
|
|
22947
|
-
file: r.file,
|
|
22948
|
-
...r.toolName === void 0 ? {} : { toolName: r.toolName },
|
|
22949
|
-
...r.eventId === void 0 ? {} : { eventId: r.eventId },
|
|
22950
|
-
...r.sessionId === void 0 ? {} : { sessionId: r.sessionId },
|
|
22951
|
-
...r.user === void 0 ? {} : { user: r.user },
|
|
22952
|
-
action: toApiAction(effectiveDbAction),
|
|
22953
|
-
detectedAt: r.occurredAt,
|
|
22954
|
-
confidence: r.confidence,
|
|
22955
|
-
status: r.status
|
|
22956
|
-
};
|
|
22957
|
-
});
|
|
22958
|
-
const agg = aggregates?.get(ruleId);
|
|
22959
|
-
const users = agg ? sortUsers(agg.users ?? []) : distinctUsers(instances);
|
|
22960
|
-
const latestDetectedAt = agg?.latestDetectedAt ?? ruleRows.reduce(
|
|
22961
|
-
(max, r) => r.occurredAt > max ? r.occurredAt : max,
|
|
22962
|
-
ruleRows[0]?.occurredAt ?? (/* @__PURE__ */ new Date(0)).toISOString()
|
|
22963
|
-
);
|
|
22964
|
-
const seenProviders = /* @__PURE__ */ new Set();
|
|
22965
|
-
const providers = (agg ? [...new Set(agg.sourceTools.map(toApiProvider))].sort() : instances.map((i) => i.provider)).filter((p) => {
|
|
22966
|
-
if (seenProviders.has(p)) return false;
|
|
22967
|
-
seenProviders.add(p);
|
|
22968
|
-
return true;
|
|
22969
|
-
});
|
|
22970
|
-
const actionSet = new Set(
|
|
22971
|
-
agg ? agg.actionsTaken.map(toApiAction) : instances.map((i) => i.action)
|
|
22972
|
-
);
|
|
22983
|
+
const types = [];
|
|
22984
|
+
for (const [ruleId, agg] of aggregates) {
|
|
22985
|
+
const users = sortUsers(agg.users ?? []);
|
|
22986
|
+
const providers = [...new Set(agg.sourceTools.map(toApiProvider))].sort();
|
|
22987
|
+
const actionSet = new Set(agg.actionsTaken.map(toApiAction));
|
|
22973
22988
|
const aggregateAction = actionSet.size === 1 ? [...actionSet][0] ?? null : null;
|
|
22974
|
-
const
|
|
22975
|
-
const
|
|
22976
|
-
id: ruleId,
|
|
22977
|
-
name: packNames?.get(ruleId) ?? null
|
|
22978
|
-
};
|
|
22979
|
-
const apiCategory = toApiCategory(ruleRows[0]?.category ?? "custom");
|
|
22980
|
-
const policy = { id: `category:${apiCategory}`, name: apiCategory };
|
|
22981
|
-
const match = {
|
|
22982
|
-
maskedValue: ruleRows[0]?.maskedMatch ?? "",
|
|
22983
|
-
contextPrefix: ""
|
|
22984
|
-
// empty (pending privacy review)
|
|
22985
|
-
};
|
|
22986
|
-
const status = foldGroupStatus(
|
|
22987
|
-
agg ? agg.statusInputs.map(deriveFindingStatus) : instances.map((i) => i.status)
|
|
22988
|
-
);
|
|
22989
|
-
const group = {
|
|
22989
|
+
const apiCategory = toApiCategory(agg.category ?? "custom");
|
|
22990
|
+
const type = {
|
|
22990
22991
|
id: ruleId,
|
|
22991
22992
|
category: apiCategory,
|
|
22992
22993
|
subtype: ruleId,
|
|
22993
22994
|
// human label comes with pack metadata later
|
|
22994
|
-
severity,
|
|
22995
|
-
|
|
22996
|
-
|
|
22997
|
-
|
|
22998
|
-
instanceCount: agg?.instanceCount ?? instances.length,
|
|
22995
|
+
severity: agg.severity ?? "low",
|
|
22996
|
+
detection: { id: ruleId, name: packNames?.get(ruleId) ?? null },
|
|
22997
|
+
policy: { id: `category:${apiCategory}`, name: apiCategory },
|
|
22998
|
+
instanceCount: agg.instanceCount,
|
|
22999
22999
|
providers,
|
|
23000
23000
|
aggregateAction,
|
|
23001
|
-
latestDetectedAt,
|
|
23002
|
-
|
|
23003
|
-
status,
|
|
23001
|
+
latestDetectedAt: agg.latestDetectedAt,
|
|
23002
|
+
status: foldGroupStatus(agg.statusInputs.map(deriveFindingStatus)),
|
|
23004
23003
|
...users.length > 0 ? { users } : {}
|
|
23005
23004
|
};
|
|
23006
|
-
|
|
23007
|
-
|
|
23008
|
-
|
|
23009
|
-
haystackCache.set(group, buildHaystack(group, agg.searchText));
|
|
23010
|
-
}
|
|
23005
|
+
actionsCache.set(type, [...actionSet]);
|
|
23006
|
+
if (agg.searchText !== void 0) {
|
|
23007
|
+
haystackCache.set(type, buildHaystack(type, agg.searchText));
|
|
23011
23008
|
}
|
|
23012
|
-
|
|
23009
|
+
types.push(type);
|
|
23013
23010
|
}
|
|
23014
|
-
return
|
|
23011
|
+
return types;
|
|
23015
23012
|
}
|
|
23016
23013
|
var haystackCache = /* @__PURE__ */ new WeakMap();
|
|
23017
|
-
function buildHaystack(
|
|
23014
|
+
function buildHaystack(t, extra) {
|
|
23018
23015
|
return [
|
|
23019
|
-
|
|
23020
|
-
|
|
23021
|
-
|
|
23022
|
-
|
|
23023
|
-
|
|
23024
|
-
...g.instances.map((i) => i.repo),
|
|
23025
|
-
...g.instances.map((i) => i.file),
|
|
23026
|
-
...g.instances.map((i) => i.toolName ? `via ${i.toolName}` : ""),
|
|
23027
|
-
...g.instances.map((i) => i.id),
|
|
23028
|
-
// The people: the whole group's list when the store folded one, plus the
|
|
23029
|
-
// preview's own — the two overlap, and a haystack does not mind.
|
|
23030
|
-
...(g.users ?? []).map((u) => u.name),
|
|
23031
|
-
...g.instances.map((i) => i.user?.name ?? ""),
|
|
23016
|
+
t.subtype,
|
|
23017
|
+
t.category,
|
|
23018
|
+
t.policy.name,
|
|
23019
|
+
t.id,
|
|
23020
|
+
...(t.users ?? []).map((u) => u.name),
|
|
23032
23021
|
...extra === void 0 ? [] : [extra]
|
|
23033
23022
|
].join(" ").toLowerCase();
|
|
23034
23023
|
}
|
|
23035
|
-
function
|
|
23036
|
-
const cached2 = haystackCache.get(
|
|
23024
|
+
function typeHaystack(t) {
|
|
23025
|
+
const cached2 = haystackCache.get(t);
|
|
23037
23026
|
if (cached2 !== void 0) return cached2;
|
|
23038
|
-
const haystack = buildHaystack(
|
|
23039
|
-
haystackCache.set(
|
|
23027
|
+
const haystack = buildHaystack(t);
|
|
23028
|
+
haystackCache.set(t, haystack);
|
|
23040
23029
|
return haystack;
|
|
23041
23030
|
}
|
|
23042
23031
|
var actionsCache = /* @__PURE__ */ new WeakMap();
|
|
23043
|
-
function
|
|
23044
|
-
|
|
23045
|
-
if (cached2 !== void 0) return cached2;
|
|
23046
|
-
const actions = [...new Set(g.instances.map((i) => i.action))];
|
|
23047
|
-
actionsCache.set(g, actions);
|
|
23048
|
-
return actions;
|
|
23032
|
+
function typeActions(t) {
|
|
23033
|
+
return actionsCache.get(t) ?? [];
|
|
23049
23034
|
}
|
|
23050
23035
|
function countInstancesByStatus(statusInputs, statuses) {
|
|
23051
23036
|
const statusSet = new Set(statuses);
|
|
@@ -23056,8 +23041,8 @@ function countInstancesByStatus(statusInputs, statuses) {
|
|
|
23056
23041
|
}
|
|
23057
23042
|
return sum;
|
|
23058
23043
|
}
|
|
23059
|
-
function applyFindingFilters(
|
|
23060
|
-
let filtered =
|
|
23044
|
+
function applyFindingFilters(types, opts) {
|
|
23045
|
+
let filtered = types;
|
|
23061
23046
|
if (opts.severity && opts.severity.length > 0) {
|
|
23062
23047
|
const sevSet = new Set(opts.severity);
|
|
23063
23048
|
filtered = filtered.filter((g) => sevSet.has(g.severity));
|
|
@@ -23068,7 +23053,7 @@ function applyFindingFilters(groups, opts) {
|
|
|
23068
23053
|
}
|
|
23069
23054
|
if (opts.actions && opts.actions.length > 0) {
|
|
23070
23055
|
const actionSet = new Set(opts.actions);
|
|
23071
|
-
filtered = filtered.filter((
|
|
23056
|
+
filtered = filtered.filter((t) => typeActions(t).some((a) => actionSet.has(a)));
|
|
23072
23057
|
}
|
|
23073
23058
|
if (opts.subtype && opts.subtype.length > 0) {
|
|
23074
23059
|
const subtypeSet = new Set(opts.subtype);
|
|
@@ -23080,7 +23065,7 @@ function applyFindingFilters(groups, opts) {
|
|
|
23080
23065
|
}
|
|
23081
23066
|
if (opts.q) {
|
|
23082
23067
|
const q = opts.q.toLowerCase();
|
|
23083
|
-
filtered = filtered.filter((
|
|
23068
|
+
filtered = filtered.filter((t) => typeHaystack(t).includes(q));
|
|
23084
23069
|
}
|
|
23085
23070
|
return filtered;
|
|
23086
23071
|
}
|
|
@@ -23095,11 +23080,11 @@ function compareFindingGroupOrder(a, b) {
|
|
|
23095
23080
|
if (recencyDiff !== 0) return recencyDiff;
|
|
23096
23081
|
return a.id.localeCompare(b.id);
|
|
23097
23082
|
}
|
|
23098
|
-
function
|
|
23099
|
-
return [...
|
|
23083
|
+
function sortFindingTypes(types) {
|
|
23084
|
+
return [...types].sort(compareFindingGroupOrder);
|
|
23100
23085
|
}
|
|
23101
|
-
function computeFindingFacets(
|
|
23102
|
-
const forSeverity = applyFindingFilters(
|
|
23086
|
+
function computeFindingFacets(allTypes, opts) {
|
|
23087
|
+
const forSeverity = applyFindingFilters(allTypes, {
|
|
23103
23088
|
providers: opts.providers,
|
|
23104
23089
|
actions: opts.actions,
|
|
23105
23090
|
statuses: opts.statuses,
|
|
@@ -23110,7 +23095,7 @@ function computeFindingFacets(allGroups, opts) {
|
|
|
23110
23095
|
for (const g of forSeverity) {
|
|
23111
23096
|
severityMap.set(g.severity, (severityMap.get(g.severity) ?? 0) + 1);
|
|
23112
23097
|
}
|
|
23113
|
-
const forProvider = applyFindingFilters(
|
|
23098
|
+
const forProvider = applyFindingFilters(allTypes, {
|
|
23114
23099
|
actions: opts.actions,
|
|
23115
23100
|
statuses: opts.statuses,
|
|
23116
23101
|
q: opts.q,
|
|
@@ -23121,7 +23106,7 @@ function computeFindingFacets(allGroups, opts) {
|
|
|
23121
23106
|
for (const g of forProvider) {
|
|
23122
23107
|
for (const p of g.providers) providerMap.set(p, (providerMap.get(p) ?? 0) + 1);
|
|
23123
23108
|
}
|
|
23124
|
-
const forAction = applyFindingFilters(
|
|
23109
|
+
const forAction = applyFindingFilters(allTypes, {
|
|
23125
23110
|
providers: opts.providers,
|
|
23126
23111
|
statuses: opts.statuses,
|
|
23127
23112
|
q: opts.q,
|
|
@@ -23130,9 +23115,9 @@ function computeFindingFacets(allGroups, opts) {
|
|
|
23130
23115
|
});
|
|
23131
23116
|
const actionMap = /* @__PURE__ */ new Map();
|
|
23132
23117
|
for (const g of forAction) {
|
|
23133
|
-
for (const a of
|
|
23118
|
+
for (const a of typeActions(g)) actionMap.set(a, (actionMap.get(a) ?? 0) + 1);
|
|
23134
23119
|
}
|
|
23135
|
-
const forSubtype = applyFindingFilters(
|
|
23120
|
+
const forSubtype = applyFindingFilters(allTypes, {
|
|
23136
23121
|
providers: opts.providers,
|
|
23137
23122
|
actions: opts.actions,
|
|
23138
23123
|
statuses: opts.statuses,
|
|
@@ -23141,7 +23126,7 @@ function computeFindingFacets(allGroups, opts) {
|
|
|
23141
23126
|
});
|
|
23142
23127
|
const subtypeMap = /* @__PURE__ */ new Map();
|
|
23143
23128
|
for (const g of forSubtype) subtypeMap.set(g.subtype, (subtypeMap.get(g.subtype) ?? 0) + 1);
|
|
23144
|
-
const forStatus = applyFindingFilters(
|
|
23129
|
+
const forStatus = applyFindingFilters(allTypes, {
|
|
23145
23130
|
providers: opts.providers,
|
|
23146
23131
|
actions: opts.actions,
|
|
23147
23132
|
q: opts.q,
|
|
@@ -23189,10 +23174,20 @@ function matchesDimension(row, opts, dimension) {
|
|
|
23189
23174
|
return !opts.statuses?.length || row.status !== void 0 && opts.statuses.includes(row.status);
|
|
23190
23175
|
case "tools":
|
|
23191
23176
|
return !opts.tools?.length || row.toolName !== void 0 && opts.tools.includes(row.toolName);
|
|
23177
|
+
// An EMPTY value is a real filter here, not an absent one. The location
|
|
23178
|
+
// list buckets a finding whose event recorded no repo — or no file — under
|
|
23179
|
+
// the empty string, and selecting that bucket has to narrow the panel to
|
|
23180
|
+
// exactly it. Only `undefined` means "no filter"; a caller that wants every
|
|
23181
|
+
// row omits the key, which every call site already does.
|
|
23182
|
+
//
|
|
23183
|
+
// Reading '' as unset is what this replaced, and it failed in the one place
|
|
23184
|
+
// it mattered: the no-repo/no-file bucket is often the largest in a real
|
|
23185
|
+
// store, and its panel dropped both predicates and returned the WHOLE scope
|
|
23186
|
+
// — a row reading 3 findings beside a panel listing every finding there is.
|
|
23192
23187
|
case "repo":
|
|
23193
|
-
return opts.repo === void 0 ||
|
|
23188
|
+
return opts.repo === void 0 || row.repo === opts.repo;
|
|
23194
23189
|
case "file":
|
|
23195
|
-
return opts.file === void 0 ||
|
|
23190
|
+
return opts.file === void 0 || row.file === opts.file;
|
|
23196
23191
|
case "q":
|
|
23197
23192
|
return !opts.q || rowHaystack(row).includes(opts.q.toLowerCase());
|
|
23198
23193
|
}
|
|
@@ -23306,6 +23301,23 @@ function addToLocation(acc, row) {
|
|
|
23306
23301
|
acc.statuses.push(row.status);
|
|
23307
23302
|
acc.ruleIds.add(row.ruleId);
|
|
23308
23303
|
}
|
|
23304
|
+
function compareLocationOrder(a, b) {
|
|
23305
|
+
const rankA = SEVERITY_ORDER2[a.maxSeverity] ?? -1;
|
|
23306
|
+
const rankB = SEVERITY_ORDER2[b.maxSeverity] ?? -1;
|
|
23307
|
+
if (rankA !== rankB) return rankA - rankB;
|
|
23308
|
+
if (a.latestDetectedAt !== b.latestDetectedAt) {
|
|
23309
|
+
return a.latestDetectedAt < b.latestDetectedAt ? 1 : -1;
|
|
23310
|
+
}
|
|
23311
|
+
if (a.repo !== b.repo) return a.repo < b.repo ? -1 : 1;
|
|
23312
|
+
if (a.file !== b.file) return a.file < b.file ? -1 : 1;
|
|
23313
|
+
return 0;
|
|
23314
|
+
}
|
|
23315
|
+
function encodeLocationId(repo, file2) {
|
|
23316
|
+
return `${encodePart(repo)}/${encodePart(file2)}`;
|
|
23317
|
+
}
|
|
23318
|
+
function encodePart(value) {
|
|
23319
|
+
return encodeURIComponent(value.replace(/[\uD800-\uDFFF]/gu, "\uFFFD"));
|
|
23320
|
+
}
|
|
23309
23321
|
|
|
23310
23322
|
// ../../packages/schema/src/zod/installed-pack.ts
|
|
23311
23323
|
var InstalledPack = external_exports.object({
|
|
@@ -23751,7 +23763,7 @@ var VaultConsent = external_exports.object({
|
|
|
23751
23763
|
// ../../packages/schema/src/zod/local.ts
|
|
23752
23764
|
var WORKSPACE_SETTINGS_SPEC_VERSION = 7;
|
|
23753
23765
|
var MODEL_JUDGE_PAYLOAD_VERSION = 1;
|
|
23754
|
-
var HISTORY_SYNC_PAYLOAD_VERSION =
|
|
23766
|
+
var HISTORY_SYNC_PAYLOAD_VERSION = 3;
|
|
23755
23767
|
var RunMode = external_exports.enum(["standalone", "attached"]);
|
|
23756
23768
|
var ControlPlaneConnection = external_exports.object({
|
|
23757
23769
|
endpoint: external_exports.string().min(1),
|
|
@@ -23817,11 +23829,11 @@ var WorkspaceSettings = external_exports.object({
|
|
|
23817
23829
|
// covers the current payload and must be re-granted.
|
|
23818
23830
|
modelJudgeConsent: ModelJudgeConsent.optional(),
|
|
23819
23831
|
// Records that the user consented to the DEFERRED send — the outbox — along
|
|
23820
|
-
// with the payload shape and the endpoint they agreed to. Since payload
|
|
23821
|
-
// that covers
|
|
23822
|
-
// carry prompt/reply text in `content
|
|
23823
|
-
// Absent until granted, and a grant for a different endpoint
|
|
23824
|
-
// payload no longer counts.
|
|
23832
|
+
// with the payload shape and the endpoint they agreed to. Since payload v3
|
|
23833
|
+
// that covers the pre-attach backlog AND undelivered captures alike, and both
|
|
23834
|
+
// carry prompt/reply/tool-output text in `content`; the key name predates
|
|
23835
|
+
// both widenings. Absent until granted, and a grant for a different endpoint
|
|
23836
|
+
// or an older payload no longer counts.
|
|
23825
23837
|
historySyncConsent: HistorySyncConsent.optional()
|
|
23826
23838
|
});
|
|
23827
23839
|
function defaultWorkspaceSettings() {
|
|
@@ -23952,6 +23964,9 @@ var ManagedSettingKey = external_exports.enum([
|
|
|
23952
23964
|
"dataSharesInPlace",
|
|
23953
23965
|
"redactFallback"
|
|
23954
23966
|
]).meta({ id: "ManagedSettingKey" });
|
|
23967
|
+
function isManagedSettingKey(value) {
|
|
23968
|
+
return ManagedSettingKey.safeParse(value).success;
|
|
23969
|
+
}
|
|
23955
23970
|
var ManagedSettingsValues = external_exports.object({
|
|
23956
23971
|
runMode: external_exports.enum(["standalone", "attached"]).optional(),
|
|
23957
23972
|
controlPlane: external_exports.object({
|
|
@@ -23976,7 +23991,27 @@ var ManagedSettings = external_exports.object({
|
|
|
23976
23991
|
// Which of those the user may not change. A key here with no matching value
|
|
23977
23992
|
// freezes whatever the user last chose; a value with no lock is a DEFAULT
|
|
23978
23993
|
// the user may still override. The two are separable on purpose.
|
|
23979
|
-
|
|
23994
|
+
//
|
|
23995
|
+
// Parsed as NAMES rather than as the enum, and split below: a name this
|
|
23996
|
+
// build does not know is dropped from the locked set and reported, never a
|
|
23997
|
+
// reason to refuse the file. The same shape reaches an older build whenever
|
|
23998
|
+
// an administrator locks a key a newer build added, and refusing it there
|
|
23999
|
+
// ran that build entirely unmanaged — every pin and lock gone — on exactly
|
|
24000
|
+
// the fleets most likely to carry a version skew. A name outside the enum
|
|
24001
|
+
// is still never HONOURED: the lockable set stays explicit above.
|
|
24002
|
+
lockedFields: external_exports.array(external_exports.string()).default([])
|
|
24003
|
+
}).transform(({ lockedFields, ...rest }) => {
|
|
24004
|
+
const known = [];
|
|
24005
|
+
const unknown2 = [];
|
|
24006
|
+
for (const name of lockedFields) {
|
|
24007
|
+
if (isManagedSettingKey(name)) known.push(name);
|
|
24008
|
+
else unknown2.push(name);
|
|
24009
|
+
}
|
|
24010
|
+
return {
|
|
24011
|
+
...rest,
|
|
24012
|
+
lockedFields: known,
|
|
24013
|
+
...unknown2.length > 0 ? { unknownLockedFields: unknown2 } : {}
|
|
24014
|
+
};
|
|
23980
24015
|
}).meta({ id: "ManagedSettings" });
|
|
23981
24016
|
|
|
23982
24017
|
// ../../packages/schema/src/zod/project-files.ts
|
|
@@ -24100,7 +24135,11 @@ var FindingsTimeseriesPoint = external_exports.object({
|
|
|
24100
24135
|
timestamp: external_exports.iso.date(),
|
|
24101
24136
|
critical: external_exports.number().int().nonnegative(),
|
|
24102
24137
|
high: external_exports.number().int().nonnegative(),
|
|
24103
|
-
medium: external_exports.number().int().nonnegative()
|
|
24138
|
+
medium: external_exports.number().int().nonnegative(),
|
|
24139
|
+
// Optional and additive, so a producer written against the earlier
|
|
24140
|
+
// three-series contract keeps validating. A consumer plotting it resolves the
|
|
24141
|
+
// absent case itself — the chart point requires a number.
|
|
24142
|
+
low: external_exports.number().int().nonnegative().optional()
|
|
24104
24143
|
}).meta({ id: "FindingsTimeseriesPoint" });
|
|
24105
24144
|
var FindingsTimeseriesResponse = external_exports.object({
|
|
24106
24145
|
range: TimeRange,
|
|
@@ -24126,6 +24165,10 @@ var ResolvedFeedItem = external_exports.object({
|
|
|
24126
24165
|
findingKey: external_exports.string(),
|
|
24127
24166
|
ruleId: external_exports.string(),
|
|
24128
24167
|
severity: Severity,
|
|
24168
|
+
// Repository slug, and the file path RELATIVE to it. The pair is what
|
|
24169
|
+
// identifies the file: a bare path matches the same name in every repo.
|
|
24170
|
+
// Optional and additive; empty when the event carried no repo.
|
|
24171
|
+
repo: external_exports.string().optional(),
|
|
24129
24172
|
path: external_exports.string(),
|
|
24130
24173
|
// ISO-8601 datetime (matches FindingInstance.detectedAt / the rest of the
|
|
24131
24174
|
// findings domain). The reader `.toISOString()`s the DB epoch-ms values.
|
|
@@ -25673,7 +25716,8 @@ var SqliteActivityRepository = class {
|
|
|
25673
25716
|
SELECT 1 FROM audit_events d
|
|
25674
25717
|
WHERE d.root_session_id = audit_events.id
|
|
25675
25718
|
AND (d.content LIKE ? ESCAPE '\\'
|
|
25676
|
-
OR json_extract(d.attributes, '$.detail')
|
|
25719
|
+
OR coalesce(json_extract(d.attributes, '$.detail'),
|
|
25720
|
+
json_extract(d.attributes, '$.target')) LIKE ? ESCAPE '\\')))`
|
|
25677
25721
|
);
|
|
25678
25722
|
params.push(pattern, pattern, pattern, pattern, pattern, pattern);
|
|
25679
25723
|
}
|
|
@@ -27011,23 +27055,6 @@ var LATEST_RESOLUTION_BY_KEY_SQL = `(
|
|
|
27011
27055
|
)`;
|
|
27012
27056
|
|
|
27013
27057
|
// ../../packages/persistence/src/repositories/findings.ts
|
|
27014
|
-
var PREVIEW_INSTANCES_PER_GROUP = 200;
|
|
27015
|
-
var DEFAULT_LOCATIONS_LIMIT = 100;
|
|
27016
|
-
var LOCATION_RULE_IDS_CAP = 20;
|
|
27017
|
-
function compareLocationOrder(a, b) {
|
|
27018
|
-
return compareFindingGroupOrder(
|
|
27019
|
-
{
|
|
27020
|
-
severity: a.maxSeverity,
|
|
27021
|
-
latestDetectedAt: a.latestDetectedAt,
|
|
27022
|
-
id: ""
|
|
27023
|
-
},
|
|
27024
|
-
{
|
|
27025
|
-
severity: b.maxSeverity,
|
|
27026
|
-
latestDetectedAt: b.latestDetectedAt,
|
|
27027
|
-
id: ""
|
|
27028
|
-
}
|
|
27029
|
-
);
|
|
27030
|
-
}
|
|
27031
27058
|
var CONCAT_SEP = ",";
|
|
27032
27059
|
var TUPLE_SEP = "|";
|
|
27033
27060
|
function splitConcat(value) {
|
|
@@ -27079,13 +27106,48 @@ function decodeGroupCursor(cursor) {
|
|
|
27079
27106
|
return null;
|
|
27080
27107
|
}
|
|
27081
27108
|
function firstAfter(sorted, cursor) {
|
|
27082
|
-
const index = sorted.findIndex((
|
|
27109
|
+
const index = sorted.findIndex((t) => compareFindingGroupOrder(t, cursor) > 0);
|
|
27083
27110
|
return index === -1 ? sorted.length : index;
|
|
27084
27111
|
}
|
|
27085
27112
|
function findDeepLinked(sorted, page, id) {
|
|
27086
|
-
if (page.some((
|
|
27087
|
-
return sorted.find((
|
|
27113
|
+
if (page.some((t) => t.id === id)) return void 0;
|
|
27114
|
+
return sorted.find((t) => t.id === id);
|
|
27088
27115
|
}
|
|
27116
|
+
function encodeLocationCursor(location) {
|
|
27117
|
+
const payload = {
|
|
27118
|
+
sev: location.maxSeverity,
|
|
27119
|
+
t: location.latestDetectedAt,
|
|
27120
|
+
r: location.repo,
|
|
27121
|
+
f: location.file
|
|
27122
|
+
};
|
|
27123
|
+
return Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
27124
|
+
}
|
|
27125
|
+
function decodeLocationCursor(cursor) {
|
|
27126
|
+
const parsed2 = parseJsonObject(Buffer.from(cursor, "base64url").toString("utf8"));
|
|
27127
|
+
if (parsed2 !== void 0 && typeof parsed2.sev === "string" && typeof parsed2.t === "string" && typeof parsed2.r === "string" && typeof parsed2.f === "string") {
|
|
27128
|
+
return { maxSeverity: parsed2.sev, latestDetectedAt: parsed2.t, repo: parsed2.r, file: parsed2.f };
|
|
27129
|
+
}
|
|
27130
|
+
return null;
|
|
27131
|
+
}
|
|
27132
|
+
function firstLocationAfter(sorted, cursor) {
|
|
27133
|
+
const index = sorted.findIndex((l) => compareLocationOrder(l, cursor) > 0);
|
|
27134
|
+
return index === -1 ? sorted.length : index;
|
|
27135
|
+
}
|
|
27136
|
+
function findDeepLinkedLocation(sorted, page, id) {
|
|
27137
|
+
if (page.some((l) => l.id === id)) return void 0;
|
|
27138
|
+
return sorted.find((l) => l.id === id);
|
|
27139
|
+
}
|
|
27140
|
+
var FINDING_ROW_COLUMNS_SQL = `f.id AS id, d.rule_id AS rule_id, d.category AS category,
|
|
27141
|
+
d.severity AS severity, f.masked_match AS masked_match,
|
|
27142
|
+
f.action_taken AS action_taken, f.confidence AS confidence,
|
|
27143
|
+
e.started_at AS occurred_at,
|
|
27144
|
+
e.source_tool AS source_tool,
|
|
27145
|
+
e.repo AS repo,
|
|
27146
|
+
e.file_path AS file,
|
|
27147
|
+
e.tool_name AS tool_name,
|
|
27148
|
+
f.audit_event_id AS event_id, e.root_session_id AS session_id,
|
|
27149
|
+
e.event_type AS kind, f.finding_key AS finding_key,
|
|
27150
|
+
${latestResolutionStatusSql("f")} AS latest_status`;
|
|
27089
27151
|
var DAY_MS3 = 864e5;
|
|
27090
27152
|
var SqliteFindingsRepository = class {
|
|
27091
27153
|
constructor(db) {
|
|
@@ -27206,30 +27268,26 @@ var SqliteFindingsRepository = class {
|
|
|
27206
27268
|
);
|
|
27207
27269
|
}
|
|
27208
27270
|
/**
|
|
27209
|
-
*
|
|
27210
|
-
*
|
|
27211
|
-
*
|
|
27212
|
-
*
|
|
27213
|
-
*
|
|
27214
|
-
*
|
|
27215
|
-
*
|
|
27216
|
-
*
|
|
27217
|
-
*
|
|
27218
|
-
*
|
|
27219
|
-
*
|
|
27220
|
-
*
|
|
27271
|
+
* Finding TYPES for the dashboard — one row per rule, scoped to the four
|
|
27272
|
+
* capture kinds (audit_events also holds structural/reconciler/scan rows this
|
|
27273
|
+
* list must never surface), with per-filter-excluded facets, the requested
|
|
27274
|
+
* filters applied, and sorted by severity then recency. Filtering and faceting
|
|
27275
|
+
* run in JS via the shared @akasecurity/schema helpers. `totals` reflect the
|
|
27276
|
+
* full filtered set; `items` is the requested page (default 50), keyset-paged.
|
|
27277
|
+
* Under a `status` filter, `totals.findings` counts only findings whose
|
|
27278
|
+
* derived status was requested.
|
|
27279
|
+
*
|
|
27280
|
+
* ONE read, which materializes no findings: a single aggregate per rule_id,
|
|
27281
|
+
* folding EVERY finding into the numbers a type row and the filters need
|
|
27282
|
+
* (count, severity, category, providers, actions, statuses, latest, search
|
|
27283
|
+
* text). The findings OF a type come from listFindingInstances scoped to
|
|
27284
|
+
* `subtype`, so neither list bounds the other and no per-type cap exists.
|
|
27221
27285
|
*
|
|
27222
|
-
* Two reads, neither of which materializes a row per finding:
|
|
27223
|
-
* 1. one aggregate row per rule_id, folding EVERY instance into the numbers
|
|
27224
|
-
* the group and the filters need (count, providers, actions, statuses,
|
|
27225
|
-
* latest, search text);
|
|
27226
|
-
* 2. each group's newest PREVIEW_INSTANCES_PER_GROUP instances, which
|
|
27227
|
-
* populate `instances` for the table's expanded rows.
|
|
27228
27286
|
* The aggregates carry raw DB values and are translated by the same
|
|
27229
|
-
* @akasecurity/schema mappers
|
|
27230
|
-
* rule is ever restated in SQL.
|
|
27287
|
+
* @akasecurity/schema mappers every other path uses, so no enum mapping or
|
|
27288
|
+
* status rule is ever restated in SQL.
|
|
27231
27289
|
*/
|
|
27232
|
-
|
|
27290
|
+
listFindingTypes(query) {
|
|
27233
27291
|
const sessionPredicate = query.sessionId ? ` AND e.root_session_id = :sessionId` : "";
|
|
27234
27292
|
const fromMs = query.from === void 0 ? void 0 : isoToEpochMillis(query.from);
|
|
27235
27293
|
const fromPredicate = fromMs === void 0 ? "" : ` AND e.started_at >= :fromMs`;
|
|
@@ -27242,12 +27300,7 @@ var SqliteFindingsRepository = class {
|
|
|
27242
27300
|
predicate,
|
|
27243
27301
|
params: sessionParams
|
|
27244
27302
|
});
|
|
27245
|
-
const
|
|
27246
|
-
sessionId: query.sessionId,
|
|
27247
|
-
from: query.from
|
|
27248
|
-
});
|
|
27249
|
-
const groupable = rows.map(toFlatFindingRow);
|
|
27250
|
-
const allGroups = buildFindingGroups(groupable, { aggregates });
|
|
27303
|
+
const allTypes = buildFindingTypes(aggregates);
|
|
27251
27304
|
const filterOpts = {
|
|
27252
27305
|
severity: query.severity,
|
|
27253
27306
|
providers: query.provider,
|
|
@@ -27256,30 +27309,25 @@ var SqliteFindingsRepository = class {
|
|
|
27256
27309
|
subtype: query.subtype,
|
|
27257
27310
|
q: query.q
|
|
27258
27311
|
};
|
|
27259
|
-
const facets = computeFindingFacets(
|
|
27260
|
-
const sorted =
|
|
27312
|
+
const facets = computeFindingFacets(allTypes, filterOpts);
|
|
27313
|
+
const sorted = sortFindingTypes(applyFindingFilters(allTypes, filterOpts));
|
|
27261
27314
|
const statusFilter = query.status ?? [];
|
|
27262
27315
|
const totals = {
|
|
27263
|
-
findings: sorted.reduce((acc,
|
|
27264
|
-
if (statusFilter.length === 0) return acc +
|
|
27265
|
-
const agg = aggregates.get(
|
|
27266
|
-
return acc + (agg ? countInstancesByStatus(agg.statusInputs, statusFilter) ??
|
|
27316
|
+
findings: sorted.reduce((acc, t) => {
|
|
27317
|
+
if (statusFilter.length === 0) return acc + t.instanceCount;
|
|
27318
|
+
const agg = aggregates.get(t.id);
|
|
27319
|
+
return acc + (agg ? countInstancesByStatus(agg.statusInputs, statusFilter) ?? t.instanceCount : t.instanceCount);
|
|
27267
27320
|
}, 0),
|
|
27268
|
-
|
|
27321
|
+
types: sorted.length
|
|
27269
27322
|
};
|
|
27270
|
-
const limit = query.limit ??
|
|
27323
|
+
const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
|
|
27271
27324
|
const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
|
|
27272
27325
|
const start = cursor === null ? 0 : firstAfter(sorted, cursor);
|
|
27273
27326
|
const page = sorted.slice(start, start + limit);
|
|
27274
27327
|
const lastOnPage = page.at(-1);
|
|
27275
27328
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
|
|
27276
27329
|
const deepLinked = query.includeId === void 0 || query.includeId === "" ? void 0 : findDeepLinked(sorted, page, query.includeId);
|
|
27277
|
-
const
|
|
27278
|
-
const narrow = (g) => statusSet ? {
|
|
27279
|
-
...g,
|
|
27280
|
-
instances: g.instances.filter((i) => i.status !== void 0 && statusSet.has(i.status))
|
|
27281
|
-
} : g;
|
|
27282
|
-
const items = [...page, ...deepLinked ? [deepLinked] : []].map(narrow);
|
|
27330
|
+
const items = [...page, ...deepLinked ? [deepLinked] : []];
|
|
27283
27331
|
return Promise.resolve({
|
|
27284
27332
|
totals,
|
|
27285
27333
|
facets,
|
|
@@ -27290,7 +27338,7 @@ var SqliteFindingsRepository = class {
|
|
|
27290
27338
|
}
|
|
27291
27339
|
/**
|
|
27292
27340
|
* One row per rule_id, folding EVERY instance of the group into the values
|
|
27293
|
-
*
|
|
27341
|
+
* buildFindingTypes cannot recover from an aggregate. Bounded by the number of
|
|
27294
27342
|
* distinct rule_ids (the installed packs' rules), not by the store's size.
|
|
27295
27343
|
*
|
|
27296
27344
|
* A single scan, folded in two levels: the inner SELECT groups by
|
|
@@ -27384,13 +27432,25 @@ var SqliteFindingsRepository = class {
|
|
|
27384
27432
|
});
|
|
27385
27433
|
}
|
|
27386
27434
|
/**
|
|
27387
|
-
* The same findings folded by
|
|
27435
|
+
* The same findings folded by WHERE they live — one row per (repo, file) pair.
|
|
27388
27436
|
*
|
|
27389
27437
|
* The grouping keys come from the capturing event's attributes, which is what
|
|
27390
|
-
* the local store relates a finding to
|
|
27391
|
-
*
|
|
27392
|
-
* empty-string bucket, which
|
|
27393
|
-
*
|
|
27438
|
+
* the local store relates a finding to; there is no finding↔asset row to group
|
|
27439
|
+
* by instead. A repo or file the event did not record folds into the
|
|
27440
|
+
* empty-string bucket, which is a real location like any other: it is listed,
|
|
27441
|
+
* it is selectable, and its `?loc=` token is as good as any other row's.
|
|
27442
|
+
*
|
|
27443
|
+
* ONE flat list rather than repos nesting files. A rollup can only be paged by
|
|
27444
|
+
* repo, which leaves the file list inside it unbounded — the shape the by-type
|
|
27445
|
+
* list was rebuilt to remove — and two-level pagination inside an
|
|
27446
|
+
* expand/collapse table is what pushed that view to master/detail in the first
|
|
27447
|
+
* place.
|
|
27448
|
+
*
|
|
27449
|
+
* Every filter narrows the FINDINGS and the locations fall out of what
|
|
27450
|
+
* survives, so each row's `instanceCount` is exactly what listFindingInstances
|
|
27451
|
+
* reports for the same filters scoped to that pair. The view depends on it:
|
|
27452
|
+
* one toolbar sits over both panels precisely because a location owns none of
|
|
27453
|
+
* its fields.
|
|
27394
27454
|
*/
|
|
27395
27455
|
listFindingLocations(query) {
|
|
27396
27456
|
const opts = {
|
|
@@ -27402,13 +27462,16 @@ var SqliteFindingsRepository = class {
|
|
|
27402
27462
|
tools: query.tool,
|
|
27403
27463
|
q: query.q
|
|
27404
27464
|
};
|
|
27405
|
-
const limit = query.limit ??
|
|
27465
|
+
const limit = query.limit ?? DEFAULT_FINDING_LOCATIONS_LIMIT;
|
|
27466
|
+
const cursor = query.cursor === void 0 ? null : decodeLocationCursor(query.cursor);
|
|
27406
27467
|
const byRepo = /* @__PURE__ */ new Map();
|
|
27468
|
+
const accumulator = createInstanceFacetAccumulator(opts);
|
|
27407
27469
|
let total = 0;
|
|
27408
27470
|
for (const row of this.scanFindingRows({
|
|
27409
27471
|
sessionId: query.sessionId,
|
|
27410
27472
|
from: query.from
|
|
27411
27473
|
})) {
|
|
27474
|
+
accumulator.add(row);
|
|
27412
27475
|
if (!matchesInstanceFilters(row, opts)) continue;
|
|
27413
27476
|
total += 1;
|
|
27414
27477
|
let files = byRepo.get(row.repo);
|
|
@@ -27423,103 +27486,35 @@ var SqliteFindingsRepository = class {
|
|
|
27423
27486
|
}
|
|
27424
27487
|
addToLocation(acc, row);
|
|
27425
27488
|
}
|
|
27426
|
-
|
|
27427
|
-
const
|
|
27428
|
-
|
|
27429
|
-
|
|
27430
|
-
|
|
27431
|
-
|
|
27432
|
-
|
|
27433
|
-
|
|
27434
|
-
|
|
27435
|
-
|
|
27436
|
-
|
|
27437
|
-
|
|
27438
|
-
|
|
27439
|
-
|
|
27440
|
-
|
|
27441
|
-
|
|
27442
|
-
|
|
27443
|
-
|
|
27444
|
-
|
|
27445
|
-
|
|
27446
|
-
|
|
27447
|
-
|
|
27448
|
-
);
|
|
27449
|
-
const statuses = fileRows.map((f) => f.status);
|
|
27450
|
-
const folded = foldGroupStatus(statuses);
|
|
27451
|
-
return {
|
|
27452
|
-
repo,
|
|
27453
|
-
instanceCount: rollup.instanceCount,
|
|
27454
|
-
maxSeverity: rollup.maxSeverity,
|
|
27455
|
-
latestDetectedAt: rollup.latestDetectedAt,
|
|
27456
|
-
...folded === void 0 ? {} : { status: folded },
|
|
27457
|
-
files: fileRows
|
|
27458
|
-
};
|
|
27459
|
-
});
|
|
27460
|
-
repos.sort(compareLocationOrder);
|
|
27489
|
+
const sorted = [];
|
|
27490
|
+
for (const [repo, files] of byRepo) {
|
|
27491
|
+
for (const [file2, acc] of files) {
|
|
27492
|
+
const status = foldGroupStatus(acc.statuses);
|
|
27493
|
+
sorted.push({
|
|
27494
|
+
id: encodeLocationId(repo, file2),
|
|
27495
|
+
repo,
|
|
27496
|
+
file: file2,
|
|
27497
|
+
instanceCount: acc.instanceCount,
|
|
27498
|
+
maxSeverity: acc.maxSeverity,
|
|
27499
|
+
latestDetectedAt: acc.latestDetectedAt,
|
|
27500
|
+
...status === void 0 ? {} : { status },
|
|
27501
|
+
ruleIds: [...acc.ruleIds]
|
|
27502
|
+
});
|
|
27503
|
+
}
|
|
27504
|
+
}
|
|
27505
|
+
sorted.sort(compareLocationOrder);
|
|
27506
|
+
const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
|
|
27507
|
+
const page = sorted.slice(start, start + limit);
|
|
27508
|
+
const lastOnPage = page.at(-1);
|
|
27509
|
+
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
|
|
27510
|
+
const deepLinked = query.includeId === void 0 || query.includeId === "" ? void 0 : findDeepLinkedLocation(sorted, page, query.includeId);
|
|
27461
27511
|
return Promise.resolve({
|
|
27462
|
-
totals: { findings: total,
|
|
27463
|
-
|
|
27464
|
-
|
|
27512
|
+
totals: { findings: total, locations: sorted.length },
|
|
27513
|
+
facets: accumulator.facets(),
|
|
27514
|
+
items: [...page, ...deepLinked ? [deepLinked] : []],
|
|
27515
|
+
nextCursor
|
|
27465
27516
|
});
|
|
27466
27517
|
}
|
|
27467
|
-
/**
|
|
27468
|
-
* Each group's newest instances, for the table's expanded rows.
|
|
27469
|
-
*
|
|
27470
|
-
* ONE index-ordered scan with early termination, and the shape is the point.
|
|
27471
|
-
* The natural spelling — `ROW_NUMBER() OVER (PARTITION BY rule_id ORDER BY
|
|
27472
|
-
* started_at DESC)` then `WHERE rn <= cap` — sorts EVERY finding in scope
|
|
27473
|
-
* through a temp B-tree to keep a bounded preview of each group, and then
|
|
27474
|
-
* sorts the survivors again for the page order. Both sorts grow with the
|
|
27475
|
-
* store while the answer does not.
|
|
27476
|
-
*
|
|
27477
|
-
* Instead the scan walks `audit_events` newest-first off `idx_audit_started_at`
|
|
27478
|
-
* (or the session or window index the scope names — see `findingScanSql`),
|
|
27479
|
-
* which is already the order the page wants, and keeps rows per rule until
|
|
27480
|
-
* each rule has as many as it can show. The aggregate the caller already holds
|
|
27481
|
-
* says how many that is: `min(instanceCount, PREVIEW_INSTANCES_PER_GROUP)`
|
|
27482
|
-
* per rule, summed, is the number of rows this scan has to find, and it stops
|
|
27483
|
-
* on the last one. That sum is bounded by `rules * PREVIEW_INSTANCES_PER_GROUP`
|
|
27484
|
-
* (8,000 at this repo's 40-rule bench corpus), not by a fixed row count — a
|
|
27485
|
-
* store with many firing rules widens it. The bound that DOES hold
|
|
27486
|
-
* unconditionally is the sorted form's floor: this scan visits at most as
|
|
27487
|
-
* many rows as `ROW_NUMBER() OVER (PARTITION BY rule_id …)` would have
|
|
27488
|
-
* sorted, and stops the moment every rule has its cap, where the sorted form
|
|
27489
|
-
* sorts the whole scope regardless. The true worst case — the rarest rule's
|
|
27490
|
-
* wanted instances sitting at the tail of the scope — is one pass over
|
|
27491
|
-
* everything in scope with a block sort of the id tie-break only, never a
|
|
27492
|
-
* sort of the scope, which is still that floor.
|
|
27493
|
-
*
|
|
27494
|
-
* A row whose rule the aggregate did not see is skipped: the two statements
|
|
27495
|
-
* run without a shared snapshot, so a capture landing between them can add a
|
|
27496
|
-
* rule here that has no counts there, and the counts are what the group is
|
|
27497
|
-
* built from.
|
|
27498
|
-
*/
|
|
27499
|
-
previewRows(aggregates, scope) {
|
|
27500
|
-
const wanted = /* @__PURE__ */ new Map();
|
|
27501
|
-
let remaining = 0;
|
|
27502
|
-
for (const [ruleId, agg] of aggregates) {
|
|
27503
|
-
const n = Math.min(agg.instanceCount, PREVIEW_INSTANCES_PER_GROUP);
|
|
27504
|
-
wanted.set(ruleId, n);
|
|
27505
|
-
remaining += n;
|
|
27506
|
-
}
|
|
27507
|
-
const rows = [];
|
|
27508
|
-
if (remaining === 0) return rows;
|
|
27509
|
-
const { sql, params } = this.findingScanSql(scope);
|
|
27510
|
-
const taken = /* @__PURE__ */ new Map();
|
|
27511
|
-
for (const r of iterateRows(this.db.prepare(sql), params)) {
|
|
27512
|
-
const want = wanted.get(r.rule_id);
|
|
27513
|
-
if (want === void 0) continue;
|
|
27514
|
-
const have = taken.get(r.rule_id) ?? 0;
|
|
27515
|
-
if (have >= want) continue;
|
|
27516
|
-
taken.set(r.rule_id, have + 1);
|
|
27517
|
-
rows.push(r);
|
|
27518
|
-
remaining -= 1;
|
|
27519
|
-
if (remaining === 0) break;
|
|
27520
|
-
}
|
|
27521
|
-
return rows;
|
|
27522
|
-
}
|
|
27523
27518
|
/**
|
|
27524
27519
|
* Every finding in scope as a FlatFindingRow, newest first, streamed.
|
|
27525
27520
|
*
|
|
@@ -27546,6 +27541,33 @@ var SqliteFindingsRepository = class {
|
|
|
27546
27541
|
yield toFlatFindingRow(r);
|
|
27547
27542
|
}
|
|
27548
27543
|
}
|
|
27544
|
+
/**
|
|
27545
|
+
* One finding by its own id, or null when no such row exists.
|
|
27546
|
+
*
|
|
27547
|
+
* A primary-key seek on `inspection_findings`, so its cost does not grow with
|
|
27548
|
+
* the store — and, unlike anything derived from a list page, it resolves a
|
|
27549
|
+
* finding of ANY age. That is what the Findings page's one-shot `?finding=`
|
|
27550
|
+
* deep link needs: the id it carries may name a finding thousands of rows
|
|
27551
|
+
* older than anything a first page holds.
|
|
27552
|
+
*
|
|
27553
|
+
* Deliberately UNFILTERED — no capture-kind, session or time predicate. It
|
|
27554
|
+
* RESOLVES an id; whether that row would survive the list's current filters is
|
|
27555
|
+
* a different question, and hiding the target because a filter excludes it is
|
|
27556
|
+
* worse than showing it.
|
|
27557
|
+
*
|
|
27558
|
+
* `groupId` on the result IS the rule id, so this one read answers both "which
|
|
27559
|
+
* type should the list select?" and "what does the drawer show?".
|
|
27560
|
+
*/
|
|
27561
|
+
findingInstance(id) {
|
|
27562
|
+
const row = this.db.prepare(
|
|
27563
|
+
`SELECT ${FINDING_ROW_COLUMNS_SQL}
|
|
27564
|
+
FROM inspection_findings f
|
|
27565
|
+
JOIN audit_events e ON e.id = f.audit_event_id
|
|
27566
|
+
JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
27567
|
+
WHERE f.id = ?`
|
|
27568
|
+
).get(id);
|
|
27569
|
+
return Promise.resolve(row === void 0 ? null : toInstanceDetail(toFlatFindingRow(row)));
|
|
27570
|
+
}
|
|
27549
27571
|
/**
|
|
27550
27572
|
* The one statement both instance-level scans run: every finding in scope,
|
|
27551
27573
|
* joined to its event and definition, newest first.
|
|
@@ -27579,17 +27601,7 @@ var SqliteFindingsRepository = class {
|
|
|
27579
27601
|
conditions.push("e.started_at >= ?");
|
|
27580
27602
|
params.push(isoToEpochMillis(scope.from));
|
|
27581
27603
|
}
|
|
27582
|
-
const sql = `SELECT
|
|
27583
|
-
d.severity AS severity, f.masked_match AS masked_match,
|
|
27584
|
-
f.action_taken AS action_taken, f.confidence AS confidence,
|
|
27585
|
-
e.started_at AS occurred_at,
|
|
27586
|
-
e.source_tool AS source_tool,
|
|
27587
|
-
e.repo AS repo,
|
|
27588
|
-
e.file_path AS file,
|
|
27589
|
-
e.tool_name AS tool_name,
|
|
27590
|
-
f.audit_event_id AS event_id, e.root_session_id AS session_id,
|
|
27591
|
-
e.event_type AS kind, f.finding_key AS finding_key,
|
|
27592
|
-
${latestResolutionStatusSql("f")} AS latest_status
|
|
27604
|
+
const sql = `SELECT ${FINDING_ROW_COLUMNS_SQL}
|
|
27593
27605
|
FROM audit_events e
|
|
27594
27606
|
CROSS JOIN inspection_findings f ON f.audit_event_id = e.id
|
|
27595
27607
|
CROSS JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
@@ -27603,6 +27615,26 @@ var SqliteFindingsRepository = class {
|
|
|
27603
27615
|
group_concat(DISTINCT 'via ' || e.tool_name) AS tool_names` : `, NULL AS repos, NULL AS files, NULL AS tool_names`;
|
|
27604
27616
|
const rows = this.db.prepare(
|
|
27605
27617
|
`SELECT rule_id,
|
|
27618
|
+
-- BARE columns beside max(latest_at), which is deliberate and
|
|
27619
|
+
-- is SQLite's documented behaviour: with a single min()/max()
|
|
27620
|
+
-- in an aggregate query, every bare column takes its value from
|
|
27621
|
+
-- the row that produced the extremum. So these are the severity
|
|
27622
|
+
-- and category of the definition whose finding is NEWEST, which
|
|
27623
|
+
-- is what the row-based build they replaced read off its first
|
|
27624
|
+
-- (newest-first) row.
|
|
27625
|
+
--
|
|
27626
|
+
-- min() is WRONG here and was the defect: inspection_definitions
|
|
27627
|
+
-- holds one row per rule VERSION (see its writer \u2014 a version bump
|
|
27628
|
+
-- mints a new row), so a rule whose severity moved between
|
|
27629
|
+
-- versions has several, and min() picks the ALPHABETICALLY
|
|
27630
|
+
-- smallest \u2014 'low' over 'medium', but 'critical' over 'high'.
|
|
27631
|
+
-- That is arbitrary in direction, and it feeds the badge, the
|
|
27632
|
+
-- filter, the facet counts and the primary sort key.
|
|
27633
|
+
--
|
|
27634
|
+
-- Adding a second min()/max() aggregate here would make these
|
|
27635
|
+
-- bare columns ambiguous again; keep max(latest_at) the only one.
|
|
27636
|
+
severity,
|
|
27637
|
+
category,
|
|
27606
27638
|
sum(tuple_count) AS instance_count,
|
|
27607
27639
|
max(latest_at) AS latest_at,
|
|
27608
27640
|
group_concat(source_tools) AS source_tools,
|
|
@@ -27613,6 +27645,14 @@ var SqliteFindingsRepository = class {
|
|
|
27613
27645
|
group_concat(tool_names) AS tool_names
|
|
27614
27646
|
FROM (
|
|
27615
27647
|
SELECT d.rule_id AS rule_id,
|
|
27648
|
+
-- Severity and category are columns of the DEFINITION, and
|
|
27649
|
+
-- a rule can have SEVERAL definitions (one per version), so
|
|
27650
|
+
-- these are grouped on below and resolved to the newest
|
|
27651
|
+
-- firing version by the outer query's bare-column select.
|
|
27652
|
+
-- They ride the aggregate because the type build has no rows
|
|
27653
|
+
-- to read them off \u2014 see buildFindingTypes.
|
|
27654
|
+
d.severity AS severity,
|
|
27655
|
+
d.category AS category,
|
|
27616
27656
|
e.event_type || '${TUPLE_SEP}' ||
|
|
27617
27657
|
(CASE WHEN f.finding_key IS NULL THEN '' ELSE 'k' END) || '${TUPLE_SEP}' ||
|
|
27618
27658
|
coalesce(latest.status, '') AS status_tuple,
|
|
@@ -27627,7 +27667,7 @@ var SqliteFindingsRepository = class {
|
|
|
27627
27667
|
LEFT JOIN ${LATEST_RESOLUTION_BY_KEY_SQL} latest
|
|
27628
27668
|
ON latest.finding_key = f.finding_key
|
|
27629
27669
|
${scope.predicate}
|
|
27630
|
-
GROUP BY d.rule_id, status_tuple
|
|
27670
|
+
GROUP BY d.rule_id, d.severity, d.category, status_tuple
|
|
27631
27671
|
)
|
|
27632
27672
|
GROUP BY rule_id`
|
|
27633
27673
|
).all(scope.params);
|
|
@@ -27636,6 +27676,8 @@ var SqliteFindingsRepository = class {
|
|
|
27636
27676
|
r.rule_id,
|
|
27637
27677
|
{
|
|
27638
27678
|
instanceCount: r.instance_count,
|
|
27679
|
+
severity: r.severity,
|
|
27680
|
+
category: r.category,
|
|
27639
27681
|
sourceTools: splitConcat(r.source_tools),
|
|
27640
27682
|
actionsTaken: splitConcat(r.actions_taken),
|
|
27641
27683
|
statusInputs: splitConcat(r.status_inputs).map((tuple2) => {
|
|
@@ -27652,7 +27694,7 @@ var SqliteFindingsRepository = class {
|
|
|
27652
27694
|
latestDetectedAt: epochMillisToIso(r.latest_at),
|
|
27653
27695
|
// Free text only — joined and substring-matched, so group_concat's
|
|
27654
27696
|
// commas need no unpicking (a repo/path containing one still matches).
|
|
27655
|
-
// Left undefined (not '') when unfetched, so
|
|
27697
|
+
// Left undefined (not '') when unfetched, so buildFindingTypes can
|
|
27656
27698
|
// tell "no q this request" from "a group with no repo/file at all"
|
|
27657
27699
|
// and skip priming a haystack nothing will read.
|
|
27658
27700
|
...withSearchText ? {
|
|
@@ -27804,6 +27846,12 @@ var SqliteHistorySyncRepository = class {
|
|
|
27804
27846
|
this.markOwedStmt = db.prepare(
|
|
27805
27847
|
`UPDATE audit_events SET outbox_owed = 1 WHERE id = :id AND synced_at IS NULL`
|
|
27806
27848
|
);
|
|
27849
|
+
this.markCaptureBacklogOwedStmt = db.prepare(
|
|
27850
|
+
`UPDATE audit_events SET outbox_owed = 1
|
|
27851
|
+
WHERE synced_at IS NULL
|
|
27852
|
+
AND event_type IN (${CAPTURE_TYPE_LIST})
|
|
27853
|
+
AND started_at < :before`
|
|
27854
|
+
);
|
|
27807
27855
|
this.stampStmt = db.prepare(
|
|
27808
27856
|
`UPDATE audit_events SET synced_at = :at, sync_claimed_at = NULL WHERE id = :id`
|
|
27809
27857
|
);
|
|
@@ -27852,7 +27900,9 @@ var SqliteHistorySyncRepository = class {
|
|
|
27852
27900
|
);
|
|
27853
27901
|
this.disownCapturesStmt = db.prepare(
|
|
27854
27902
|
`UPDATE audit_events SET outbox_owed = NULL
|
|
27855
|
-
WHERE outbox_owed IS NOT NULL
|
|
27903
|
+
WHERE outbox_owed IS NOT NULL
|
|
27904
|
+
AND event_type IN (${CAPTURE_TYPE_LIST})
|
|
27905
|
+
AND started_at < :attachedAt`
|
|
27856
27906
|
);
|
|
27857
27907
|
this.rearmStmt = db.prepare(
|
|
27858
27908
|
`UPDATE audit_events SET synced_at = NULL
|
|
@@ -27928,6 +27978,7 @@ var SqliteHistorySyncRepository = class {
|
|
|
27928
27978
|
freezeBoundaryStmt;
|
|
27929
27979
|
captureRowsStmt;
|
|
27930
27980
|
markOwedStmt;
|
|
27981
|
+
markCaptureBacklogOwedStmt;
|
|
27931
27982
|
captureSkipCountStmt;
|
|
27932
27983
|
disownCapturesStmt;
|
|
27933
27984
|
partitionStmt;
|
|
@@ -27991,6 +28042,23 @@ var SqliteHistorySyncRepository = class {
|
|
|
27991
28042
|
markCaptureOwed(id) {
|
|
27992
28043
|
this.markOwedStmt.run({ id });
|
|
27993
28044
|
}
|
|
28045
|
+
/**
|
|
28046
|
+
* Mark every capture already on disk as owed, as of `before`.
|
|
28047
|
+
*
|
|
28048
|
+
* The consent-time backfill, called once from `aka attach` when a human
|
|
28049
|
+
* grants existing-history consent — never from an ongoing drain pass, and
|
|
28050
|
+
* never inferred from a boundary that could later move. `before` is the
|
|
28051
|
+
* caller's own "now" at the moment consent was granted, so what this marks
|
|
28052
|
+
* is exactly the backlog the consent prompt already counted, not whatever a
|
|
28053
|
+
* later re-attach or key rotation might widen it to.
|
|
28054
|
+
*
|
|
28055
|
+
* Returns how many rows matched, for the caller to log or test against. Not a
|
|
28056
|
+
* count of NEWLY marked rows — a row still unsynced from an earlier call
|
|
28057
|
+
* matches again and is counted again, the same as `UPDATE`'s own `changes`.
|
|
28058
|
+
*/
|
|
28059
|
+
markCaptureBacklogOwed(before) {
|
|
28060
|
+
return Number(this.markCaptureBacklogOwedStmt.run({ before }).changes);
|
|
28061
|
+
}
|
|
27994
28062
|
/** Record delivery. Called only AFTER the far side has accepted the rows. */
|
|
27995
28063
|
markSynced(ids, atMs) {
|
|
27996
28064
|
this.stampAll(ids, atMs);
|
|
@@ -28107,15 +28175,42 @@ var SqliteHistorySyncRepository = class {
|
|
|
28107
28175
|
*
|
|
28108
28176
|
* Delivery is a fact about ONE recipient: rows sent to the deployment a
|
|
28109
28177
|
* machine has just left are undelivered as far as the new one is concerned.
|
|
28110
|
-
* All
|
|
28111
|
-
* attributed to the wrong deployment,
|
|
28178
|
+
* All four in one transaction, so a crash between them cannot leave stamps
|
|
28179
|
+
* attributed to the wrong deployment, a boundary that belongs to another, or
|
|
28180
|
+
* a disown with no re-mark to follow it.
|
|
28112
28181
|
*
|
|
28113
28182
|
* The boundary is written HERE and only here, which is what freezes it: a
|
|
28114
28183
|
* re-attach to the SAME deployment (a key rotation) leaves the fingerprint
|
|
28115
28184
|
* unchanged, so this never runs and the backlog does not widen back over rows
|
|
28116
28185
|
* the live path has since delivered.
|
|
28186
|
+
*
|
|
28187
|
+
* `backfillCapturesBefore` is the caller's OWN "now" at the instant a human
|
|
28188
|
+
* granted existing-history consent for the deployment this call is arming —
|
|
28189
|
+
* a DIFFERENT instant from `backlogBefore`: the re-mark boundary is the GRANT
|
|
28190
|
+
* instant, `backlogBefore` is the ATTACH instant, and the two can be far
|
|
28191
|
+
* apart. Passed only when that grant is valid, since this method has no way
|
|
28192
|
+
* to check consent itself and must not mark a row owed for a machine that
|
|
28193
|
+
* never agreed to it. Applied AFTER the disown above, in the SAME
|
|
28194
|
+
* transaction: what the disown clears is every marker below `backlogBefore`,
|
|
28195
|
+
* which includes this deployment's OWN pre-attach rows — `aka attach` calls
|
|
28196
|
+
* `seedCaptureBacklogOwed` at the attach instant, so every row it marks sits
|
|
28197
|
+
* on the cleared side of that bound — and the re-mark in the same
|
|
28198
|
+
* transaction is what puts those rows back. A crash between the two cannot
|
|
28199
|
+
* strand the ledger disowned with nothing re-marked — the transaction either
|
|
28200
|
+
* lands whole or not at all, and a fingerprint mismatch that has not yet
|
|
28201
|
+
* committed re-enters this method on the very next pass. Omit it (the
|
|
28202
|
+
* structural-only tests do) to exercise the disown in isolation.
|
|
28203
|
+
*
|
|
28204
|
+
* The disown is bounded by `backlogBefore`, which is what keeps it from
|
|
28205
|
+
* touching a marker the NEW deployment's OWN live path has already set: B's
|
|
28206
|
+
* live path can mark a capture owed from the moment `aka attach` writes the
|
|
28207
|
+
* descriptor, before the drain's first pass ever reaches this method, and
|
|
28208
|
+
* such a row sits at or after the bound rather than below it. What keeps the
|
|
28209
|
+
* disown from eating THIS SAME CALL's own re-mark is the order, not the
|
|
28210
|
+
* bound — disown runs first, re-mark second, both inside the one
|
|
28211
|
+
* transaction above.
|
|
28117
28212
|
*/
|
|
28118
|
-
rearmFor(fingerprint, backlogBefore) {
|
|
28213
|
+
rearmFor(fingerprint, backlogBefore, backfillCapturesBefore) {
|
|
28119
28214
|
this.ensureRowStmt.run();
|
|
28120
28215
|
withTransaction(
|
|
28121
28216
|
this.db,
|
|
@@ -28123,7 +28218,10 @@ var SqliteHistorySyncRepository = class {
|
|
|
28123
28218
|
const previous = getRow(this.fingerprintStmt)?.fingerprint;
|
|
28124
28219
|
this.rearmStmt.run();
|
|
28125
28220
|
if (previous !== null && previous !== void 0 && previous !== fingerprint) {
|
|
28126
|
-
this.disownCapturesStmt.run();
|
|
28221
|
+
this.disownCapturesStmt.run({ attachedAt: backlogBefore });
|
|
28222
|
+
}
|
|
28223
|
+
if (backfillCapturesBefore !== void 0) {
|
|
28224
|
+
this.markCaptureBacklogOwedStmt.run({ before: backfillCapturesBefore });
|
|
28127
28225
|
}
|
|
28128
28226
|
this.setFingerprintStmt.run({ fingerprint, backlogBefore });
|
|
28129
28227
|
},
|
|
@@ -28403,7 +28501,8 @@ function managedSettingsPaths(platform2 = process.platform) {
|
|
|
28403
28501
|
}
|
|
28404
28502
|
return [posix.join("/etc", "aka", MANAGED_SETTINGS_FILENAME)];
|
|
28405
28503
|
}
|
|
28406
|
-
|
|
28504
|
+
var testOnlyManagedPaths = null;
|
|
28505
|
+
function readManagedSettings(paths = testOnlyManagedPaths ?? managedSettingsPaths()) {
|
|
28407
28506
|
for (const path of paths) {
|
|
28408
28507
|
let text;
|
|
28409
28508
|
try {
|
|
@@ -30883,7 +30982,7 @@ function toUtcDateString(ms) {
|
|
|
30883
30982
|
return new Date(ms).toISOString().slice(0, 10);
|
|
30884
30983
|
}
|
|
30885
30984
|
function isTimeseriesSeverity(s) {
|
|
30886
|
-
return s === "critical" || s === "high" || s === "medium";
|
|
30985
|
+
return s === "critical" || s === "high" || s === "medium" || s === "low";
|
|
30887
30986
|
}
|
|
30888
30987
|
var SqliteSecurityRepository = class {
|
|
30889
30988
|
constructor(db, now = () => Date.now()) {
|
|
@@ -31012,12 +31111,16 @@ var SqliteSecurityRepository = class {
|
|
|
31012
31111
|
const now = this.now();
|
|
31013
31112
|
const windowStart = startOfUtcDay2(now) - (lenDays - 1) * DAY_MS4;
|
|
31014
31113
|
const rows = this.findingsInRange(windowStart, now);
|
|
31015
|
-
const points = Array.from(
|
|
31016
|
-
|
|
31017
|
-
|
|
31018
|
-
|
|
31019
|
-
|
|
31020
|
-
|
|
31114
|
+
const points = Array.from(
|
|
31115
|
+
{ length: numBuckets },
|
|
31116
|
+
(_, i) => ({
|
|
31117
|
+
timestamp: toUtcDateString(windowStart + i * bucketMs),
|
|
31118
|
+
critical: 0,
|
|
31119
|
+
high: 0,
|
|
31120
|
+
medium: 0,
|
|
31121
|
+
low: 0
|
|
31122
|
+
})
|
|
31123
|
+
);
|
|
31021
31124
|
for (const r of rows) {
|
|
31022
31125
|
const idx = Math.floor((r.occurredAt - windowStart) / bucketMs);
|
|
31023
31126
|
const bucket = points[idx];
|
|
@@ -31235,6 +31338,7 @@ var SqliteSecurityRepository = class {
|
|
|
31235
31338
|
`SELECT f.finding_key AS finding_key,
|
|
31236
31339
|
d.rule_id AS rule_id,
|
|
31237
31340
|
d.severity AS severity,
|
|
31341
|
+
e.repo AS repo,
|
|
31238
31342
|
e.file_path AS path,
|
|
31239
31343
|
COALESCE(f.first_detected_at, e.started_at) AS first_detected_at,
|
|
31240
31344
|
latest.resolved_at AS latest_resolved_at
|
|
@@ -31254,6 +31358,7 @@ var SqliteSecurityRepository = class {
|
|
|
31254
31358
|
const items = rows.map((r) => ({
|
|
31255
31359
|
findingKey: r.finding_key,
|
|
31256
31360
|
ruleId: r.rule_id,
|
|
31361
|
+
repo: r.repo ?? "",
|
|
31257
31362
|
severity: r.severity,
|
|
31258
31363
|
path: r.path ?? "",
|
|
31259
31364
|
resolvedAt: new Date(r.latest_resolved_at).toISOString(),
|
|
@@ -31263,13 +31368,66 @@ var SqliteSecurityRepository = class {
|
|
|
31263
31368
|
}));
|
|
31264
31369
|
return Promise.resolve({ items });
|
|
31265
31370
|
}
|
|
31371
|
+
/**
|
|
31372
|
+
* Per-rule tallies of the findings that are still OPEN, whole-store.
|
|
31373
|
+
*
|
|
31374
|
+
* Scoped by status rather than by time, because the card this feeds is a to-do
|
|
31375
|
+
* list: a secret committed three weeks ago and never rotated is still the most
|
|
31376
|
+
* important thing to fix, and any window hides it. It carried a "newest N
|
|
31377
|
+
* findings" cap and then a range; the first meant a different span on every
|
|
31378
|
+
* machine, and the second reported "no recommendations" over live exposure.
|
|
31379
|
+
*
|
|
31380
|
+
* `open` mirrors `deriveFindingStatus` — at-rest, minus resolved and dismissed —
|
|
31381
|
+
* so a row's count is exactly what `?status=open&type=<rule>` returns. Note that
|
|
31382
|
+
* is NOT `severitySummary`'s `openAtRest`, which keeps dismissed findings (a
|
|
31383
|
+
* dismissal is a judgement, not a remediation) and drops untracked legacy rows.
|
|
31384
|
+
* The two answer different questions and only this one has to match a link.
|
|
31385
|
+
*
|
|
31386
|
+
* Aggregated in SQL: the result is O(distinct rule × category × severity), so a
|
|
31387
|
+
* whole-store scope costs a grouped scan rather than a row per finding.
|
|
31388
|
+
*/
|
|
31389
|
+
recommendationInputs() {
|
|
31390
|
+
const rows = allRows(
|
|
31391
|
+
this.db.prepare(
|
|
31392
|
+
`SELECT d.rule_id AS rule_id,
|
|
31393
|
+
d.category AS category,
|
|
31394
|
+
d.severity AS severity,
|
|
31395
|
+
COUNT(*) AS count
|
|
31396
|
+
FROM inspection_findings f
|
|
31397
|
+
JOIN audit_events e ON e.id = f.audit_event_id
|
|
31398
|
+
JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
31399
|
+
LEFT JOIN ${LATEST_RESOLUTION_BY_KEY_SQL} latest
|
|
31400
|
+
ON latest.finding_key = f.finding_key
|
|
31401
|
+
WHERE e.event_type IN (${CAPTURE_EVENT_TYPES_SQL})
|
|
31402
|
+
AND e.event_type = 'code_change'
|
|
31403
|
+
AND (
|
|
31404
|
+
f.finding_key IS NULL
|
|
31405
|
+
OR latest.status IS NULL
|
|
31406
|
+
OR latest.status NOT IN ('resolved', 'dismissed')
|
|
31407
|
+
)
|
|
31408
|
+
GROUP BY d.rule_id, d.category, d.severity`
|
|
31409
|
+
)
|
|
31410
|
+
);
|
|
31411
|
+
return Promise.resolve(
|
|
31412
|
+
rows.map((r) => ({
|
|
31413
|
+
ruleId: r.rule_id,
|
|
31414
|
+
category: r.category,
|
|
31415
|
+
severity: r.severity,
|
|
31416
|
+
count: r.count
|
|
31417
|
+
}))
|
|
31418
|
+
);
|
|
31419
|
+
}
|
|
31266
31420
|
// Findings whose parent event occurred in [fromMs, toMs), with the parent's
|
|
31267
31421
|
// epoch-millis timestamp. started_at is an INTEGER column, so the bounds stay
|
|
31268
31422
|
// numeric and the JS aggregations bucket/split on ms directly.
|
|
31269
31423
|
findingsInRange(fromMs, toMs) {
|
|
31270
31424
|
const rows = allRows(
|
|
31271
31425
|
this.db.prepare(
|
|
31272
|
-
`
|
|
31426
|
+
// `rule_id`/`category` cost nothing extra: inspection_definitions is already
|
|
31427
|
+
// joined for `severity`, so they are two more columns off a row this read
|
|
31428
|
+
// already fetches. They feed the recommended-actions rollup.
|
|
31429
|
+
`SELECT e.started_at AS occurred_at, d.severity AS severity, f.action_taken AS action_taken,
|
|
31430
|
+
d.rule_id AS rule_id, d.category AS category
|
|
31273
31431
|
FROM inspection_findings f
|
|
31274
31432
|
JOIN audit_events e ON e.id = f.audit_event_id
|
|
31275
31433
|
JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
@@ -31282,7 +31440,9 @@ var SqliteSecurityRepository = class {
|
|
|
31282
31440
|
return rows.map((r) => ({
|
|
31283
31441
|
occurredAt: r.occurred_at,
|
|
31284
31442
|
severity: r.severity,
|
|
31285
|
-
actionTaken: r.action_taken
|
|
31443
|
+
actionTaken: r.action_taken,
|
|
31444
|
+
ruleId: r.rule_id,
|
|
31445
|
+
category: r.category
|
|
31286
31446
|
}));
|
|
31287
31447
|
}
|
|
31288
31448
|
};
|
|
@@ -32452,8 +32612,45 @@ function openLocalDatabase(dir) {
|
|
|
32452
32612
|
};
|
|
32453
32613
|
}
|
|
32454
32614
|
|
|
32455
|
-
// ../../packages/persistence/src/
|
|
32615
|
+
// ../../packages/persistence/src/egress-wire.ts
|
|
32456
32616
|
import { createHash as createHash3 } from "crypto";
|
|
32617
|
+
function hashProjectKey(projectKey) {
|
|
32618
|
+
return createHash3("sha256").update(projectKey, "utf8").digest("hex");
|
|
32619
|
+
}
|
|
32620
|
+
function toIngestHit(hit) {
|
|
32621
|
+
return {
|
|
32622
|
+
host: hit.host,
|
|
32623
|
+
kind: hit.kind,
|
|
32624
|
+
name: hit.name,
|
|
32625
|
+
category: hit.category,
|
|
32626
|
+
trust: hit.trust,
|
|
32627
|
+
network: hit.network,
|
|
32628
|
+
method: hit.method,
|
|
32629
|
+
transport: hit.transport,
|
|
32630
|
+
url: hit.url,
|
|
32631
|
+
template: hit.template,
|
|
32632
|
+
dataClass: hit.dataClass,
|
|
32633
|
+
site: {
|
|
32634
|
+
file: hit.site.file,
|
|
32635
|
+
line: hit.site.line,
|
|
32636
|
+
dynamic: hit.site.dynamic,
|
|
32637
|
+
vendored: hit.site.vendored
|
|
32638
|
+
}
|
|
32639
|
+
};
|
|
32640
|
+
}
|
|
32641
|
+
function toEgressIngestRequest(input2) {
|
|
32642
|
+
const { hits, droppedFiles } = capHits(input2.hits, input2.reconcile.mode);
|
|
32643
|
+
const reconcile = withoutDroppedFiles(input2.reconcile, droppedFiles);
|
|
32644
|
+
return {
|
|
32645
|
+
projectKey: hashProjectKey(input2.projectKey),
|
|
32646
|
+
project: input2.project,
|
|
32647
|
+
reconcile,
|
|
32648
|
+
hits: hits.map(toIngestHit)
|
|
32649
|
+
};
|
|
32650
|
+
}
|
|
32651
|
+
|
|
32652
|
+
// ../../packages/persistence/src/finding-key.ts
|
|
32653
|
+
import { createHash as createHash4 } from "crypto";
|
|
32457
32654
|
|
|
32458
32655
|
// ../../packages/persistence/src/fingerprint.ts
|
|
32459
32656
|
import { createHmac, randomBytes } from "crypto";
|
|
@@ -32494,14 +32691,18 @@ function readFingerprintKey(dataDir2) {
|
|
|
32494
32691
|
return parseKeyFile(raw);
|
|
32495
32692
|
}
|
|
32496
32693
|
|
|
32497
|
-
// ../../packages/persistence/src/history-
|
|
32694
|
+
// ../../packages/persistence/src/history-backfill.ts
|
|
32498
32695
|
import { existsSync as existsSync4 } from "fs";
|
|
32499
32696
|
import { join as join9 } from "path";
|
|
32697
|
+
|
|
32698
|
+
// ../../packages/persistence/src/history-preview.ts
|
|
32699
|
+
import { existsSync as existsSync5 } from "fs";
|
|
32700
|
+
import { join as join10 } from "path";
|
|
32500
32701
|
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
32501
32702
|
|
|
32502
32703
|
// ../../packages/persistence/src/store-symlinks.ts
|
|
32503
|
-
import { existsSync as
|
|
32504
|
-
import { dirname as dirname3, join as
|
|
32704
|
+
import { existsSync as existsSync6, lstatSync as lstatSync3, readlinkSync, realpathSync, statSync as statSync4 } from "fs";
|
|
32705
|
+
import { dirname as dirname3, join as join11, resolve } from "path";
|
|
32505
32706
|
var STORE_DB = "the store database (including the prompt corpus)";
|
|
32506
32707
|
var STORE_SETTINGS = "your settings file";
|
|
32507
32708
|
function storeContents(home) {
|
|
@@ -32510,7 +32711,7 @@ function storeContents(home) {
|
|
|
32510
32711
|
[settingsDir(home), STORE_SETTINGS],
|
|
32511
32712
|
[dataDir(home), STORE_DB],
|
|
32512
32713
|
[keysDir(home), "the vault key"],
|
|
32513
|
-
[
|
|
32714
|
+
[join11(settingsDir(home), "settings.json"), STORE_SETTINGS],
|
|
32514
32715
|
[dbPath(home), STORE_DB]
|
|
32515
32716
|
]);
|
|
32516
32717
|
}
|
|
@@ -32525,7 +32726,7 @@ function symlinkedStorePaths(home, platform2 = process.platform) {
|
|
|
32525
32726
|
holds,
|
|
32526
32727
|
// existsSync follows the link, so a target that is gone reads as
|
|
32527
32728
|
// absent here while lstat above still sees the link itself.
|
|
32528
|
-
missing: !
|
|
32729
|
+
missing: !existsSync6(path),
|
|
32529
32730
|
mode: targetMode(path, platform2)
|
|
32530
32731
|
}
|
|
32531
32732
|
];
|
|
@@ -32563,61 +32764,25 @@ import {
|
|
|
32563
32764
|
import { execFileSync } from "child_process";
|
|
32564
32765
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
32565
32766
|
import { chmodSync as chmodSync3, readFileSync as readFileSync7, renameSync as renameSync4, rmSync as rmSync6, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
|
|
32566
|
-
import { join as
|
|
32767
|
+
import { join as join12 } from "path";
|
|
32567
32768
|
|
|
32568
32769
|
// ../../packages/persistence/src/vault/vault.ts
|
|
32569
32770
|
import { randomBytes as randomBytes3, randomUUID as randomUUID12 } from "crypto";
|
|
32570
32771
|
|
|
32571
32772
|
// ../../packages/persistence/src/warn-era-cap.ts
|
|
32572
|
-
import { existsSync as
|
|
32573
|
-
import { join as
|
|
32773
|
+
import { existsSync as existsSync7, writeFileSync as writeFileSync4 } from "fs";
|
|
32774
|
+
import { join as join13 } from "path";
|
|
32574
32775
|
var MARKER = "warn-era-capped";
|
|
32575
32776
|
function capWarnEraEnforcementOnce(db, policyMode, dataDir2) {
|
|
32576
32777
|
if (policyMode !== "warn") return { capped: 0, skipped: "not-warn" };
|
|
32577
|
-
const marker =
|
|
32578
|
-
if (
|
|
32778
|
+
const marker = join13(dataDir2, MARKER);
|
|
32779
|
+
if (existsSync7(marker)) return { capped: 0, skipped: "already-run" };
|
|
32579
32780
|
const capped = db.policies.capCategoryActions();
|
|
32580
32781
|
writeFileSync4(marker, `${new Date(Date.now()).toISOString()}
|
|
32581
32782
|
`, { mode: DATA_FILE_MODE });
|
|
32582
32783
|
return { capped };
|
|
32583
32784
|
}
|
|
32584
32785
|
|
|
32585
|
-
// ../../packages/plugin-runtime/src/attached/egress-wire.ts
|
|
32586
|
-
function hashProjectKey(projectKey) {
|
|
32587
|
-
return createHash4("sha256").update(projectKey, "utf8").digest("hex");
|
|
32588
|
-
}
|
|
32589
|
-
function toIngestHit(hit) {
|
|
32590
|
-
return {
|
|
32591
|
-
host: hit.host,
|
|
32592
|
-
kind: hit.kind,
|
|
32593
|
-
name: hit.name,
|
|
32594
|
-
category: hit.category,
|
|
32595
|
-
trust: hit.trust,
|
|
32596
|
-
network: hit.network,
|
|
32597
|
-
method: hit.method,
|
|
32598
|
-
transport: hit.transport,
|
|
32599
|
-
url: hit.url,
|
|
32600
|
-
template: hit.template,
|
|
32601
|
-
dataClass: hit.dataClass,
|
|
32602
|
-
site: {
|
|
32603
|
-
file: hit.site.file,
|
|
32604
|
-
line: hit.site.line,
|
|
32605
|
-
dynamic: hit.site.dynamic,
|
|
32606
|
-
vendored: hit.site.vendored
|
|
32607
|
-
}
|
|
32608
|
-
};
|
|
32609
|
-
}
|
|
32610
|
-
function toEgressIngestRequest(input2) {
|
|
32611
|
-
const { hits, droppedFiles } = capHits(input2.hits, input2.reconcile.mode);
|
|
32612
|
-
const reconcile = withoutDroppedFiles(input2.reconcile, droppedFiles);
|
|
32613
|
-
return {
|
|
32614
|
-
projectKey: hashProjectKey(input2.projectKey),
|
|
32615
|
-
project: input2.project,
|
|
32616
|
-
reconcile,
|
|
32617
|
-
hits: hits.map(toIngestHit)
|
|
32618
|
-
};
|
|
32619
|
-
}
|
|
32620
|
-
|
|
32621
32786
|
// ../../packages/remote/src/http.ts
|
|
32622
32787
|
import { request as httpRequest } from "http";
|
|
32623
32788
|
import { request as httpsRequest } from "https";
|
|
@@ -32897,6 +33062,7 @@ function createRemoteClient(options) {
|
|
|
32897
33062
|
url: url2(ROUTES.shares),
|
|
32898
33063
|
body: JSON.stringify(validated.data)
|
|
32899
33064
|
});
|
|
33065
|
+
if (response.status === 404) throw new RemoteRouteAbsent(ROUTES.shares);
|
|
32900
33066
|
okBody(response);
|
|
32901
33067
|
},
|
|
32902
33068
|
async pollCommand() {
|
|
@@ -32919,19 +33085,51 @@ function createRemoteClient(options) {
|
|
|
32919
33085
|
};
|
|
32920
33086
|
}
|
|
32921
33087
|
|
|
32922
|
-
// ../../packages/
|
|
33088
|
+
// ../../packages/remote/src/failure-kind.ts
|
|
32923
33089
|
function statusOf(err) {
|
|
32924
33090
|
if (typeof err !== "object" || err === null || !("status" in err)) return null;
|
|
32925
33091
|
const { status } = err;
|
|
32926
33092
|
if (typeof status !== "number" || !Number.isInteger(status)) return null;
|
|
32927
33093
|
return status >= 100 && status <= 599 ? status : null;
|
|
32928
33094
|
}
|
|
32929
|
-
function
|
|
32930
|
-
|
|
33095
|
+
function nameOf(err) {
|
|
33096
|
+
if (typeof err !== "object" || err === null || !("name" in err)) return null;
|
|
33097
|
+
return typeof err.name === "string" ? err.name : null;
|
|
33098
|
+
}
|
|
33099
|
+
function classifyRemoteFailure(err) {
|
|
33100
|
+
switch (nameOf(err)) {
|
|
33101
|
+
case "RemoteRouteAbsent":
|
|
33102
|
+
return "route-absent";
|
|
33103
|
+
case "RemoteRequestInvalid":
|
|
33104
|
+
return "invalid-request";
|
|
33105
|
+
case "RemoteResponseInvalid":
|
|
33106
|
+
return "rejected";
|
|
33107
|
+
default:
|
|
33108
|
+
break;
|
|
33109
|
+
}
|
|
33110
|
+
const status = statusOf(err);
|
|
33111
|
+
if (status === null) return "unreachable";
|
|
33112
|
+
switch (status) {
|
|
32931
33113
|
case 401:
|
|
32932
33114
|
return "unauthorized";
|
|
32933
33115
|
case 403:
|
|
32934
33116
|
return "forbidden";
|
|
33117
|
+
case 429:
|
|
33118
|
+
return "unreachable";
|
|
33119
|
+
case 404:
|
|
33120
|
+
return "unreachable";
|
|
33121
|
+
default:
|
|
33122
|
+
return status >= 400 && status <= 499 ? "rejected" : "unreachable";
|
|
33123
|
+
}
|
|
33124
|
+
}
|
|
33125
|
+
|
|
33126
|
+
// ../../packages/plugin-runtime/src/attached/failure.ts
|
|
33127
|
+
function classifyFailure(err) {
|
|
33128
|
+
switch (classifyRemoteFailure(err)) {
|
|
33129
|
+
case "unauthorized":
|
|
33130
|
+
return "unauthorized";
|
|
33131
|
+
case "forbidden":
|
|
33132
|
+
return "forbidden";
|
|
32935
33133
|
default:
|
|
32936
33134
|
return "unreachable";
|
|
32937
33135
|
}
|
|
@@ -32954,10 +33152,10 @@ function withTimeout(promise2, ms) {
|
|
|
32954
33152
|
|
|
32955
33153
|
// ../../packages/plugin-runtime/src/attached/forward-drops.ts
|
|
32956
33154
|
import { readFileSync as readFileSync8 } from "fs";
|
|
32957
|
-
import { join as
|
|
33155
|
+
import { join as join14 } from "path";
|
|
32958
33156
|
var FORWARD_DROPS_FILENAME = ATTACHED_FORWARD_DROPS_FILENAME;
|
|
32959
33157
|
function forwardDropsPath(dataDir2) {
|
|
32960
|
-
return
|
|
33158
|
+
return join14(dataDir2, FORWARD_DROPS_FILENAME);
|
|
32961
33159
|
}
|
|
32962
33160
|
function recordForwardDrops(dataDir2, count, nowMs) {
|
|
32963
33161
|
if (count <= 0) return;
|
|
@@ -32993,13 +33191,13 @@ function readForwardDrops(dataDir2) {
|
|
|
32993
33191
|
|
|
32994
33192
|
// ../../packages/plugin-runtime/src/attached/forward-policy.ts
|
|
32995
33193
|
import { randomUUID as randomUUID15 } from "crypto";
|
|
32996
|
-
import { readFileSync as
|
|
33194
|
+
import { readFileSync as readFileSync15 } from "fs";
|
|
32997
33195
|
import { readFile, rename, writeFile } from "fs/promises";
|
|
32998
|
-
import { join as
|
|
33196
|
+
import { join as join24 } from "path";
|
|
32999
33197
|
|
|
33000
33198
|
// ../../packages/plugin-sdk/src/config.ts
|
|
33001
|
-
import { existsSync as
|
|
33002
|
-
import { join as
|
|
33199
|
+
import { existsSync as existsSync8 } from "fs";
|
|
33200
|
+
import { join as join15 } from "path";
|
|
33003
33201
|
|
|
33004
33202
|
// ../../packages/plugin-sdk/src/provider-env.ts
|
|
33005
33203
|
var DEFAULT_ANTHROPIC_HOST = "api.anthropic.com";
|
|
@@ -33053,8 +33251,8 @@ function resolveProvider() {
|
|
|
33053
33251
|
function loadConfig(base = defaultDataDir(), resolveProviderFn = resolveProvider) {
|
|
33054
33252
|
try {
|
|
33055
33253
|
ensureLayoutDirSync(base);
|
|
33056
|
-
const settingsFile =
|
|
33057
|
-
if (
|
|
33254
|
+
const settingsFile = join15(settingsDir(base), "settings.json");
|
|
33255
|
+
if (existsSync8(settingsFile)) tightenFile(settingsFile);
|
|
33058
33256
|
} catch {
|
|
33059
33257
|
}
|
|
33060
33258
|
migrateLegacyLayout(base);
|
|
@@ -33079,7 +33277,7 @@ function resolveProviderSafe(resolveProviderFn) {
|
|
|
33079
33277
|
// ../../packages/plugin-sdk/src/config-inventory.ts
|
|
33080
33278
|
import { readdirSync as readdirSync2, readFileSync as readFileSync10, realpathSync as realpathSync2, statSync as statSync7 } from "fs";
|
|
33081
33279
|
import { homedir as homedir2 } from "os";
|
|
33082
|
-
import { basename as basename4, join as
|
|
33280
|
+
import { basename as basename4, join as join17 } from "path";
|
|
33083
33281
|
|
|
33084
33282
|
// ../../packages/detections/src/egress/registry.ts
|
|
33085
33283
|
var EXTRACTOR_VERSION = "1";
|
|
@@ -36208,8 +36406,8 @@ function maskText(text) {
|
|
|
36208
36406
|
}
|
|
36209
36407
|
|
|
36210
36408
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
36211
|
-
import { existsSync as
|
|
36212
|
-
import { basename as basename3, dirname as dirname4, isAbsolute, join as
|
|
36409
|
+
import { existsSync as existsSync9, readFileSync as readFileSync9, statSync as statSync6 } from "fs";
|
|
36410
|
+
import { basename as basename3, dirname as dirname4, isAbsolute, join as join16, sep as sep2 } from "path";
|
|
36213
36411
|
function resolveRepoIdentity(cwd) {
|
|
36214
36412
|
try {
|
|
36215
36413
|
const root = findGitRoot(cwd);
|
|
@@ -36259,7 +36457,7 @@ function resolveGitBranch(cwd) {
|
|
|
36259
36457
|
try {
|
|
36260
36458
|
const root = findGitRoot(cwd);
|
|
36261
36459
|
if (!root) return void 0;
|
|
36262
|
-
const dotGit =
|
|
36460
|
+
const dotGit = join16(root, ".git");
|
|
36263
36461
|
let gitdir;
|
|
36264
36462
|
try {
|
|
36265
36463
|
gitdir = statSync6(dotGit).isDirectory() ? dotGit : resolveWorktreeGitdir(root, dotGit);
|
|
@@ -36267,7 +36465,7 @@ function resolveGitBranch(cwd) {
|
|
|
36267
36465
|
return void 0;
|
|
36268
36466
|
}
|
|
36269
36467
|
if (gitdir === void 0) return void 0;
|
|
36270
|
-
const head = safeRead(
|
|
36468
|
+
const head = safeRead(join16(gitdir, "HEAD"));
|
|
36271
36469
|
if (!head) return void 0;
|
|
36272
36470
|
return /^ref:\s*refs\/heads\/(.+?)\s*$/m.exec(head)?.[1];
|
|
36273
36471
|
} catch {
|
|
@@ -36277,37 +36475,37 @@ function resolveGitBranch(cwd) {
|
|
|
36277
36475
|
function resolveWorktreeGitdir(root, dotGitFile) {
|
|
36278
36476
|
const target = /^gitdir:\s*(.+?)\s*$/m.exec(safeRead(dotGitFile) ?? "")?.[1];
|
|
36279
36477
|
if (!target) return void 0;
|
|
36280
|
-
return isAbsolute(target) ? target :
|
|
36478
|
+
return isAbsolute(target) ? target : join16(root, target);
|
|
36281
36479
|
}
|
|
36282
36480
|
function findGitRoot(start) {
|
|
36283
36481
|
let dir = start;
|
|
36284
36482
|
for (; ; ) {
|
|
36285
|
-
if (
|
|
36483
|
+
if (existsSync9(join16(dir, ".git"))) return dir;
|
|
36286
36484
|
const parent = dirname4(dir);
|
|
36287
36485
|
if (parent === dir) return void 0;
|
|
36288
36486
|
dir = parent;
|
|
36289
36487
|
}
|
|
36290
36488
|
}
|
|
36291
36489
|
function resolveGitContext(root) {
|
|
36292
|
-
const dotGit =
|
|
36490
|
+
const dotGit = join16(root, ".git");
|
|
36293
36491
|
try {
|
|
36294
36492
|
if (statSync6(dotGit).isDirectory()) {
|
|
36295
|
-
return { configPath:
|
|
36493
|
+
return { configPath: join16(dotGit, "config"), headRoot: root };
|
|
36296
36494
|
}
|
|
36297
36495
|
} catch {
|
|
36298
36496
|
return void 0;
|
|
36299
36497
|
}
|
|
36300
36498
|
const target = /^gitdir:\s*(.+?)\s*$/m.exec(safeRead(dotGit) ?? "")?.[1];
|
|
36301
36499
|
if (!target) return void 0;
|
|
36302
|
-
const gitdir = isAbsolute(target) ? target :
|
|
36303
|
-
if (
|
|
36304
|
-
return { configPath:
|
|
36500
|
+
const gitdir = isAbsolute(target) ? target : join16(root, target);
|
|
36501
|
+
if (existsSync9(join16(gitdir, "config"))) {
|
|
36502
|
+
return { configPath: join16(gitdir, "config"), headRoot: root };
|
|
36305
36503
|
}
|
|
36306
|
-
const commonRaw = safeRead(
|
|
36504
|
+
const commonRaw = safeRead(join16(gitdir, "commondir"))?.trim();
|
|
36307
36505
|
if (!commonRaw) return void 0;
|
|
36308
|
-
const commonGitDir = isAbsolute(commonRaw) ? commonRaw :
|
|
36506
|
+
const commonGitDir = isAbsolute(commonRaw) ? commonRaw : join16(gitdir, commonRaw);
|
|
36309
36507
|
const headRoot = basename3(commonGitDir) === ".git" ? dirname4(commonGitDir) : root;
|
|
36310
|
-
return { configPath:
|
|
36508
|
+
return { configPath: join16(commonGitDir, "config"), headRoot };
|
|
36311
36509
|
}
|
|
36312
36510
|
function safeRead(path) {
|
|
36313
36511
|
try {
|
|
@@ -36373,31 +36571,31 @@ function resolveConfigInventory(input2) {
|
|
|
36373
36571
|
};
|
|
36374
36572
|
try {
|
|
36375
36573
|
const home = input2.homeDir ?? homedir2();
|
|
36376
|
-
const claudeDir =
|
|
36574
|
+
const claudeDir = join17(home, ".claude");
|
|
36377
36575
|
const repo = resolveRepoIdentity(input2.cwd);
|
|
36378
36576
|
const repoIdentity = repo?.url ?? input2.cwd;
|
|
36379
36577
|
const projectSource = `project:${repoIdentity}`;
|
|
36380
|
-
collectSettingsHooks(scan2,
|
|
36381
|
-
collectSettingsHooks(scan2,
|
|
36382
|
-
collectSettingsHooks(scan2,
|
|
36578
|
+
collectSettingsHooks(scan2, join17(claudeDir, "settings.json"), "user");
|
|
36579
|
+
collectSettingsHooks(scan2, join17(input2.cwd, ".claude", "settings.json"), "project");
|
|
36580
|
+
collectSettingsHooks(scan2, join17(input2.cwd, ".claude", "settings.local.json"), "local");
|
|
36383
36581
|
const projectOrigin = { scope: "project", project: repoIdentity };
|
|
36384
|
-
collectMcpFile(scan2,
|
|
36385
|
-
collectUserClaudeJson(scan2,
|
|
36386
|
-
collectMcpFile(scan2,
|
|
36387
|
-
collectMcpFile(scan2,
|
|
36388
|
-
collectMcpFile(scan2,
|
|
36582
|
+
collectMcpFile(scan2, join17(input2.cwd, ".mcp.json"), projectOrigin, { recordErrors: true });
|
|
36583
|
+
collectUserClaudeJson(scan2, join17(home, ".claude.json"), input2.cwd, repoIdentity);
|
|
36584
|
+
collectMcpFile(scan2, join17(claudeDir, "settings.json"), { scope: "user" });
|
|
36585
|
+
collectMcpFile(scan2, join17(input2.cwd, ".claude", "settings.json"), projectOrigin);
|
|
36586
|
+
collectMcpFile(scan2, join17(input2.cwd, ".claude", "settings.local.json"), {
|
|
36389
36587
|
scope: "local",
|
|
36390
36588
|
project: repoIdentity
|
|
36391
36589
|
});
|
|
36392
36590
|
collectConfigFiles(scan2, claudeDir, input2.cwd);
|
|
36393
|
-
collectSkillsDir(scan2,
|
|
36394
|
-
collectSkillsDir(scan2,
|
|
36591
|
+
collectSkillsDir(scan2, join17(claudeDir, "skills"), { source: "local", scope: "user" });
|
|
36592
|
+
collectSkillsDir(scan2, join17(input2.cwd, ".claude", "skills"), {
|
|
36395
36593
|
source: projectSource,
|
|
36396
36594
|
scope: "project"
|
|
36397
36595
|
});
|
|
36398
36596
|
collectInstalledPlugins(scan2, claudeDir);
|
|
36399
36597
|
collectMarketplaceSkills(scan2, claudeDir);
|
|
36400
|
-
collectSkillsDir(scan2,
|
|
36598
|
+
collectSkillsDir(scan2, join17(input2.cwd, "skills"), { source: projectSource, scope: "project" });
|
|
36401
36599
|
scan2.skills = dedupeSkills(scan2.skills);
|
|
36402
36600
|
scan2.mcpServers = dedupeMcpServers(scan2.mcpServers);
|
|
36403
36601
|
} catch (err) {
|
|
@@ -36526,7 +36724,7 @@ function projectEntryFor(projects, cwd) {
|
|
|
36526
36724
|
return void 0;
|
|
36527
36725
|
}
|
|
36528
36726
|
function collectPluginManifestMcp(scan2, installPath, origin) {
|
|
36529
|
-
const manifestPath =
|
|
36727
|
+
const manifestPath = join17(installPath, ".claude-plugin", "plugin.json");
|
|
36530
36728
|
const raw = readOptional(manifestPath);
|
|
36531
36729
|
if (raw === void 0) return;
|
|
36532
36730
|
try {
|
|
@@ -36534,7 +36732,7 @@ function collectPluginManifestMcp(scan2, installPath, origin) {
|
|
|
36534
36732
|
if (typeof parsed2 !== "object" || parsed2 === null) return;
|
|
36535
36733
|
const declared = parsed2.mcpServers;
|
|
36536
36734
|
if (typeof declared === "string" && declared.length > 0) {
|
|
36537
|
-
collectMcpFile(scan2,
|
|
36735
|
+
collectMcpFile(scan2, join17(installPath, declared), origin, { recordErrors: true });
|
|
36538
36736
|
} else {
|
|
36539
36737
|
collectMcpObject(scan2, declared, manifestPath, origin);
|
|
36540
36738
|
}
|
|
@@ -36551,14 +36749,14 @@ var SETTINGS_KEY_LABELS = [
|
|
|
36551
36749
|
["statusLine", "status line"]
|
|
36552
36750
|
];
|
|
36553
36751
|
function collectConfigFiles(scan2, claudeDir, cwd) {
|
|
36554
|
-
settingsConfigFile(scan2,
|
|
36555
|
-
settingsConfigFile(scan2,
|
|
36556
|
-
settingsConfigFile(scan2,
|
|
36557
|
-
memoryConfigFile(scan2,
|
|
36558
|
-
memoryConfigFile(scan2,
|
|
36559
|
-
mcpJsonConfigFile(scan2,
|
|
36560
|
-
dirConfigFile(scan2,
|
|
36561
|
-
dirConfigFile(scan2,
|
|
36752
|
+
settingsConfigFile(scan2, join17(claudeDir, "settings.json"), "user", "User settings");
|
|
36753
|
+
settingsConfigFile(scan2, join17(cwd, ".claude", "settings.json"), "project", "Project settings");
|
|
36754
|
+
settingsConfigFile(scan2, join17(cwd, ".claude", "settings.local.json"), "local", "Local overrides");
|
|
36755
|
+
memoryConfigFile(scan2, join17(claudeDir, "CLAUDE.md"), "user", "User memory");
|
|
36756
|
+
memoryConfigFile(scan2, join17(cwd, "CLAUDE.md"), "project", "Project memory");
|
|
36757
|
+
mcpJsonConfigFile(scan2, join17(cwd, ".mcp.json"));
|
|
36758
|
+
dirConfigFile(scan2, join17(cwd, ".claude", "commands"), "Slash commands", "command");
|
|
36759
|
+
dirConfigFile(scan2, join17(cwd, ".claude", "agents"), "Subagents", "subagent");
|
|
36562
36760
|
}
|
|
36563
36761
|
function configFileEntry(path, scope, kind) {
|
|
36564
36762
|
try {
|
|
@@ -36633,7 +36831,7 @@ function countMarkdownFiles(dir, depth) {
|
|
|
36633
36831
|
let count = 0;
|
|
36634
36832
|
for (const dirent of readdirSync2(dir, { withFileTypes: true })) {
|
|
36635
36833
|
if (dirent.name.startsWith(".")) continue;
|
|
36636
|
-
if (dirent.isDirectory()) count += countMarkdownFiles(
|
|
36834
|
+
if (dirent.isDirectory()) count += countMarkdownFiles(join17(dir, dirent.name), depth + 1);
|
|
36637
36835
|
else if (dirent.name.endsWith(".md")) count += 1;
|
|
36638
36836
|
}
|
|
36639
36837
|
return count;
|
|
@@ -36646,7 +36844,7 @@ function collectSkillsDir(scan2, dir, origin) {
|
|
|
36646
36844
|
return;
|
|
36647
36845
|
}
|
|
36648
36846
|
for (const name of names) {
|
|
36649
|
-
const skillFile =
|
|
36847
|
+
const skillFile = join17(dir, name, "SKILL.md");
|
|
36650
36848
|
try {
|
|
36651
36849
|
const raw = readOptional(skillFile);
|
|
36652
36850
|
if (raw === void 0) continue;
|
|
@@ -36655,7 +36853,7 @@ function collectSkillsDir(scan2, dir, origin) {
|
|
|
36655
36853
|
name: front.name ?? name,
|
|
36656
36854
|
source: origin.source,
|
|
36657
36855
|
scope: origin.scope,
|
|
36658
|
-
location:
|
|
36856
|
+
location: join17(dir, name),
|
|
36659
36857
|
updatedAt: statSync7(skillFile).mtime.toISOString()
|
|
36660
36858
|
};
|
|
36661
36859
|
const version2 = front.version ?? origin.defaultVersion;
|
|
@@ -36686,7 +36884,7 @@ function parseFrontmatter(raw) {
|
|
|
36686
36884
|
return out;
|
|
36687
36885
|
}
|
|
36688
36886
|
function collectInstalledPlugins(scan2, claudeDir) {
|
|
36689
|
-
const manifestPath =
|
|
36887
|
+
const manifestPath = join17(claudeDir, "plugins", "installed_plugins.json");
|
|
36690
36888
|
const raw = readOptional(manifestPath);
|
|
36691
36889
|
if (raw === void 0) return;
|
|
36692
36890
|
let plugins;
|
|
@@ -36711,7 +36909,7 @@ function collectInstalledPlugins(scan2, claudeDir) {
|
|
|
36711
36909
|
if (typeof installPath !== "string" || seen.has(installPath)) continue;
|
|
36712
36910
|
seen.add(installPath);
|
|
36713
36911
|
const version2 = install.version;
|
|
36714
|
-
const hooksPath =
|
|
36912
|
+
const hooksPath = join17(installPath, "hooks", "hooks.json");
|
|
36715
36913
|
const hooksRaw = readOptional(hooksPath);
|
|
36716
36914
|
if (hooksRaw !== void 0) {
|
|
36717
36915
|
try {
|
|
@@ -36731,22 +36929,22 @@ function collectInstalledPlugins(scan2, claudeDir) {
|
|
|
36731
36929
|
}
|
|
36732
36930
|
const origin = { source: marketplace, scope: "plugin", pluginName };
|
|
36733
36931
|
if (typeof version2 === "string") origin.defaultVersion = version2;
|
|
36734
|
-
collectSkillsDir(scan2,
|
|
36932
|
+
collectSkillsDir(scan2, join17(installPath, "skills"), origin);
|
|
36735
36933
|
const mcpOrigin = { scope: "plugin", pluginName, marketplace };
|
|
36736
|
-
collectMcpFile(scan2,
|
|
36934
|
+
collectMcpFile(scan2, join17(installPath, ".mcp.json"), mcpOrigin, { recordErrors: true });
|
|
36737
36935
|
collectPluginManifestMcp(scan2, installPath, mcpOrigin);
|
|
36738
36936
|
}
|
|
36739
36937
|
}
|
|
36740
36938
|
}
|
|
36741
36939
|
function collectMarketplaceSkills(scan2, claudeDir) {
|
|
36742
|
-
for (const mp of readMarketplaces(
|
|
36940
|
+
for (const mp of readMarketplaces(join17(claudeDir, "plugins", "known_marketplaces.json"))) {
|
|
36743
36941
|
if (isClaudeOfficialMarketplace(mp.name, mp.repo)) continue;
|
|
36744
|
-
collectSkillsDir(scan2,
|
|
36942
|
+
collectSkillsDir(scan2, join17(mp.installLocation, "skills"), {
|
|
36745
36943
|
source: mp.name,
|
|
36746
36944
|
scope: "plugin"
|
|
36747
36945
|
});
|
|
36748
|
-
collectPluginSkillDirs(scan2,
|
|
36749
|
-
collectPluginSkillDirs(scan2,
|
|
36946
|
+
collectPluginSkillDirs(scan2, join17(mp.installLocation, "plugins"), mp.name);
|
|
36947
|
+
collectPluginSkillDirs(scan2, join17(mp.installLocation, "external_plugins"), mp.name);
|
|
36750
36948
|
}
|
|
36751
36949
|
}
|
|
36752
36950
|
function collectPluginSkillDirs(scan2, pluginsDir, marketplace) {
|
|
@@ -36757,7 +36955,7 @@ function collectPluginSkillDirs(scan2, pluginsDir, marketplace) {
|
|
|
36757
36955
|
return;
|
|
36758
36956
|
}
|
|
36759
36957
|
for (const plugin of plugins) {
|
|
36760
|
-
collectSkillsDir(scan2,
|
|
36958
|
+
collectSkillsDir(scan2, join17(pluginsDir, plugin, "skills"), {
|
|
36761
36959
|
source: marketplace,
|
|
36762
36960
|
scope: "plugin",
|
|
36763
36961
|
pluginName: plugin
|
|
@@ -36839,17 +37037,52 @@ function offersMaintenance(gateway, member) {
|
|
|
36839
37037
|
import { createHash as createHash5, randomUUID as randomUUID13 } from "crypto";
|
|
36840
37038
|
|
|
36841
37039
|
// ../../packages/plugin-sdk/src/isolated-scan.ts
|
|
36842
|
-
import { existsSync as
|
|
37040
|
+
import { existsSync as existsSync10 } from "fs";
|
|
36843
37041
|
import { fileURLToPath } from "url";
|
|
36844
37042
|
import { Worker } from "worker_threads";
|
|
36845
37043
|
|
|
37044
|
+
// ../../packages/plugin-sdk/src/host-floor.ts
|
|
37045
|
+
import { readFileSync as readFileSync12 } from "fs";
|
|
37046
|
+
import { join as join19 } from "path";
|
|
37047
|
+
|
|
37048
|
+
// ../../packages/plugin-sdk/src/model-governance.ts
|
|
37049
|
+
import {
|
|
37050
|
+
closeSync as closeSync2,
|
|
37051
|
+
fstatSync,
|
|
37052
|
+
mkdirSync as mkdirSync2,
|
|
37053
|
+
openSync as openSync2,
|
|
37054
|
+
readFileSync as readFileSync11,
|
|
37055
|
+
readSync,
|
|
37056
|
+
writeFileSync as writeFileSync5
|
|
37057
|
+
} from "fs";
|
|
37058
|
+
import { join as join18 } from "path";
|
|
37059
|
+
var TAIL_BYTES = 256 * 1024;
|
|
37060
|
+
|
|
37061
|
+
// ../../packages/plugin-sdk/src/host-floor.ts
|
|
37062
|
+
var HOST_FEATURE = {
|
|
37063
|
+
ModelSwitch: "model-switch",
|
|
37064
|
+
VaultPointerDisplay: "vault-pointer-display"
|
|
37065
|
+
};
|
|
37066
|
+
var HOST_FLOORS = {
|
|
37067
|
+
[HOST_FEATURE.ModelSwitch]: {
|
|
37068
|
+
label: "model-switch protection",
|
|
37069
|
+
hookEvents: ["PreModelSwitch", "PostModelSwitch"],
|
|
37070
|
+
since: "2.1.251"
|
|
37071
|
+
},
|
|
37072
|
+
[HOST_FEATURE.VaultPointerDisplay]: {
|
|
37073
|
+
label: "vault pointer display",
|
|
37074
|
+
hookEvents: ["MessageDisplay"],
|
|
37075
|
+
since: "2.1.152"
|
|
37076
|
+
}
|
|
37077
|
+
};
|
|
37078
|
+
|
|
36846
37079
|
// ../../packages/plugin-sdk/src/ignore-layers.ts
|
|
36847
37080
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
36848
|
-
import { readFileSync as
|
|
36849
|
-
import { join as
|
|
37081
|
+
import { readFileSync as readFileSync13 } from "fs";
|
|
37082
|
+
import { join as join20 } from "path";
|
|
36850
37083
|
function readIgnoreLayer(dir, filename, anchorLen) {
|
|
36851
37084
|
try {
|
|
36852
|
-
return { matcher: (0, import_ignore.default)().add(
|
|
37085
|
+
return { matcher: (0, import_ignore.default)().add(readFileSync13(join20(dir, filename), "utf8")), anchorLen };
|
|
36853
37086
|
} catch {
|
|
36854
37087
|
return void 0;
|
|
36855
37088
|
}
|
|
@@ -36905,31 +37138,18 @@ function resolveInventoryContext(input2) {
|
|
|
36905
37138
|
return ctx;
|
|
36906
37139
|
}
|
|
36907
37140
|
|
|
36908
|
-
// ../../packages/plugin-sdk/src/model-governance.ts
|
|
36909
|
-
import {
|
|
36910
|
-
closeSync as closeSync2,
|
|
36911
|
-
fstatSync,
|
|
36912
|
-
mkdirSync as mkdirSync2,
|
|
36913
|
-
openSync as openSync2,
|
|
36914
|
-
readFileSync as readFileSync12,
|
|
36915
|
-
readSync,
|
|
36916
|
-
writeFileSync as writeFileSync5
|
|
36917
|
-
} from "fs";
|
|
36918
|
-
import { join as join18 } from "path";
|
|
36919
|
-
var TAIL_BYTES = 256 * 1024;
|
|
36920
|
-
|
|
36921
37141
|
// ../../packages/plugin-sdk/src/nudge.ts
|
|
36922
|
-
import { mkdirSync as mkdirSync3, readFileSync as
|
|
36923
|
-
import { join as
|
|
37142
|
+
import { mkdirSync as mkdirSync3, readFileSync as readFileSync14, writeFileSync as writeFileSync6 } from "fs";
|
|
37143
|
+
import { join as join21 } from "path";
|
|
36924
37144
|
var SESSION_START_MARKER = "session-start-last";
|
|
36925
37145
|
function claimSessionStart(dataDir2, sessionId) {
|
|
36926
37146
|
return claimOncePerSession(dataDir2, SESSION_START_MARKER, sessionId);
|
|
36927
37147
|
}
|
|
36928
37148
|
function claimOncePerSession(dataDir2, marker, sessionId) {
|
|
36929
37149
|
if (!sessionId) return true;
|
|
36930
|
-
const path =
|
|
37150
|
+
const path = join21(dataDir2, marker);
|
|
36931
37151
|
try {
|
|
36932
|
-
if (
|
|
37152
|
+
if (readFileSync14(path, "utf8") === sessionId) return false;
|
|
36933
37153
|
} catch {
|
|
36934
37154
|
}
|
|
36935
37155
|
try {
|
|
@@ -36945,8 +37165,8 @@ import { readdirSync as readdirSync3, realpathSync as realpathSync3 } from "fs";
|
|
|
36945
37165
|
import { basename as basename5, dirname as dirname5, sep as sep3 } from "path";
|
|
36946
37166
|
|
|
36947
37167
|
// ../../packages/plugin-sdk/src/project-files.ts
|
|
36948
|
-
import { existsSync as
|
|
36949
|
-
import { basename as basename6, join as
|
|
37168
|
+
import { existsSync as existsSync11, readdirSync as readdirSync4 } from "fs";
|
|
37169
|
+
import { basename as basename6, join as join22 } from "path";
|
|
36950
37170
|
var SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
36951
37171
|
".git",
|
|
36952
37172
|
"node_modules",
|
|
@@ -37043,8 +37263,8 @@ function resolveProjectFiles(cwd, opts = {}) {
|
|
|
37043
37263
|
}
|
|
37044
37264
|
if (entry.isDirectory()) {
|
|
37045
37265
|
if (SKIP_DIRS.has(entry.name) || isIgnored(dirLayers, dirRel, entry.name, true)) continue;
|
|
37046
|
-
const fullPath =
|
|
37047
|
-
if (
|
|
37266
|
+
const fullPath = join22(dir, entry.name);
|
|
37267
|
+
if (existsSync11(join22(fullPath, ".git"))) continue;
|
|
37048
37268
|
if (depth >= bounds.maxDepth) {
|
|
37049
37269
|
walk.omitted = true;
|
|
37050
37270
|
continue;
|
|
@@ -37145,9 +37365,9 @@ var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
|
37145
37365
|
|
|
37146
37366
|
// ../../packages/plugin-sdk/src/throttle.ts
|
|
37147
37367
|
import { mkdirSync as mkdirSync4, statSync as statSync8, writeFileSync as writeFileSync7 } from "fs";
|
|
37148
|
-
import { join as
|
|
37368
|
+
import { join as join23 } from "path";
|
|
37149
37369
|
function throttled(dataDir2, markerName, windowMs) {
|
|
37150
|
-
const marker =
|
|
37370
|
+
const marker = join23(dataDir2, markerName);
|
|
37151
37371
|
try {
|
|
37152
37372
|
if (Date.now() - statSync8(marker).mtimeMs < windowMs) return true;
|
|
37153
37373
|
} catch {
|
|
@@ -37198,7 +37418,7 @@ function parseBreakerState(raw, nowMs) {
|
|
|
37198
37418
|
}
|
|
37199
37419
|
function createForwardPolicy(deps) {
|
|
37200
37420
|
const now = deps.now ?? (() => Date.now());
|
|
37201
|
-
const file2 =
|
|
37421
|
+
const file2 = join24(deps.dir, STATE_FILENAME);
|
|
37202
37422
|
let state = null;
|
|
37203
37423
|
let loading = null;
|
|
37204
37424
|
async function readState() {
|
|
@@ -37920,8 +38140,8 @@ function toolAuditEvent(input2) {
|
|
|
37920
38140
|
}
|
|
37921
38141
|
|
|
37922
38142
|
// ../../packages/plugin-runtime/src/attached/history-state.ts
|
|
37923
|
-
import { readFileSync as
|
|
37924
|
-
import { join as
|
|
38143
|
+
import { readFileSync as readFileSync16 } from "fs";
|
|
38144
|
+
import { join as join25 } from "path";
|
|
37925
38145
|
|
|
37926
38146
|
// ../../packages/plugin-runtime/src/attached/history-sync.ts
|
|
37927
38147
|
import { createHash as createHash6 } from "crypto";
|
|
@@ -37962,14 +38182,14 @@ function spawnDetached(scriptPath) {
|
|
|
37962
38182
|
}
|
|
37963
38183
|
|
|
37964
38184
|
// ../../packages/plugin-runtime/src/attached/plugin-block.ts
|
|
37965
|
-
import { readFileSync as
|
|
38185
|
+
import { readFileSync as readFileSync17 } from "fs";
|
|
37966
38186
|
var manifestBuildCache = /* @__PURE__ */ new Map();
|
|
37967
38187
|
function readManifestBuild(manifestUrl, packageName) {
|
|
37968
38188
|
const key = manifestUrl.href;
|
|
37969
38189
|
if (!manifestBuildCache.has(key)) {
|
|
37970
38190
|
let build;
|
|
37971
38191
|
try {
|
|
37972
|
-
const manifest = JSON.parse(
|
|
38192
|
+
const manifest = JSON.parse(readFileSync17(manifestUrl, "utf8"));
|
|
37973
38193
|
build = typeof manifest.version === "string" && manifest.version.length > 0 ? { package: packageName, version: manifest.version } : void 0;
|
|
37974
38194
|
} catch {
|
|
37975
38195
|
build = void 0;
|
|
@@ -37996,7 +38216,7 @@ function createPluginBlock(build, policyStore) {
|
|
|
37996
38216
|
// ../../packages/plugin-runtime/src/attached/policy-store.ts
|
|
37997
38217
|
import { randomUUID as randomUUID16 } from "crypto";
|
|
37998
38218
|
import { readFile as readFile2, rm, writeFile as writeFile2 } from "fs/promises";
|
|
37999
|
-
import { join as
|
|
38219
|
+
import { join as join26 } from "path";
|
|
38000
38220
|
|
|
38001
38221
|
// ../../packages/plugin-runtime/src/attached/atomic-publish.ts
|
|
38002
38222
|
import { rename as rename2 } from "fs/promises";
|
|
@@ -38020,7 +38240,7 @@ async function publishByRename(tmp, file2, move = rename2) {
|
|
|
38020
38240
|
|
|
38021
38241
|
// ../../packages/plugin-runtime/src/attached/policy-store.ts
|
|
38022
38242
|
function createPolicyStore(dir = dataDir()) {
|
|
38023
|
-
const file2 =
|
|
38243
|
+
const file2 = join26(dir, "policy-cache.json");
|
|
38024
38244
|
async function read() {
|
|
38025
38245
|
try {
|
|
38026
38246
|
const raw = await readFile2(file2, "utf8");
|
|
@@ -38251,11 +38471,11 @@ function readStorePosture(dbPath2) {
|
|
|
38251
38471
|
// ../../packages/plugin-runtime/src/attached/posture-store.ts
|
|
38252
38472
|
import { randomUUID as randomUUID17 } from "crypto";
|
|
38253
38473
|
import { readFile as readFile3, rm as rm2, writeFile as writeFile3 } from "fs/promises";
|
|
38254
|
-
import { join as
|
|
38474
|
+
import { join as join27 } from "path";
|
|
38255
38475
|
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
38256
38476
|
function createPostureStore(dir = settingsDir(), legacyDir) {
|
|
38257
|
-
const file2 =
|
|
38258
|
-
const legacyFile = legacyDir === void 0 ? null :
|
|
38477
|
+
const file2 = join27(dir, "posture-state.json");
|
|
38478
|
+
const legacyFile = legacyDir === void 0 ? null : join27(legacyDir, "posture-state.json");
|
|
38259
38479
|
async function persist(state) {
|
|
38260
38480
|
await ensureDataDir(dir);
|
|
38261
38481
|
const tmp = `${file2}.${randomUUID17()}.tmp`;
|
|
@@ -38323,8 +38543,8 @@ function createPostureStore(dir = settingsDir(), legacyDir) {
|
|
|
38323
38543
|
}
|
|
38324
38544
|
|
|
38325
38545
|
// ../../packages/plugin-runtime/src/attached/sync-state.ts
|
|
38326
|
-
import { readFileSync as
|
|
38327
|
-
import { join as
|
|
38546
|
+
import { readFileSync as readFileSync18 } from "fs";
|
|
38547
|
+
import { join as join28 } from "path";
|
|
38328
38548
|
|
|
38329
38549
|
// ../../packages/plugin-runtime/src/attached/status.ts
|
|
38330
38550
|
var REFUSAL_LINES = {
|
|
@@ -38964,7 +39184,7 @@ function pluginBuild() {
|
|
|
38964
39184
|
|
|
38965
39185
|
// src/history/reconcile-trigger.ts
|
|
38966
39186
|
import { spawn as spawn3 } from "child_process";
|
|
38967
|
-
import { dirname as dirname6, join as
|
|
39187
|
+
import { dirname as dirname6, join as join30 } from "path";
|
|
38968
39188
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
38969
39189
|
|
|
38970
39190
|
// src/history/tail.ts
|
|
@@ -38974,11 +39194,11 @@ import {
|
|
|
38974
39194
|
fstatSync as fstatSync2,
|
|
38975
39195
|
mkdirSync as mkdirSync5,
|
|
38976
39196
|
openSync as openSync3,
|
|
38977
|
-
readFileSync as
|
|
39197
|
+
readFileSync as readFileSync19,
|
|
38978
39198
|
readSync as readSync2,
|
|
38979
39199
|
writeFileSync as writeFileSync8
|
|
38980
39200
|
} from "fs";
|
|
38981
|
-
import { join as
|
|
39201
|
+
import { join as join29 } from "path";
|
|
38982
39202
|
var SAFE_SESSION_ID = /^[A-Za-z0-9._-]+$/;
|
|
38983
39203
|
function safeSessionId(sessionId) {
|
|
38984
39204
|
if (SAFE_SESSION_ID.test(sessionId) && sessionId !== "." && sessionId !== "..") {
|
|
@@ -38995,7 +39215,7 @@ function triggerReconcile(dataDir2, sessionId, transcriptPath) {
|
|
|
38995
39215
|
const marker = `${RECONCILE_MARKER_PREFIX}-${safeSessionId(sessionId)}`;
|
|
38996
39216
|
if (throttled(dataDir2, marker, RECONCILE_THROTTLE_MS)) return;
|
|
38997
39217
|
const here = dirname6(fileURLToPath4(import.meta.url));
|
|
38998
|
-
const child = spawn3(process.execPath, [
|
|
39218
|
+
const child = spawn3(process.execPath, [join30(here, "reconcile.js"), sessionId, transcriptPath], {
|
|
38999
39219
|
detached: true,
|
|
39000
39220
|
stdio: "ignore"
|
|
39001
39221
|
});
|
|
@@ -39005,9 +39225,9 @@ function triggerReconcile(dataDir2, sessionId, transcriptPath) {
|
|
|
39005
39225
|
}
|
|
39006
39226
|
|
|
39007
39227
|
// src/history/transcripts.ts
|
|
39008
|
-
import { closeSync as closeSync4, openSync as openSync4, readdirSync as readdirSync5, readFileSync as
|
|
39228
|
+
import { closeSync as closeSync4, openSync as openSync4, readdirSync as readdirSync5, readFileSync as readFileSync20, readSync as readSync3, statSync as statSync10 } from "fs";
|
|
39009
39229
|
import { homedir as homedir3 } from "os";
|
|
39010
|
-
import { join as
|
|
39230
|
+
import { join as join31 } from "path";
|
|
39011
39231
|
function isRecord(value) {
|
|
39012
39232
|
return typeof value === "object" && value !== null;
|
|
39013
39233
|
}
|
|
@@ -39081,8 +39301,8 @@ function getString(record2, key) {
|
|
|
39081
39301
|
}
|
|
39082
39302
|
|
|
39083
39303
|
// src/hooks/store-health.ts
|
|
39084
|
-
import { mkdirSync as mkdirSync6, readFileSync as
|
|
39085
|
-
import { dirname as dirname7, join as
|
|
39304
|
+
import { mkdirSync as mkdirSync6, readFileSync as readFileSync21, writeFileSync as writeFileSync9 } from "fs";
|
|
39305
|
+
import { dirname as dirname7, join as join32 } from "path";
|
|
39086
39306
|
var STORE_REDIRECT_MARKER = "store-redirect-last-session";
|
|
39087
39307
|
function markerDirs(dataDir2) {
|
|
39088
39308
|
return [dataDir2, dirname7(dataDir2)];
|
|
@@ -39090,7 +39310,7 @@ function markerDirs(dataDir2) {
|
|
|
39090
39310
|
function alreadyClaimed(dirs, marker, sessionId) {
|
|
39091
39311
|
return dirs.some((dir) => {
|
|
39092
39312
|
try {
|
|
39093
|
-
return
|
|
39313
|
+
return readFileSync21(join32(dir, marker), "utf8") === sessionId;
|
|
39094
39314
|
} catch {
|
|
39095
39315
|
return false;
|
|
39096
39316
|
}
|
|
@@ -39100,7 +39320,7 @@ function recordClaim(dirs, marker, sessionId) {
|
|
|
39100
39320
|
for (const dir of dirs) {
|
|
39101
39321
|
try {
|
|
39102
39322
|
mkdirSync6(dir, { recursive: true, mode: DATA_DIR_MODE });
|
|
39103
|
-
writeFileSync9(
|
|
39323
|
+
writeFileSync9(join32(dir, marker), sessionId, { mode: DATA_FILE_MODE });
|
|
39104
39324
|
return;
|
|
39105
39325
|
} catch {
|
|
39106
39326
|
}
|
|
@@ -39144,7 +39364,7 @@ function harnessVersion() {
|
|
|
39144
39364
|
const manifestPath = process.argv[2];
|
|
39145
39365
|
if (!manifestPath) return void 0;
|
|
39146
39366
|
try {
|
|
39147
|
-
const manifest = JSON.parse(
|
|
39367
|
+
const manifest = JSON.parse(readFileSync22(manifestPath, "utf8"));
|
|
39148
39368
|
return typeof manifest.version === "string" ? manifest.version : void 0;
|
|
39149
39369
|
} catch {
|
|
39150
39370
|
return void 0;
|