-
Notifications
You must be signed in to change notification settings - Fork 475
fix: find access.log in sandbox/firewall/logs/squid-logs/ subdirectory #42513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1f0ea3d
c2fec63
60b5712
2d5d517
6fe1fb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -372,9 +372,27 @@ func analyzeFirewallLogs(runDir string, verbose bool) (*FirewallAnalysis, error) | |
|
|
||
| // First, check for sandbox/firewall/logs/ directory (new path after artifact download) | ||
| // Firewall logs are uploaded from /tmp/gh-aw/sandbox/firewall/logs/ and the common parent | ||
| // /tmp/gh-aw/ is stripped during artifact upload, resulting in sandbox/firewall/logs/ after download | ||
| // /tmp/gh-aw/ is stripped during artifact upload, resulting in sandbox/firewall/logs/ after download. | ||
| // Within that directory, AWF writes Squid access logs to a squid-logs/ subdirectory. | ||
| sandboxFirewallLogsDir := filepath.Join(runDir, "sandbox", "firewall", "logs") | ||
| if fileutil.DirExists(sandboxFirewallLogsDir) { | ||
| // AWF writes the Squid access.log to a squid-logs/ subdirectory within --proxy-logs-dir. | ||
| // Check for that subdirectory first before falling back to the parent directory. | ||
| squidSubDir := filepath.Join(sandboxFirewallLogsDir, "squid-logs") | ||
| if fileutil.DirExists(squidSubDir) { | ||
| firewallLogLog.Printf("Found firewall logs directory: sandbox/firewall/logs/squid-logs") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardcoded path literal in log message will mislead debugging: the message emits Suggested fixEvery other log site in this function uses the actual resolved path variable. Use firewallLogLog.Printf("Found firewall logs directory: %s", squidSubDir)
if verbose {
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Found firewall logs directory: "+squidSubDir))
}The existing fallback at line 390-393 has the same issue with |
||
| if verbose { | ||
| fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Found firewall logs directory: sandbox/firewall/logs/squid-logs")) | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [/tdd] No test covers the edge case where 💡 Suggested testAdd func TestAnalyzeFirewallLogsSandboxSquidSubdirEmpty(t *testing.T) {
tmpDir := testutil.TempDir(t, "test-squid-empty-*")
squidDir := filepath.Join(tmpDir, "sandbox", "firewall", "logs", "squid-logs")
os.MkdirAll(squidDir, 0755)
// no files written
analysis, err := analyzeFirewallLogs(tmpDir, false)
// assert expected behaviour: err != nil OR analysis.TotalRequests == 0
}@copilot please address this. |
||
| analysis, err := analyzeMultipleFirewallLogs(squidSubDir, verbose) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| if analysis != nil { | ||
| return analysis, nil | ||
| } | ||
| } | ||
| // Fall back to direct *.log files at the sandbox/firewall/logs/ level (older AWF layout). | ||
| firewallLogLog.Printf("Found firewall logs directory: sandbox/firewall/logs") | ||
| if verbose { | ||
| fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Found firewall logs directory: sandbox/firewall/logs")) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[/codebase-design] The string path
sandbox/firewall/logs/squid-logsis now duplicated verbatim acrossfirewall_log.go(here) andlogs_parsing_firewall.go(line 44). If the artifact layout ever changes again, both sites need updating and it's easy to miss one.💡 Suggested approach
Define a package-level constant or constructor to centralise the path:
Or extract a helper function that returns the ordered candidate dirs (see also the comment in
logs_parsing_firewall.goabout divergent fallback chains).@copilot please address this.