Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

revamp UI for findings

Matheus Nogueira587a63f8d93d
diff --git a/frontend/src/helpers/secretScanningV2.ts b/frontend/src/helpers/secretScanningV2.ts
index ee52266110..30dc26382a 100644
--- a/frontend/src/helpers/secretScanningV2.ts
+++ b/frontend/src/helpers/secretScanningV2.ts
@@ -72,26 +72,47 @@ export const RESOURCE_DESCRIPTION_HELPER: Record<
export const SECRET_SCANNING_FINDING_STATUS_MAP: Record<
SecretScanningFindingStatus,
- { Icon: LucideIcon; variant: TBadgeProps["variant"]; className: string }
+ {
+ Icon: LucideIcon;
+ variant: TBadgeProps["variant"];
+ className: string;
+ name: string;
+ description: string;
+ }
> = {
[SecretScanningFindingStatus.Resolved]: {
Icon: CheckIcon,
variant: "success",
- className: "text-success"
+ className: "text-success",
+ name: "Resolved",
+ description: "The credential was rotated or revoked."
},
[SecretScanningFindingStatus.Unresolved]: {
Icon: AlertTriangleIcon,
variant: "warning",
- className: "text-warning"
+ className: "text-warning",
+ name: "Unresolved",
+ description: "Needs review. New findings start here."
},
[SecretScanningFindingStatus.Ignore]: {
Icon: BanIcon,
variant: "neutral",
- className: "text-neutral"
+ className: "text-neutral",
+ name: "Ignored",
+ description: "The risk is accepted. Ignored findings don't count as unresolved."
},
[SecretScanningFindingStatus.FalsePositive]: {
Icon: SearchSlashIcon,
variant: "neutral",
- className: "text-neutral"
+ className: "text-neutral",
+ name: "False Positive",
+ description: "Not a secret. The rule matched something harmless."
}
};
+
+export const SECRET_SCANNING_FINDING_STATUS_ORDER = [
+ SecretScanningFindingStatus.Unresolved,
+ SecretScanningFindingStatus.Resolved,
+ SecretScanningFindingStatus.FalsePositive,
+ SecretScanningFindingStatus.Ignore
+] as const;
diff --git a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/SecretScanningDataSourceByIdPage.tsx b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/SecretScanningDataSourceByIdPage.tsx
index e7df66905e..38fe635905 100644
--- a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/SecretScanningDataSourceByIdPage.tsx
+++ b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/SecretScanningDataSourceByIdPage.tsx
@@ -5,16 +5,26 @@ import { useNavigate, useParams } from "@tanstack/react-router";
import { ProjectPermissionCan } from "@app/components/permissions";
import { Button, ContentLoader, EmptyState } from "@app/components/v2";
-import { ProviderIcon } from "@app/components/v3";
+import {
+ CardDescription,
+ CardHeader,
+ CardTitle,
+ DocumentationLinkBadge,
+ ProviderIcon
+} from "@app/components/v3";
import { ROUTE_PATHS } from "@app/const/routes";
import { ProjectPermissionSub } from "@app/context";
-import { ProjectPermissionSecretScanningDataSourceActions } from "@app/context/ProjectPermissionContext/types";
+import {
+ ProjectPermissionSecretScanningDataSourceActions,
+ ProjectPermissionSecretScanningFindingActions
+} from "@app/context/ProjectPermissionContext/types";
import { SECRET_SCANNING_DATA_SOURCE_MAP } from "@app/helpers/secretScanningV2";
import {
SecretScanningDataSource,
useGetSecretScanningDataSource
} from "@app/hooks/api/secretScanningV2";
+import { SecretScanningFindingsSection } from "../components/findings";
import {
SecretScanningDataSourceSection,
SecretScanningResourceSection,
@@ -86,7 +96,25 @@ const PageContent = () => {
<div className="mr-4 flex w-72 flex-col gap-4">
<SecretScanningDataSourceSection dataSource={dataSource} />
</div>
- <div className="flex flex-1 flex-col gap-4">
+ <div className="flex min-w-0 flex-1 flex-col gap-4">
+ <ProjectPermissionCan
+ passThrough={false}
+ I={ProjectPermissionSecretScanningFindingActions.Read}
+ a={ProjectPermissionSub.SecretScanningFindings}
+ >
+ <SecretScanningFindingsSection
+ dataSource={dataSource}
+ cardHeader={
+ <CardHeader>
+ <CardTitle>
+ Findings
+ <DocumentationLinkBadge href="https://infisical.com/docs/documentation/platform/secret-scanning/findings" />
+ </CardTitle>
+ <CardDescription>Secrets detected in this data source.</CardDescription>
+ </CardHeader>
+ }
+ />
+ </ProjectPermissionCan>
<SecretScanningResourceSection dataSource={dataSource} />
<SecretScanningScanSection dataSource={dataSource} />
</div>
diff --git a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/SecretScanningResourceRow.tsx b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/SecretScanningResourceRow.tsx
index a39270ce68..c1f068a360 100644
--- a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/SecretScanningResourceRow.tsx
+++ b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/SecretScanningResourceRow.tsx
@@ -152,7 +152,8 @@ export const SecretScanningResourceRow = ({ resource, dataSource }: Props) => {
orgId: currentOrg.id
},
search: {
- search: name,
+ dataSourceId: dataSource.id,
+ resourceId: id,
status: SecretScanningFindingStatus.Unresolved
}
})
diff --git a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/SecretScanningScanRow.tsx b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/SecretScanningScanRow.tsx
index 3a3b91d786..821f2fda9e 100644
--- a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/SecretScanningScanRow.tsx
+++ b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/SecretScanningScanRow.tsx
@@ -1,7 +1,6 @@
import { useCallback } from "react";
import { faCheck, faCopy, faEllipsisV } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { useNavigate } from "@tanstack/react-router";
import { format } from "date-fns";
import { AlertTriangleIcon, CheckIcon } from "lucide-react";
import { twMerge } from "tailwind-merge";
@@ -19,7 +18,6 @@ import {
Tr
} from "@app/components/v2";
import { Badge } from "@app/components/v3";
-import { useOrganization } from "@app/context";
import { useToggle } from "@app/hooks";
import {
SecretScanningScanStatus,
@@ -42,9 +40,7 @@ export const SecretScanningScanRow = ({ scan }: Props) => {
resolvedFindings,
type
} = scan;
- const { currentOrg } = useOrganization();
const totalFindings = resolvedFindings + unresolvedFindings;
- const navigate = useNavigate();
const [isIdCopied, setIsIdCopied] = useToggle(false);
@@ -93,27 +89,12 @@ export const SecretScanningScanRow = ({ scan }: Props) => {
) : // eslint-disable-next-line no-nested-ternary
totalFindings ? (
<div className="flex flex-col">
- <Badge asChild variant={unresolvedFindings ? "warning" : "success"}>
- <button
- type="button"
- onClick={() =>
- navigate({
- to: "/organizations/$orgId/secret-scanning/findings",
- params: {
- orgId: currentOrg.id
- },
- search: {
- search: `scanId:${id}`
- }
- })
- }
- >
- {unresolvedFindings ? <AlertTriangleIcon /> : <CheckIcon />}
- {totalFindings}{" "}
- {unresolvedFindings
- ? `Secret${totalFindings > 1 ? "s" : ""} Detected`
- : "Leak Resolved"}
- </button>
+ <Badge variant={unresolvedFindings ? "warning" : "success"}>
+ {unresolvedFindings ? <AlertTriangleIcon /> : <CheckIcon />}
+ {totalFindings}{" "}
+ {unresolvedFindings
+ ? `Secret${totalFindings > 1 ? "s" : ""} Detected`
+ : "Leak Resolved"}
</Badge>
</div>
) : status === SecretScanningScanStatus.Failed ? (
diff --git a/frontend/src/pages/secret-scanning/SecretScanningDataSourcesPage/components/SecretScanningDataSourceRow.tsx b/frontend/src/pages/secret-scanning/SecretScanningDataSourcesPage/components/SecretScanningDataSourceRow.tsx
index 42b1842123..2181bbb380 100644
--- a/frontend/src/pages/secret-scanning/SecretScanningDataSourcesPage/components/SecretScanningDataSourceRow.tsx
+++ b/frontend/src/pages/secret-scanning/SecretScanningDataSourcesPage/components/SecretScanningDataSourceRow.tsx
@@ -155,7 +155,7 @@ export const SecretScanningDataSourceRow = ({
orgId: currentOrg.id
},
search: {
- search: name,
+ dataSourceId: id,
status: SecretScanningFindingStatus.Unresolved
}
});
diff --git a/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/SecretScanningFindingsPage.tsx b/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/SecretScanningFindingsPage.tsx
index b8dc0142fd..9ef1e63636 100644
--- a/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/SecretScanningFindingsPage.tsx
+++ b/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/SecretScanningFindingsPage.tsx
@@ -1,16 +1,22 @@
import { Helmet } from "react-helmet";
import { useTranslation } from "react-i18next";
+import { useSearch } from "@tanstack/react-router";
import { ProjectPermissionCan } from "@app/components/permissions";
import { PageHeader } from "@app/components/v3/platform";
+import { ROUTE_PATHS } from "@app/const/routes";
import { ProjectPermissionSub } from "@app/context";
import { ProjectPermissionSecretScanningFindingActions } from "@app/context/ProjectPermissionContext/types";
import { ProjectType } from "@app/hooks/api/projects/types";
-import { SecretScanningFindingsSection } from "./components";
+import { SecretScanningFindingsSection } from "../components/findings";
export const SecretScanningFindingsPage = () => {
const { t } = useTranslation();
+ const { status, dataSourceId, resourceId } = useSearch({
+ from: ROUTE_PATHS.SecretScanning.FindingsPage.id
+ });
+
return (
<>
<Helmet>
@@ -27,9 +33,13 @@ export const SecretScanningFindingsPage = () => {
<PageHeader
scope={ProjectType.SecretScanning}
title="Findings"
- description="View secret leaks across your data sources."
+ description="Secrets detected across every data source."
+ />
+ <SecretScanningFindingsSection
+ initialStatus={status}
+ initialDataSourceId={dataSourceId}
+ initialResourceId={resourceId}
/>
- <SecretScanningFindingsSection />
</div>
</div>
</div>
diff --git a/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/components/SecretScanningFindingRow.tsx b/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/components/SecretScanningFindingRow.tsx
deleted file mode 100644
index 2f33fa2419..0000000000
--- a/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/components/SecretScanningFindingRow.tsx
+++ /dev/null
@@ -1,240 +0,0 @@
-import { useCallback } from "react";
-import { faCheck, faCopy, faEllipsisV } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { format } from "date-fns";
-import { twMerge } from "tailwind-merge";
-
-import { createNotification } from "@app/components/notifications";
-import { ProjectPermissionCan } from "@app/components/permissions";
-import {
- Button,
- Checkbox,
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
- GenericFieldLabel,
- IconButton,
- Td,
- Tooltip,
- Tr
-} from "@app/components/v2";
-import { Badge, ProviderIcon } from "@app/components/v3";
-import {
- ProjectPermissionSecretScanningFindingActions,
- ProjectPermissionSub
-} from "@app/context/ProjectPermissionContext/types";
-import {
- SECRET_SCANNING_DATA_SOURCE_MAP,
- SECRET_SCANNING_FINDING_STATUS_MAP
-} from "@app/helpers/secretScanningV2";
-import { useToggle } from "@app/hooks";
-import { TSecretScanningFinding } from "@app/hooks/api/secretScanningV2";
-
-type Props = {
- isSelected: boolean;
- onToggleSelect: (e: boolean) => void;
- finding: TSecretScanningFinding;
- onUpdate: (finding: TSecretScanningFinding) => void;
-};
-
-export const SecretScanningFindingRow = ({
- isSelected,
- onToggleSelect,
- finding,
- onUpdate
-}: Props) => {
- const {
- resourceName,
- id,
- dataSourceType,
- createdAt,
- dataSourceName,
- rule,
- status,
- details,
- triageComment
- } = finding;
-
- const [isIdCopied, setIsIdCopied] = useToggle(false);
-
- const handleCopyId = useCallback(
- (idToCopy: string) => {
- setIsIdCopied.on();
- navigator.clipboard.writeText(idToCopy);
-
- createNotification({
- text: "Resource ID copied to clipboard",
- type: "info"
- });
-
- const timer = setTimeout(() => setIsIdCopied.off(), 2000);
-
- // eslint-disable-next-line consistent-return
- return () => clearTimeout(timer);
- },
- [isIdCopied]
- );
-
- const sourceDetails = SECRET_SCANNING_DATA_SOURCE_MAP[dataSourceType];
-
- const [isExpanded, setIsExpanded] = useToggle(false);
-
- const StatusIcon = SECRET_SCANNING_FINDING_STATUS_MAP[status].Icon;
-
- return (
- <>
- <Tr
- onClick={setIsExpanded.toggle}
- className={twMerge(
- "group h-10 cursor-pointer transition-colors duration-100 hover:bg-surface-hover"
- )}
- key={`resource-${id}`}
- >
- <Td className="pr-0">
- <Checkbox
- id={`checkbox-${id}`}
- isChecked={isSelected}
- onCheckedChange={() => onToggleSelect(!isSelected)}
- onClick={(e) => {
- e.stopPropagation();
- }}
- />
- </Td>
- <Td className="max-w-0 min-w-16!">
- <div className="flex w-full items-center">
- <ProviderIcon
- alt={`${sourceDetails.name} Data Source`}
- icon={sourceDetails.image}
- className="w-5"
- />
- <p className="ml-2 truncate">{sourceDetails.name}</p>
- </div>
- </Td>
- <Td>
- <div className="flex items-center gap-1 whitespace-nowrap">
- <p>{format(createdAt, "MMM dd yyyy")}</p>
- <p className="text-label">{format(createdAt, "h:mm aa")}</p>
- </div>
- </Td>
- <Td className="max-w-0 min-w-32!">
- <div className="w-full items-center">
- <p className="truncate">{resourceName}</p>
- <p className="truncate text-xs text-muted">{dataSourceName}</p>
- </div>
- </Td>
- <Td className="whitespace-nowrap">{rule}</Td>
- <Td className="whitespace-nowrap">
- <Tooltip position="left" content={triageComment}>
- <Badge variant={SECRET_SCANNING_FINDING_STATUS_MAP[status].variant}>
- <StatusIcon />
- <span className="capitalize">{status.replace("-", " ")}</span>
- </Badge>
- </Tooltip>
- </Td>
- <Td>
- <Tooltip className="max-w-sm text-center" content="Options">
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <IconButton
- ariaLabel="Options"
- colorSchema="secondary"
- className="w-6"
- variant="plain"
- >
- <FontAwesomeIcon icon={faEllipsisV} />
- </IconButton>
- </DropdownMenuTrigger>
- <DropdownMenuContent sideOffset={2} align="end">
- <DropdownMenuItem
- icon={<FontAwesomeIcon icon={isIdCopied ? faCheck : faCopy} />}
- onClick={(e) => {
- e.stopPropagation();
- handleCopyId(id);
- }}
- >
- Copy Finding ID
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </Tooltip>
- </Td>
- </Tr>
- <Tr>
- <Td colSpan={7} className="border-none! p-0">
- <div
- className={`w-full bg-surface-base/75 transition-all duration-500 ${
- isExpanded ? "max-h-200 overflow-y-auto opacity-100" : "max-h-0 overflow-hidden"
- }`}
- >
- <div className="grid gap-4 p-4 2xl:grid-cols-6">
- <GenericFieldLabel truncate className="col-span-full" label="Description">
- {details.description}
- </GenericFieldLabel>
- <GenericFieldLabel truncate label="Date">
- {format(details.date, "MMM dd yyyy h:mm aa")}
- </GenericFieldLabel>
- <GenericFieldLabel truncate label="Author">
- {details.author}
- </GenericFieldLabel>
- <GenericFieldLabel className="col-span-4" truncate label="Email">
- {details.email}
- </GenericFieldLabel>
- <GenericFieldLabel truncate className="col-span-full" label="File">
- {details.file}
- </GenericFieldLabel>
- <GenericFieldLabel truncate className="col-span-full" label="Commit">
- {details.commit}
- </GenericFieldLabel>
- <GenericFieldLabel className="col-span-full" label="Commit Message">
- <div className="max-h-48 overflow-y-auto">{details.message}</div>
- </GenericFieldLabel>
- <GenericFieldLabel label="Start Line">{details.startLine}</GenericFieldLabel>
- <GenericFieldLabel label="End Line">{details.endLine}</GenericFieldLabel>
- <GenericFieldLabel label="Start Column">{details.startColumn}</GenericFieldLabel>
- <GenericFieldLabel label="End Column">{details.endColumn}</GenericFieldLabel>
- <GenericFieldLabel className="col-span-full" label="Link">
- <a
- target="_blank"
- rel="noopener noreferrer"
- className="cursor-pointer text-label underline underline-offset-2 hover:text-foreground"
- href={details.link}
- >
- {details.link}
- </a>
- </GenericFieldLabel>
- <div className="col-span-full flex items-center border-t border-border-strong" />
- <ProjectPermissionCan
- I={ProjectPermissionSecretScanningFindingActions.Update}
- a={ProjectPermissionSub.SecretScanningFindings}
- >
- {(isAllowed) => (
- <Button
- onClick={() => onUpdate(finding)}
- colorSchema="secondary"
- isDisabled={!isAllowed}
- leftIcon={
- <StatusIcon
- className={twMerge(
- "size-4",
- SECRET_SCANNING_FINDING_STATUS_MAP[status].className
- )}
- />
- }
- >
- Update Status
- </Button>
- )}
- </ProjectPermissionCan>
- {Boolean(triageComment) && (
- <GenericFieldLabel className="col-span-3" label="Remarks">
- {triageComment}
- </GenericFieldLabel>
- )}
- </div>
- </div>
- </Td>
- </Tr>
- </>
- );
-};
diff --git a/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/components/SecretScanningFindingsSection.tsx b/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/components/SecretScanningFindingsSection.tsx
deleted file mode 100644
index 1218d5379b..0000000000
--- a/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/components/SecretScanningFindingsSection.tsx
+++ /dev/null
@@ -1,36 +0,0 @@
-import { ContentLoader } from "@app/components/v2";
-import { DocumentationLinkBadge } from "@app/components/v3";
-import { useProject } from "@app/context";
-import { useListSecretScanningFindings } from "@app/hooks/api/secretScanningV2";
-
-import { SecretScanningFindingsTable } from "./SecretScanningFindingsTable";
-
-export const SecretScanningFindingsSection = () => {
- const { currentProject } = useProject();
-
- const { data: findings = [], isPending: isFindingsPending } = useListSecretScanningFindings(
- currentProject.id,
- {
- refetchInterval: 30000
- }
- );
-
- if (isFindingsPending) return <ContentLoader />;
-
- return (
- <div className="w-full rounded-lg border border-border-control bg-surface-base p-4">
- <div className="mb-4 flex items-center justify-between">
- <div>
- <div className="flex items-center gap-x-2">
- <p className="text-xl font-medium text-foreground">Findings</p>
- <DocumentationLinkBadge href="https://infisical.com/docs/documentation/platform/secret-scanning/findings" />
- </div>
- <p className="text-sm text-label-secondary">
- Secret leaks discovered across your data sources
- </p>
- </div>
- </div>
- <SecretScanningFindingsTable findings={findings} />
- </div>
- );
-};
diff --git a/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/components/SecretScanningFindingsTable.tsx b/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/components/SecretScanningFindingsTable.tsx
deleted file mode 100644
index b61b112fe9..0000000000
--- a/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/components/SecretScanningFindingsTable.tsx
+++ /dev/null
@@ -1,454 +0,0 @@
-import { useMemo, useState } from "react";
-import {
- faArrowDown,
- faArrowUp,
- faCheckCircle,
- faFilter,
- faMagnifyingGlass,
- faSearch
-} from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { useSearch } from "@tanstack/react-router";
-import { twMerge } from "tailwind-merge";
-
-import { ProjectPermissionCan } from "@app/components/permissions";
-import {
- Button,
- Checkbox,
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuLabel,
- DropdownMenuTrigger,
- EmptyState,
- IconButton,
- Input,
- Pagination,
- Table,
- TableContainer,
- TBody,
- Th,
- THead,
- Tr
-} from "@app/components/v2";
-import { ProviderIcon } from "@app/components/v3";
-import { ROUTE_PATHS } from "@app/const/routes";
-import {
- ProjectPermissionSecretScanningFindingActions,
- ProjectPermissionSub
-} from "@app/context/ProjectPermissionContext/types";
-import {
- SECRET_SCANNING_DATA_SOURCE_MAP,
- SECRET_SCANNING_FINDING_STATUS_MAP
-} from "@app/helpers/secretScanningV2";
-import { usePagination, usePopUp, useResetPageHelper } from "@app/hooks";
-import { OrderByDirection } from "@app/hooks/api/generic/types";
-import {
- SecretScanningDataSource,
- SecretScanningFindingStatus,
- TSecretScanningFinding
-} from "@app/hooks/api/secretScanningV2";
-
-import { SecretScanningFindingRow } from "./SecretScanningFindingRow";
-import { SecretScanningUpdateFindingModal } from "./SecretScanningUpdateFindingModal";
-
-enum FindingsOrderBy {
- ResourceName = "resource-name",
- Status = "status",
- Rule = "rule",
- Timestamp = "timestamp"
-}
-
-type DataSourceFilters = {
- dataSourceTypes: SecretScanningDataSource[];
- status: SecretScanningFindingStatus[];
-};
-
-type Props = {
- findings: TSecretScanningFinding[];
-};
-
-const getStatusOrderValue = (status: SecretScanningFindingStatus) => {
- switch (status) {
- case SecretScanningFindingStatus.Unresolved:
- return 0;
- case SecretScanningFindingStatus.Ignore:
- return 1;
- case SecretScanningFindingStatus.FalsePositive:
- return 2;
- default:
- return 3;
- }
-};
-
-export const SecretScanningFindingsTable = ({ findings }: Props) => {
- const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["updateFinding"] as const);
-
- const { search: initSearch, status: initStatus } = useSearch({
- from: ROUTE_PATHS.SecretScanning.FindingsPage.id
- });
-
- const [filters, setFilters] = useState<DataSourceFilters>({
- dataSourceTypes: [],
- status: initStatus ? [initStatus] : []
- });
-
- const [selectedRows, setSelectedRows] = useState<string[]>([]);
-
- const {
- search,
- setSearch,
- setPage,
- page,
- perPage,
- setPerPage,
- offset,
- orderDirection,
- toggleOrderDirection,
- orderBy,
- setOrderDirection,
- setOrderBy
- } = usePagination<FindingsOrderBy>(FindingsOrderBy.Timestamp, { initPerPage: 20, initSearch });
-
- const filteredFindings = useMemo(
- () =>
- findings
- .filter((finding) => {
- const { rule, resourceName, dataSourceType, dataSourceName, status, scanId } = finding;
-
- if (filters.dataSourceTypes.length && !filters.dataSourceTypes.includes(dataSourceType))
- return false;
-
- if (filters.status.length && !filters.status.includes(status)) {
- return false;
- }
-
- if (search.includes("scanId")) {
- return search.split(":")[1] === scanId;
- }
-
- const searchValue = search.trim().toLowerCase();
-
- return (
- SECRET_SCANNING_DATA_SOURCE_MAP[dataSourceType].name
- .toLowerCase()
- .includes(searchValue) ||
- resourceName.toLowerCase().includes(searchValue) ||
- dataSourceName.toLowerCase().includes(searchValue) ||
- rule.toLowerCase().includes(searchValue)
- );
- })
- .sort((a, b) => {
- const [findingOne, findingTwo] =
- orderDirection === OrderByDirection.ASC ? [a, b] : [b, a];
-
- switch (orderBy) {
- case FindingsOrderBy.Timestamp:
- return (
- new Date(findingTwo.createdAt).getTime() - new Date(findingOne.createdAt).getTime()
- );
- case FindingsOrderBy.Rule:
- return findingOne.rule.toLowerCase().localeCompare(findingTwo.rule.toLowerCase());
- case FindingsOrderBy.Status:
- return (
- getStatusOrderValue(findingOne.status) - getStatusOrderValue(findingTwo.status)
- );
- case FindingsOrderBy.ResourceName:
- default:
- return findingOne.resourceName
- .toLowerCase()
- .localeCompare(findingTwo.resourceName.toLowerCase());
- }
- }),
- [findings, orderDirection, search, orderBy, filters]
- );
-
- useResetPageHelper({
- totalCount: filteredFindings.length,
- offset,
- setPage
- });
-
- const currentPageData = useMemo(
- () => filteredFindings.slice(offset, perPage * page),
- [filteredFindings, offset, perPage, page]
- );
-
- const currentPageDataIds = useMemo(() => currentPageData.map((f) => f.id), [currentPageData]);
-
- const handleSort = (column: FindingsOrderBy) => {
- if (column === orderBy) {
- toggleOrderDirection();
- return;
- }
-
- setOrderBy(column);
- setOrderDirection(OrderByDirection.ASC);
- };
-
- const getClassName = (col: FindingsOrderBy) =>
- twMerge("ml-2", orderBy === col ? "" : "opacity-30");
-
- const getColSortIcon = (col: FindingsOrderBy) =>
- orderDirection === OrderByDirection.DESC && orderBy === col ? faArrowUp : faArrowDown;
-
- const isTableFiltered = Boolean(filters.dataSourceTypes.length || filters.status.length);
-
- return (
- <div>
- <div className="flex gap-2">
- <Input
- value={search}
- onChange={(e) => setSearch(e.target.value)}
- leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
- placeholder="Search findings..."
- className="flex-1"
- />
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <IconButton
- ariaLabel="Filter findings"
- variant="plain"
- size="sm"
- className={twMerge(
- "flex h-10 w-11 items-center justify-center overflow-hidden border border-border-control bg-surface-raised p-0 transition-all hover:border-project/60 hover:bg-project/10",
- isTableFiltered && "border-project/50 text-project"
- )}
- >
- <FontAwesomeIcon icon={faFilter} />
- </IconButton>
- </DropdownMenuTrigger>
- <DropdownMenuContent className="max-h-[70vh] thin-scrollbar overflow-y-auto" align="end">
- <DropdownMenuLabel>Status</DropdownMenuLabel>
- {Object.values(SecretScanningFindingStatus).map((status) => {
- const { Icon } = SECRET_SCANNING_FINDING_STATUS_MAP[status];
-
- return (
- <DropdownMenuItem
- onClick={(e) => {
- e.preventDefault();
- setFilters((prev) => ({
- ...prev,
- status: prev.status.includes(status)
- ? prev.status.filter((s) => s !== status)
- : [...prev.status, status]
- }));
- }}
- key={status}
- icon={
- filters.status.includes(status) && (
- <FontAwesomeIcon className="text-project" icon={faCheckCircle} />
- )
- }
- iconPos="right"
- >
- <div className="flex items-center gap-2">
- <Icon
- className={twMerge(
- SECRET_SCANNING_FINDING_STATUS_MAP[status].className,
- "size-3.5"
- )}
- />
- <span className="capitalize">{status.replace("-", " ")}</span>
- </div>
- </DropdownMenuItem>
- );
- })}
- <DropdownMenuLabel>Platform</DropdownMenuLabel>
- {findings.length ? (
- [...new Set(findings.map(({ dataSourceType: type }) => type))].map((type) => {
- const { name, image } = SECRET_SCANNING_DATA_SOURCE_MAP[type];
-
- return (
- <DropdownMenuItem
- onClick={(e) => {
- e.preventDefault();
- setFilters((prev) => ({
- ...prev,
- dataSourceTypes: prev.dataSourceTypes.includes(type)
- ? prev.dataSourceTypes.filter((a) => a !== type)
- : [...prev.dataSourceTypes, type]
- }));
- }}
- key={type}
- icon={
- filters.dataSourceTypes.includes(type) && (
- <FontAwesomeIcon className="text-project" icon={faCheckCircle} />
- )
- }
- iconPos="right"
- >
- <div className="flex items-center gap-2">
- <ProviderIcon alt={`${name} integration`} icon={image} className="h-4 w-4" />
- <span>{name}</span>
- </div>
- </DropdownMenuItem>
- );
- })
- ) : (
- <DropdownMenuItem isDisabled>No Data Source Findings</DropdownMenuItem>
- )}
- </DropdownMenuContent>
- </DropdownMenu>
- </div>
- <TableContainer className="mt-4">
- <Table>
- <THead>
- <Tr>
- <Th className="">
- <Checkbox
- id="checkbox-select-all"
- isChecked={
- currentPageDataIds.length > 0 &&
- currentPageDataIds.every((id) => selectedRows.includes(id))
- }
- onCheckedChange={() => {
- const allCurrentlySelectedOnPage =
- currentPageDataIds.length > 0 &&
- currentPageDataIds.every((id) => selectedRows.includes(id));
-
- if (allCurrentlySelectedOnPage) {
- // Deselect all on current page
- setSelectedRows((prev) =>
- prev.filter((rowId) => !currentPageDataIds.includes(rowId))
- );
- } else {
- // Select all on current page
- setSelectedRows((prev) => {
- const newSelectedRows = new Set(prev);
- currentPageDataIds.forEach((id) => newSelectedRows.add(id));
- return Array.from(newSelectedRows);
- });
- }
- }}
- onClick={(e) => {
- e.stopPropagation();
- }}
- />
- </Th>
- <Th className="min-w-40">Platform</Th>
- <Th className="w-1/4">
- <div className="flex items-center">
- Timestamp
- <IconButton
- variant="plain"
- className={getClassName(FindingsOrderBy.Timestamp)}
- ariaLabel="sort"
- onClick={() => handleSort(FindingsOrderBy.Timestamp)}
- >
- <FontAwesomeIcon icon={getColSortIcon(FindingsOrderBy.Timestamp)} />
- </IconButton>
- </div>
- </Th>
- <Th className="w-1/3 whitespace-nowrap">
- <div className="flex items-center">
- Resource Name
- <IconButton
- variant="plain"
- className={getClassName(FindingsOrderBy.ResourceName)}
- ariaLabel="sort"
- onClick={() => handleSort(FindingsOrderBy.ResourceName)}
- >
- <FontAwesomeIcon icon={getColSortIcon(FindingsOrderBy.ResourceName)} />
- </IconButton>
- </div>
- </Th>
- <Th className="w-1/4">
- <div className="flex items-center">
- Rule
- <IconButton
- variant="plain"
- className={getClassName(FindingsOrderBy.Rule)}
- ariaLabel="sort"
- onClick={() => handleSort(FindingsOrderBy.Rule)}
- >
- <FontAwesomeIcon icon={getColSortIcon(FindingsOrderBy.Rule)} />
- </IconButton>
- </div>
- </Th>
- <Th className="w-1/4">
- <div className="flex items-center">
- Status
- <IconButton
- variant="plain"
- className={getClassName(FindingsOrderBy.Status)}
- ariaLabel="sort"
- onClick={() => handleSort(FindingsOrderBy.Status)}
- >
- <FontAwesomeIcon icon={getColSortIcon(FindingsOrderBy.Status)} />
- </IconButton>
- </div>
- </Th>
- <Th className="w-5" />
- </Tr>
- </THead>
- <TBody>
- {currentPageData.map((finding) => (
- <SecretScanningFindingRow
- isSelected={selectedRows.includes(finding.id)}
- onToggleSelect={(v) =>
- v
- ? setSelectedRows((sr) => [...sr, finding.id])
- : setSelectedRows((sr) => sr.filter((r) => r !== finding.id))
- }
- key={finding.id}
- finding={finding}
- onUpdate={() => handlePopUpOpen("updateFinding", [finding])}
- />
- ))}
- </TBody>
- </Table>
- {Boolean(filteredFindings.length) && (
- <Pagination
- count={filteredFindings.length}
- page={page}
- perPage={perPage}
- onChangePage={setPage}
- onChangePerPage={setPerPage}
- />
- )}
- {!filteredFindings?.length && (
- <EmptyState
- title={findings.length ? "No findings match search..." : "No secret leaks uncovered"}
- icon={faSearch}
- />
- )}
- </TableContainer>
- <SecretScanningUpdateFindingModal
- isOpen={popUp.updateFinding.isOpen}
- onOpenChange={(isOpen) => handlePopUpToggle("updateFinding", isOpen)}
- onComplete={() => setSelectedRows([])}
- findings={popUp.updateFinding.data}
- />
- {selectedRows.length > 0 && (
- <div className="mt-4 flex items-center justify-between rounded-lg border border-border-control bg-surface-raised p-2 pl-4">
- <span>
- {selectedRows.length} finding{selectedRows.length === 1 ? "" : "s"} selected
- </span>
-
- <div className="flex gap-2">
- <ProjectPermissionCan
- I={ProjectPermissionSecretScanningFindingActions.Update}
- a={ProjectPermissionSub.SecretScanningFindings}
- >
- {(isAllowed) => (
- <Button
- onClick={() =>
- handlePopUpOpen(
- "updateFinding",
- findings.filter((f) => selectedRows.includes(f.id))
- )
- }
- colorSchema="secondary"
- isDisabled={!isAllowed}
- >
- Update Status
- </Button>
- )}
- </ProjectPermissionCan>
- </div>
- </div>
- )}
- </div>
- );
-};
diff --git a/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/components/SecretScanningUpdateFindingModal.tsx b/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/components/SecretScanningUpdateFindingModal.tsx
deleted file mode 100644
index 66cd6b3a60..0000000000
--- a/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/components/SecretScanningUpdateFindingModal.tsx
+++ /dev/null
@@ -1,170 +0,0 @@
-import { Controller, useForm } from "react-hook-form";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { z } from "zod";
-
-import { createNotification } from "@app/components/notifications";
-import {
- Button,
- FormControl,
- Modal,
- ModalClose,
- ModalContent,
- Select,
- SelectItem,
- TextArea
-} from "@app/components/v2";
-import { SECRET_SCANNING_FINDING_STATUS_MAP } from "@app/helpers/secretScanningV2";
-import {
- SecretScanningFindingStatus,
- TSecretScanningFinding,
- useUpdateMultipleSecretScanningFinding
-} from "@app/hooks/api/secretScanningV2";
-
-type Props = {
- findings?: TSecretScanningFinding[];
- isOpen: boolean;
- onOpenChange: (isOpen: boolean) => void;
- onComplete?: () => void;
-};
-
-const FormSchema = z.object({
- triageComment: z.string().max(1024, "Cannot exceed 1024 characters").optional(),
- status: z.nativeEnum(SecretScanningFindingStatus).optional()
-});
-
-type FormType = z.infer<typeof FormSchema>;
-
-type ContentProps = {
- findings: TSecretScanningFinding[];
- onComplete: () => void;
-};
-
-const Content = ({ findings, onComplete }: ContentProps) => {
- const updateMultipleFindings = useUpdateMultipleSecretScanningFinding();
-
- const single = findings.length === 1;
-
- const { handleSubmit, control } = useForm<FormType>({
- resolver: zodResolver(FormSchema),
- defaultValues: {
- status: single ? findings[0].status : undefined,
- triageComment: single ? (findings[0].triageComment ?? undefined) : undefined
- }
- });
-
- const onSubmit = async (data: FormType) => {
- if (!data.status) return;
-
- if (findings.length > 1) {
- await updateMultipleFindings.mutateAsync(
- findings.map((f) => ({
- ...data,
- status: data.status!,
- findingId: f.id,
- projectId: f.projectId
- }))
- );
- } else {
- await updateMultipleFindings.mutateAsync([
- {
- ...data,
- status: data.status,
- findingId: findings[0].id,
- projectId: findings[0].projectId
- }
- ]);
- }
-
- createNotification({
- type: "success",
- text: `Finding status${single ? "" : "es"} successfully updated`
- });
-
- onComplete();
- };
-
- return (
- <form onSubmit={handleSubmit(onSubmit)}>
- <Controller
- control={control}
- name="status"
- render={({ field: { value, onChange }, fieldState: { error } }) => {
- return (
- <FormControl label="Status" isError={Boolean(error)} errorText={error?.message}>
- <Select
- value={value}
- placeholder="Select status..."
- onValueChange={onChange}
- className="w-full border border-border-strong capitalize"
- position="popper"
- dropdownContainerClassName="max-w-none"
- LucideIcon={value ? SECRET_SCANNING_FINDING_STATUS_MAP[value].Icon : undefined}
- iconClassName={
- value ? SECRET_SCANNING_FINDING_STATUS_MAP[value].className : undefined
- }
- >
- {Object.values(SecretScanningFindingStatus).map((status) => {
- return (
- <SelectItem className="capitalize" value={status} key={status}>
- {status.replace("-", " ")}
- </SelectItem>
- );
- })}
- </Select>
- </FormControl>
- );
- }}
- />
- <Controller
- control={control}
- name="triageComment"
- render={({ field, fieldState: { error } }) => {
- return (
- <FormControl label="Comment" isError={Boolean(error)} errorText={error?.message}>
- <TextArea className="h-40 resize-none!" {...field} />
- </FormControl>
- );
- }}
- />
- <div className="flex w-full flex-row-reverse justify-between gap-4 pt-4">
- <Button
- type="submit"
- isLoading={updateMultipleFindings.isPending}
- isDisabled={updateMultipleFindings.isPending}
- colorSchema="secondary"
- >
- Update Status
- </Button>
- <ModalClose asChild>
- <Button colorSchema="secondary">Cancel</Button>
- </ModalClose>
- </div>
- </form>
- );
-};
-
-export const SecretScanningUpdateFindingModal = ({
- findings,
- isOpen,
- onOpenChange,
- onComplete
-}: Props) => {
- if (!findings?.length) return null;
-
- return (
- <Modal isOpen={isOpen} onOpenChange={onOpenChange}>
- <ModalContent
- title={`Update Finding${findings.length === 1 ? "" : "s"}`}
- subTitle="Update the status or leave a comment"
- >
- <Content
- findings={findings}
- onComplete={() => {
- onOpenChange(false);
- if (onComplete) onComplete();
- }}
- />
- </ModalContent>
- </Modal>
- );
-};
diff --git a/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/components/index.ts b/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/components/index.ts
deleted file mode 100644
index c48fc51353..0000000000
--- a/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/components/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./SecretScanningFindingsSection";
diff --git a/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/route.tsx b/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/route.tsx
index ceabc13b0b..6118ab76f3 100644
--- a/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/route.tsx
+++ b/frontend/src/pages/secret-scanning/SecretScanningFindingsPage/route.tsx
@@ -11,8 +11,12 @@ export const Route = createFileRoute(
)({
validateSearch: zodValidator(
z.object({
- search: z.string().optional(),
- status: z.nativeEnum(SecretScanningFindingStatus).optional().catch(undefined)
+ dataSourceId: z.string().uuid().optional().catch(undefined),
+ resourceId: z.string().uuid().optional().catch(undefined),
+ status: z
+ .union([z.nativeEnum(SecretScanningFindingStatus), z.literal("all")])
+ .optional()
+ .catch(undefined)
})
),
beforeLoad: ({ context }) => {
diff --git a/frontend/src/pages/secret-scanning/components/findings/FindingDetailSheet.tsx b/frontend/src/pages/secret-scanning/components/findings/FindingDetailSheet.tsx
new file mode 100644
index 0000000000..9299e65893
--- /dev/null
+++ b/frontend/src/pages/secret-scanning/components/findings/FindingDetailSheet.tsx
@@ -0,0 +1,244 @@
+import { format } from "date-fns";
+import { ChevronDownIcon, ChevronUpIcon, CopyIcon, ExternalLinkIcon } from "lucide-react";
+
+import { createNotification } from "@app/components/notifications";
+import { ProjectPermissionCan } from "@app/components/permissions";
+import {
+ Button,
+ ButtonGroup,
+ CopyButton,
+ Detail,
+ DetailLabel,
+ DetailValue,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ IconButton,
+ ProviderIcon,
+ Sheet,
+ SheetContent,
+ SheetDescription,
+ SheetFooter,
+ SheetHeader,
+ SheetTitle
+} from "@app/components/v3";
+import {
+ ProjectPermissionSecretScanningFindingActions,
+ ProjectPermissionSub
+} from "@app/context/ProjectPermissionContext/types";
+import { SECRET_SCANNING_DATA_SOURCE_MAP } from "@app/helpers/secretScanningV2";
+import {
+ SecretScanningFindingStatus,
+ TSecretScanningFinding
+} from "@app/hooks/api/secretScanningV2";
+
+import { FindingStatusBadge } from "./FindingStatusBadge";
+
+type Props = {
+ finding?: TSecretScanningFinding;
+ position: { index: number; total: number } | null;
+ onClose: () => void;
+ onPrevious: () => void;
+ onNext: () => void;
+ onChangeStatus: (status: SecretScanningFindingStatus) => void;
+ isReopening: boolean;
+};
+
+const formatDate = (date: string | Date) => format(new Date(date), "MMM d, yyyy h:mm a");
+
+export const FindingDetailSheet = ({
+ finding,
+ position,
+ onClose,
+ onPrevious,
+ onNext,
+ onChangeStatus,
+ isReopening
+}: Props) => {
+ const handleCopyFindingId = (id: string) => {
+ navigator.clipboard.writeText(id);
+ createNotification({ type: "info", text: "Finding ID copied to clipboard" });
+ };
+
+ return (
+ <Sheet open={Boolean(finding)} onOpenChange={(open) => !open && onClose()}>
+ <SheetContent onOpenAutoFocus={(event) => event.preventDefault()}>
+ {finding && (
+ <>
+ <SheetHeader>
+ <div className="flex items-center gap-1 pr-8">
+ <span className="mr-auto flex items-center gap-2 text-xs text-muted">
+ <ProviderIcon
+ alt={`${SECRET_SCANNING_DATA_SOURCE_MAP[finding.dataSourceType].name} data source`}
+ icon={SECRET_SCANNING_DATA_SOURCE_MAP[finding.dataSourceType].image}
+ className="size-4"
+ />
+ {finding.dataSourceName}
+ </span>
+ {position && (
+ <span className="mr-1 text-xs text-muted">
+ {position.index + 1} of {position.total}
+ </span>
+ )}
+ <IconButton
+ variant="ghost"
+ size="xs"
+ aria-label="Previous finding"
+ isDisabled={!position || position.index === 0}
+ onClick={onPrevious}
+ >
+ <ChevronUpIcon />
+ </IconButton>
+ <IconButton
+ variant="ghost"
+ size="xs"
+ aria-label="Next finding"
+ isDisabled={!position || position.index >= position.total - 1}
+ onClick={onNext}
+ >
+ <ChevronDownIcon />
+ </IconButton>
+ </div>
+ <div className="flex flex-wrap items-center gap-2">
+ <SheetTitle className="font-mono">{finding.rule}</SheetTitle>
+ <FindingStatusBadge status={finding.status} />
+ </div>
+ <SheetDescription>{finding.details.description}</SheetDescription>
+ </SheetHeader>
+
+ <div className="grid flex-1 grid-cols-2 content-start gap-4 overflow-y-auto p-4">
+ <Detail className="col-span-2">
+ <DetailLabel>File</DetailLabel>
+ <DetailValue className="font-mono">
+ {finding.details.link ? (
+ <a
+ href={finding.details.link}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="inline-flex items-center gap-1.5 hover:underline hover:underline-offset-2"
+ >
+ {finding.details.file}:{finding.details.startLine}
+ <ExternalLinkIcon className="size-3.5 shrink-0" />
+ </a>
+ ) : (
+ `${finding.details.file}:${finding.details.startLine}`
+ )}
+ </DetailValue>
+ </Detail>
+ <Detail>
+ <DetailLabel>Resource</DetailLabel>
+ <DetailValue className="font-mono">{finding.resourceName}</DetailValue>
+ </Detail>
+ <Detail>
+ <DetailLabel>Detected</DetailLabel>
+ <DetailValue>{formatDate(finding.createdAt)}</DetailValue>
+ </Detail>
+ <Detail>
+ <DetailLabel>Commit</DetailLabel>
+ <DetailValue className="font-mono">
+ {finding.details.commit.slice(0, 7)}
+ </DetailValue>
+ {finding.details.message && (
+ <DetailValue className="line-clamp-3 text-xs text-muted">
+ {finding.details.message}
+ </DetailValue>
+ )}
+ </Detail>
+ <Detail>
+ <DetailLabel>Author</DetailLabel>
+ <DetailValue>{finding.details.author}</DetailValue>
+ {finding.details.email && (
+ <DetailValue className="text-xs text-muted">{finding.details.email}</DetailValue>
+ )}
+ </Detail>
+ <Detail>
+ <DetailLabel>Committed</DetailLabel>
+ <DetailValue>{formatDate(finding.details.date)}</DetailValue>
+ </Detail>
+ <Detail>
+ <DetailLabel>Severity</DetailLabel>
+ <DetailValue className="capitalize">{finding.severity}</DetailValue>
+ </Detail>
+ <Detail className="col-span-2">
+ <DetailLabel>Fingerprint</DetailLabel>
+ <DetailValue className="flex items-center gap-1 font-mono text-xs">
+ <span className="min-w-0 break-all">{finding.fingerprint}</span>
+ <CopyButton value={finding.fingerprint} ariaLabel="Copy fingerprint" />
+ </DetailValue>
+ </Detail>
+ {finding.triageComment && (
+ <Detail className="col-span-2">
+ <DetailLabel>Comment</DetailLabel>
+ <DetailValue className="whitespace-pre-wrap">{finding.triageComment}</DetailValue>
+ </Detail>
+ )}
+ </div>
+
+ <SheetFooter className="justify-between border-t">
+ <Button variant="outline" size="sm" onClick={() => handleCopyFindingId(finding.id)}>
+ <CopyIcon />
+ Copy Finding ID
+ </Button>
+ <ProjectPermissionCan
+ I={ProjectPermissionSecretScanningFindingActions.Update}
+ a={ProjectPermissionSub.SecretScanningFindings}
+ >
+ {(isAllowed) =>
+ finding.status === SecretScanningFindingStatus.Unresolved ? (
+ <ButtonGroup>
+ <Button
+ variant="success"
+ size="sm"
+ isDisabled={!isAllowed}
+ onClick={() => onChangeStatus(SecretScanningFindingStatus.Resolved)}
+ >
+ Mark Resolved
+ </Button>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton
+ variant="success"
+ size="sm"
+ aria-label="More status options"
+ isDisabled={!isAllowed}
+ >
+ <ChevronDownIcon />
+ </IconButton>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <DropdownMenuItem
+ onClick={() =>
+ onChangeStatus(SecretScanningFindingStatus.FalsePositive)
+ }
+ >
+ Mark False Positive
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onClick={() => onChangeStatus(SecretScanningFindingStatus.Ignore)}
+ >
+ Ignore
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </ButtonGroup>
+ ) : (
+ <Button
+ variant="outline"
+ size="sm"
+ isDisabled={!isAllowed || isReopening}
+ isPending={isReopening}
+ onClick={() => onChangeStatus(SecretScanningFindingStatus.Unresolved)}
+ >
+ Reopen
+ </Button>
+ )
+ }
+ </ProjectPermissionCan>
+ </SheetFooter>
+ </>
+ )}
+ </SheetContent>
+ </Sheet>
+ );
+};
diff --git a/frontend/src/pages/secret-scanning/components/findings/FindingStatusBadge.tsx b/frontend/src/pages/secret-scanning/components/findings/FindingStatusBadge.tsx
new file mode 100644
index 0000000000..1a55b4220b
--- /dev/null
+++ b/frontend/src/pages/secret-scanning/components/findings/FindingStatusBadge.tsx
@@ -0,0 +1,18 @@
+import { Badge } from "@app/components/v3";
+import { SECRET_SCANNING_FINDING_STATUS_MAP } from "@app/helpers/secretScanningV2";
+import { SecretScanningFindingStatus } from "@app/hooks/api/secretScanningV2";
+
+type Props = {
+ status: SecretScanningFindingStatus;
+};
+
+export const FindingStatusBadge = ({ status }: Props) => {
+ const { Icon, variant, name } = SECRET_SCANNING_FINDING_STATUS_MAP[status];
+
+ return (
+ <Badge variant={variant}>
+ <Icon />
+ {name}
+ </Badge>
+ );
+};
diff --git a/frontend/src/pages/secret-scanning/components/findings/FindingStatusDialog.tsx b/frontend/src/pages/secret-scanning/components/findings/FindingStatusDialog.tsx
new file mode 100644
index 0000000000..5d408353b8
--- /dev/null
+++ b/frontend/src/pages/secret-scanning/components/findings/FindingStatusDialog.tsx
@@ -0,0 +1,129 @@
+import { useEffect } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ Field,
+ FieldError,
+ FieldLabel,
+ TextArea
+} from "@app/components/v3";
+import { SECRET_SCANNING_FINDING_STATUS_MAP } from "@app/helpers/secretScanningV2";
+import {
+ SecretScanningFindingStatus,
+ TSecretScanningFinding,
+ useUpdateMultipleSecretScanningFinding
+} from "@app/hooks/api/secretScanningV2";
+
+const formSchema = z.object({
+ comment: z.string().trim().max(1024, "Comment cannot exceed 1024 characters")
+});
+
+type TFormData = z.infer<typeof formSchema>;
+
+type Props = {
+ findings: TSecretScanningFinding[];
+ status: SecretScanningFindingStatus | null;
+ onOpenChange: (isOpen: boolean) => void;
+ onComplete?: () => void;
+};
+
+export const FindingStatusDialog = ({ findings, status, onOpenChange, onComplete }: Props) => {
+ const updateFindings = useUpdateMultipleSecretScanningFinding();
+
+ const { control, handleSubmit, reset } = useForm<TFormData>({
+ resolver: zodResolver(formSchema),
+ defaultValues: { comment: "" }
+ });
+
+ const isOpen = Boolean(status && findings.length);
+
+ useEffect(() => {
+ if (isOpen) reset({ comment: "" });
+ }, [isOpen, reset]);
+
+ if (!status) return null;
+
+ const { name, description } = SECRET_SCANNING_FINDING_STATUS_MAP[status];
+ const isBulk = findings.length > 1;
+
+ const onSubmit = ({ comment }: TFormData) => {
+ updateFindings.mutate(
+ findings.map((finding) => ({
+ findingId: finding.id,
+ projectId: finding.projectId,
+ status,
+ triageComment: comment || undefined
+ })),
+ {
+ onSuccess: () => {
+ createNotification({
+ type: "success",
+ text: isBulk
+ ? `${findings.length} findings marked as ${name}`
+ : `Finding marked as ${name}`
+ });
+ onOpenChange(false);
+ onComplete?.();
+ }
+ }
+ );
+ };
+
+ return (
+ <Dialog open={isOpen} onOpenChange={onOpenChange}>
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>
+ {isBulk ? `Mark ${findings.length} Findings as ${name}` : `Mark as ${name}`}
+ </DialogTitle>
+ <DialogDescription>{description}</DialogDescription>
+ </DialogHeader>
+ <form onSubmit={handleSubmit(onSubmit)} className="flex flex-col gap-4">
+ <Controller
+ control={control}
+ name="comment"
+ render={({ field, fieldState: { error } }) => (
+ <Field data-invalid={Boolean(error)}>
+ <FieldLabel htmlFor="finding-status-comment">Comment (Optional)</FieldLabel>
+ <TextArea
+ {...field}
+ id="finding-status-comment"
+ rows={3}
+ placeholder="Explain why, e.g. rotated in the provider and redeployed."
+ isError={Boolean(error)}
+ />
+ <FieldError>{error?.message}</FieldError>
+ </Field>
+ )}
+ />
+ <DialogFooter>
+ <DialogClose asChild>
+ <Button variant="ghost" type="button">
+ Cancel
+ </Button>
+ </DialogClose>
+ <Button
+ variant="project"
+ type="submit"
+ isPending={updateFindings.isPending}
+ isDisabled={updateFindings.isPending}
+ >
+ Confirm
+ </Button>
+ </DialogFooter>
+ </form>
+ </DialogContent>
+ </Dialog>
+ );
+};
diff --git a/frontend/src/pages/secret-scanning/components/findings/SecretScanningFindingsSection.tsx b/frontend/src/pages/secret-scanning/components/findings/SecretScanningFindingsSection.tsx
new file mode 100644
index 0000000000..a52f91362f
--- /dev/null
+++ b/frontend/src/pages/secret-scanning/components/findings/SecretScanningFindingsSection.tsx
@@ -0,0 +1,18 @@
+import { ComponentProps } from "react";
+
+import { useProject } from "@app/context";
+import { useListSecretScanningFindings } from "@app/hooks/api/secretScanningV2";
+
+import { SecretScanningFindingsTable } from "./SecretScanningFindingsTable";
+
+type Props = Omit<ComponentProps<typeof SecretScanningFindingsTable>, "findings" | "isPending">;
+
+export const SecretScanningFindingsSection = (props: Props) => {
+ const { currentProject } = useProject();
+
+ const { data: findings = [], isPending } = useListSecretScanningFindings(currentProject.id, {
+ refetchInterval: 30000
+ });
+
+ return <SecretScanningFindingsTable findings={findings} isPending={isPending} {...props} />;
+};
diff --git a/frontend/src/pages/secret-scanning/components/findings/SecretScanningFindingsTable.tsx b/frontend/src/pages/secret-scanning/components/findings/SecretScanningFindingsTable.tsx
new file mode 100644
index 0000000000..a689856219
--- /dev/null
+++ b/frontend/src/pages/secret-scanning/components/findings/SecretScanningFindingsTable.tsx
@@ -0,0 +1,616 @@
+import { ReactNode, useMemo, useState } from "react";
+import { formatDistanceToNowStrict } from "date-fns";
+import { ChevronDownIcon, FilterIcon, ShieldCheckIcon } from "lucide-react";
+import { twMerge } from "tailwind-merge";
+
+import { createNotification } from "@app/components/notifications";
+import { ProjectPermissionCan } from "@app/components/permissions";
+import {
+ Button,
+ Card,
+ CardContent,
+ Checkbox,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuRadioGroup,
+ DropdownMenuRadioItem,
+ DropdownMenuSeparator,
+ DropdownMenuShortcut,
+ DropdownMenuTrigger,
+ Empty,
+ EmptyContent,
+ EmptyDescription,
+ EmptyHeader,
+ EmptyMedia,
+ EmptyTitle,
+ Pagination,
+ ProviderIcon,
+ SelectedActionBar,
+ Skeleton,
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+ type TableSortDirection
+} from "@app/components/v3";
+import {
+ ProjectPermissionSecretScanningFindingActions,
+ ProjectPermissionSub
+} from "@app/context/ProjectPermissionContext/types";
+import {
+ RESOURCE_DESCRIPTION_HELPER,
+ SECRET_SCANNING_DATA_SOURCE_MAP,
+ SECRET_SCANNING_FINDING_STATUS_MAP,
+ SECRET_SCANNING_FINDING_STATUS_ORDER
+} from "@app/helpers/secretScanningV2";
+import { usePagination, useResetPageHelper } from "@app/hooks";
+import {
+ SecretScanningFindingStatus,
+ TSecretScanningDataSource,
+ TSecretScanningFinding,
+ useUpdateMultipleSecretScanningFinding
+} from "@app/hooks/api/secretScanningV2";
+
+import { FindingDetailSheet } from "./FindingDetailSheet";
+import { FindingStatusBadge } from "./FindingStatusBadge";
+import { FindingStatusDialog } from "./FindingStatusDialog";
+
+export type FindingsStatusFilter = SecretScanningFindingStatus | "all";
+
+enum FindingsOrderBy {
+ Rule = "rule",
+ Resource = "resource",
+ Author = "author",
+ Detected = "detected",
+ Status = "status"
+}
+
+type TSort = { column: FindingsOrderBy; direction: Exclude<TableSortDirection, "none"> };
+
+const DEFAULT_SORT: TSort = { column: FindingsOrderBy.Detected, direction: "descending" };
+
+const ALL_OPTION = "all";
+
+const compareFindings = (
+ a: TSecretScanningFinding,
+ b: TSecretScanningFinding,
+ column: FindingsOrderBy
+) => {
+ switch (column) {
+ case FindingsOrderBy.Rule:
+ return a.rule.localeCompare(b.rule);
+ case FindingsOrderBy.Resource:
+ return a.resourceName.localeCompare(b.resourceName);
+ case FindingsOrderBy.Author:
+ return (a.details.author ?? "").localeCompare(b.details.author ?? "");
+ case FindingsOrderBy.Status:
+ return (
+ SECRET_SCANNING_FINDING_STATUS_ORDER.indexOf(a.status) -
+ SECRET_SCANNING_FINDING_STATUS_ORDER.indexOf(b.status)
+ );
+ case FindingsOrderBy.Detected:
+ default:
+ return new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime();
+ }
+};
+
+const countBy = <T extends string>(
+ items: TSecretScanningFinding[],
+ key: (f: TSecretScanningFinding) => T
+) =>
+ items.reduce<Record<string, number>>((acc, item) => {
+ const value = key(item);
+ acc[value] = (acc[value] ?? 0) + 1;
+ return acc;
+ }, {});
+
+type Props = {
+ findings: TSecretScanningFinding[];
+ isPending: boolean;
+ dataSource?: TSecretScanningDataSource;
+ initialStatus?: FindingsStatusFilter;
+ initialDataSourceId?: string;
+ initialResourceId?: string;
+ cardHeader?: ReactNode;
+};
+
+export const SecretScanningFindingsTable = ({
+ findings,
+ isPending,
+ dataSource,
+ initialStatus = SecretScanningFindingStatus.Unresolved,
+ initialDataSourceId,
+ initialResourceId,
+ cardHeader
+}: Props) => {
+ const isScoped = Boolean(dataSource);
+
+ const [statusFilter, setStatusFilter] = useState<FindingsStatusFilter>(initialStatus);
+ const [dataSourceFilter, setDataSourceFilter] = useState<string | null>(
+ initialDataSourceId ?? null
+ );
+ const [resourceFilter, setResourceFilter] = useState<string | null>(initialResourceId ?? null);
+ const [sort, setSort] = useState<TSort>(DEFAULT_SORT);
+ const [selectedIds, setSelectedIds] = useState<string[]>([]);
+ const [openFindingId, setOpenFindingId] = useState<string | null>(null);
+ const [statusChange, setStatusChange] = useState<{
+ findingIds: string[];
+ status: SecretScanningFindingStatus;
+ } | null>(null);
+
+ const { page, setPage, perPage, setPerPage, offset } = usePagination(FindingsOrderBy.Detected, {
+ initPerPage: 20
+ });
+
+ const reopenFinding = useUpdateMultipleSecretScanningFinding();
+
+ const scopedFindings = useMemo(
+ () => (dataSource ? findings.filter((f) => f.dataSourceId === dataSource.id) : findings),
+ [findings, dataSource]
+ );
+
+ const dataSourceOptions = useMemo(() => {
+ const counts = countBy(scopedFindings, (f) => f.dataSourceId);
+ const seen = new Map<string, TSecretScanningFinding>();
+ scopedFindings.forEach((f) => {
+ if (!seen.has(f.dataSourceId)) seen.set(f.dataSourceId, f);
+ });
+ return [...seen.values()]
+ .map((f) => ({
+ id: f.dataSourceId,
+ name: f.dataSourceName,
+ type: f.dataSourceType,
+ count: counts[f.dataSourceId]
+ }))
+ .sort((a, b) => a.name.localeCompare(b.name));
+ }, [scopedFindings]);
+
+ const sourceFilteredFindings = useMemo(
+ () =>
+ dataSourceFilter
+ ? scopedFindings.filter((f) => f.dataSourceId === dataSourceFilter)
+ : scopedFindings,
+ [scopedFindings, dataSourceFilter]
+ );
+
+ const resourceOptions = useMemo(() => {
+ const counts = countBy(sourceFilteredFindings, (f) => f.resourceId);
+ const seen = new Map<string, string>();
+ sourceFilteredFindings.forEach((f) => {
+ if (!seen.has(f.resourceId)) seen.set(f.resourceId, f.resourceName);
+ });
+ return [...seen.entries()]
+ .map(([id, name]) => ({ id, name, count: counts[id] }))
+ .sort((a, b) => a.name.localeCompare(b.name));
+ }, [sourceFilteredFindings]);
+
+ const inScopeFindings = useMemo(
+ () =>
+ resourceFilter
+ ? sourceFilteredFindings.filter((f) => f.resourceId === resourceFilter)
+ : sourceFilteredFindings,
+ [sourceFilteredFindings, resourceFilter]
+ );
+
+ const statusCounts = useMemo(() => countBy(inScopeFindings, (f) => f.status), [inScopeFindings]);
+
+ const filteredFindings = useMemo(() => {
+ const direction = sort.direction === "ascending" ? 1 : -1;
+ return inScopeFindings
+ .filter((f) => statusFilter === "all" || f.status === statusFilter)
+ .sort((a, b) => compareFindings(a, b, sort.column) * direction);
+ }, [inScopeFindings, statusFilter, sort]);
+
+ useResetPageHelper({ totalCount: filteredFindings.length, offset, setPage });
+
+ const pageFindings = filteredFindings.slice(offset, offset + perPage);
+ const pageIds = pageFindings.map((f) => f.id);
+ const selectedFindings = filteredFindings.filter((f) => selectedIds.includes(f.id));
+ const isPageSelected = pageIds.length > 0 && pageIds.every((id) => selectedIds.includes(id));
+
+ const openFinding = findings.find((f) => f.id === openFindingId);
+ const openIndex = openFindingId ? filteredFindings.findIndex((f) => f.id === openFindingId) : -1;
+
+ const resourceLabel = dataSource
+ ? RESOURCE_DESCRIPTION_HELPER[dataSource.type].singularTitle
+ : "Resource";
+ const selectedResourceName = resourceOptions.find((r) => r.id === resourceFilter)?.name;
+ const selectedDataSourceName = dataSourceOptions.find((d) => d.id === dataSourceFilter)?.name;
+
+ const resetSelection = () => setSelectedIds([]);
+
+ const handleSortChange = (column: FindingsOrderBy, direction: TableSortDirection) => {
+ setSort(direction === "none" ? DEFAULT_SORT : { column, direction });
+ };
+
+ const getSortDirection = (column: FindingsOrderBy): TableSortDirection =>
+ sort.column === column ? sort.direction : "none";
+
+ const getSortIconClassName = (column: FindingsOrderBy) =>
+ twMerge(
+ "transition-transform",
+ getSortDirection(column) === "descending" && "rotate-180",
+ getSortDirection(column) === "none" && "opacity-30"
+ );
+
+ const handleChangeStatus = (
+ targetFindings: TSecretScanningFinding[],
+ status: SecretScanningFindingStatus
+ ) => {
+ if (status !== SecretScanningFindingStatus.Unresolved) {
+ setStatusChange({ findingIds: targetFindings.map((f) => f.id), status });
+ return;
+ }
+
+ reopenFinding.mutate(
+ targetFindings.map((f) => ({ findingId: f.id, projectId: f.projectId, status })),
+ {
+ onSuccess: () =>
+ createNotification({
+ type: "success",
+ text:
+ targetFindings.length === 1
+ ? "Finding reopened"
+ : `${targetFindings.length} findings reopened`
+ })
+ }
+ );
+ };
+
+ const renderSortableHead = (column: FindingsOrderBy, label: string, className?: string) => (
+ <TableHead
+ className={className}
+ sortDirection={getSortDirection(column)}
+ onSortChange={(direction) => handleSortChange(column, direction)}
+ >
+ {label}
+ <ChevronDownIcon className={getSortIconClassName(column)} />
+ </TableHead>
+ );
+
+ const renderEmpty = () => {
+ if (!scopedFindings.length) {
+ return (
+ <Empty className="border">
+ <EmptyHeader>
+ <EmptyMedia variant="icon">
+ <ShieldCheckIcon />
+ </EmptyMedia>
+ <EmptyTitle>No secret leaks found</EmptyTitle>
+ <EmptyDescription>
+ {isScoped
+ ? "Findings appear here when a scan of this data source detects a secret."
+ : "Findings appear here when a scan detects a secret."}
+ </EmptyDescription>
+ </EmptyHeader>
+ </Empty>
+ );
+ }
+
+ const statusName =
+ statusFilter === "all"
+ ? ""
+ : `${SECRET_SCANNING_FINDING_STATUS_MAP[statusFilter].name.toLowerCase()} `;
+ const scopeName = selectedResourceName ?? selectedDataSourceName;
+
+ return (
+ <Empty className="border">
+ <EmptyHeader>
+ <EmptyMedia variant="icon">
+ <ShieldCheckIcon />
+ </EmptyMedia>
+ <EmptyTitle>
+ No {statusName}findings{scopeName ? ` in ${scopeName}` : ""}
+ </EmptyTitle>
+ </EmptyHeader>
+ {statusFilter !== "all" && (
+ <EmptyContent>
+ <Button variant="outline" size="xs" onClick={() => setStatusFilter("all")}>
+ Show All Statuses
+ </Button>
+ </EmptyContent>
+ )}
+ </Empty>
+ );
+ };
+
+ const showEmpty = !isPending && filteredFindings.length === 0;
+
+ return (
+ <>
+ <Card>
+ {cardHeader}
+ <CardContent className="flex flex-wrap items-center gap-2">
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="outline">
+ <FilterIcon />
+ Status:{" "}
+ {statusFilter === "all"
+ ? "All"
+ : SECRET_SCANNING_FINDING_STATUS_MAP[statusFilter].name}
+ <ChevronDownIcon />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="min-w-56">
+ <DropdownMenuRadioGroup
+ value={statusFilter}
+ onValueChange={(value) => {
+ setStatusFilter(value as FindingsStatusFilter);
+ resetSelection();
+ }}
+ >
+ {SECRET_SCANNING_FINDING_STATUS_ORDER.map((status) => {
+ const { Icon, className, name } = SECRET_SCANNING_FINDING_STATUS_MAP[status];
+ return (
+ <DropdownMenuRadioItem key={status} value={status}>
+ <Icon className={className} />
+ {name}
+ <DropdownMenuShortcut>{statusCounts[status] ?? 0}</DropdownMenuShortcut>
+ </DropdownMenuRadioItem>
+ );
+ })}
+ <DropdownMenuSeparator />
+ <DropdownMenuRadioItem value="all">
+ All
+ <DropdownMenuShortcut>{inScopeFindings.length}</DropdownMenuShortcut>
+ </DropdownMenuRadioItem>
+ </DropdownMenuRadioGroup>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ {!isScoped && (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="outline">
+ Data Source: {selectedDataSourceName ?? "All"}
+ <ChevronDownIcon />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent
+ align="end"
+ className="max-h-80 thin-scrollbar min-w-64 overflow-y-auto"
+ >
+ <DropdownMenuRadioGroup
+ value={dataSourceFilter ?? ALL_OPTION}
+ onValueChange={(value) => {
+ setDataSourceFilter(value === ALL_OPTION ? null : value);
+ setResourceFilter(null);
+ resetSelection();
+ }}
+ >
+ <DropdownMenuRadioItem value={ALL_OPTION}>
+ All Data Sources
+ <DropdownMenuShortcut>{scopedFindings.length}</DropdownMenuShortcut>
+ </DropdownMenuRadioItem>
+ <DropdownMenuSeparator />
+ {dataSourceOptions.map((option) => (
+ <DropdownMenuRadioItem key={option.id} value={option.id}>
+ <ProviderIcon
+ alt={`${SECRET_SCANNING_DATA_SOURCE_MAP[option.type].name} data source`}
+ icon={SECRET_SCANNING_DATA_SOURCE_MAP[option.type].image}
+ className="size-4"
+ />
+ <span className="truncate">{option.name}</span>
+ <DropdownMenuShortcut>{option.count}</DropdownMenuShortcut>
+ </DropdownMenuRadioItem>
+ ))}
+ </DropdownMenuRadioGroup>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )}
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="outline">
+ {resourceLabel}: {selectedResourceName ?? "All"}
+ <ChevronDownIcon />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent
+ align="end"
+ className="max-h-80 thin-scrollbar min-w-64 overflow-y-auto"
+ >
+ <DropdownMenuRadioGroup
+ value={resourceFilter ?? ALL_OPTION}
+ onValueChange={(value) => {
+ setResourceFilter(value === ALL_OPTION ? null : value);
+ resetSelection();
+ }}
+ >
+ <DropdownMenuRadioItem value={ALL_OPTION}>
+ All{" "}
+ {dataSource
+ ? RESOURCE_DESCRIPTION_HELPER[dataSource.type].pluralTitle
+ : "Resources"}
+ <DropdownMenuShortcut>{sourceFilteredFindings.length}</DropdownMenuShortcut>
+ </DropdownMenuRadioItem>
+ <DropdownMenuSeparator />
+ {resourceOptions.map((option) => (
+ <DropdownMenuRadioItem key={option.id} value={option.id}>
+ <span className="truncate font-mono">{option.name}</span>
+ <DropdownMenuShortcut>{option.count}</DropdownMenuShortcut>
+ </DropdownMenuRadioItem>
+ ))}
+ </DropdownMenuRadioGroup>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </CardContent>
+
+ {showEmpty ? (
+ <CardContent>{renderEmpty()}</CardContent>
+ ) : (
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead className="w-0">
+ <Checkbox
+ aria-label="Select all findings on this page"
+ isChecked={isPageSelected}
+ isDisabled={isPending || !pageIds.length}
+ onCheckedChange={() =>
+ setSelectedIds((prev) =>
+ isPageSelected
+ ? prev.filter((id) => !pageIds.includes(id))
+ : [...new Set([...prev, ...pageIds])]
+ )
+ }
+ />
+ </TableHead>
+ {renderSortableHead(FindingsOrderBy.Rule, "Rule")}
+ {renderSortableHead(FindingsOrderBy.Resource, resourceLabel)}
+ {renderSortableHead(FindingsOrderBy.Author, "Author")}
+ {renderSortableHead(FindingsOrderBy.Detected, "Detected", "w-36")}
+ {renderSortableHead(FindingsOrderBy.Status, "Status", "w-36")}
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {isPending &&
+ Array.from({ length: 8 }).map((_, i) => (
+ <TableRow key={`finding-skeleton-${i + 1}`}>
+ <TableCell>
+ <Skeleton className="size-4" />
+ </TableCell>
+ {Array.from({ length: 5 }).map((__, j) => (
+ <TableCell key={`finding-skeleton-cell-${j + 1}`}>
+ <Skeleton className="h-4 w-full" />
+ </TableCell>
+ ))}
+ </TableRow>
+ ))}
+ {!isPending &&
+ pageFindings.map((finding) => {
+ const isSelected = selectedIds.includes(finding.id);
+ const source = SECRET_SCANNING_DATA_SOURCE_MAP[finding.dataSourceType];
+
+ return (
+ <TableRow
+ key={finding.id}
+ data-state={isSelected ? "selected" : undefined}
+ onClick={() => setOpenFindingId(finding.id)}
+ >
+ <TableCell onClick={(e) => e.stopPropagation()}>
+ <Checkbox
+ aria-label={`Select finding ${finding.rule}`}
+ isChecked={isSelected}
+ onCheckedChange={() =>
+ setSelectedIds((prev) =>
+ isSelected
+ ? prev.filter((id) => id !== finding.id)
+ : [...prev, finding.id]
+ )
+ }
+ />
+ </TableCell>
+ <TableCell isTruncatable className="h-auto py-2">
+ <p className="truncate font-mono">{finding.rule}</p>
+ <p className="truncate font-mono text-xs text-muted">
+ {finding.details.file}:{finding.details.startLine}
+ </p>
+ </TableCell>
+ <TableCell isTruncatable className="h-auto py-2">
+ <p className="truncate font-mono">{finding.resourceName}</p>
+ {!isScoped && (
+ <p className="flex items-center gap-1.5 truncate text-xs text-muted">
+ <ProviderIcon
+ alt={`${source.name} data source`}
+ icon={source.image}
+ className="size-3.5"
+ />
+ {finding.dataSourceName}
+ </p>
+ )}
+ </TableCell>
+ <TableCell isTruncatable>{finding.details.author}</TableCell>
+ <TableCell>
+ {formatDistanceToNowStrict(new Date(finding.createdAt), {
+ addSuffix: true
+ })}
+ </TableCell>
+ <TableCell>
+ <FindingStatusBadge status={finding.status} />
+ </TableCell>
+ </TableRow>
+ );
+ })}
+ </TableBody>
+ </Table>
+ )}
+
+ {!isPending && filteredFindings.length > 0 && (
+ <CardContent className="-mt-5 pt-0">
+ <Pagination
+ count={filteredFindings.length}
+ page={page}
+ perPage={perPage}
+ onChangePage={setPage}
+ onChangePerPage={(newPerPage) => {
+ setPerPage(newPerPage);
+ setPage(1);
+ }}
+ />
+ </CardContent>
+ )}
+ </Card>
+
+ <SelectedActionBar
+ selectedCount={selectedFindings.length}
+ selectionLabel={`${selectedFindings.length} ${selectedFindings.length === 1 ? "Finding" : "Findings"} Selected`}
+ onClearSelection={resetSelection}
+ >
+ <ProjectPermissionCan
+ I={ProjectPermissionSecretScanningFindingActions.Update}
+ a={ProjectPermissionSub.SecretScanningFindings}
+ >
+ {(isAllowed) => (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="project" size="xs" isDisabled={!isAllowed}>
+ Set Status
+ <ChevronDownIcon />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ {SECRET_SCANNING_FINDING_STATUS_ORDER.map((status) => {
+ const { Icon, className, name } = SECRET_SCANNING_FINDING_STATUS_MAP[status];
+ return (
+ <DropdownMenuItem
+ key={status}
+ onClick={() => handleChangeStatus(selectedFindings, status)}
+ >
+ <Icon className={className} />
+ {name}
+ </DropdownMenuItem>
+ );
+ })}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )}
+ </ProjectPermissionCan>
+ </SelectedActionBar>
+
+ <FindingDetailSheet
+ finding={openFinding}
+ position={openIndex >= 0 ? { index: openIndex, total: filteredFindings.length } : null}
+ onClose={() => setOpenFindingId(null)}
+ onPrevious={() => {
+ if (openIndex > 0) setOpenFindingId(filteredFindings[openIndex - 1].id);
+ }}
+ onNext={() => {
+ if (openIndex >= 0 && openIndex < filteredFindings.length - 1)
+ setOpenFindingId(filteredFindings[openIndex + 1].id);
+ }}
+ onChangeStatus={(status) => openFinding && handleChangeStatus([openFinding], status)}
+ isReopening={reopenFinding.isPending}
+ />
+
+ <FindingStatusDialog
+ findings={findings.filter((f) => statusChange?.findingIds.includes(f.id))}
+ status={statusChange?.status ?? null}
+ onOpenChange={(isOpen) => !isOpen && setStatusChange(null)}
+ onComplete={resetSelection}
+ />
+ </>
+ );
+};
diff --git a/frontend/src/pages/secret-scanning/components/findings/index.ts b/frontend/src/pages/secret-scanning/components/findings/index.ts
new file mode 100644
index 0000000000..c5bd4a418d
--- /dev/null
+++ b/frontend/src/pages/secret-scanning/components/findings/index.ts
@@ -0,0 +1,2 @@
+export { SecretScanningFindingsSection } from "./SecretScanningFindingsSection";
+export type { FindingsStatusFilter } from "./SecretScanningFindingsTable";