Skip to content
This repository was archived by the owner on Jul 8, 2025. It is now read-only.

Commit c07eeac

Browse files
committed
display detected problem properly
1 parent 2a742d8 commit c07eeac

File tree

3 files changed

+70
-2
lines changed

3 files changed

+70
-2
lines changed

src/components/AlertsTable.tsx

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ import {
1616
import { Switch } from "@stacklok/ui-kit";
1717
import { AlertConversation, QuestionType } from "@/api/generated";
1818
import { Tooltip, TooltipTrigger } from "@stacklok/ui-kit";
19-
import { sanitizeQuestionPrompt, parsingPromptText } from "@/lib/utils";
20-
import { Search } from "lucide-react";
19+
import {
20+
sanitizeQuestionPrompt,
21+
parsingPromptText,
22+
getIssueDetectedType,
23+
} from "@/lib/utils";
24+
import { KeyRoundIcon, PackageX, Search } from "lucide-react";
2125
import { useAlertSearch } from "@/hooks/useAlertSearch";
2226
import { useCallback } from "react";
2327
import { useNavigate, useSearchParams } from "react-router-dom";
@@ -50,6 +54,29 @@ function TypeCellContent({ alert }: { alert: AlertConversation }) {
5054
}
5155
}
5256

57+
function IssueDetectedCellContent({ alert }: { alert: AlertConversation }) {
58+
const issueDetected = getIssueDetectedType(alert);
59+
60+
switch (issueDetected) {
61+
case "leaked_secret":
62+
return (
63+
<>
64+
<KeyRoundIcon className="size-4" />
65+
Blocked secret exposure
66+
</>
67+
);
68+
case "malicious_package":
69+
return (
70+
<>
71+
<PackageX className="size-4" />
72+
Blocked malicious package
73+
</>
74+
);
75+
default:
76+
return "";
77+
}
78+
}
79+
5380
export function AlertsTable() {
5481
const {
5582
isMaliciousFilterActive,
@@ -154,6 +181,7 @@ export function AlertsTable() {
154181
Type
155182
</Column>
156183
<Column width={300}>Event</Column>
184+
<Column width={300}>Issue Detected</Column>
157185
</Row>
158186
</TableHeader>
159187
<TableBody>
@@ -174,6 +202,11 @@ export function AlertsTable() {
174202
<TypeCellContent alert={alert} />
175203
</Cell>
176204
<Cell className="truncate">{getTitle(alert)}</Cell>
205+
<Cell>
206+
<div className="truncate flex gap-2 text-blue-800 items-center">
207+
<IssueDetectedCellContent alert={alert} />
208+
</div>
209+
</Cell>
177210
</Row>
178211
))}
179212
</TableBody>

src/lib/utils.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,15 @@ export function getMaliciousPackage(
175175

176176
return null;
177177
}
178+
179+
export function getIssueDetectedType(
180+
alert: AlertConversation,
181+
): "malicious_package" | "leaked_secret" {
182+
const maliciousPackage = getMaliciousPackage(alert.trigger_string);
183+
184+
if (maliciousPackage !== null && typeof maliciousPackage === "object") {
185+
return "malicious_package";
186+
}
187+
188+
return "leaked_secret";
189+
}

src/routes/__tests__/route-dashboard.test.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ describe("Dashboard", () => {
156156
}),
157157
).toBeVisible();
158158

159+
expect(
160+
screen.getByRole("columnheader", {
161+
name: /issue detected/i,
162+
}),
163+
).toBeVisible();
164+
159165
expect(
160166
screen.getByRole("switch", {
161167
name: /malicious packages/i,
@@ -169,6 +175,11 @@ describe("Dashboard", () => {
169175

170176
expect(within(firstRow).getByText(/chat/i)).toBeVisible();
171177
expect(within(firstRow).getByText(/[0-9]+.*ago/i)).toBeVisible();
178+
expect(
179+
screen.getAllByRole("gridcell", {
180+
name: /blocked secret exposure/i,
181+
}).length,
182+
).toBeGreaterThanOrEqual(1);
172183
});
173184

174185
it("should render malicious pkg", async () => {
@@ -188,6 +199,12 @@ describe("Dashboard", () => {
188199
/codegate-context-retriever/i,
189200
),
190201
).toBeVisible();
202+
203+
expect(
204+
screen.getByRole("gridcell", {
205+
name: /blocked malicious package/i,
206+
}),
207+
).toBeVisible();
191208
});
192209

193210
it("renders event column", async () => {
@@ -224,6 +241,12 @@ describe("Dashboard", () => {
224241
expect(screen.getByTestId(/alerts-count/i)).toHaveTextContent("1"),
225242
);
226243

244+
expect(
245+
screen.queryAllByRole("gridcell", {
246+
name: /blocked secret exposure/i,
247+
}).length,
248+
).toBe(0);
249+
227250
userEvent.click(
228251
screen.getByRole("switch", {
229252
name: /malicious packages/i,

0 commit comments

Comments
 (0)