Skip to content

Fix firewall analysis inflating blocked count with internal Squid error entries#20137

Merged
pelikhan merged 3 commits intomainfrom
copilot/fix-firewall-analysis-error-count
Mar 9, 2026
Merged

Fix firewall analysis inflating blocked count with internal Squid error entries#20137
pelikhan merged 3 commits intomainfrom
copilot/fix-firewall-analysis-error-count

Conversation

Copy link
Contributor

Copilot AI commented Mar 9, 2026

  • Fix pkg/cli/firewall_log.go: skip internal Squid error entries (::1: client, domain -, destIPPort -:- or -) before counting, and fix domain fallback to exclude -:-
  • Fix actions/setup/js/parse_firewall_logs.cjs: skip internal Squid error entries and fix domain fallback to exclude -:-
  • Fix actions/setup/js/firewall_blocked_domains.cjs: skip internal Squid error entries and fix domain fallback to explicitly exclude -:-
  • Add tests to pkg/cli/firewall_log_test.go for internal Squid error entries being filtered
  • Add tests to actions/setup/js/firewall_blocked_domains.test.cjs for internal Squid error entries being filtered
  • Extract analyzeFirewallLogLines from main() in parse_firewall_logs.cjs for testability
  • Add tests to actions/setup/js/parse_firewall_logs.test.cjs covering internal Squid entry filtering in the main parsing loop (totals, per-domain stats, -:- domain fallback fix)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.



✨ PR Review Safe Output Test - Run 22833942676

💥 [THE END] — Illustrated by Smoke Claude ·

…r entries (#issue)"

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix internal Squid error entries inflating blocked count Fix firewall analysis inflating blocked count with internal Squid error entries Mar 9, 2026
@pelikhan pelikhan marked this pull request as ready for review March 9, 2026 00:39
Copilot AI review requested due to automatic review settings March 9, 2026 00:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes firewall log analysis incorrectly counting internal Squid error entries (localhost ::1 + placeholder domain/destination) as blocked external requests, which inflated blocked_requests and triggered false high-severity findings.

Changes:

  • Filter out internal Squid error entries (::1:*, domain -, dest -/-:-) in both Go and JS log parsers.
  • Tighten domain fallback logic to avoid treating -:- as a real destination.
  • Add/extend tests to validate filtering behavior (Go + JS blocked-domain extractor).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/cli/firewall_log.go Skips internal Squid error entries and prevents -:- from being used as a domain fallback.
pkg/cli/firewall_log_test.go Adds Go tests to ensure internal Squid entries are excluded from totals/domains.
actions/setup/js/parse_firewall_logs.cjs Mirrors the Go filtering + fallback fix for the step-summary parser.
actions/setup/js/firewall_blocked_domains.cjs Mirrors filtering + makes fallback explicitly exclude placeholder destinations.
actions/setup/js/firewall_blocked_domains.test.cjs Adds a JS test to ensure internal Squid errors don’t affect blocked-domain extraction.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

…ry filtering

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

💥 Automated smoke test review - all systems nominal!

💥 [THE END] — Illustrated by Smoke Claude

}

// Skip internal Squid error entries (client IP ::1, no domain, no destination)
// These are internal Squid connection errors (e.g., error:transaction-end-before-headers)
Copy link
Contributor

Choose a reason for hiding this comment

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

Good defensive check for internal Squid error entries. The condition correctly identifies entries with ::1: client IP, no domain (-), and no destination (-:- or -). This prevents these internal errors from inflating blocked domain counts.

const requestsByDomain = new Map();

for (const line of lines) {
const entry = parseFirewallLogLine(line);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice refactoring - extracting analyzeFirewallLogLines as a separate function improves testability significantly. The function signature is clear and the return type is well-documented in the JSDoc comment.

@pelikhan pelikhan merged commit 5f23272 into main Mar 9, 2026
80 checks passed
@pelikhan pelikhan deleted the copilot/fix-firewall-analysis-error-count branch March 9, 2026 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[cli-tools-test] Firewall analysis inflates blocked count with internal squid error entries (domain "-:-")

3 participants