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: 5 additions & 0 deletions .changeset/patch-successful-none-none-firewall-records.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions actions/setup/js/firewall_blocked_domains.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ function parseFirewallLogLine(line) {
function isRequestBlocked(decision, status) {
// Check status code first
const statusCode = parseInt(status, 10);
if (statusCode === 200 || statusCode === 206 || statusCode === 304) {
return false;
}

if (statusCode === 403 || statusCode === 407) {
return true;
}
Expand All @@ -82,11 +86,6 @@ function isRequestBlocked(decision, status) {
return true;
}

// Check for allowed indicators
if (statusCode === 200 || statusCode === 206 || statusCode === 304) {
return false;
}

if (decision.includes("TCP_TUNNEL") || decision.includes("TCP_HIT") || decision.includes("TCP_MISS")) {
return false;
}
Expand Down
20 changes: 20 additions & 0 deletions actions/setup/js/firewall_blocked_domains.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ describe("firewall_blocked_domains.cjs", () => {
expect(isRequestBlocked("TCP_TUNNEL:HIER_DIRECT", "200")).toBe(false);
});

it("should identify successful NONE_NONE requests as allowed", () => {
expect(isRequestBlocked("NONE_NONE:HIER_NONE", "200")).toBe(false);
expect(isRequestBlocked("NONE_NONE:HIER_NONE", "206")).toBe(false);
expect(isRequestBlocked("NONE_NONE:HIER_NONE", "304")).toBe(false);
});

it("should identify allowed request with TCP_TUNNEL decision", () => {
expect(isRequestBlocked("TCP_TUNNEL:HIER_DIRECT", "200")).toBe(false);
});
Expand Down Expand Up @@ -291,6 +297,20 @@ describe("firewall_blocked_domains.cjs", () => {
expect(result).not.toContain("api.anthropic.com");
});

it("should not report successful SNI guard records as blocked", () => {
const logsDir = path.join(testDir, "logs-sni-guard");
fs.mkdirSync(logsDir, { recursive: true });

const logContent = [
'1773003475.166 172.30.0.30:50232 api.anthropic.com:443 18.64.224.91:443 1.1 CONNECT 200 NONE_NONE:HIER_NONE api.anthropic.com:443 "-"',
'1773003475.167 172.30.0.30:50232 api.anthropic.com:443 18.64.224.91:443 1.1 CONNECT 200 TCP_TUNNEL:HIER_DIRECT api.anthropic.com:443 "-"',
].join("\n");

fs.writeFileSync(path.join(logsDir, "access.log"), logContent);

expect(getBlockedDomains(logsDir)).toEqual([]);
});

it("should handle invalid log lines gracefully", () => {
const logsDir = path.join(testDir, "logs6");
fs.mkdirSync(logsDir, { recursive: true });
Expand Down
Loading