analyzeAccessLogs analyzes access logs in a run directory
(runDir string, verbose bool)
| 155 | |
| 156 | // analyzeAccessLogs analyzes access logs in a run directory |
| 157 | func analyzeAccessLogs(runDir string, verbose bool) (*DomainAnalysis, error) { |
| 158 | accessLogLog.Printf("Analyzing access logs in: %s", runDir) |
| 159 | |
| 160 | // Check for access log files in access.log directory (legacy path) |
| 161 | accessLogsDir := filepath.Join(runDir, "access.log") |
| 162 | if _, err := os.Stat(accessLogsDir); err == nil { |
| 163 | accessLogLog.Printf("Found access logs directory: %s", accessLogsDir) |
| 164 | return analyzeMultipleAccessLogs(accessLogsDir, verbose) |
| 165 | } |
| 166 | |
| 167 | // Check for access logs in sandbox/firewall/logs/ directory (new path after artifact download) |
| 168 | // Firewall logs are uploaded from /tmp/gh-aw/sandbox/firewall/logs/ and the common parent |
| 169 | // /tmp/gh-aw/ is stripped during artifact upload, resulting in sandbox/firewall/logs/ after download |
| 170 | sandboxFirewallLogsDir := filepath.Join(runDir, "sandbox", "firewall", "logs") |
| 171 | if _, err := os.Stat(sandboxFirewallLogsDir); err == nil { |
| 172 | accessLogLog.Printf("Found firewall logs directory: %s", sandboxFirewallLogsDir) |
| 173 | return analyzeMultipleAccessLogs(sandboxFirewallLogsDir, verbose) |
| 174 | } |
| 175 | |
| 176 | // No access logs found |
| 177 | accessLogLog.Printf("No access logs directory found in: %s", runDir) |
| 178 | if verbose { |
| 179 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage("No access logs found in "+runDir)) |
| 180 | } |
| 181 | return nil, nil |
| 182 | } |
| 183 | |
| 184 | // analyzeMultipleAccessLogs analyzes multiple separate access log files |
| 185 | func analyzeMultipleAccessLogs(accessLogsDir string, verbose bool) (*DomainAnalysis, error) { |