Skip to content

[Test Coverage] squid-log-reader.ts: 100% coverage#5378

Merged
lpcox merged 4 commits into
mainfrom
test-coverage/squid-log-reader-95cff70be270c18f
Jun 22, 2026
Merged

[Test Coverage] squid-log-reader.ts: 100% coverage#5378
lpcox merged 4 commits into
mainfrom
test-coverage/squid-log-reader-95cff70be270c18f

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

What

Adds src/squid-log-reader-coverage.test.ts — 10 new tests that cover every previously untested branch in src/squid-log-reader.ts, raising it from ~80% to 100% across all four coverage metrics (statements, branches, functions, lines).

Why

squid-log-reader.ts is a security-critical component: it scans Squid proxy logs to detect blocked domain attempts. Incomplete coverage left several error-handling paths untested, including the EISDIR catch block and edge cases in domain-target parsing.

Covered lines / branches

Gap What was missing Fix
Line 36 (continue) Lines containing TCP_DENIED but failing the log-format regex were silently ignored without a test Test with malformed text that includes the token
Lines 48-49 (catch block) fs.readFileSync error path never exercised Point the log path at a directory so the OS throws EISDIR
Lines 64-66 (normalizeTarget URL branch) CONNECT entries whose URL field includes :// were never tested Craft a log line with (example.com/redacted) as the URL field
Line 66 (port-absent arm) + Line 75 (parseTarget no-colon) URL with no port component returns bare hostname → parseTarget colonIndex = -1 branch Use (noport.example.com/redacted) as the URL
Lines 67-68 (normalizeTarget catch) Invalid URL passed to new URL() → catch fallback Use (redacted) which throws TypeError: Invalid URL`
Line 81 (parseTarget non-digit port) Port segment like notaport never hit the !/^\d+$/ guard Write a log entry with example.com:notaport as the target

Verification

PASS src/squid-log-reader.test.ts
PASS src/squid-log-reader-coverage.test.ts

squid-log-reader.ts | 100 | 100 | 100 | 100 |

All 10 new tests pass. Pre-existing tests remain green. Lint clean (--max-warnings=0 on the new file).

Generated by Test Coverage Improver · 127.6 AIC · ⊞ 5.9K ·

Cover previously untested branches in squid-log-reader.ts:
- Line 36 (continue): lines containing 'TCP_DENIED' that fail regex match
- Lines 48-49 (catch): fs.readFileSync throws EISDIR when path is a directory
- Lines 64-66 (normalizeTarget URL branch): URLs with '://' including port
- Line 66 / 75: URL with no port → hostname-only → parseTarget no-colon path
- Lines 67-68 (normalizeTarget catch): malformed URL triggers URL parse error
- Line 81 (parseTarget): non-numeric port segment → domain-only BlockedTarget
- proxyLogsDir option correctly overrides default squid-logs path

Raises squid-log-reader.ts statement/branch/line/function coverage from ~80% to 100%.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lpcox lpcox marked this pull request as ready for review June 22, 2026 13:34
Copilot AI review requested due to automatic review settings June 22, 2026 13:34
@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 97.85% 98.05% 📈 +0.20%
Statements 97.79% 97.98% 📈 +0.19%
Functions 99.50% 99.51% 📈 +0.01%
Branches 93.55% 93.72% 📈 +0.17%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/workdir-setup.ts 92.7% → 94.5% (+1.82%) 92.7% → 94.5% (+1.82%)
src/squid-log-reader.ts 82.2% → 100.0% (+17.78%) 82.2% → 100.0% (+17.78%)
✨ New Files (1 files)
  • src/logs/audit-enricher.test-utils.ts: 100.0% lines

Coverage comparison generated by scripts/ci/compare-coverage.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a dedicated Jest test suite to fully exercise previously uncovered branches in src/squid-log-reader.ts (Squid access.log denial scanning), bringing the file’s coverage up to 100% across statements/branches/functions/lines.

Changes:

  • Add src/squid-log-reader-coverage.test.ts with targeted cases for malformed TCP_DENIED lines, readFileSync error handling, URL normalization branches, and parseTarget edge cases.
  • Add coverage for proxyLogsDir behavior by reading access.log from a custom directory.
Show a summary per file
File Description
src/squid-log-reader-coverage.test.ts Adds focused branch-coverage tests for denial detection and target parsing in squid-log-reader.ts.

Copilot's findings

Tip

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

  • Files reviewed: 1/1 changed files
  • Comments generated: 2

Comment thread src/squid-log-reader-coverage.test.ts Outdated
Comment thread src/squid-log-reader-coverage.test.ts Outdated
lpcox and others added 2 commits June 22, 2026 07:44
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor Author

✅ Copilot review passed with no inline comments.

@github-actions[bot] Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

🔌 Smoke Services — All services reachable! ✅

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Smoke Copilot BYOK AOAI (Entra) reports failed. AOAI BYOK (Entra) mode investigation needed...

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Smoke Claude passed

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Build Test Suite completed successfully!

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Smoke Gemini completed. All facets verified. 💎

Verifying safeoutputs

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Smoke Copilot BYOK AOAI (api-key) completed. Copilot AOAI BYOK (api-key) mode operational. 🔓

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅

Comment thread src/squid-log-reader-coverage.test.ts Fixed
Comment thread src/squid-log-reader-coverage.test.ts Fixed
Comment thread src/squid-log-reader-coverage.test.ts Fixed
Comment thread src/squid-log-reader-coverage.test.ts Fixed
@github-actions

Copy link
Copy Markdown
Contributor Author

🤖 Smoke Test Results

Test Status
GitHub MCP connectivity
GitHub.com HTTP connectivity
File write/read ✅ (smoke-test-copilot-27961256090.txt verified)

PR: [Test Coverage] squid-log-reader.ts: 100% coverage
Author: @github-actions[bot]

🟢 Overall: PASS

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

Copy link
Copy Markdown
Contributor Author

Smoke Test: Claude Engine Validation

  • API status: ✅ PASS
  • gh check: ✅ PASS
  • File status: ✅ PASS

Overall result: PASS

Generated by Smoke Claude for issue #5378 · 36.6 AIC · ⊞ 3.1K ·

@github-actions

Copy link
Copy Markdown
Contributor Author

Smoke Test: Copilot BYOK (Direct Mode) — PASS

  • ✅ GitHub MCP connectivity
  • ✅ GitHub.com HTTP 200
  • ✅ File write/read test
  • ✅ BYOK inference test (api-proxy → api.githubcopilot.com)

Running in direct BYOK mode via COPILOT_PROVIDER_API_KEY with api-proxy sidecar.

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions

Copy link
Copy Markdown
Contributor Author

Smoke Test: Copilot PAT Auth — PASS

Test Result
GitHub MCP connectivity
GitHub.com HTTP
File write/read /tmp/gh-aw/agent/smoke-test-copilot-pat-27961255545.txt

PR: [Test Coverage] squid-log-reader.ts: 100% coverage by @github-actions[bot]
Auth mode: PAT (COPILOT_GITHUB_TOKEN)

🔑 PAT report filed by Smoke Copilot PAT

@github-actions

Copy link
Copy Markdown
Contributor Author

Smoke test results:

  • Merged PRs: Split docker-manager cleanup tests by concern; Split api-proxy token parser tests by JSON, SSE, and normalization concerns
  • GitHub title check: ✅
  • Temp file write/read: ✅
  • Build (npm ci && npm run build): ✅
  • Discussion comment: skipped (no valid discussion number)
  • Overall: PASS

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • registry.npmjs.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "registry.npmjs.org"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex

@github-actions

Copy link
Copy Markdown
Contributor Author

Chroot Smoke Test Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3
Node.js v24.16.0 v22.22.3
Go go1.22.12 go1.22.12

Overall: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot environments.

Tested by Smoke Chroot

@github-actions

Copy link
Copy Markdown
Contributor Author

Smoke Test: Services Connectivity

Check Result
Redis PING ❌ no response
PostgreSQL pg_isready ❌ no response
PostgreSQL SELECT 1 ❌ no response

Overall: FAILhost.docker.internal unreachable from runner (all three checks timed out / returned no response).

🔌 Service connectivity validated by Smoke Services

@github-actions

Copy link
Copy Markdown
Contributor Author

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A ✅ PASS
.NET json-parse N/A ✅ PASS
Go color 1/1 passed ✅ PASS
Go env 1/1 passed ✅ PASS
Go uuid 1/1 passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx All passed ✅ PASS
Node.js execa All passed ✅ PASS
Node.js p-limit All passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Generated by Build Test Suite for issue #5378 · 52.7 AIC · ⊞ 7.7K ·

@github-actions

Copy link
Copy Markdown
Contributor Author

Smoke Test Results

Overall status: FAIL

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • localhost

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "localhost"

See Network Configuration for more information.

💎 Faceted by Smoke Gemini

@github-actions

Copy link
Copy Markdown
Contributor Author

@github-actions[bot]

[Test Coverage] squid-log-reader.ts: 100% coverage
GitHub MCP: ✅
github.com: ✅
file I/O: ✅
BYOK inference: ✅

Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw)
Overall: PASS

🔑 BYOK (AOAI api-key) report filed by Smoke Copilot BYOK AOAI (api-key)

@github-actions

Copy link
Copy Markdown
Contributor Author

🔍 Smoke Test: API Proxy OpenTelemetry Tracing

Scenario Result Notes
1. Module Loading ✅ Pass otel.js loads; isEnabled: true; exports 7 public functions + test helpers
2. Test Suite ✅ Pass 59/59 tests passed across 2 suites (otel.test.js, otel-fanout.test.js)
3. Env Var Forwarding ⚠️ False Negative Check greps api-proxy-service.ts but vars are in api-proxy-service-config.ts — OTEL vars are forwarded via pickEnvVars(...)
4. Token Tracker Integration ✅ Pass onUsage callback confirmed in token-tracker-http.js
5. OTEL Diagnostics ➖ N/A "Collect OTEL diagnostics" step not present in workflow lock file

Summary: OTEL tracing is fully implemented and functional. Scenario 3's workflow check produces a false negative — the grep targets api-proxy-service.ts but forwarding logic lives in api-proxy-service-config.ts.

📡 OTel tracing validated by Smoke OTel Tracing

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@lpcox lpcox merged commit aa7b5f6 into main Jun 22, 2026
22 of 23 checks passed
@lpcox lpcox deleted the test-coverage/squid-log-reader-95cff70be270c18f branch June 22, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants