Skip to content

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

remove stale secrets from warning table

adilson4728bb9340a2
diff --git a/backend/src/ee/services/insights/insights-dal.ts b/backend/src/ee/services/insights/insights-dal.ts
index 1f39d25a78..9d2c5a31d3 100644
--- a/backend/src/ee/services/insights/insights-dal.ts
+++ b/backend/src/ee/services/insights/insights-dal.ts
@@ -17,7 +17,6 @@ export const PROJECT_WARNING_SEVERITY_WEIGHTS = {
failedRotation: 100,
failedSync: 50,
orphanedLease: 25,
- staleSecret: 5,
duplicatedSecret: 1
} as const;
@@ -64,9 +63,6 @@ export const insightsDALFactory = (db: TDbClient) => {
`${TableName.Project}.secretBlindIndexEnabled`
)
)
- // totalSecrets + staleSecrets share one scan via FILTER. Mirrors
- // countByProject / countStaleByProject in secret-v2-bridge-dal.ts:
- // exclude personal/override secrets, skip soft-deleted environments.
.with("secret_counts", (qb) =>
qb
.from(TableName.SecretV2)
@@ -95,7 +91,6 @@ export const insightsDALFactory = (db: TDbClient) => {
// prohibitively expensive for a paginated org-level listing. Secrets that
// merely reference the same secret are therefore counted as duplicates
// here, so this count can be slightly higher than the duplication insight.
- // TODO: perform a load testing to check how bad this can be for large orgs.
.with("duplicate_groups", (qb) =>
qb
.from(TableName.SecretV2)
@@ -183,16 +178,9 @@ export const insightsDALFactory = (db: TDbClient) => {
`(? * coalesce(fr."failedRotations", 0)
+ ? * coalesce(fs."failedSyncs", 0)
+ ? * coalesce(ol."orphanedLeases", 0)
- + ? * coalesce(sc."staleSecrets", 0)
+ ? * (case when p."secretBlindIndexEnabled" then coalesce(dc."duplicatedSecrets", 0) else 0 end)
) as "severityScore"`,
- [
- weights.failedRotation,
- weights.failedSync,
- weights.orphanedLease,
- weights.staleSecret,
- weights.duplicatedSecret
- ]
+ [weights.failedRotation, weights.failedSync, weights.orphanedLease, weights.duplicatedSecret]
)
)
)
diff --git a/frontend/src/hooks/api/secretInsights/queries.tsx b/frontend/src/hooks/api/secretInsights/queries.tsx
index bc7914b462..35e3e1094a 100644
--- a/frontend/src/hooks/api/secretInsights/queries.tsx
+++ b/frontend/src/hooks/api/secretInsights/queries.tsx
@@ -274,12 +274,10 @@ export const useGetOrgSecretsProjects = (orgId: string, params: TGetOrgSecretsPr
);
return data.projectWarnings;
},
- // Rows are ordered severityScore desc, so the first `projectsWithIssues` rows are
- // exactly the problem projects; there is nothing worth fetching past that boundary.
getNextPageParam: (lastPage) => {
if (lastPage.projects.length === 0) return undefined;
const nextOffset = lastPage.offset + lastPage.projects.length;
- return nextOffset < lastPage.projectsWithIssues ? nextOffset : undefined;
+ return nextOffset < lastPage.totalProjects ? nextOffset : undefined;
},
enabled: Boolean(orgId),
staleTime: INSIGHTS_STALE_TIME
diff --git a/frontend/src/pages/organization/SecretInsightsPage/SecretInsightsPage.tsx b/frontend/src/pages/organization/SecretInsightsPage/SecretInsightsPage.tsx
index 74ed5ee4df..88ea261604 100644
--- a/frontend/src/pages/organization/SecretInsightsPage/SecretInsightsPage.tsx
+++ b/frontend/src/pages/organization/SecretInsightsPage/SecretInsightsPage.tsx
@@ -175,12 +175,11 @@ export const SecretInsightsPage = withPermission(
{(isAllowed) => {
const generateButton = (
<Button
- variant="neutral"
+ variant="project"
size="xs"
isDisabled={!isAllowed || hasInFlightReport}
onClick={() => handlePopUpOpen("requestOrgReport")}
>
- <PlusIcon />
Generate Report
</Button>
);
diff --git a/frontend/src/pages/organization/SecretInsightsPage/components/NeedsAttentionCard.tsx b/frontend/src/pages/organization/SecretInsightsPage/components/NeedsAttentionCard.tsx
index 09a1df7e5f..1f71abb8c9 100644
--- a/frontend/src/pages/organization/SecretInsightsPage/components/NeedsAttentionCard.tsx
+++ b/frontend/src/pages/organization/SecretInsightsPage/components/NeedsAttentionCard.tsx
@@ -1,12 +1,6 @@
import { useMemo, useState } from "react";
import { useNavigate } from "@tanstack/react-router";
-import {
- CheckIcon,
- ChevronDownIcon,
- ChevronRightIcon,
- ChevronUpIcon,
- SearchIcon
-} from "lucide-react";
+import { ChevronDownIcon, ChevronRightIcon, ChevronUpIcon, SearchIcon } from "lucide-react";
import {
Badge,
@@ -50,7 +44,6 @@ const WARNING_CHIPS: {
}[] = [
{ key: "failedRotations", variant: "danger", label: (c) => pluralize(c, "failed rotation") },
{ key: "failedSyncs", variant: "warning", label: (c) => pluralize(c, "failed sync") },
- { key: "staleSecrets", variant: "warning", label: (c) => pluralize(c, "stale secret") },
{ key: "orphanedLeases", variant: "warning", label: (c) => pluralize(c, "orphaned lease") },
{ key: "duplicatedSecrets", variant: "neutral", label: (c) => `${c.toLocaleString()} duplicated` }
];
@@ -70,9 +63,6 @@ const WarningBadges = ({ warnings }: { warnings: TOrgProjectInsightWarnings }) =
</div>
);
-const hasIssues = (warnings: TOrgProjectInsightWarnings) =>
- WARNING_CHIPS.some(({ key }) => (warnings[key] ?? 0) > 0);
-
export const NeedsAttentionCard = ({
data,
hasMore,
@@ -89,35 +79,37 @@ export const NeedsAttentionCard = ({
const [search, setSearch] = useState("");
const [showAll, setShowAll] = useState(false);
- const issueProjects = useMemo(
+ const sortedProjects = useMemo(
() =>
- data.projects
- .filter((project) => hasIssues(project.warnings))
- .sort((a, b) => b.severityScore - a.severityScore),
+ [...data.projects].sort(
+ (a, b) => b.severityScore - a.severityScore || a.projectName.localeCompare(b.projectName)
+ ),
[data.projects]
);
+ const isHealthy = data.projectsWithIssues === 0;
+
const filtered = useMemo(() => {
const query = search.trim().toLowerCase();
- if (!query) return issueProjects;
- return issueProjects.filter(
+ if (!query) return sortedProjects;
+ return sortedProjects.filter(
(project) =>
project.projectName.toLowerCase().includes(query) ||
project.projectSlug.toLowerCase().includes(query)
);
- }, [issueProjects, search]);
+ }, [sortedProjects, search]);
const isSearching = search.trim().length > 0;
const visible = showAll || isSearching ? filtered : filtered.slice(0, COLLAPSED_ROW_COUNT);
- const cleanCount = data.totalProjects - data.projectsWithIssues;
return (
<Card>
<CardHeader>
<CardTitle>Needs Attention</CardTitle>
<CardDescription>
- {data.projectsWithIssues} of {data.totalProjects} projects have outstanding issues,
- ordered by severity.
+ {isHealthy
+ ? "You don't have any projects with issues"
+ : `${data.projectsWithIssues} of ${data.totalProjects} projects have outstanding issues, ordered by severity.`}
</CardDescription>
<CardAction>
<InputGroup className="w-64">
@@ -133,14 +125,7 @@ export const NeedsAttentionCard = ({
</CardAction>
</CardHeader>
<CardContent>
- {issueProjects.length === 0 && (
- <Empty className="border-0">
- <EmptyHeader>
- <EmptyTitle>All projects are healthy</EmptyTitle>
- </EmptyHeader>
- </Empty>
- )}
- {issueProjects.length > 0 && filtered.length === 0 && (
+ {sortedProjects.length > 0 && filtered.length === 0 && (
<Empty className="border-0">
<EmptyHeader>
<EmptyTitle>No projects match your search</EmptyTitle>
@@ -153,8 +138,8 @@ export const NeedsAttentionCard = ({
<TableRow>
<TableHead>Project</TableHead>
<TableHead>Issues</TableHead>
- <TableHead className="text-right">Stale</TableHead>
- <TableHead className="text-right">Secrets</TableHead>
+ <TableHead className="text-right">Stale Secrets</TableHead>
+ <TableHead className="text-right">Total Secrets</TableHead>
<TableHead className="w-8" />
</TableRow>
</TableHeader>
@@ -192,12 +177,7 @@ export const NeedsAttentionCard = ({
</Table>
)}
</CardContent>
- <CardFooter className="justify-between">
- <span className="flex items-center gap-2 text-sm text-success">
- <CheckIcon className="size-3.5" />
- {cleanCount.toLocaleString()} {cleanCount === 1 ? "project has" : "projects have"} no
- outstanding issues
- </span>
+ <CardFooter className="justify-end">
{!isSearching && hasMore && (
<Button
variant="ghost"