Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions actions/setup/js/gateway_difc_filtered.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function generateDifcFilteredSection(filteredEvents) {

let section = "\n\n> [!NOTE]\n";
section += `> <details>\n`;
section += `> <summary>**πŸ”’ Integrity filter blocked ${count} ${itemWord}**</summary>\n`;
section += `> <summary><b>πŸ”’ Integrity filter blocked ${count} ${itemWord}</b></summary>\n`;
section += `>\n`;
section += `> The following ${itemWord} were blocked because they don't meet the GitHub integrity level.\n`;
section += `>\n`;
Expand All @@ -110,7 +110,8 @@ function generateDifcFilteredSection(filteredEvents) {
reference = `[${label}](${event.html_url})`;
} else {
const desc = event.description ? event.description.replace(/^[a-z-]+:(?!\/\/)/i, "") : null;
reference = desc || (event.tool_name ? `\`${event.tool_name}\`` : "-");
const validDesc = desc && desc !== "#unknown" ? desc : null;
reference = validDesc || (event.tool_name ? `\`${event.tool_name}\`` : "-");
}
const tool = event.tool_name ? `\`${event.tool_name}\`` : "-";
const reason = (event.reason || "-").replace(/^Resource '[^']*' /, "").replace(/\n/g, " ");
Expand Down
51 changes: 47 additions & 4 deletions actions/setup/js/gateway_difc_filtered.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ describe("gateway_difc_filtered.cjs", () => {
expect(result).toContain("> [!NOTE]");
expect(result).toContain("> <details>");
expect(result).toContain("> </details>");
expect(result).toContain("> <summary>**πŸ”’ Integrity filter blocked 1 item**</summary>");
expect(result).toContain("> <summary><b>πŸ”’ Integrity filter blocked 1 item</b></summary>");
expect(result).toContain("[#42](https://github.com/org/repo/issues/42)");
expect(result).toContain("`list_issues`");
expect(result).toContain("Integrity check failed");
Expand All @@ -202,7 +202,7 @@ describe("gateway_difc_filtered.cjs", () => {
const result = generateDifcFilteredSection(events);

expect(result).toContain("> [!NOTE]");
expect(result).toContain("> <summary>**πŸ”’ Integrity filter blocked 2 items**</summary>");
expect(result).toContain("> <summary><b>πŸ”’ Integrity filter blocked 2 items</b></summary>");
expect(result).toContain("[#42](https://github.com/org/repo/issues/42)");
expect(result).toContain("[#99](https://github.com/org/repo/issues/99)");
});
Expand Down Expand Up @@ -318,7 +318,7 @@ describe("gateway_difc_filtered.cjs", () => {

const result = generateDifcFilteredSection(events);

expect(result).toContain("> <summary>**πŸ”’ Integrity filter blocked 2 items**</summary>");
expect(result).toContain("> <summary><b>πŸ”’ Integrity filter blocked 2 items</b></summary>");
expect(result).toContain("[#42](https://github.com/org/repo/issues/42)");
expect(result).toContain("[#99](https://github.com/org/repo/issues/99)");
});
Expand Down Expand Up @@ -363,7 +363,7 @@ describe("gateway_difc_filtered.cjs", () => {
const result = generateDifcFilteredSection(events);

// Summary still shows the total count
expect(result).toContain("> <summary>**πŸ”’ Integrity filter blocked 20 items**</summary>");
expect(result).toContain("> <summary><b>πŸ”’ Integrity filter blocked 20 items</b></summary>");
// First 16 items rendered
expect(result).toContain("[#1](https://github.com/org/repo/issues/1)");
expect(result).toContain("[#16](https://github.com/org/repo/issues/16)");
Expand Down Expand Up @@ -397,5 +397,48 @@ describe("gateway_difc_filtered.cjs", () => {
expect(result).toContain("... and 1 more item");
expect(result).not.toContain("... and 1 more items");
});

it("should show events with #unknown description using tool_name instead", () => {
const events = [
{
type: "DIFC_FILTERED",
tool_name: "search_issues",
description: "github:#unknown",
reason: "has lower integrity than agent requires.",
},
{
type: "DIFC_FILTERED",
tool_name: "list_issues",
reason: "Integrity check failed",
html_url: "https://github.com/org/repo/issues/42",
number: "42",
},
];

const result = generateDifcFilteredSection(events);

// Both entries should be shown; #unknown text hidden, tool_name used instead
expect(result).toContain("> <summary><b>πŸ”’ Integrity filter blocked 2 items</b></summary>");
expect(result).not.toContain("#unknown");
expect(result).toContain("`search_issues`");
expect(result).toContain("[#42](https://github.com/org/repo/issues/42)");
});

it("should show entry using tool_name when description is #unknown", () => {
const events = [
{
type: "DIFC_FILTERED",
tool_name: "search_issues",
description: "github:#unknown",
reason: "has lower integrity",
},
];

const result = generateDifcFilteredSection(events);

expect(result).toContain("> <summary><b>πŸ”’ Integrity filter blocked 1 item</b></summary>");
expect(result).toContain("`search_issues`");
expect(result).not.toContain("#unknown");
});
});
});