diff --git a/ui/app/(prowler)/attack-paths/(workflow)/query-builder/attack-paths-page.tsx b/ui/app/(prowler)/attack-paths/(workflow)/query-builder/attack-paths-page.tsx index 477003b206..850935067c 100644 --- a/ui/app/(prowler)/attack-paths/(workflow)/query-builder/attack-paths-page.tsx +++ b/ui/app/(prowler)/attack-paths/(workflow)/query-builder/attack-paths-page.tsx @@ -412,6 +412,7 @@ export default function AttackPathsPage() { >; const lighthouseContext = scanId ? buildAttackPathContext({ + pathname, scanId, queryId: queryBuilder.selectedQuery, queryLabel: queryBuilder.selectedQueryData?.attributes.name, diff --git a/ui/lib/lighthouse/context/contributions.test.ts b/ui/lib/lighthouse/context/contributions.test.ts index e091d1d5c9..26ec90ad31 100644 --- a/ui/lib/lighthouse/context/contributions.test.ts +++ b/ui/lib/lighthouse/context/contributions.test.ts @@ -144,6 +144,7 @@ describe("Lighthouse page contributions", () => { it("builds an attack-path snapshot and excludes unsafe query parameters", () => { expect( buildAttackPathContext({ + pathname: "/attack-paths/query-builder", scanId: "scan-1", queryId: "internet-exposed", queryLabel: "Internet exposed resources", @@ -162,7 +163,7 @@ describe("Lighthouse page contributions", () => { kind: "attack_path", id: "current-query", source: "automatic", - scopeKey: "attack-paths:/attack-paths", + scopeKey: "attack-paths:/attack-paths/query-builder", label: "Internet exposed resources", scanId: "scan-1", queryId: "internet-exposed", @@ -178,6 +179,17 @@ describe("Lighthouse page contributions", () => { }); }); + it("builds an attack-path scope from the current route", () => { + // Given / When + const context = buildAttackPathContext({ + pathname: "/attack-paths", + scanId: "scan-1", + }); + + // Then + expect(context.scopeKey).toBe("attack-paths:/attack-paths"); + }); + it("builds scan summary and selected scan snapshots", () => { expect(buildScanSummaryContext(9, "completed")).toEqual({ kind: "scan", diff --git a/ui/lib/lighthouse/context/contributions.ts b/ui/lib/lighthouse/context/contributions.ts index 258f05929a..0110b77495 100644 --- a/ui/lib/lighthouse/context/contributions.ts +++ b/ui/lib/lighthouse/context/contributions.ts @@ -64,6 +64,7 @@ interface ComplianceContextInput { } interface AttackPathContextInput { + pathname: string; scanId: string; queryId?: string | null; queryLabel?: string; @@ -211,7 +212,7 @@ export function buildAttackPathContext( kind: LIGHTHOUSE_CONTEXT_KIND.ATTACK_PATH, id: input.queryId ? "current-query" : "current-scan", source: LIGHTHOUSE_CONTEXT_SOURCE.AUTOMATIC, - scopeKey: getLighthouseScopeKey("/attack-paths"), + scopeKey: getLighthouseScopeKey(input.pathname), label: toBoundedString(input.queryLabel || "Selected attack-path scan"), scanId: toBoundedString(input.scanId), queryId: optionalBoundedString(input.queryId ?? undefined),