@akasecurity/cli 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/README.md +12 -12
- package/dist/cli.js +1466 -766
- package/extension/manifest.json +1 -1
- package/native-host/host.js +756 -528
- package/native-host/scan-worker.js +153 -58
- package/native-host/sync.js +284 -103
- package/package.json +5 -5
- package/web-ui/package.json +1 -1
- package/web-ui/web-ui/.next/BUILD_ID +1 -1
- package/web-ui/web-ui/.next/app-build-manifest.json +64 -64
- package/web-ui/web-ui/.next/app-path-routes-manifest.json +5 -5
- package/web-ui/web-ui/.next/build-manifest.json +2 -2
- package/web-ui/web-ui/.next/prerender-manifest.json +14 -14
- package/web-ui/web-ui/.next/server/app/(app)/activity/page.js +2 -2
- package/web-ui/web-ui/.next/server/app/(app)/activity/page.js.nft.json +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/activity/page_client-reference-manifest.js +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/data-shares/page.js +2 -2
- package/web-ui/web-ui/.next/server/app/(app)/data-shares/page.js.nft.json +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/data-shares/page_client-reference-manifest.js +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/detections/page.js +2 -2
- package/web-ui/web-ui/.next/server/app/(app)/detections/page.js.nft.json +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/detections/page_client-reference-manifest.js +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/exceptions/[id]/page.js +2 -2
- package/web-ui/web-ui/.next/server/app/(app)/exceptions/[id]/page.js.nft.json +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/exceptions/[id]/page_client-reference-manifest.js +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/exceptions/new/page.js +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/exceptions/new/page.js.nft.json +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/exceptions/new/page_client-reference-manifest.js +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/exceptions/page.js +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/exceptions/page.js.nft.json +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/exceptions/page_client-reference-manifest.js +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/findings/page.js +2 -2
- package/web-ui/web-ui/.next/server/app/(app)/findings/page.js.nft.json +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/findings/page_client-reference-manifest.js +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/inventory/page.js +2 -2
- package/web-ui/web-ui/.next/server/app/(app)/inventory/page.js.nft.json +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/inventory/page_client-reference-manifest.js +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/policies/page.js +2 -2
- package/web-ui/web-ui/.next/server/app/(app)/policies/page.js.nft.json +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/policies/page_client-reference-manifest.js +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/scan/page.js +3 -3
- package/web-ui/web-ui/.next/server/app/(app)/scan/page.js.nft.json +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/scan/page_client-reference-manifest.js +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/security/page.js +2 -2
- package/web-ui/web-ui/.next/server/app/(app)/security/page.js.nft.json +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/security/page_client-reference-manifest.js +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/settings/page.js +2 -2
- package/web-ui/web-ui/.next/server/app/(app)/settings/page.js.nft.json +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/settings/page_client-reference-manifest.js +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/updates/page.js +2 -2
- package/web-ui/web-ui/.next/server/app/(app)/updates/page.js.nft.json +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/updates/page_client-reference-manifest.js +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/vault/page.js +2 -2
- package/web-ui/web-ui/.next/server/app/(app)/vault/page.js.nft.json +1 -1
- package/web-ui/web-ui/.next/server/app/(app)/vault/page_client-reference-manifest.js +1 -1
- package/web-ui/web-ui/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/web-ui/web-ui/.next/server/app/_not-found.html +1 -1
- package/web-ui/web-ui/.next/server/app/_not-found.rsc +2 -2
- package/web-ui/web-ui/.next/server/app/index.html +1 -1
- package/web-ui/web-ui/.next/server/app/index.rsc +2 -2
- package/web-ui/web-ui/.next/server/app/page_client-reference-manifest.js +1 -1
- package/web-ui/web-ui/.next/server/app-paths-manifest.json +5 -5
- package/web-ui/web-ui/.next/server/chunks/471.js +950 -0
- package/web-ui/web-ui/.next/server/chunks/475.js +1 -1
- package/web-ui/web-ui/.next/server/chunks/7.js +1 -1
- package/web-ui/web-ui/.next/server/chunks/739.js +1 -0
- package/web-ui/web-ui/.next/server/chunks/766.js +6 -0
- package/web-ui/web-ui/.next/server/chunks/851.js +1 -1
- package/web-ui/web-ui/.next/server/chunks/905.js +959 -0
- package/web-ui/web-ui/.next/server/functions-config-manifest.json +5 -5
- package/web-ui/web-ui/.next/server/middleware-manifest.json +5 -5
- package/web-ui/web-ui/.next/server/pages/404.html +1 -1
- package/web-ui/web-ui/.next/server/pages/500.html +1 -1
- package/web-ui/web-ui/.next/server/server-reference-manifest.js +1 -1
- package/web-ui/web-ui/.next/server/server-reference-manifest.json +1 -1
- package/web-ui/web-ui/.next/static/chunks/907-2ba9428e7818b656.js +1 -0
- package/web-ui/web-ui/.next/static/chunks/app/(app)/activity/page-c5a55618d187c906.js +1 -0
- package/web-ui/web-ui/.next/static/chunks/app/(app)/data-shares/page-b1c76b8c00e1ae2a.js +1 -0
- package/web-ui/web-ui/.next/static/chunks/app/(app)/detections/page-159167b47a005b33.js +1 -0
- package/web-ui/web-ui/.next/static/chunks/app/(app)/error-dead9507fc349f26.js +1 -0
- package/web-ui/web-ui/.next/static/chunks/app/(app)/exceptions/[id]/page-5e872a82af85ef64.js +1 -0
- package/web-ui/web-ui/.next/static/chunks/app/(app)/exceptions/new/page-0695d0006518b2cb.js +1 -0
- package/web-ui/web-ui/.next/static/chunks/app/(app)/exceptions/page-adec99f2f4bbc180.js +1 -0
- package/web-ui/web-ui/.next/static/chunks/app/(app)/findings/page-d013384d2ddb3036.js +1 -0
- package/web-ui/web-ui/.next/static/chunks/app/(app)/inventory/page-42c1b48a01fdecb0.js +1 -0
- package/web-ui/web-ui/.next/static/chunks/app/(app)/layout-dc7ae7664dcdc3c5.js +1 -0
- package/web-ui/web-ui/.next/static/chunks/app/(app)/policies/page-9b6d7cc4ce9fb33e.js +1 -0
- package/web-ui/web-ui/.next/static/chunks/app/(app)/scan/page-f3ee9ecde06df153.js +1 -0
- package/web-ui/web-ui/.next/static/chunks/app/(app)/security/page-24a003c709776317.js +1 -0
- package/web-ui/web-ui/.next/static/chunks/app/(app)/settings/page-4ea49ce2e765fffb.js +1 -0
- package/web-ui/web-ui/.next/static/chunks/app/(app)/updates/page-6c7b94b070de8986.js +1 -0
- package/web-ui/web-ui/.next/static/chunks/app/(app)/vault/page-f37ab8e1edc67663.js +1 -0
- package/web-ui/web-ui/.next/static/css/c6954dd65f2115e6.css +2 -0
- package/web-ui/web-ui/dist/scan-worker.js +153 -58
- package/web-ui/web-ui/.next/server/chunks/389.js +0 -903
- package/web-ui/web-ui/.next/server/chunks/667.js +0 -894
- package/web-ui/web-ui/.next/server/chunks/950.js +0 -6
- package/web-ui/web-ui/.next/static/chunks/907-207847c57011ba44.js +0 -1
- package/web-ui/web-ui/.next/static/chunks/app/(app)/activity/page-e4f94a75c631ce86.js +0 -1
- package/web-ui/web-ui/.next/static/chunks/app/(app)/data-shares/page-d70fcc5612f380b7.js +0 -1
- package/web-ui/web-ui/.next/static/chunks/app/(app)/detections/page-e1823ce15bb6277d.js +0 -1
- package/web-ui/web-ui/.next/static/chunks/app/(app)/error-14165283b00c8626.js +0 -1
- package/web-ui/web-ui/.next/static/chunks/app/(app)/exceptions/[id]/page-0fcffe4b9dff201f.js +0 -1
- package/web-ui/web-ui/.next/static/chunks/app/(app)/exceptions/new/page-c95079a2acd284fd.js +0 -1
- package/web-ui/web-ui/.next/static/chunks/app/(app)/exceptions/page-4b9f034bd078f5d3.js +0 -1
- package/web-ui/web-ui/.next/static/chunks/app/(app)/findings/page-b97fc083884ef341.js +0 -1
- package/web-ui/web-ui/.next/static/chunks/app/(app)/inventory/page-e96e7e947ed5f279.js +0 -1
- package/web-ui/web-ui/.next/static/chunks/app/(app)/layout-83072d434c6b6b0e.js +0 -1
- package/web-ui/web-ui/.next/static/chunks/app/(app)/policies/page-b90748d139a546c9.js +0 -1
- package/web-ui/web-ui/.next/static/chunks/app/(app)/scan/page-7a46abe149271870.js +0 -1
- package/web-ui/web-ui/.next/static/chunks/app/(app)/security/page-f4a1ee202d6e60a4.js +0 -1
- package/web-ui/web-ui/.next/static/chunks/app/(app)/settings/page-2ec6d863f1a31792.js +0 -1
- package/web-ui/web-ui/.next/static/chunks/app/(app)/updates/page-b388003fb0d3efd1.js +0 -1
- package/web-ui/web-ui/.next/static/chunks/app/(app)/vault/page-6bda74d234a1376a.js +0 -1
- package/web-ui/web-ui/.next/static/css/81a7ed955b02c959.css +0 -2
- /package/web-ui/web-ui/.next/static/{k7tk0MLkPITbi_x6JL01X → osEmGZG6yEV-XkQlklt-B}/_buildManifest.js +0 -0
- /package/web-ui/web-ui/.next/static/{k7tk0MLkPITbi_x6JL01X → osEmGZG6yEV-XkQlklt-B}/_ssgManifest.js +0 -0
package/native-host/host.js
CHANGED
|
@@ -494,9 +494,6 @@ var require_ignore = __commonJS({
|
|
|
494
494
|
// src/native-host/host.ts
|
|
495
495
|
import { homedir as homedir3 } from "os";
|
|
496
496
|
|
|
497
|
-
// ../../packages/plugin-runtime/src/attached/egress-wire.ts
|
|
498
|
-
import { createHash as createHash4 } from "crypto";
|
|
499
|
-
|
|
500
497
|
// ../../packages/persistence/src/attached-derived.ts
|
|
501
498
|
import { rmSync } from "fs";
|
|
502
499
|
import { join } from "path";
|
|
@@ -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 name2 of lockedFields) {
|
|
24007
|
+
if (isManagedSettingKey(name2)) known.push(name2);
|
|
24008
|
+
else unknown2.push(name2);
|
|
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.
|
|
@@ -25703,7 +25746,8 @@ var SqliteActivityRepository = class {
|
|
|
25703
25746
|
SELECT 1 FROM audit_events d
|
|
25704
25747
|
WHERE d.root_session_id = audit_events.id
|
|
25705
25748
|
AND (d.content LIKE ? ESCAPE '\\'
|
|
25706
|
-
OR json_extract(d.attributes, '$.detail')
|
|
25749
|
+
OR coalesce(json_extract(d.attributes, '$.detail'),
|
|
25750
|
+
json_extract(d.attributes, '$.target')) LIKE ? ESCAPE '\\')))`
|
|
25707
25751
|
);
|
|
25708
25752
|
params.push(pattern, pattern, pattern, pattern, pattern, pattern);
|
|
25709
25753
|
}
|
|
@@ -27041,23 +27085,6 @@ var LATEST_RESOLUTION_BY_KEY_SQL = `(
|
|
|
27041
27085
|
)`;
|
|
27042
27086
|
|
|
27043
27087
|
// ../../packages/persistence/src/repositories/findings.ts
|
|
27044
|
-
var PREVIEW_INSTANCES_PER_GROUP = 200;
|
|
27045
|
-
var DEFAULT_LOCATIONS_LIMIT = 100;
|
|
27046
|
-
var LOCATION_RULE_IDS_CAP = 20;
|
|
27047
|
-
function compareLocationOrder(a, b) {
|
|
27048
|
-
return compareFindingGroupOrder(
|
|
27049
|
-
{
|
|
27050
|
-
severity: a.maxSeverity,
|
|
27051
|
-
latestDetectedAt: a.latestDetectedAt,
|
|
27052
|
-
id: ""
|
|
27053
|
-
},
|
|
27054
|
-
{
|
|
27055
|
-
severity: b.maxSeverity,
|
|
27056
|
-
latestDetectedAt: b.latestDetectedAt,
|
|
27057
|
-
id: ""
|
|
27058
|
-
}
|
|
27059
|
-
);
|
|
27060
|
-
}
|
|
27061
27088
|
var CONCAT_SEP = ",";
|
|
27062
27089
|
var TUPLE_SEP = "|";
|
|
27063
27090
|
function splitConcat(value) {
|
|
@@ -27109,13 +27136,48 @@ function decodeGroupCursor(cursor) {
|
|
|
27109
27136
|
return null;
|
|
27110
27137
|
}
|
|
27111
27138
|
function firstAfter(sorted, cursor) {
|
|
27112
|
-
const index = sorted.findIndex((
|
|
27139
|
+
const index = sorted.findIndex((t) => compareFindingGroupOrder(t, cursor) > 0);
|
|
27113
27140
|
return index === -1 ? sorted.length : index;
|
|
27114
27141
|
}
|
|
27115
27142
|
function findDeepLinked(sorted, page, id) {
|
|
27116
|
-
if (page.some((
|
|
27117
|
-
return sorted.find((
|
|
27143
|
+
if (page.some((t) => t.id === id)) return void 0;
|
|
27144
|
+
return sorted.find((t) => t.id === id);
|
|
27118
27145
|
}
|
|
27146
|
+
function encodeLocationCursor(location) {
|
|
27147
|
+
const payload = {
|
|
27148
|
+
sev: location.maxSeverity,
|
|
27149
|
+
t: location.latestDetectedAt,
|
|
27150
|
+
r: location.repo,
|
|
27151
|
+
f: location.file
|
|
27152
|
+
};
|
|
27153
|
+
return Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
27154
|
+
}
|
|
27155
|
+
function decodeLocationCursor(cursor) {
|
|
27156
|
+
const parsed2 = parseJsonObject(Buffer.from(cursor, "base64url").toString("utf8"));
|
|
27157
|
+
if (parsed2 !== void 0 && typeof parsed2.sev === "string" && typeof parsed2.t === "string" && typeof parsed2.r === "string" && typeof parsed2.f === "string") {
|
|
27158
|
+
return { maxSeverity: parsed2.sev, latestDetectedAt: parsed2.t, repo: parsed2.r, file: parsed2.f };
|
|
27159
|
+
}
|
|
27160
|
+
return null;
|
|
27161
|
+
}
|
|
27162
|
+
function firstLocationAfter(sorted, cursor) {
|
|
27163
|
+
const index = sorted.findIndex((l) => compareLocationOrder(l, cursor) > 0);
|
|
27164
|
+
return index === -1 ? sorted.length : index;
|
|
27165
|
+
}
|
|
27166
|
+
function findDeepLinkedLocation(sorted, page, id) {
|
|
27167
|
+
if (page.some((l) => l.id === id)) return void 0;
|
|
27168
|
+
return sorted.find((l) => l.id === id);
|
|
27169
|
+
}
|
|
27170
|
+
var FINDING_ROW_COLUMNS_SQL = `f.id AS id, d.rule_id AS rule_id, d.category AS category,
|
|
27171
|
+
d.severity AS severity, f.masked_match AS masked_match,
|
|
27172
|
+
f.action_taken AS action_taken, f.confidence AS confidence,
|
|
27173
|
+
e.started_at AS occurred_at,
|
|
27174
|
+
e.source_tool AS source_tool,
|
|
27175
|
+
e.repo AS repo,
|
|
27176
|
+
e.file_path AS file,
|
|
27177
|
+
e.tool_name AS tool_name,
|
|
27178
|
+
f.audit_event_id AS event_id, e.root_session_id AS session_id,
|
|
27179
|
+
e.event_type AS kind, f.finding_key AS finding_key,
|
|
27180
|
+
${latestResolutionStatusSql("f")} AS latest_status`;
|
|
27119
27181
|
var DAY_MS3 = 864e5;
|
|
27120
27182
|
var SqliteFindingsRepository = class {
|
|
27121
27183
|
constructor(db) {
|
|
@@ -27236,30 +27298,26 @@ var SqliteFindingsRepository = class {
|
|
|
27236
27298
|
);
|
|
27237
27299
|
}
|
|
27238
27300
|
/**
|
|
27239
|
-
*
|
|
27240
|
-
*
|
|
27241
|
-
*
|
|
27242
|
-
*
|
|
27243
|
-
*
|
|
27244
|
-
*
|
|
27245
|
-
*
|
|
27246
|
-
*
|
|
27247
|
-
*
|
|
27248
|
-
*
|
|
27249
|
-
*
|
|
27250
|
-
*
|
|
27301
|
+
* Finding TYPES for the dashboard — one row per rule, scoped to the four
|
|
27302
|
+
* capture kinds (audit_events also holds structural/reconciler/scan rows this
|
|
27303
|
+
* list must never surface), with per-filter-excluded facets, the requested
|
|
27304
|
+
* filters applied, and sorted by severity then recency. Filtering and faceting
|
|
27305
|
+
* run in JS via the shared @akasecurity/schema helpers. `totals` reflect the
|
|
27306
|
+
* full filtered set; `items` is the requested page (default 50), keyset-paged.
|
|
27307
|
+
* Under a `status` filter, `totals.findings` counts only findings whose
|
|
27308
|
+
* derived status was requested.
|
|
27309
|
+
*
|
|
27310
|
+
* ONE read, which materializes no findings: a single aggregate per rule_id,
|
|
27311
|
+
* folding EVERY finding into the numbers a type row and the filters need
|
|
27312
|
+
* (count, severity, category, providers, actions, statuses, latest, search
|
|
27313
|
+
* text). The findings OF a type come from listFindingInstances scoped to
|
|
27314
|
+
* `subtype`, so neither list bounds the other and no per-type cap exists.
|
|
27251
27315
|
*
|
|
27252
|
-
* Two reads, neither of which materializes a row per finding:
|
|
27253
|
-
* 1. one aggregate row per rule_id, folding EVERY instance into the numbers
|
|
27254
|
-
* the group and the filters need (count, providers, actions, statuses,
|
|
27255
|
-
* latest, search text);
|
|
27256
|
-
* 2. each group's newest PREVIEW_INSTANCES_PER_GROUP instances, which
|
|
27257
|
-
* populate `instances` for the table's expanded rows.
|
|
27258
27316
|
* The aggregates carry raw DB values and are translated by the same
|
|
27259
|
-
* @akasecurity/schema mappers
|
|
27260
|
-
* rule is ever restated in SQL.
|
|
27317
|
+
* @akasecurity/schema mappers every other path uses, so no enum mapping or
|
|
27318
|
+
* status rule is ever restated in SQL.
|
|
27261
27319
|
*/
|
|
27262
|
-
|
|
27320
|
+
listFindingTypes(query) {
|
|
27263
27321
|
const sessionPredicate = query.sessionId ? ` AND e.root_session_id = :sessionId` : "";
|
|
27264
27322
|
const fromMs = query.from === void 0 ? void 0 : isoToEpochMillis(query.from);
|
|
27265
27323
|
const fromPredicate = fromMs === void 0 ? "" : ` AND e.started_at >= :fromMs`;
|
|
@@ -27272,12 +27330,7 @@ var SqliteFindingsRepository = class {
|
|
|
27272
27330
|
predicate,
|
|
27273
27331
|
params: sessionParams
|
|
27274
27332
|
});
|
|
27275
|
-
const
|
|
27276
|
-
sessionId: query.sessionId,
|
|
27277
|
-
from: query.from
|
|
27278
|
-
});
|
|
27279
|
-
const groupable = rows.map(toFlatFindingRow);
|
|
27280
|
-
const allGroups = buildFindingGroups(groupable, { aggregates });
|
|
27333
|
+
const allTypes = buildFindingTypes(aggregates);
|
|
27281
27334
|
const filterOpts = {
|
|
27282
27335
|
severity: query.severity,
|
|
27283
27336
|
providers: query.provider,
|
|
@@ -27286,30 +27339,25 @@ var SqliteFindingsRepository = class {
|
|
|
27286
27339
|
subtype: query.subtype,
|
|
27287
27340
|
q: query.q
|
|
27288
27341
|
};
|
|
27289
|
-
const facets = computeFindingFacets(
|
|
27290
|
-
const sorted =
|
|
27342
|
+
const facets = computeFindingFacets(allTypes, filterOpts);
|
|
27343
|
+
const sorted = sortFindingTypes(applyFindingFilters(allTypes, filterOpts));
|
|
27291
27344
|
const statusFilter = query.status ?? [];
|
|
27292
27345
|
const totals = {
|
|
27293
|
-
findings: sorted.reduce((acc,
|
|
27294
|
-
if (statusFilter.length === 0) return acc +
|
|
27295
|
-
const agg = aggregates.get(
|
|
27296
|
-
return acc + (agg ? countInstancesByStatus(agg.statusInputs, statusFilter) ??
|
|
27346
|
+
findings: sorted.reduce((acc, t) => {
|
|
27347
|
+
if (statusFilter.length === 0) return acc + t.instanceCount;
|
|
27348
|
+
const agg = aggregates.get(t.id);
|
|
27349
|
+
return acc + (agg ? countInstancesByStatus(agg.statusInputs, statusFilter) ?? t.instanceCount : t.instanceCount);
|
|
27297
27350
|
}, 0),
|
|
27298
|
-
|
|
27351
|
+
types: sorted.length
|
|
27299
27352
|
};
|
|
27300
|
-
const limit = query.limit ??
|
|
27353
|
+
const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
|
|
27301
27354
|
const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
|
|
27302
27355
|
const start = cursor === null ? 0 : firstAfter(sorted, cursor);
|
|
27303
27356
|
const page = sorted.slice(start, start + limit);
|
|
27304
27357
|
const lastOnPage = page.at(-1);
|
|
27305
27358
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
|
|
27306
27359
|
const deepLinked = query.includeId === void 0 || query.includeId === "" ? void 0 : findDeepLinked(sorted, page, query.includeId);
|
|
27307
|
-
const
|
|
27308
|
-
const narrow = (g) => statusSet ? {
|
|
27309
|
-
...g,
|
|
27310
|
-
instances: g.instances.filter((i) => i.status !== void 0 && statusSet.has(i.status))
|
|
27311
|
-
} : g;
|
|
27312
|
-
const items = [...page, ...deepLinked ? [deepLinked] : []].map(narrow);
|
|
27360
|
+
const items = [...page, ...deepLinked ? [deepLinked] : []];
|
|
27313
27361
|
return Promise.resolve({
|
|
27314
27362
|
totals,
|
|
27315
27363
|
facets,
|
|
@@ -27320,7 +27368,7 @@ var SqliteFindingsRepository = class {
|
|
|
27320
27368
|
}
|
|
27321
27369
|
/**
|
|
27322
27370
|
* One row per rule_id, folding EVERY instance of the group into the values
|
|
27323
|
-
*
|
|
27371
|
+
* buildFindingTypes cannot recover from an aggregate. Bounded by the number of
|
|
27324
27372
|
* distinct rule_ids (the installed packs' rules), not by the store's size.
|
|
27325
27373
|
*
|
|
27326
27374
|
* A single scan, folded in two levels: the inner SELECT groups by
|
|
@@ -27414,13 +27462,25 @@ var SqliteFindingsRepository = class {
|
|
|
27414
27462
|
});
|
|
27415
27463
|
}
|
|
27416
27464
|
/**
|
|
27417
|
-
* The same findings folded by
|
|
27465
|
+
* The same findings folded by WHERE they live — one row per (repo, file) pair.
|
|
27418
27466
|
*
|
|
27419
27467
|
* The grouping keys come from the capturing event's attributes, which is what
|
|
27420
|
-
* the local store relates a finding to
|
|
27421
|
-
*
|
|
27422
|
-
* empty-string bucket, which
|
|
27423
|
-
*
|
|
27468
|
+
* the local store relates a finding to; there is no finding↔asset row to group
|
|
27469
|
+
* by instead. A repo or file the event did not record folds into the
|
|
27470
|
+
* empty-string bucket, which is a real location like any other: it is listed,
|
|
27471
|
+
* it is selectable, and its `?loc=` token is as good as any other row's.
|
|
27472
|
+
*
|
|
27473
|
+
* ONE flat list rather than repos nesting files. A rollup can only be paged by
|
|
27474
|
+
* repo, which leaves the file list inside it unbounded — the shape the by-type
|
|
27475
|
+
* list was rebuilt to remove — and two-level pagination inside an
|
|
27476
|
+
* expand/collapse table is what pushed that view to master/detail in the first
|
|
27477
|
+
* place.
|
|
27478
|
+
*
|
|
27479
|
+
* Every filter narrows the FINDINGS and the locations fall out of what
|
|
27480
|
+
* survives, so each row's `instanceCount` is exactly what listFindingInstances
|
|
27481
|
+
* reports for the same filters scoped to that pair. The view depends on it:
|
|
27482
|
+
* one toolbar sits over both panels precisely because a location owns none of
|
|
27483
|
+
* its fields.
|
|
27424
27484
|
*/
|
|
27425
27485
|
listFindingLocations(query) {
|
|
27426
27486
|
const opts = {
|
|
@@ -27432,13 +27492,16 @@ var SqliteFindingsRepository = class {
|
|
|
27432
27492
|
tools: query.tool,
|
|
27433
27493
|
q: query.q
|
|
27434
27494
|
};
|
|
27435
|
-
const limit = query.limit ??
|
|
27495
|
+
const limit = query.limit ?? DEFAULT_FINDING_LOCATIONS_LIMIT;
|
|
27496
|
+
const cursor = query.cursor === void 0 ? null : decodeLocationCursor(query.cursor);
|
|
27436
27497
|
const byRepo = /* @__PURE__ */ new Map();
|
|
27498
|
+
const accumulator = createInstanceFacetAccumulator(opts);
|
|
27437
27499
|
let total = 0;
|
|
27438
27500
|
for (const row of this.scanFindingRows({
|
|
27439
27501
|
sessionId: query.sessionId,
|
|
27440
27502
|
from: query.from
|
|
27441
27503
|
})) {
|
|
27504
|
+
accumulator.add(row);
|
|
27442
27505
|
if (!matchesInstanceFilters(row, opts)) continue;
|
|
27443
27506
|
total += 1;
|
|
27444
27507
|
let files = byRepo.get(row.repo);
|
|
@@ -27453,103 +27516,35 @@ var SqliteFindingsRepository = class {
|
|
|
27453
27516
|
}
|
|
27454
27517
|
addToLocation(acc, row);
|
|
27455
27518
|
}
|
|
27456
|
-
|
|
27457
|
-
const
|
|
27458
|
-
|
|
27459
|
-
|
|
27460
|
-
|
|
27461
|
-
|
|
27462
|
-
|
|
27463
|
-
|
|
27464
|
-
|
|
27465
|
-
|
|
27466
|
-
|
|
27467
|
-
|
|
27468
|
-
|
|
27469
|
-
|
|
27470
|
-
|
|
27471
|
-
|
|
27472
|
-
|
|
27473
|
-
|
|
27474
|
-
|
|
27475
|
-
|
|
27476
|
-
|
|
27477
|
-
|
|
27478
|
-
);
|
|
27479
|
-
const statuses = fileRows.map((f) => f.status);
|
|
27480
|
-
const folded = foldGroupStatus(statuses);
|
|
27481
|
-
return {
|
|
27482
|
-
repo,
|
|
27483
|
-
instanceCount: rollup.instanceCount,
|
|
27484
|
-
maxSeverity: rollup.maxSeverity,
|
|
27485
|
-
latestDetectedAt: rollup.latestDetectedAt,
|
|
27486
|
-
...folded === void 0 ? {} : { status: folded },
|
|
27487
|
-
files: fileRows
|
|
27488
|
-
};
|
|
27489
|
-
});
|
|
27490
|
-
repos.sort(compareLocationOrder);
|
|
27519
|
+
const sorted = [];
|
|
27520
|
+
for (const [repo, files] of byRepo) {
|
|
27521
|
+
for (const [file2, acc] of files) {
|
|
27522
|
+
const status = foldGroupStatus(acc.statuses);
|
|
27523
|
+
sorted.push({
|
|
27524
|
+
id: encodeLocationId(repo, file2),
|
|
27525
|
+
repo,
|
|
27526
|
+
file: file2,
|
|
27527
|
+
instanceCount: acc.instanceCount,
|
|
27528
|
+
maxSeverity: acc.maxSeverity,
|
|
27529
|
+
latestDetectedAt: acc.latestDetectedAt,
|
|
27530
|
+
...status === void 0 ? {} : { status },
|
|
27531
|
+
ruleIds: [...acc.ruleIds]
|
|
27532
|
+
});
|
|
27533
|
+
}
|
|
27534
|
+
}
|
|
27535
|
+
sorted.sort(compareLocationOrder);
|
|
27536
|
+
const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
|
|
27537
|
+
const page = sorted.slice(start, start + limit);
|
|
27538
|
+
const lastOnPage = page.at(-1);
|
|
27539
|
+
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
|
|
27540
|
+
const deepLinked = query.includeId === void 0 || query.includeId === "" ? void 0 : findDeepLinkedLocation(sorted, page, query.includeId);
|
|
27491
27541
|
return Promise.resolve({
|
|
27492
|
-
totals: { findings: total,
|
|
27493
|
-
|
|
27494
|
-
|
|
27542
|
+
totals: { findings: total, locations: sorted.length },
|
|
27543
|
+
facets: accumulator.facets(),
|
|
27544
|
+
items: [...page, ...deepLinked ? [deepLinked] : []],
|
|
27545
|
+
nextCursor
|
|
27495
27546
|
});
|
|
27496
27547
|
}
|
|
27497
|
-
/**
|
|
27498
|
-
* Each group's newest instances, for the table's expanded rows.
|
|
27499
|
-
*
|
|
27500
|
-
* ONE index-ordered scan with early termination, and the shape is the point.
|
|
27501
|
-
* The natural spelling — `ROW_NUMBER() OVER (PARTITION BY rule_id ORDER BY
|
|
27502
|
-
* started_at DESC)` then `WHERE rn <= cap` — sorts EVERY finding in scope
|
|
27503
|
-
* through a temp B-tree to keep a bounded preview of each group, and then
|
|
27504
|
-
* sorts the survivors again for the page order. Both sorts grow with the
|
|
27505
|
-
* store while the answer does not.
|
|
27506
|
-
*
|
|
27507
|
-
* Instead the scan walks `audit_events` newest-first off `idx_audit_started_at`
|
|
27508
|
-
* (or the session or window index the scope names — see `findingScanSql`),
|
|
27509
|
-
* which is already the order the page wants, and keeps rows per rule until
|
|
27510
|
-
* each rule has as many as it can show. The aggregate the caller already holds
|
|
27511
|
-
* says how many that is: `min(instanceCount, PREVIEW_INSTANCES_PER_GROUP)`
|
|
27512
|
-
* per rule, summed, is the number of rows this scan has to find, and it stops
|
|
27513
|
-
* on the last one. That sum is bounded by `rules * PREVIEW_INSTANCES_PER_GROUP`
|
|
27514
|
-
* (8,000 at this repo's 40-rule bench corpus), not by a fixed row count — a
|
|
27515
|
-
* store with many firing rules widens it. The bound that DOES hold
|
|
27516
|
-
* unconditionally is the sorted form's floor: this scan visits at most as
|
|
27517
|
-
* many rows as `ROW_NUMBER() OVER (PARTITION BY rule_id …)` would have
|
|
27518
|
-
* sorted, and stops the moment every rule has its cap, where the sorted form
|
|
27519
|
-
* sorts the whole scope regardless. The true worst case — the rarest rule's
|
|
27520
|
-
* wanted instances sitting at the tail of the scope — is one pass over
|
|
27521
|
-
* everything in scope with a block sort of the id tie-break only, never a
|
|
27522
|
-
* sort of the scope, which is still that floor.
|
|
27523
|
-
*
|
|
27524
|
-
* A row whose rule the aggregate did not see is skipped: the two statements
|
|
27525
|
-
* run without a shared snapshot, so a capture landing between them can add a
|
|
27526
|
-
* rule here that has no counts there, and the counts are what the group is
|
|
27527
|
-
* built from.
|
|
27528
|
-
*/
|
|
27529
|
-
previewRows(aggregates, scope) {
|
|
27530
|
-
const wanted = /* @__PURE__ */ new Map();
|
|
27531
|
-
let remaining = 0;
|
|
27532
|
-
for (const [ruleId, agg] of aggregates) {
|
|
27533
|
-
const n = Math.min(agg.instanceCount, PREVIEW_INSTANCES_PER_GROUP);
|
|
27534
|
-
wanted.set(ruleId, n);
|
|
27535
|
-
remaining += n;
|
|
27536
|
-
}
|
|
27537
|
-
const rows = [];
|
|
27538
|
-
if (remaining === 0) return rows;
|
|
27539
|
-
const { sql, params } = this.findingScanSql(scope);
|
|
27540
|
-
const taken = /* @__PURE__ */ new Map();
|
|
27541
|
-
for (const r of iterateRows(this.db.prepare(sql), params)) {
|
|
27542
|
-
const want = wanted.get(r.rule_id);
|
|
27543
|
-
if (want === void 0) continue;
|
|
27544
|
-
const have = taken.get(r.rule_id) ?? 0;
|
|
27545
|
-
if (have >= want) continue;
|
|
27546
|
-
taken.set(r.rule_id, have + 1);
|
|
27547
|
-
rows.push(r);
|
|
27548
|
-
remaining -= 1;
|
|
27549
|
-
if (remaining === 0) break;
|
|
27550
|
-
}
|
|
27551
|
-
return rows;
|
|
27552
|
-
}
|
|
27553
27548
|
/**
|
|
27554
27549
|
* Every finding in scope as a FlatFindingRow, newest first, streamed.
|
|
27555
27550
|
*
|
|
@@ -27576,6 +27571,33 @@ var SqliteFindingsRepository = class {
|
|
|
27576
27571
|
yield toFlatFindingRow(r);
|
|
27577
27572
|
}
|
|
27578
27573
|
}
|
|
27574
|
+
/**
|
|
27575
|
+
* One finding by its own id, or null when no such row exists.
|
|
27576
|
+
*
|
|
27577
|
+
* A primary-key seek on `inspection_findings`, so its cost does not grow with
|
|
27578
|
+
* the store — and, unlike anything derived from a list page, it resolves a
|
|
27579
|
+
* finding of ANY age. That is what the Findings page's one-shot `?finding=`
|
|
27580
|
+
* deep link needs: the id it carries may name a finding thousands of rows
|
|
27581
|
+
* older than anything a first page holds.
|
|
27582
|
+
*
|
|
27583
|
+
* Deliberately UNFILTERED — no capture-kind, session or time predicate. It
|
|
27584
|
+
* RESOLVES an id; whether that row would survive the list's current filters is
|
|
27585
|
+
* a different question, and hiding the target because a filter excludes it is
|
|
27586
|
+
* worse than showing it.
|
|
27587
|
+
*
|
|
27588
|
+
* `groupId` on the result IS the rule id, so this one read answers both "which
|
|
27589
|
+
* type should the list select?" and "what does the drawer show?".
|
|
27590
|
+
*/
|
|
27591
|
+
findingInstance(id) {
|
|
27592
|
+
const row = this.db.prepare(
|
|
27593
|
+
`SELECT ${FINDING_ROW_COLUMNS_SQL}
|
|
27594
|
+
FROM inspection_findings f
|
|
27595
|
+
JOIN audit_events e ON e.id = f.audit_event_id
|
|
27596
|
+
JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
27597
|
+
WHERE f.id = ?`
|
|
27598
|
+
).get(id);
|
|
27599
|
+
return Promise.resolve(row === void 0 ? null : toInstanceDetail(toFlatFindingRow(row)));
|
|
27600
|
+
}
|
|
27579
27601
|
/**
|
|
27580
27602
|
* The one statement both instance-level scans run: every finding in scope,
|
|
27581
27603
|
* joined to its event and definition, newest first.
|
|
@@ -27609,17 +27631,7 @@ var SqliteFindingsRepository = class {
|
|
|
27609
27631
|
conditions.push("e.started_at >= ?");
|
|
27610
27632
|
params.push(isoToEpochMillis(scope.from));
|
|
27611
27633
|
}
|
|
27612
|
-
const sql = `SELECT
|
|
27613
|
-
d.severity AS severity, f.masked_match AS masked_match,
|
|
27614
|
-
f.action_taken AS action_taken, f.confidence AS confidence,
|
|
27615
|
-
e.started_at AS occurred_at,
|
|
27616
|
-
e.source_tool AS source_tool,
|
|
27617
|
-
e.repo AS repo,
|
|
27618
|
-
e.file_path AS file,
|
|
27619
|
-
e.tool_name AS tool_name,
|
|
27620
|
-
f.audit_event_id AS event_id, e.root_session_id AS session_id,
|
|
27621
|
-
e.event_type AS kind, f.finding_key AS finding_key,
|
|
27622
|
-
${latestResolutionStatusSql("f")} AS latest_status
|
|
27634
|
+
const sql = `SELECT ${FINDING_ROW_COLUMNS_SQL}
|
|
27623
27635
|
FROM audit_events e
|
|
27624
27636
|
CROSS JOIN inspection_findings f ON f.audit_event_id = e.id
|
|
27625
27637
|
CROSS JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
@@ -27633,6 +27645,26 @@ var SqliteFindingsRepository = class {
|
|
|
27633
27645
|
group_concat(DISTINCT 'via ' || e.tool_name) AS tool_names` : `, NULL AS repos, NULL AS files, NULL AS tool_names`;
|
|
27634
27646
|
const rows = this.db.prepare(
|
|
27635
27647
|
`SELECT rule_id,
|
|
27648
|
+
-- BARE columns beside max(latest_at), which is deliberate and
|
|
27649
|
+
-- is SQLite's documented behaviour: with a single min()/max()
|
|
27650
|
+
-- in an aggregate query, every bare column takes its value from
|
|
27651
|
+
-- the row that produced the extremum. So these are the severity
|
|
27652
|
+
-- and category of the definition whose finding is NEWEST, which
|
|
27653
|
+
-- is what the row-based build they replaced read off its first
|
|
27654
|
+
-- (newest-first) row.
|
|
27655
|
+
--
|
|
27656
|
+
-- min() is WRONG here and was the defect: inspection_definitions
|
|
27657
|
+
-- holds one row per rule VERSION (see its writer \u2014 a version bump
|
|
27658
|
+
-- mints a new row), so a rule whose severity moved between
|
|
27659
|
+
-- versions has several, and min() picks the ALPHABETICALLY
|
|
27660
|
+
-- smallest \u2014 'low' over 'medium', but 'critical' over 'high'.
|
|
27661
|
+
-- That is arbitrary in direction, and it feeds the badge, the
|
|
27662
|
+
-- filter, the facet counts and the primary sort key.
|
|
27663
|
+
--
|
|
27664
|
+
-- Adding a second min()/max() aggregate here would make these
|
|
27665
|
+
-- bare columns ambiguous again; keep max(latest_at) the only one.
|
|
27666
|
+
severity,
|
|
27667
|
+
category,
|
|
27636
27668
|
sum(tuple_count) AS instance_count,
|
|
27637
27669
|
max(latest_at) AS latest_at,
|
|
27638
27670
|
group_concat(source_tools) AS source_tools,
|
|
@@ -27643,6 +27675,14 @@ var SqliteFindingsRepository = class {
|
|
|
27643
27675
|
group_concat(tool_names) AS tool_names
|
|
27644
27676
|
FROM (
|
|
27645
27677
|
SELECT d.rule_id AS rule_id,
|
|
27678
|
+
-- Severity and category are columns of the DEFINITION, and
|
|
27679
|
+
-- a rule can have SEVERAL definitions (one per version), so
|
|
27680
|
+
-- these are grouped on below and resolved to the newest
|
|
27681
|
+
-- firing version by the outer query's bare-column select.
|
|
27682
|
+
-- They ride the aggregate because the type build has no rows
|
|
27683
|
+
-- to read them off \u2014 see buildFindingTypes.
|
|
27684
|
+
d.severity AS severity,
|
|
27685
|
+
d.category AS category,
|
|
27646
27686
|
e.event_type || '${TUPLE_SEP}' ||
|
|
27647
27687
|
(CASE WHEN f.finding_key IS NULL THEN '' ELSE 'k' END) || '${TUPLE_SEP}' ||
|
|
27648
27688
|
coalesce(latest.status, '') AS status_tuple,
|
|
@@ -27657,7 +27697,7 @@ var SqliteFindingsRepository = class {
|
|
|
27657
27697
|
LEFT JOIN ${LATEST_RESOLUTION_BY_KEY_SQL} latest
|
|
27658
27698
|
ON latest.finding_key = f.finding_key
|
|
27659
27699
|
${scope.predicate}
|
|
27660
|
-
GROUP BY d.rule_id, status_tuple
|
|
27700
|
+
GROUP BY d.rule_id, d.severity, d.category, status_tuple
|
|
27661
27701
|
)
|
|
27662
27702
|
GROUP BY rule_id`
|
|
27663
27703
|
).all(scope.params);
|
|
@@ -27666,6 +27706,8 @@ var SqliteFindingsRepository = class {
|
|
|
27666
27706
|
r.rule_id,
|
|
27667
27707
|
{
|
|
27668
27708
|
instanceCount: r.instance_count,
|
|
27709
|
+
severity: r.severity,
|
|
27710
|
+
category: r.category,
|
|
27669
27711
|
sourceTools: splitConcat(r.source_tools),
|
|
27670
27712
|
actionsTaken: splitConcat(r.actions_taken),
|
|
27671
27713
|
statusInputs: splitConcat(r.status_inputs).map((tuple2) => {
|
|
@@ -27682,7 +27724,7 @@ var SqliteFindingsRepository = class {
|
|
|
27682
27724
|
latestDetectedAt: epochMillisToIso(r.latest_at),
|
|
27683
27725
|
// Free text only — joined and substring-matched, so group_concat's
|
|
27684
27726
|
// commas need no unpicking (a repo/path containing one still matches).
|
|
27685
|
-
// Left undefined (not '') when unfetched, so
|
|
27727
|
+
// Left undefined (not '') when unfetched, so buildFindingTypes can
|
|
27686
27728
|
// tell "no q this request" from "a group with no repo/file at all"
|
|
27687
27729
|
// and skip priming a haystack nothing will read.
|
|
27688
27730
|
...withSearchText ? {
|
|
@@ -27834,6 +27876,12 @@ var SqliteHistorySyncRepository = class {
|
|
|
27834
27876
|
this.markOwedStmt = db.prepare(
|
|
27835
27877
|
`UPDATE audit_events SET outbox_owed = 1 WHERE id = :id AND synced_at IS NULL`
|
|
27836
27878
|
);
|
|
27879
|
+
this.markCaptureBacklogOwedStmt = db.prepare(
|
|
27880
|
+
`UPDATE audit_events SET outbox_owed = 1
|
|
27881
|
+
WHERE synced_at IS NULL
|
|
27882
|
+
AND event_type IN (${CAPTURE_TYPE_LIST})
|
|
27883
|
+
AND started_at < :before`
|
|
27884
|
+
);
|
|
27837
27885
|
this.stampStmt = db.prepare(
|
|
27838
27886
|
`UPDATE audit_events SET synced_at = :at, sync_claimed_at = NULL WHERE id = :id`
|
|
27839
27887
|
);
|
|
@@ -27882,7 +27930,9 @@ var SqliteHistorySyncRepository = class {
|
|
|
27882
27930
|
);
|
|
27883
27931
|
this.disownCapturesStmt = db.prepare(
|
|
27884
27932
|
`UPDATE audit_events SET outbox_owed = NULL
|
|
27885
|
-
WHERE outbox_owed IS NOT NULL
|
|
27933
|
+
WHERE outbox_owed IS NOT NULL
|
|
27934
|
+
AND event_type IN (${CAPTURE_TYPE_LIST})
|
|
27935
|
+
AND started_at < :attachedAt`
|
|
27886
27936
|
);
|
|
27887
27937
|
this.rearmStmt = db.prepare(
|
|
27888
27938
|
`UPDATE audit_events SET synced_at = NULL
|
|
@@ -27958,6 +28008,7 @@ var SqliteHistorySyncRepository = class {
|
|
|
27958
28008
|
freezeBoundaryStmt;
|
|
27959
28009
|
captureRowsStmt;
|
|
27960
28010
|
markOwedStmt;
|
|
28011
|
+
markCaptureBacklogOwedStmt;
|
|
27961
28012
|
captureSkipCountStmt;
|
|
27962
28013
|
disownCapturesStmt;
|
|
27963
28014
|
partitionStmt;
|
|
@@ -28021,6 +28072,23 @@ var SqliteHistorySyncRepository = class {
|
|
|
28021
28072
|
markCaptureOwed(id) {
|
|
28022
28073
|
this.markOwedStmt.run({ id });
|
|
28023
28074
|
}
|
|
28075
|
+
/**
|
|
28076
|
+
* Mark every capture already on disk as owed, as of `before`.
|
|
28077
|
+
*
|
|
28078
|
+
* The consent-time backfill, called once from `aka attach` when a human
|
|
28079
|
+
* grants existing-history consent — never from an ongoing drain pass, and
|
|
28080
|
+
* never inferred from a boundary that could later move. `before` is the
|
|
28081
|
+
* caller's own "now" at the moment consent was granted, so what this marks
|
|
28082
|
+
* is exactly the backlog the consent prompt already counted, not whatever a
|
|
28083
|
+
* later re-attach or key rotation might widen it to.
|
|
28084
|
+
*
|
|
28085
|
+
* Returns how many rows matched, for the caller to log or test against. Not a
|
|
28086
|
+
* count of NEWLY marked rows — a row still unsynced from an earlier call
|
|
28087
|
+
* matches again and is counted again, the same as `UPDATE`'s own `changes`.
|
|
28088
|
+
*/
|
|
28089
|
+
markCaptureBacklogOwed(before) {
|
|
28090
|
+
return Number(this.markCaptureBacklogOwedStmt.run({ before }).changes);
|
|
28091
|
+
}
|
|
28024
28092
|
/** Record delivery. Called only AFTER the far side has accepted the rows. */
|
|
28025
28093
|
markSynced(ids, atMs) {
|
|
28026
28094
|
this.stampAll(ids, atMs);
|
|
@@ -28137,15 +28205,42 @@ var SqliteHistorySyncRepository = class {
|
|
|
28137
28205
|
*
|
|
28138
28206
|
* Delivery is a fact about ONE recipient: rows sent to the deployment a
|
|
28139
28207
|
* machine has just left are undelivered as far as the new one is concerned.
|
|
28140
|
-
* All
|
|
28141
|
-
* attributed to the wrong deployment,
|
|
28208
|
+
* All four in one transaction, so a crash between them cannot leave stamps
|
|
28209
|
+
* attributed to the wrong deployment, a boundary that belongs to another, or
|
|
28210
|
+
* a disown with no re-mark to follow it.
|
|
28142
28211
|
*
|
|
28143
28212
|
* The boundary is written HERE and only here, which is what freezes it: a
|
|
28144
28213
|
* re-attach to the SAME deployment (a key rotation) leaves the fingerprint
|
|
28145
28214
|
* unchanged, so this never runs and the backlog does not widen back over rows
|
|
28146
28215
|
* the live path has since delivered.
|
|
28216
|
+
*
|
|
28217
|
+
* `backfillCapturesBefore` is the caller's OWN "now" at the instant a human
|
|
28218
|
+
* granted existing-history consent for the deployment this call is arming —
|
|
28219
|
+
* a DIFFERENT instant from `backlogBefore`: the re-mark boundary is the GRANT
|
|
28220
|
+
* instant, `backlogBefore` is the ATTACH instant, and the two can be far
|
|
28221
|
+
* apart. Passed only when that grant is valid, since this method has no way
|
|
28222
|
+
* to check consent itself and must not mark a row owed for a machine that
|
|
28223
|
+
* never agreed to it. Applied AFTER the disown above, in the SAME
|
|
28224
|
+
* transaction: what the disown clears is every marker below `backlogBefore`,
|
|
28225
|
+
* which includes this deployment's OWN pre-attach rows — `aka attach` calls
|
|
28226
|
+
* `seedCaptureBacklogOwed` at the attach instant, so every row it marks sits
|
|
28227
|
+
* on the cleared side of that bound — and the re-mark in the same
|
|
28228
|
+
* transaction is what puts those rows back. A crash between the two cannot
|
|
28229
|
+
* strand the ledger disowned with nothing re-marked — the transaction either
|
|
28230
|
+
* lands whole or not at all, and a fingerprint mismatch that has not yet
|
|
28231
|
+
* committed re-enters this method on the very next pass. Omit it (the
|
|
28232
|
+
* structural-only tests do) to exercise the disown in isolation.
|
|
28233
|
+
*
|
|
28234
|
+
* The disown is bounded by `backlogBefore`, which is what keeps it from
|
|
28235
|
+
* touching a marker the NEW deployment's OWN live path has already set: B's
|
|
28236
|
+
* live path can mark a capture owed from the moment `aka attach` writes the
|
|
28237
|
+
* descriptor, before the drain's first pass ever reaches this method, and
|
|
28238
|
+
* such a row sits at or after the bound rather than below it. What keeps the
|
|
28239
|
+
* disown from eating THIS SAME CALL's own re-mark is the order, not the
|
|
28240
|
+
* bound — disown runs first, re-mark second, both inside the one
|
|
28241
|
+
* transaction above.
|
|
28147
28242
|
*/
|
|
28148
|
-
rearmFor(fingerprint, backlogBefore) {
|
|
28243
|
+
rearmFor(fingerprint, backlogBefore, backfillCapturesBefore) {
|
|
28149
28244
|
this.ensureRowStmt.run();
|
|
28150
28245
|
withTransaction(
|
|
28151
28246
|
this.db,
|
|
@@ -28153,7 +28248,10 @@ var SqliteHistorySyncRepository = class {
|
|
|
28153
28248
|
const previous = getRow(this.fingerprintStmt)?.fingerprint;
|
|
28154
28249
|
this.rearmStmt.run();
|
|
28155
28250
|
if (previous !== null && previous !== void 0 && previous !== fingerprint) {
|
|
28156
|
-
this.disownCapturesStmt.run();
|
|
28251
|
+
this.disownCapturesStmt.run({ attachedAt: backlogBefore });
|
|
28252
|
+
}
|
|
28253
|
+
if (backfillCapturesBefore !== void 0) {
|
|
28254
|
+
this.markCaptureBacklogOwedStmt.run({ before: backfillCapturesBefore });
|
|
28157
28255
|
}
|
|
28158
28256
|
this.setFingerprintStmt.run({ fingerprint, backlogBefore });
|
|
28159
28257
|
},
|
|
@@ -28430,7 +28528,8 @@ function managedSettingsPaths(platform2 = process.platform) {
|
|
|
28430
28528
|
}
|
|
28431
28529
|
return [posix.join("/etc", "aka", MANAGED_SETTINGS_FILENAME)];
|
|
28432
28530
|
}
|
|
28433
|
-
|
|
28531
|
+
var testOnlyManagedPaths = null;
|
|
28532
|
+
function readManagedSettings(paths = testOnlyManagedPaths ?? managedSettingsPaths()) {
|
|
28434
28533
|
for (const path of paths) {
|
|
28435
28534
|
let text;
|
|
28436
28535
|
try {
|
|
@@ -30910,7 +31009,7 @@ function toUtcDateString(ms) {
|
|
|
30910
31009
|
return new Date(ms).toISOString().slice(0, 10);
|
|
30911
31010
|
}
|
|
30912
31011
|
function isTimeseriesSeverity(s) {
|
|
30913
|
-
return s === "critical" || s === "high" || s === "medium";
|
|
31012
|
+
return s === "critical" || s === "high" || s === "medium" || s === "low";
|
|
30914
31013
|
}
|
|
30915
31014
|
var SqliteSecurityRepository = class {
|
|
30916
31015
|
constructor(db, now = () => Date.now()) {
|
|
@@ -31039,12 +31138,16 @@ var SqliteSecurityRepository = class {
|
|
|
31039
31138
|
const now = this.now();
|
|
31040
31139
|
const windowStart = startOfUtcDay2(now) - (lenDays - 1) * DAY_MS4;
|
|
31041
31140
|
const rows = this.findingsInRange(windowStart, now);
|
|
31042
|
-
const points = Array.from(
|
|
31043
|
-
|
|
31044
|
-
|
|
31045
|
-
|
|
31046
|
-
|
|
31047
|
-
|
|
31141
|
+
const points = Array.from(
|
|
31142
|
+
{ length: numBuckets },
|
|
31143
|
+
(_, i) => ({
|
|
31144
|
+
timestamp: toUtcDateString(windowStart + i * bucketMs),
|
|
31145
|
+
critical: 0,
|
|
31146
|
+
high: 0,
|
|
31147
|
+
medium: 0,
|
|
31148
|
+
low: 0
|
|
31149
|
+
})
|
|
31150
|
+
);
|
|
31048
31151
|
for (const r of rows) {
|
|
31049
31152
|
const idx = Math.floor((r.occurredAt - windowStart) / bucketMs);
|
|
31050
31153
|
const bucket = points[idx];
|
|
@@ -31262,6 +31365,7 @@ var SqliteSecurityRepository = class {
|
|
|
31262
31365
|
`SELECT f.finding_key AS finding_key,
|
|
31263
31366
|
d.rule_id AS rule_id,
|
|
31264
31367
|
d.severity AS severity,
|
|
31368
|
+
e.repo AS repo,
|
|
31265
31369
|
e.file_path AS path,
|
|
31266
31370
|
COALESCE(f.first_detected_at, e.started_at) AS first_detected_at,
|
|
31267
31371
|
latest.resolved_at AS latest_resolved_at
|
|
@@ -31281,6 +31385,7 @@ var SqliteSecurityRepository = class {
|
|
|
31281
31385
|
const items = rows.map((r) => ({
|
|
31282
31386
|
findingKey: r.finding_key,
|
|
31283
31387
|
ruleId: r.rule_id,
|
|
31388
|
+
repo: r.repo ?? "",
|
|
31284
31389
|
severity: r.severity,
|
|
31285
31390
|
path: r.path ?? "",
|
|
31286
31391
|
resolvedAt: new Date(r.latest_resolved_at).toISOString(),
|
|
@@ -31290,13 +31395,66 @@ var SqliteSecurityRepository = class {
|
|
|
31290
31395
|
}));
|
|
31291
31396
|
return Promise.resolve({ items });
|
|
31292
31397
|
}
|
|
31398
|
+
/**
|
|
31399
|
+
* Per-rule tallies of the findings that are still OPEN, whole-store.
|
|
31400
|
+
*
|
|
31401
|
+
* Scoped by status rather than by time, because the card this feeds is a to-do
|
|
31402
|
+
* list: a secret committed three weeks ago and never rotated is still the most
|
|
31403
|
+
* important thing to fix, and any window hides it. It carried a "newest N
|
|
31404
|
+
* findings" cap and then a range; the first meant a different span on every
|
|
31405
|
+
* machine, and the second reported "no recommendations" over live exposure.
|
|
31406
|
+
*
|
|
31407
|
+
* `open` mirrors `deriveFindingStatus` — at-rest, minus resolved and dismissed —
|
|
31408
|
+
* so a row's count is exactly what `?status=open&type=<rule>` returns. Note that
|
|
31409
|
+
* is NOT `severitySummary`'s `openAtRest`, which keeps dismissed findings (a
|
|
31410
|
+
* dismissal is a judgement, not a remediation) and drops untracked legacy rows.
|
|
31411
|
+
* The two answer different questions and only this one has to match a link.
|
|
31412
|
+
*
|
|
31413
|
+
* Aggregated in SQL: the result is O(distinct rule × category × severity), so a
|
|
31414
|
+
* whole-store scope costs a grouped scan rather than a row per finding.
|
|
31415
|
+
*/
|
|
31416
|
+
recommendationInputs() {
|
|
31417
|
+
const rows = allRows(
|
|
31418
|
+
this.db.prepare(
|
|
31419
|
+
`SELECT d.rule_id AS rule_id,
|
|
31420
|
+
d.category AS category,
|
|
31421
|
+
d.severity AS severity,
|
|
31422
|
+
COUNT(*) AS count
|
|
31423
|
+
FROM inspection_findings f
|
|
31424
|
+
JOIN audit_events e ON e.id = f.audit_event_id
|
|
31425
|
+
JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
31426
|
+
LEFT JOIN ${LATEST_RESOLUTION_BY_KEY_SQL} latest
|
|
31427
|
+
ON latest.finding_key = f.finding_key
|
|
31428
|
+
WHERE e.event_type IN (${CAPTURE_EVENT_TYPES_SQL})
|
|
31429
|
+
AND e.event_type = 'code_change'
|
|
31430
|
+
AND (
|
|
31431
|
+
f.finding_key IS NULL
|
|
31432
|
+
OR latest.status IS NULL
|
|
31433
|
+
OR latest.status NOT IN ('resolved', 'dismissed')
|
|
31434
|
+
)
|
|
31435
|
+
GROUP BY d.rule_id, d.category, d.severity`
|
|
31436
|
+
)
|
|
31437
|
+
);
|
|
31438
|
+
return Promise.resolve(
|
|
31439
|
+
rows.map((r) => ({
|
|
31440
|
+
ruleId: r.rule_id,
|
|
31441
|
+
category: r.category,
|
|
31442
|
+
severity: r.severity,
|
|
31443
|
+
count: r.count
|
|
31444
|
+
}))
|
|
31445
|
+
);
|
|
31446
|
+
}
|
|
31293
31447
|
// Findings whose parent event occurred in [fromMs, toMs), with the parent's
|
|
31294
31448
|
// epoch-millis timestamp. started_at is an INTEGER column, so the bounds stay
|
|
31295
31449
|
// numeric and the JS aggregations bucket/split on ms directly.
|
|
31296
31450
|
findingsInRange(fromMs, toMs) {
|
|
31297
31451
|
const rows = allRows(
|
|
31298
31452
|
this.db.prepare(
|
|
31299
|
-
`
|
|
31453
|
+
// `rule_id`/`category` cost nothing extra: inspection_definitions is already
|
|
31454
|
+
// joined for `severity`, so they are two more columns off a row this read
|
|
31455
|
+
// already fetches. They feed the recommended-actions rollup.
|
|
31456
|
+
`SELECT e.started_at AS occurred_at, d.severity AS severity, f.action_taken AS action_taken,
|
|
31457
|
+
d.rule_id AS rule_id, d.category AS category
|
|
31300
31458
|
FROM inspection_findings f
|
|
31301
31459
|
JOIN audit_events e ON e.id = f.audit_event_id
|
|
31302
31460
|
JOIN inspection_definitions d ON d.id = f.inspection_definition_id
|
|
@@ -31309,7 +31467,9 @@ var SqliteSecurityRepository = class {
|
|
|
31309
31467
|
return rows.map((r) => ({
|
|
31310
31468
|
occurredAt: r.occurred_at,
|
|
31311
31469
|
severity: r.severity,
|
|
31312
|
-
actionTaken: r.action_taken
|
|
31470
|
+
actionTaken: r.action_taken,
|
|
31471
|
+
ruleId: r.rule_id,
|
|
31472
|
+
category: r.category
|
|
31313
31473
|
}));
|
|
31314
31474
|
}
|
|
31315
31475
|
};
|
|
@@ -32479,14 +32639,51 @@ function openLocalDatabase(dir) {
|
|
|
32479
32639
|
};
|
|
32480
32640
|
}
|
|
32481
32641
|
|
|
32482
|
-
// ../../packages/persistence/src/
|
|
32642
|
+
// ../../packages/persistence/src/egress-wire.ts
|
|
32483
32643
|
import { createHash as createHash3 } from "crypto";
|
|
32644
|
+
function hashProjectKey(projectKey) {
|
|
32645
|
+
return createHash3("sha256").update(projectKey, "utf8").digest("hex");
|
|
32646
|
+
}
|
|
32647
|
+
function toIngestHit(hit) {
|
|
32648
|
+
return {
|
|
32649
|
+
host: hit.host,
|
|
32650
|
+
kind: hit.kind,
|
|
32651
|
+
name: hit.name,
|
|
32652
|
+
category: hit.category,
|
|
32653
|
+
trust: hit.trust,
|
|
32654
|
+
network: hit.network,
|
|
32655
|
+
method: hit.method,
|
|
32656
|
+
transport: hit.transport,
|
|
32657
|
+
url: hit.url,
|
|
32658
|
+
template: hit.template,
|
|
32659
|
+
dataClass: hit.dataClass,
|
|
32660
|
+
site: {
|
|
32661
|
+
file: hit.site.file,
|
|
32662
|
+
line: hit.site.line,
|
|
32663
|
+
dynamic: hit.site.dynamic,
|
|
32664
|
+
vendored: hit.site.vendored
|
|
32665
|
+
}
|
|
32666
|
+
};
|
|
32667
|
+
}
|
|
32668
|
+
function toEgressIngestRequest(input2) {
|
|
32669
|
+
const { hits, droppedFiles } = capHits(input2.hits, input2.reconcile.mode);
|
|
32670
|
+
const reconcile = withoutDroppedFiles(input2.reconcile, droppedFiles);
|
|
32671
|
+
return {
|
|
32672
|
+
projectKey: hashProjectKey(input2.projectKey),
|
|
32673
|
+
project: input2.project,
|
|
32674
|
+
reconcile,
|
|
32675
|
+
hits: hits.map(toIngestHit)
|
|
32676
|
+
};
|
|
32677
|
+
}
|
|
32678
|
+
|
|
32679
|
+
// ../../packages/persistence/src/finding-key.ts
|
|
32680
|
+
import { createHash as createHash4 } from "crypto";
|
|
32484
32681
|
function normalizeFilePath(filePath) {
|
|
32485
32682
|
return filePath.replaceAll("\\", "/");
|
|
32486
32683
|
}
|
|
32487
32684
|
function computeFindingKey(input2) {
|
|
32488
32685
|
const normalizedPath = normalizeFilePath(input2.filePath);
|
|
32489
|
-
return
|
|
32686
|
+
return createHash4("sha256").update(`${input2.ruleId}\0${normalizedPath}\0${input2.valueFingerprint}`).digest("hex");
|
|
32490
32687
|
}
|
|
32491
32688
|
|
|
32492
32689
|
// ../../packages/persistence/src/fingerprint.ts
|
|
@@ -32612,14 +32809,18 @@ function fingerprintValue(key, raw) {
|
|
|
32612
32809
|
return createHmac("sha256", key.material).update(raw, "utf8").digest("hex");
|
|
32613
32810
|
}
|
|
32614
32811
|
|
|
32615
|
-
// ../../packages/persistence/src/history-
|
|
32812
|
+
// ../../packages/persistence/src/history-backfill.ts
|
|
32616
32813
|
import { existsSync as existsSync4 } from "fs";
|
|
32617
32814
|
import { join as join9 } from "path";
|
|
32815
|
+
|
|
32816
|
+
// ../../packages/persistence/src/history-preview.ts
|
|
32817
|
+
import { existsSync as existsSync5 } from "fs";
|
|
32818
|
+
import { join as join10 } from "path";
|
|
32618
32819
|
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
32619
32820
|
|
|
32620
32821
|
// ../../packages/persistence/src/store-symlinks.ts
|
|
32621
|
-
import { existsSync as
|
|
32622
|
-
import { dirname as dirname3, join as
|
|
32822
|
+
import { existsSync as existsSync6, lstatSync as lstatSync3, readlinkSync, realpathSync, statSync as statSync4 } from "fs";
|
|
32823
|
+
import { dirname as dirname3, join as join11, resolve } from "path";
|
|
32623
32824
|
|
|
32624
32825
|
// ../../packages/persistence/src/vault/crypto.ts
|
|
32625
32826
|
import {
|
|
@@ -32634,61 +32835,25 @@ import {
|
|
|
32634
32835
|
import { execFileSync } from "child_process";
|
|
32635
32836
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
32636
32837
|
import { chmodSync as chmodSync3, readFileSync as readFileSync7, renameSync as renameSync4, rmSync as rmSync6, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
|
|
32637
|
-
import { join as
|
|
32838
|
+
import { join as join12 } from "path";
|
|
32638
32839
|
|
|
32639
32840
|
// ../../packages/persistence/src/vault/vault.ts
|
|
32640
32841
|
import { randomBytes as randomBytes3, randomUUID as randomUUID12 } from "crypto";
|
|
32641
32842
|
|
|
32642
32843
|
// ../../packages/persistence/src/warn-era-cap.ts
|
|
32643
|
-
import { existsSync as
|
|
32644
|
-
import { join as
|
|
32844
|
+
import { existsSync as existsSync7, writeFileSync as writeFileSync4 } from "fs";
|
|
32845
|
+
import { join as join13 } from "path";
|
|
32645
32846
|
var MARKER = "warn-era-capped";
|
|
32646
32847
|
function capWarnEraEnforcementOnce(db, policyMode, dataDir2) {
|
|
32647
32848
|
if (policyMode !== "warn") return { capped: 0, skipped: "not-warn" };
|
|
32648
|
-
const marker =
|
|
32649
|
-
if (
|
|
32849
|
+
const marker = join13(dataDir2, MARKER);
|
|
32850
|
+
if (existsSync7(marker)) return { capped: 0, skipped: "already-run" };
|
|
32650
32851
|
const capped = db.policies.capCategoryActions();
|
|
32651
32852
|
writeFileSync4(marker, `${new Date(Date.now()).toISOString()}
|
|
32652
32853
|
`, { mode: DATA_FILE_MODE });
|
|
32653
32854
|
return { capped };
|
|
32654
32855
|
}
|
|
32655
32856
|
|
|
32656
|
-
// ../../packages/plugin-runtime/src/attached/egress-wire.ts
|
|
32657
|
-
function hashProjectKey(projectKey) {
|
|
32658
|
-
return createHash4("sha256").update(projectKey, "utf8").digest("hex");
|
|
32659
|
-
}
|
|
32660
|
-
function toIngestHit(hit) {
|
|
32661
|
-
return {
|
|
32662
|
-
host: hit.host,
|
|
32663
|
-
kind: hit.kind,
|
|
32664
|
-
name: hit.name,
|
|
32665
|
-
category: hit.category,
|
|
32666
|
-
trust: hit.trust,
|
|
32667
|
-
network: hit.network,
|
|
32668
|
-
method: hit.method,
|
|
32669
|
-
transport: hit.transport,
|
|
32670
|
-
url: hit.url,
|
|
32671
|
-
template: hit.template,
|
|
32672
|
-
dataClass: hit.dataClass,
|
|
32673
|
-
site: {
|
|
32674
|
-
file: hit.site.file,
|
|
32675
|
-
line: hit.site.line,
|
|
32676
|
-
dynamic: hit.site.dynamic,
|
|
32677
|
-
vendored: hit.site.vendored
|
|
32678
|
-
}
|
|
32679
|
-
};
|
|
32680
|
-
}
|
|
32681
|
-
function toEgressIngestRequest(input2) {
|
|
32682
|
-
const { hits, droppedFiles } = capHits(input2.hits, input2.reconcile.mode);
|
|
32683
|
-
const reconcile = withoutDroppedFiles(input2.reconcile, droppedFiles);
|
|
32684
|
-
return {
|
|
32685
|
-
projectKey: hashProjectKey(input2.projectKey),
|
|
32686
|
-
project: input2.project,
|
|
32687
|
-
reconcile,
|
|
32688
|
-
hits: hits.map(toIngestHit)
|
|
32689
|
-
};
|
|
32690
|
-
}
|
|
32691
|
-
|
|
32692
32857
|
// ../../packages/remote/src/http.ts
|
|
32693
32858
|
import { request as httpRequest } from "http";
|
|
32694
32859
|
import { request as httpsRequest } from "https";
|
|
@@ -32968,6 +33133,7 @@ function createRemoteClient(options) {
|
|
|
32968
33133
|
url: url2(ROUTES.shares),
|
|
32969
33134
|
body: JSON.stringify(validated.data)
|
|
32970
33135
|
});
|
|
33136
|
+
if (response.status === 404) throw new RemoteRouteAbsent(ROUTES.shares);
|
|
32971
33137
|
okBody(response);
|
|
32972
33138
|
},
|
|
32973
33139
|
async pollCommand() {
|
|
@@ -32990,19 +33156,51 @@ function createRemoteClient(options) {
|
|
|
32990
33156
|
};
|
|
32991
33157
|
}
|
|
32992
33158
|
|
|
32993
|
-
// ../../packages/
|
|
33159
|
+
// ../../packages/remote/src/failure-kind.ts
|
|
32994
33160
|
function statusOf(err) {
|
|
32995
33161
|
if (typeof err !== "object" || err === null || !("status" in err)) return null;
|
|
32996
33162
|
const { status } = err;
|
|
32997
33163
|
if (typeof status !== "number" || !Number.isInteger(status)) return null;
|
|
32998
33164
|
return status >= 100 && status <= 599 ? status : null;
|
|
32999
33165
|
}
|
|
33000
|
-
function
|
|
33001
|
-
|
|
33166
|
+
function nameOf(err) {
|
|
33167
|
+
if (typeof err !== "object" || err === null || !("name" in err)) return null;
|
|
33168
|
+
return typeof err.name === "string" ? err.name : null;
|
|
33169
|
+
}
|
|
33170
|
+
function classifyRemoteFailure(err) {
|
|
33171
|
+
switch (nameOf(err)) {
|
|
33172
|
+
case "RemoteRouteAbsent":
|
|
33173
|
+
return "route-absent";
|
|
33174
|
+
case "RemoteRequestInvalid":
|
|
33175
|
+
return "invalid-request";
|
|
33176
|
+
case "RemoteResponseInvalid":
|
|
33177
|
+
return "rejected";
|
|
33178
|
+
default:
|
|
33179
|
+
break;
|
|
33180
|
+
}
|
|
33181
|
+
const status = statusOf(err);
|
|
33182
|
+
if (status === null) return "unreachable";
|
|
33183
|
+
switch (status) {
|
|
33002
33184
|
case 401:
|
|
33003
33185
|
return "unauthorized";
|
|
33004
33186
|
case 403:
|
|
33005
33187
|
return "forbidden";
|
|
33188
|
+
case 429:
|
|
33189
|
+
return "unreachable";
|
|
33190
|
+
case 404:
|
|
33191
|
+
return "unreachable";
|
|
33192
|
+
default:
|
|
33193
|
+
return status >= 400 && status <= 499 ? "rejected" : "unreachable";
|
|
33194
|
+
}
|
|
33195
|
+
}
|
|
33196
|
+
|
|
33197
|
+
// ../../packages/plugin-runtime/src/attached/failure.ts
|
|
33198
|
+
function classifyFailure(err) {
|
|
33199
|
+
switch (classifyRemoteFailure(err)) {
|
|
33200
|
+
case "unauthorized":
|
|
33201
|
+
return "unauthorized";
|
|
33202
|
+
case "forbidden":
|
|
33203
|
+
return "forbidden";
|
|
33006
33204
|
default:
|
|
33007
33205
|
return "unreachable";
|
|
33008
33206
|
}
|
|
@@ -33025,10 +33223,10 @@ function withTimeout(promise2, ms) {
|
|
|
33025
33223
|
|
|
33026
33224
|
// ../../packages/plugin-runtime/src/attached/forward-drops.ts
|
|
33027
33225
|
import { readFileSync as readFileSync8 } from "fs";
|
|
33028
|
-
import { join as
|
|
33226
|
+
import { join as join14 } from "path";
|
|
33029
33227
|
var FORWARD_DROPS_FILENAME = ATTACHED_FORWARD_DROPS_FILENAME;
|
|
33030
33228
|
function forwardDropsPath(dataDir2) {
|
|
33031
|
-
return
|
|
33229
|
+
return join14(dataDir2, FORWARD_DROPS_FILENAME);
|
|
33032
33230
|
}
|
|
33033
33231
|
function recordForwardDrops(dataDir2, count, nowMs) {
|
|
33034
33232
|
if (count <= 0) return;
|
|
@@ -33064,13 +33262,13 @@ function readForwardDrops(dataDir2) {
|
|
|
33064
33262
|
|
|
33065
33263
|
// ../../packages/plugin-runtime/src/attached/forward-policy.ts
|
|
33066
33264
|
import { randomUUID as randomUUID15 } from "crypto";
|
|
33067
|
-
import { readFileSync as
|
|
33265
|
+
import { readFileSync as readFileSync15 } from "fs";
|
|
33068
33266
|
import { readFile, rename, writeFile } from "fs/promises";
|
|
33069
|
-
import { join as
|
|
33267
|
+
import { join as join24 } from "path";
|
|
33070
33268
|
|
|
33071
33269
|
// ../../packages/plugin-sdk/src/config.ts
|
|
33072
|
-
import { existsSync as
|
|
33073
|
-
import { join as
|
|
33270
|
+
import { existsSync as existsSync8 } from "fs";
|
|
33271
|
+
import { join as join15 } from "path";
|
|
33074
33272
|
|
|
33075
33273
|
// ../../packages/plugin-sdk/src/provider-env.ts
|
|
33076
33274
|
var DEFAULT_ANTHROPIC_HOST = "api.anthropic.com";
|
|
@@ -33124,8 +33322,8 @@ function resolveProvider() {
|
|
|
33124
33322
|
function loadConfig(base = defaultDataDir(), resolveProviderFn = resolveProvider) {
|
|
33125
33323
|
try {
|
|
33126
33324
|
ensureLayoutDirSync(base);
|
|
33127
|
-
const settingsFile =
|
|
33128
|
-
if (
|
|
33325
|
+
const settingsFile = join15(settingsDir(base), "settings.json");
|
|
33326
|
+
if (existsSync8(settingsFile)) tightenFile(settingsFile);
|
|
33129
33327
|
} catch {
|
|
33130
33328
|
}
|
|
33131
33329
|
migrateLegacyLayout(base);
|
|
@@ -33150,7 +33348,7 @@ function resolveProviderSafe(resolveProviderFn) {
|
|
|
33150
33348
|
// ../../packages/plugin-sdk/src/config-inventory.ts
|
|
33151
33349
|
import { readdirSync as readdirSync2, readFileSync as readFileSync10, realpathSync as realpathSync2, statSync as statSync7 } from "fs";
|
|
33152
33350
|
import { homedir as homedir2 } from "os";
|
|
33153
|
-
import { basename as basename4, join as
|
|
33351
|
+
import { basename as basename4, join as join17 } from "path";
|
|
33154
33352
|
|
|
33155
33353
|
// ../../packages/detections/src/egress/registry.ts
|
|
33156
33354
|
var EXTRACTOR_VERSION = "1";
|
|
@@ -36366,8 +36564,8 @@ function maskText(text) {
|
|
|
36366
36564
|
}
|
|
36367
36565
|
|
|
36368
36566
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
36369
|
-
import { existsSync as
|
|
36370
|
-
import { basename as basename3, dirname as dirname4, isAbsolute, join as
|
|
36567
|
+
import { existsSync as existsSync9, readFileSync as readFileSync9, statSync as statSync6 } from "fs";
|
|
36568
|
+
import { basename as basename3, dirname as dirname4, isAbsolute, join as join16, sep as sep2 } from "path";
|
|
36371
36569
|
function resolveRepoIdentity(cwd) {
|
|
36372
36570
|
try {
|
|
36373
36571
|
const root = findGitRoot(cwd);
|
|
@@ -36417,7 +36615,7 @@ function resolveGitBranch(cwd) {
|
|
|
36417
36615
|
try {
|
|
36418
36616
|
const root = findGitRoot(cwd);
|
|
36419
36617
|
if (!root) return void 0;
|
|
36420
|
-
const dotGit =
|
|
36618
|
+
const dotGit = join16(root, ".git");
|
|
36421
36619
|
let gitdir;
|
|
36422
36620
|
try {
|
|
36423
36621
|
gitdir = statSync6(dotGit).isDirectory() ? dotGit : resolveWorktreeGitdir(root, dotGit);
|
|
@@ -36425,7 +36623,7 @@ function resolveGitBranch(cwd) {
|
|
|
36425
36623
|
return void 0;
|
|
36426
36624
|
}
|
|
36427
36625
|
if (gitdir === void 0) return void 0;
|
|
36428
|
-
const head = safeRead(
|
|
36626
|
+
const head = safeRead(join16(gitdir, "HEAD"));
|
|
36429
36627
|
if (!head) return void 0;
|
|
36430
36628
|
return /^ref:\s*refs\/heads\/(.+?)\s*$/m.exec(head)?.[1];
|
|
36431
36629
|
} catch {
|
|
@@ -36435,37 +36633,37 @@ function resolveGitBranch(cwd) {
|
|
|
36435
36633
|
function resolveWorktreeGitdir(root, dotGitFile) {
|
|
36436
36634
|
const target = /^gitdir:\s*(.+?)\s*$/m.exec(safeRead(dotGitFile) ?? "")?.[1];
|
|
36437
36635
|
if (!target) return void 0;
|
|
36438
|
-
return isAbsolute(target) ? target :
|
|
36636
|
+
return isAbsolute(target) ? target : join16(root, target);
|
|
36439
36637
|
}
|
|
36440
36638
|
function findGitRoot(start) {
|
|
36441
36639
|
let dir = start;
|
|
36442
36640
|
for (; ; ) {
|
|
36443
|
-
if (
|
|
36641
|
+
if (existsSync9(join16(dir, ".git"))) return dir;
|
|
36444
36642
|
const parent = dirname4(dir);
|
|
36445
36643
|
if (parent === dir) return void 0;
|
|
36446
36644
|
dir = parent;
|
|
36447
36645
|
}
|
|
36448
36646
|
}
|
|
36449
36647
|
function resolveGitContext(root) {
|
|
36450
|
-
const dotGit =
|
|
36648
|
+
const dotGit = join16(root, ".git");
|
|
36451
36649
|
try {
|
|
36452
36650
|
if (statSync6(dotGit).isDirectory()) {
|
|
36453
|
-
return { configPath:
|
|
36651
|
+
return { configPath: join16(dotGit, "config"), headRoot: root };
|
|
36454
36652
|
}
|
|
36455
36653
|
} catch {
|
|
36456
36654
|
return void 0;
|
|
36457
36655
|
}
|
|
36458
36656
|
const target = /^gitdir:\s*(.+?)\s*$/m.exec(safeRead(dotGit) ?? "")?.[1];
|
|
36459
36657
|
if (!target) return void 0;
|
|
36460
|
-
const gitdir = isAbsolute(target) ? target :
|
|
36461
|
-
if (
|
|
36462
|
-
return { configPath:
|
|
36658
|
+
const gitdir = isAbsolute(target) ? target : join16(root, target);
|
|
36659
|
+
if (existsSync9(join16(gitdir, "config"))) {
|
|
36660
|
+
return { configPath: join16(gitdir, "config"), headRoot: root };
|
|
36463
36661
|
}
|
|
36464
|
-
const commonRaw = safeRead(
|
|
36662
|
+
const commonRaw = safeRead(join16(gitdir, "commondir"))?.trim();
|
|
36465
36663
|
if (!commonRaw) return void 0;
|
|
36466
|
-
const commonGitDir = isAbsolute(commonRaw) ? commonRaw :
|
|
36664
|
+
const commonGitDir = isAbsolute(commonRaw) ? commonRaw : join16(gitdir, commonRaw);
|
|
36467
36665
|
const headRoot = basename3(commonGitDir) === ".git" ? dirname4(commonGitDir) : root;
|
|
36468
|
-
return { configPath:
|
|
36666
|
+
return { configPath: join16(commonGitDir, "config"), headRoot };
|
|
36469
36667
|
}
|
|
36470
36668
|
function safeRead(path) {
|
|
36471
36669
|
try {
|
|
@@ -36531,31 +36729,31 @@ function resolveConfigInventory(input2) {
|
|
|
36531
36729
|
};
|
|
36532
36730
|
try {
|
|
36533
36731
|
const home = input2.homeDir ?? homedir2();
|
|
36534
|
-
const claudeDir =
|
|
36732
|
+
const claudeDir = join17(home, ".claude");
|
|
36535
36733
|
const repo = resolveRepoIdentity(input2.cwd);
|
|
36536
36734
|
const repoIdentity = repo?.url ?? input2.cwd;
|
|
36537
36735
|
const projectSource = `project:${repoIdentity}`;
|
|
36538
|
-
collectSettingsHooks(scan2,
|
|
36539
|
-
collectSettingsHooks(scan2,
|
|
36540
|
-
collectSettingsHooks(scan2,
|
|
36736
|
+
collectSettingsHooks(scan2, join17(claudeDir, "settings.json"), "user");
|
|
36737
|
+
collectSettingsHooks(scan2, join17(input2.cwd, ".claude", "settings.json"), "project");
|
|
36738
|
+
collectSettingsHooks(scan2, join17(input2.cwd, ".claude", "settings.local.json"), "local");
|
|
36541
36739
|
const projectOrigin = { scope: "project", project: repoIdentity };
|
|
36542
|
-
collectMcpFile(scan2,
|
|
36543
|
-
collectUserClaudeJson(scan2,
|
|
36544
|
-
collectMcpFile(scan2,
|
|
36545
|
-
collectMcpFile(scan2,
|
|
36546
|
-
collectMcpFile(scan2,
|
|
36740
|
+
collectMcpFile(scan2, join17(input2.cwd, ".mcp.json"), projectOrigin, { recordErrors: true });
|
|
36741
|
+
collectUserClaudeJson(scan2, join17(home, ".claude.json"), input2.cwd, repoIdentity);
|
|
36742
|
+
collectMcpFile(scan2, join17(claudeDir, "settings.json"), { scope: "user" });
|
|
36743
|
+
collectMcpFile(scan2, join17(input2.cwd, ".claude", "settings.json"), projectOrigin);
|
|
36744
|
+
collectMcpFile(scan2, join17(input2.cwd, ".claude", "settings.local.json"), {
|
|
36547
36745
|
scope: "local",
|
|
36548
36746
|
project: repoIdentity
|
|
36549
36747
|
});
|
|
36550
36748
|
collectConfigFiles(scan2, claudeDir, input2.cwd);
|
|
36551
|
-
collectSkillsDir(scan2,
|
|
36552
|
-
collectSkillsDir(scan2,
|
|
36749
|
+
collectSkillsDir(scan2, join17(claudeDir, "skills"), { source: "local", scope: "user" });
|
|
36750
|
+
collectSkillsDir(scan2, join17(input2.cwd, ".claude", "skills"), {
|
|
36553
36751
|
source: projectSource,
|
|
36554
36752
|
scope: "project"
|
|
36555
36753
|
});
|
|
36556
36754
|
collectInstalledPlugins(scan2, claudeDir);
|
|
36557
36755
|
collectMarketplaceSkills(scan2, claudeDir);
|
|
36558
|
-
collectSkillsDir(scan2,
|
|
36756
|
+
collectSkillsDir(scan2, join17(input2.cwd, "skills"), { source: projectSource, scope: "project" });
|
|
36559
36757
|
scan2.skills = dedupeSkills(scan2.skills);
|
|
36560
36758
|
scan2.mcpServers = dedupeMcpServers(scan2.mcpServers);
|
|
36561
36759
|
} catch (err) {
|
|
@@ -36684,7 +36882,7 @@ function projectEntryFor(projects, cwd) {
|
|
|
36684
36882
|
return void 0;
|
|
36685
36883
|
}
|
|
36686
36884
|
function collectPluginManifestMcp(scan2, installPath, origin) {
|
|
36687
|
-
const manifestPath =
|
|
36885
|
+
const manifestPath = join17(installPath, ".claude-plugin", "plugin.json");
|
|
36688
36886
|
const raw = readOptional(manifestPath);
|
|
36689
36887
|
if (raw === void 0) return;
|
|
36690
36888
|
try {
|
|
@@ -36692,7 +36890,7 @@ function collectPluginManifestMcp(scan2, installPath, origin) {
|
|
|
36692
36890
|
if (typeof parsed2 !== "object" || parsed2 === null) return;
|
|
36693
36891
|
const declared = parsed2.mcpServers;
|
|
36694
36892
|
if (typeof declared === "string" && declared.length > 0) {
|
|
36695
|
-
collectMcpFile(scan2,
|
|
36893
|
+
collectMcpFile(scan2, join17(installPath, declared), origin, { recordErrors: true });
|
|
36696
36894
|
} else {
|
|
36697
36895
|
collectMcpObject(scan2, declared, manifestPath, origin);
|
|
36698
36896
|
}
|
|
@@ -36709,14 +36907,14 @@ var SETTINGS_KEY_LABELS = [
|
|
|
36709
36907
|
["statusLine", "status line"]
|
|
36710
36908
|
];
|
|
36711
36909
|
function collectConfigFiles(scan2, claudeDir, cwd) {
|
|
36712
|
-
settingsConfigFile(scan2,
|
|
36713
|
-
settingsConfigFile(scan2,
|
|
36714
|
-
settingsConfigFile(scan2,
|
|
36715
|
-
memoryConfigFile(scan2,
|
|
36716
|
-
memoryConfigFile(scan2,
|
|
36717
|
-
mcpJsonConfigFile(scan2,
|
|
36718
|
-
dirConfigFile(scan2,
|
|
36719
|
-
dirConfigFile(scan2,
|
|
36910
|
+
settingsConfigFile(scan2, join17(claudeDir, "settings.json"), "user", "User settings");
|
|
36911
|
+
settingsConfigFile(scan2, join17(cwd, ".claude", "settings.json"), "project", "Project settings");
|
|
36912
|
+
settingsConfigFile(scan2, join17(cwd, ".claude", "settings.local.json"), "local", "Local overrides");
|
|
36913
|
+
memoryConfigFile(scan2, join17(claudeDir, "CLAUDE.md"), "user", "User memory");
|
|
36914
|
+
memoryConfigFile(scan2, join17(cwd, "CLAUDE.md"), "project", "Project memory");
|
|
36915
|
+
mcpJsonConfigFile(scan2, join17(cwd, ".mcp.json"));
|
|
36916
|
+
dirConfigFile(scan2, join17(cwd, ".claude", "commands"), "Slash commands", "command");
|
|
36917
|
+
dirConfigFile(scan2, join17(cwd, ".claude", "agents"), "Subagents", "subagent");
|
|
36720
36918
|
}
|
|
36721
36919
|
function configFileEntry(path, scope, kind) {
|
|
36722
36920
|
try {
|
|
@@ -36791,7 +36989,7 @@ function countMarkdownFiles(dir, depth) {
|
|
|
36791
36989
|
let count = 0;
|
|
36792
36990
|
for (const dirent of readdirSync2(dir, { withFileTypes: true })) {
|
|
36793
36991
|
if (dirent.name.startsWith(".")) continue;
|
|
36794
|
-
if (dirent.isDirectory()) count += countMarkdownFiles(
|
|
36992
|
+
if (dirent.isDirectory()) count += countMarkdownFiles(join17(dir, dirent.name), depth + 1);
|
|
36795
36993
|
else if (dirent.name.endsWith(".md")) count += 1;
|
|
36796
36994
|
}
|
|
36797
36995
|
return count;
|
|
@@ -36804,7 +37002,7 @@ function collectSkillsDir(scan2, dir, origin) {
|
|
|
36804
37002
|
return;
|
|
36805
37003
|
}
|
|
36806
37004
|
for (const name2 of names) {
|
|
36807
|
-
const skillFile =
|
|
37005
|
+
const skillFile = join17(dir, name2, "SKILL.md");
|
|
36808
37006
|
try {
|
|
36809
37007
|
const raw = readOptional(skillFile);
|
|
36810
37008
|
if (raw === void 0) continue;
|
|
@@ -36813,7 +37011,7 @@ function collectSkillsDir(scan2, dir, origin) {
|
|
|
36813
37011
|
name: front.name ?? name2,
|
|
36814
37012
|
source: origin.source,
|
|
36815
37013
|
scope: origin.scope,
|
|
36816
|
-
location:
|
|
37014
|
+
location: join17(dir, name2),
|
|
36817
37015
|
updatedAt: statSync7(skillFile).mtime.toISOString()
|
|
36818
37016
|
};
|
|
36819
37017
|
const version3 = front.version ?? origin.defaultVersion;
|
|
@@ -36844,7 +37042,7 @@ function parseFrontmatter(raw) {
|
|
|
36844
37042
|
return out;
|
|
36845
37043
|
}
|
|
36846
37044
|
function collectInstalledPlugins(scan2, claudeDir) {
|
|
36847
|
-
const manifestPath =
|
|
37045
|
+
const manifestPath = join17(claudeDir, "plugins", "installed_plugins.json");
|
|
36848
37046
|
const raw = readOptional(manifestPath);
|
|
36849
37047
|
if (raw === void 0) return;
|
|
36850
37048
|
let plugins;
|
|
@@ -36869,7 +37067,7 @@ function collectInstalledPlugins(scan2, claudeDir) {
|
|
|
36869
37067
|
if (typeof installPath !== "string" || seen.has(installPath)) continue;
|
|
36870
37068
|
seen.add(installPath);
|
|
36871
37069
|
const version3 = install.version;
|
|
36872
|
-
const hooksPath =
|
|
37070
|
+
const hooksPath = join17(installPath, "hooks", "hooks.json");
|
|
36873
37071
|
const hooksRaw = readOptional(hooksPath);
|
|
36874
37072
|
if (hooksRaw !== void 0) {
|
|
36875
37073
|
try {
|
|
@@ -36889,22 +37087,22 @@ function collectInstalledPlugins(scan2, claudeDir) {
|
|
|
36889
37087
|
}
|
|
36890
37088
|
const origin = { source: marketplace, scope: "plugin", pluginName };
|
|
36891
37089
|
if (typeof version3 === "string") origin.defaultVersion = version3;
|
|
36892
|
-
collectSkillsDir(scan2,
|
|
37090
|
+
collectSkillsDir(scan2, join17(installPath, "skills"), origin);
|
|
36893
37091
|
const mcpOrigin = { scope: "plugin", pluginName, marketplace };
|
|
36894
|
-
collectMcpFile(scan2,
|
|
37092
|
+
collectMcpFile(scan2, join17(installPath, ".mcp.json"), mcpOrigin, { recordErrors: true });
|
|
36895
37093
|
collectPluginManifestMcp(scan2, installPath, mcpOrigin);
|
|
36896
37094
|
}
|
|
36897
37095
|
}
|
|
36898
37096
|
}
|
|
36899
37097
|
function collectMarketplaceSkills(scan2, claudeDir) {
|
|
36900
|
-
for (const mp of readMarketplaces(
|
|
37098
|
+
for (const mp of readMarketplaces(join17(claudeDir, "plugins", "known_marketplaces.json"))) {
|
|
36901
37099
|
if (isClaudeOfficialMarketplace(mp.name, mp.repo)) continue;
|
|
36902
|
-
collectSkillsDir(scan2,
|
|
37100
|
+
collectSkillsDir(scan2, join17(mp.installLocation, "skills"), {
|
|
36903
37101
|
source: mp.name,
|
|
36904
37102
|
scope: "plugin"
|
|
36905
37103
|
});
|
|
36906
|
-
collectPluginSkillDirs(scan2,
|
|
36907
|
-
collectPluginSkillDirs(scan2,
|
|
37104
|
+
collectPluginSkillDirs(scan2, join17(mp.installLocation, "plugins"), mp.name);
|
|
37105
|
+
collectPluginSkillDirs(scan2, join17(mp.installLocation, "external_plugins"), mp.name);
|
|
36908
37106
|
}
|
|
36909
37107
|
}
|
|
36910
37108
|
function collectPluginSkillDirs(scan2, pluginsDir, marketplace) {
|
|
@@ -36915,7 +37113,7 @@ function collectPluginSkillDirs(scan2, pluginsDir, marketplace) {
|
|
|
36915
37113
|
return;
|
|
36916
37114
|
}
|
|
36917
37115
|
for (const plugin of plugins) {
|
|
36918
|
-
collectSkillsDir(scan2,
|
|
37116
|
+
collectSkillsDir(scan2, join17(pluginsDir, plugin, "skills"), {
|
|
36919
37117
|
source: marketplace,
|
|
36920
37118
|
scope: "plugin",
|
|
36921
37119
|
pluginName: plugin
|
|
@@ -37022,7 +37220,7 @@ function buildIngestEvent(input2) {
|
|
|
37022
37220
|
}
|
|
37023
37221
|
|
|
37024
37222
|
// ../../packages/plugin-sdk/src/isolated-scan.ts
|
|
37025
|
-
import { existsSync as
|
|
37223
|
+
import { existsSync as existsSync10 } from "fs";
|
|
37026
37224
|
import { fileURLToPath } from "url";
|
|
37027
37225
|
import { Worker } from "worker_threads";
|
|
37028
37226
|
var ISOLATED_SCAN_BUDGET_MS = 2e3;
|
|
@@ -37036,7 +37234,7 @@ function resolveWorkerUrl() {
|
|
|
37036
37234
|
for (const name2 of ["scan-worker.js", "scan-worker.ts"]) {
|
|
37037
37235
|
const candidate = new URL(name2, import.meta.url);
|
|
37038
37236
|
try {
|
|
37039
|
-
if (
|
|
37237
|
+
if (existsSync10(fileURLToPath(candidate))) {
|
|
37040
37238
|
resolvedWorkerUrl = candidate;
|
|
37041
37239
|
return candidate;
|
|
37042
37240
|
}
|
|
@@ -37499,13 +37697,48 @@ function createGuardedScanner(partition, gateway, opts) {
|
|
|
37499
37697
|
};
|
|
37500
37698
|
}
|
|
37501
37699
|
|
|
37700
|
+
// ../../packages/plugin-sdk/src/host-floor.ts
|
|
37701
|
+
import { readFileSync as readFileSync12 } from "fs";
|
|
37702
|
+
import { join as join19 } from "path";
|
|
37703
|
+
|
|
37704
|
+
// ../../packages/plugin-sdk/src/model-governance.ts
|
|
37705
|
+
import {
|
|
37706
|
+
closeSync as closeSync2,
|
|
37707
|
+
fstatSync,
|
|
37708
|
+
mkdirSync as mkdirSync2,
|
|
37709
|
+
openSync as openSync2,
|
|
37710
|
+
readFileSync as readFileSync11,
|
|
37711
|
+
readSync,
|
|
37712
|
+
writeFileSync as writeFileSync5
|
|
37713
|
+
} from "fs";
|
|
37714
|
+
import { join as join18 } from "path";
|
|
37715
|
+
var TAIL_BYTES = 256 * 1024;
|
|
37716
|
+
|
|
37717
|
+
// ../../packages/plugin-sdk/src/host-floor.ts
|
|
37718
|
+
var HOST_FEATURE = {
|
|
37719
|
+
ModelSwitch: "model-switch",
|
|
37720
|
+
VaultPointerDisplay: "vault-pointer-display"
|
|
37721
|
+
};
|
|
37722
|
+
var HOST_FLOORS = {
|
|
37723
|
+
[HOST_FEATURE.ModelSwitch]: {
|
|
37724
|
+
label: "model-switch protection",
|
|
37725
|
+
hookEvents: ["PreModelSwitch", "PostModelSwitch"],
|
|
37726
|
+
since: "2.1.251"
|
|
37727
|
+
},
|
|
37728
|
+
[HOST_FEATURE.VaultPointerDisplay]: {
|
|
37729
|
+
label: "vault pointer display",
|
|
37730
|
+
hookEvents: ["MessageDisplay"],
|
|
37731
|
+
since: "2.1.152"
|
|
37732
|
+
}
|
|
37733
|
+
};
|
|
37734
|
+
|
|
37502
37735
|
// ../../packages/plugin-sdk/src/ignore-layers.ts
|
|
37503
37736
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
37504
|
-
import { readFileSync as
|
|
37505
|
-
import { join as
|
|
37737
|
+
import { readFileSync as readFileSync13 } from "fs";
|
|
37738
|
+
import { join as join20 } from "path";
|
|
37506
37739
|
function readIgnoreLayer(dir, filename, anchorLen) {
|
|
37507
37740
|
try {
|
|
37508
|
-
return { matcher: (0, import_ignore.default)().add(
|
|
37741
|
+
return { matcher: (0, import_ignore.default)().add(readFileSync13(join20(dir, filename), "utf8")), anchorLen };
|
|
37509
37742
|
} catch {
|
|
37510
37743
|
return void 0;
|
|
37511
37744
|
}
|
|
@@ -37561,31 +37794,18 @@ function resolveInventoryContext(input2) {
|
|
|
37561
37794
|
return ctx;
|
|
37562
37795
|
}
|
|
37563
37796
|
|
|
37564
|
-
// ../../packages/plugin-sdk/src/model-governance.ts
|
|
37565
|
-
import {
|
|
37566
|
-
closeSync as closeSync2,
|
|
37567
|
-
fstatSync,
|
|
37568
|
-
mkdirSync as mkdirSync2,
|
|
37569
|
-
openSync as openSync2,
|
|
37570
|
-
readFileSync as readFileSync12,
|
|
37571
|
-
readSync,
|
|
37572
|
-
writeFileSync as writeFileSync5
|
|
37573
|
-
} from "fs";
|
|
37574
|
-
import { join as join18 } from "path";
|
|
37575
|
-
var TAIL_BYTES = 256 * 1024;
|
|
37576
|
-
|
|
37577
37797
|
// ../../packages/plugin-sdk/src/nudge.ts
|
|
37578
|
-
import { mkdirSync as mkdirSync3, readFileSync as
|
|
37579
|
-
import { join as
|
|
37798
|
+
import { mkdirSync as mkdirSync3, readFileSync as readFileSync14, writeFileSync as writeFileSync6 } from "fs";
|
|
37799
|
+
import { join as join21 } from "path";
|
|
37580
37800
|
var SESSION_START_MARKER = "session-start-last";
|
|
37581
37801
|
function claimSessionStart(dataDir2, sessionId) {
|
|
37582
37802
|
return claimOncePerSession(dataDir2, SESSION_START_MARKER, sessionId);
|
|
37583
37803
|
}
|
|
37584
37804
|
function claimOncePerSession(dataDir2, marker, sessionId) {
|
|
37585
37805
|
if (!sessionId) return true;
|
|
37586
|
-
const path =
|
|
37806
|
+
const path = join21(dataDir2, marker);
|
|
37587
37807
|
try {
|
|
37588
|
-
if (
|
|
37808
|
+
if (readFileSync14(path, "utf8") === sessionId) return false;
|
|
37589
37809
|
} catch {
|
|
37590
37810
|
}
|
|
37591
37811
|
try {
|
|
@@ -37636,8 +37856,8 @@ function createPolicyResolver(bundle) {
|
|
|
37636
37856
|
}
|
|
37637
37857
|
|
|
37638
37858
|
// ../../packages/plugin-sdk/src/project-files.ts
|
|
37639
|
-
import { existsSync as
|
|
37640
|
-
import { basename as basename6, join as
|
|
37859
|
+
import { existsSync as existsSync11, readdirSync as readdirSync4 } from "fs";
|
|
37860
|
+
import { basename as basename6, join as join22 } from "path";
|
|
37641
37861
|
var SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
37642
37862
|
".git",
|
|
37643
37863
|
"node_modules",
|
|
@@ -37734,8 +37954,8 @@ function resolveProjectFiles(cwd, opts = {}) {
|
|
|
37734
37954
|
}
|
|
37735
37955
|
if (entry.isDirectory()) {
|
|
37736
37956
|
if (SKIP_DIRS.has(entry.name) || isIgnored(dirLayers, dirRel, entry.name, true)) continue;
|
|
37737
|
-
const fullPath =
|
|
37738
|
-
if (
|
|
37957
|
+
const fullPath = join22(dir, entry.name);
|
|
37958
|
+
if (existsSync11(join22(fullPath, ".git"))) continue;
|
|
37739
37959
|
if (depth >= bounds.maxDepth) {
|
|
37740
37960
|
walk.omitted = true;
|
|
37741
37961
|
continue;
|
|
@@ -37803,6 +38023,14 @@ var CodexProviderEnvSchema = external_exports.object(codexProviderEnvShape);
|
|
|
37803
38023
|
// ../../packages/plugin-sdk/src/runtime.ts
|
|
37804
38024
|
import { randomUUID as randomUUID14 } from "crypto";
|
|
37805
38025
|
var ENFORCEMENT_CEILING_ENABLED = false;
|
|
38026
|
+
function applyEnforcementCeiling(action, policyMode, enabled) {
|
|
38027
|
+
if (!enabled || policyMode !== "warn") return action;
|
|
38028
|
+
return action === "block" || action === "redact" ? "warn" : action;
|
|
38029
|
+
}
|
|
38030
|
+
function resolveEnforcedAction(action, opts) {
|
|
38031
|
+
const degraded = !opts.rewritable && action === "redact" ? builtinPolicyToAction(opts.redactFallback) : action;
|
|
38032
|
+
return applyEnforcementCeiling(degraded, opts.policyMode, opts.ceilingEnabled);
|
|
38033
|
+
}
|
|
37806
38034
|
function startTiming() {
|
|
37807
38035
|
try {
|
|
37808
38036
|
return performance.now();
|
|
@@ -37911,12 +38139,12 @@ function createPluginRuntime(gateway, settings, opts) {
|
|
|
37911
38139
|
}
|
|
37912
38140
|
function actionForFinding(finding2, excepted, rewritable = true) {
|
|
37913
38141
|
if (excepted?.has(finding2)) return "allow";
|
|
37914
|
-
|
|
37915
|
-
|
|
37916
|
-
|
|
37917
|
-
|
|
37918
|
-
|
|
37919
|
-
|
|
38142
|
+
return resolveEnforcedAction(resolveAction(finding2.ruleId, finding2.category), {
|
|
38143
|
+
policyMode,
|
|
38144
|
+
redactFallback,
|
|
38145
|
+
rewritable,
|
|
38146
|
+
ceilingEnabled: ENFORCEMENT_CEILING_ENABLED
|
|
38147
|
+
});
|
|
37920
38148
|
}
|
|
37921
38149
|
function decide(findings, text, excepted, rewritable = true) {
|
|
37922
38150
|
if (findings.length === 0) return { action: "log", text, findings: [] };
|
|
@@ -38165,9 +38393,9 @@ var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
|
38165
38393
|
|
|
38166
38394
|
// ../../packages/plugin-sdk/src/throttle.ts
|
|
38167
38395
|
import { mkdirSync as mkdirSync4, statSync as statSync8, writeFileSync as writeFileSync7 } from "fs";
|
|
38168
|
-
import { join as
|
|
38396
|
+
import { join as join23 } from "path";
|
|
38169
38397
|
function throttled(dataDir2, markerName, windowMs) {
|
|
38170
|
-
const marker =
|
|
38398
|
+
const marker = join23(dataDir2, markerName);
|
|
38171
38399
|
try {
|
|
38172
38400
|
if (Date.now() - statSync8(marker).mtimeMs < windowMs) return true;
|
|
38173
38401
|
} catch {
|
|
@@ -38218,7 +38446,7 @@ function parseBreakerState(raw, nowMs) {
|
|
|
38218
38446
|
}
|
|
38219
38447
|
function createForwardPolicy(deps) {
|
|
38220
38448
|
const now = deps.now ?? (() => Date.now());
|
|
38221
|
-
const file2 =
|
|
38449
|
+
const file2 = join24(deps.dir, STATE_FILENAME);
|
|
38222
38450
|
let state = null;
|
|
38223
38451
|
let loading = null;
|
|
38224
38452
|
async function readState() {
|
|
@@ -38940,8 +39168,8 @@ function toolAuditEvent(input2) {
|
|
|
38940
39168
|
}
|
|
38941
39169
|
|
|
38942
39170
|
// ../../packages/plugin-runtime/src/attached/history-state.ts
|
|
38943
|
-
import { readFileSync as
|
|
38944
|
-
import { join as
|
|
39171
|
+
import { readFileSync as readFileSync16 } from "fs";
|
|
39172
|
+
import { join as join25 } from "path";
|
|
38945
39173
|
|
|
38946
39174
|
// ../../packages/plugin-runtime/src/attached/history-sync.ts
|
|
38947
39175
|
import { createHash as createHash6 } from "crypto";
|
|
@@ -38982,7 +39210,7 @@ function spawnDetached(scriptPath) {
|
|
|
38982
39210
|
}
|
|
38983
39211
|
|
|
38984
39212
|
// ../../packages/plugin-runtime/src/attached/plugin-block.ts
|
|
38985
|
-
import { readFileSync as
|
|
39213
|
+
import { readFileSync as readFileSync17 } from "fs";
|
|
38986
39214
|
function createPluginBlock(build, policyStore) {
|
|
38987
39215
|
return async () => {
|
|
38988
39216
|
const cached2 = await policyStore.read();
|
|
@@ -39001,7 +39229,7 @@ function createPluginBlock(build, policyStore) {
|
|
|
39001
39229
|
// ../../packages/plugin-runtime/src/attached/policy-store.ts
|
|
39002
39230
|
import { randomUUID as randomUUID16 } from "crypto";
|
|
39003
39231
|
import { readFile as readFile2, rm, writeFile as writeFile2 } from "fs/promises";
|
|
39004
|
-
import { join as
|
|
39232
|
+
import { join as join26 } from "path";
|
|
39005
39233
|
|
|
39006
39234
|
// ../../packages/plugin-runtime/src/attached/atomic-publish.ts
|
|
39007
39235
|
import { rename as rename2 } from "fs/promises";
|
|
@@ -39025,7 +39253,7 @@ async function publishByRename(tmp, file2, move = rename2) {
|
|
|
39025
39253
|
|
|
39026
39254
|
// ../../packages/plugin-runtime/src/attached/policy-store.ts
|
|
39027
39255
|
function createPolicyStore(dir = dataDir()) {
|
|
39028
|
-
const file2 =
|
|
39256
|
+
const file2 = join26(dir, "policy-cache.json");
|
|
39029
39257
|
async function read() {
|
|
39030
39258
|
try {
|
|
39031
39259
|
const raw = await readFile2(file2, "utf8");
|
|
@@ -39256,11 +39484,11 @@ function readStorePosture(dbPath2) {
|
|
|
39256
39484
|
// ../../packages/plugin-runtime/src/attached/posture-store.ts
|
|
39257
39485
|
import { randomUUID as randomUUID17 } from "crypto";
|
|
39258
39486
|
import { readFile as readFile3, rm as rm2, writeFile as writeFile3 } from "fs/promises";
|
|
39259
|
-
import { join as
|
|
39487
|
+
import { join as join27 } from "path";
|
|
39260
39488
|
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
39261
39489
|
function createPostureStore(dir = settingsDir(), legacyDir) {
|
|
39262
|
-
const file2 =
|
|
39263
|
-
const legacyFile = legacyDir === void 0 ? null :
|
|
39490
|
+
const file2 = join27(dir, "posture-state.json");
|
|
39491
|
+
const legacyFile = legacyDir === void 0 ? null : join27(legacyDir, "posture-state.json");
|
|
39264
39492
|
async function persist(state) {
|
|
39265
39493
|
await ensureDataDir(dir);
|
|
39266
39494
|
const tmp = `${file2}.${randomUUID17()}.tmp`;
|
|
@@ -39328,8 +39556,8 @@ function createPostureStore(dir = settingsDir(), legacyDir) {
|
|
|
39328
39556
|
}
|
|
39329
39557
|
|
|
39330
39558
|
// ../../packages/plugin-runtime/src/attached/sync-state.ts
|
|
39331
|
-
import { readFileSync as
|
|
39332
|
-
import { join as
|
|
39559
|
+
import { readFileSync as readFileSync18 } from "fs";
|
|
39560
|
+
import { join as join28 } from "path";
|
|
39333
39561
|
|
|
39334
39562
|
// ../../packages/plugin-runtime/src/attached/status.ts
|
|
39335
39563
|
var REFUSAL_LINES = {
|