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: 1 addition & 4 deletions actions/setup/js/firewall_blocked_domains.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ function generateBlockedDomainsSection(blockedDomains) {
const domainWord = domainCount === 1 ? "domain" : "domains";

let section = "\n\n> [!WARNING]\n";
section += `> <details>\n`;
section += `> <summary><strong>⚠️ Firewall blocked ${domainCount} ${domainWord}</strong></summary>\n`;
section += `> **⚠️ Firewall blocked ${domainCount} ${domainWord}**\n`;
section += `>\n`;
section += `> The following ${domainWord} ${domainCount === 1 ? "was" : "were"} blocked by the firewall during workflow execution:\n`;
section += `>\n`;
Expand All @@ -220,8 +219,6 @@ function generateBlockedDomainsSection(blockedDomains) {
section += `> \`\`\`\n`;
section += `>\n`;
section += `> See [Network Configuration](https://github.github.com/gh-aw/reference/network/) for more information.\n`;
section += `>\n`;
section += `> </details>\n`;

return section;
}
Expand Down
12 changes: 4 additions & 8 deletions actions/setup/js/firewall_blocked_domains.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -305,27 +305,23 @@ describe("firewall_blocked_domains.cjs", () => {
expect(generateBlockedDomainsSection(undefined)).toBe("");
});

it("should generate details section for single blocked domain", () => {
it("should generate warning section for single blocked domain", () => {
const result = generateBlockedDomainsSection(["blocked.example.com"]);

expect(result).toContain("> [!WARNING]");
expect(result).toContain("> <details>");
expect(result).toContain("> </details>");
expect(result).toContain("> <summary><strong>⚠️ Firewall blocked 1 domain</strong></summary>");
expect(result).toContain("> **⚠️ Firewall blocked 1 domain**");
expect(result).toContain("> - `blocked.example.com`");
expect(result).toContain("> The following domain was blocked by the firewall during workflow execution:");
expect(result).toContain('> ```yaml\n> network:\n> allowed:\n> - defaults\n> - "blocked.example.com"\n> ```');
expect(result).toContain("> See [Network Configuration](https://github.github.com/gh-aw/reference/network/) for more information.");
});

it("should generate details section for multiple blocked domains", () => {
it("should generate warning section for multiple blocked domains", () => {
const domains = ["alpha.example.com", "beta.example.com", "gamma.example.com"];
const result = generateBlockedDomainsSection(domains);

expect(result).toContain("> [!WARNING]");
expect(result).toContain("> <details>");
expect(result).toContain("> </details>");
expect(result).toContain("> <summary><strong>⚠️ Firewall blocked 3 domains</strong></summary>");
expect(result).toContain("> **⚠️ Firewall blocked 3 domains**");
expect(result).toContain("> - `alpha.example.com`");
expect(result).toContain("> - `beta.example.com`");
expect(result).toContain("> - `gamma.example.com`");
Expand Down
4 changes: 3 additions & 1 deletion actions/setup/js/gateway_difc_filtered.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,14 @@ function generateDifcFilteredSection(filteredEvents) {

const count = uniqueEvents.length;
const itemWord = count === 1 ? "item" : "items";
const verb = count === 1 ? "was" : "were";
const subjectNegationPhrase = count === 1 ? "it doesn't" : "they don't";

let section = "\n\n> [!NOTE]\n";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot keep details for NOTE

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to keep the NOTE section collapsible with <details>/<summary> in gateway_difc_filtered.cjs, and adjusted tests accordingly in commit 05a15ac.

Screenshot: /tmp/gh-aw-note-details-preview.png (preview of the restored NOTE details block).

section += `> <details>\n`;
section += `> <summary>🔒 Integrity filter blocked ${count} ${itemWord}</summary>\n`;
section += `>\n`;
section += `> The following ${itemWord} were blocked because they don't meet the GitHub integrity level.\n`;
section += `> The following ${itemWord} ${verb} blocked because ${subjectNegationPhrase} meet the GitHub integrity level.\n`;
section += `>\n`;

const maxItems = 16;
Expand Down
4 changes: 3 additions & 1 deletion actions/setup/js/gateway_difc_filtered.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ describe("gateway_difc_filtered.cjs", () => {
const events = [{ type: "DIFC_FILTERED", tool_name: "tool", reason: "reason" }];
const result = generateDifcFilteredSection(events);

expect(result).toContain("blocked because they don't meet");
expect(result).toContain("blocked because it doesn't meet");
expect(result).toContain("GitHub integrity level");
});

Expand Down Expand Up @@ -300,13 +300,15 @@ describe("gateway_difc_filtered.cjs", () => {
const singleResult = generateDifcFilteredSection(singleEvent);
expect(singleResult).toContain("1 item");
expect(singleResult).not.toContain("items");
expect(singleResult).toContain("blocked because it doesn't meet");

const multiEvents = [
{ type: "DIFC_FILTERED", tool_name: "tool1", reason: "r1" },
{ type: "DIFC_FILTERED", tool_name: "tool2", reason: "r2" },
];
const multiResult = generateDifcFilteredSection(multiEvents);
expect(multiResult).toContain("2 items");
expect(multiResult).toContain("blocked because they don't meet");
});

it("should deduplicate filtered events with identical fields", () => {
Expand Down
Loading