-
Notifications
You must be signed in to change notification settings - Fork 359
Fix firewall cleanup permissions to include audit logs directory #27742
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
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 |
|---|---|---|
|
|
@@ -4,9 +4,11 @@ import ( | |
| "errors" | ||
| "fmt" | ||
| "os" | ||
| "path" | ||
| "strings" | ||
|
|
||
| "github.com/github/gh-aw/pkg/console" | ||
| "github.com/github/gh-aw/pkg/constants" | ||
| "github.com/github/gh-aw/pkg/logger" | ||
| ) | ||
|
|
||
|
|
@@ -118,7 +120,8 @@ func generateSquidLogsUploadStep(workflowName string) GitHubActionStep { | |
| // generateFirewallLogParsingStep creates a GitHub Actions step to parse firewall logs and create step summary. | ||
| func generateFirewallLogParsingStep(workflowName string) GitHubActionStep { | ||
| // Firewall logs are at a known location in the sandbox folder structure | ||
| firewallLogsDir := "/tmp/gh-aw/sandbox/firewall/logs" | ||
| firewallLogsDir := constants.AWFProxyLogsDir | ||
| firewallDir := path.Dir(firewallLogsDir) | ||
|
|
||
|
Comment on lines
122
to
125
|
||
| stepLines := []string{ | ||
| " - name: Print firewall logs", | ||
|
|
@@ -127,9 +130,9 @@ func generateFirewallLogParsingStep(workflowName string) GitHubActionStep { | |
| " env:", | ||
| " AWF_LOGS_DIR: " + firewallLogsDir, | ||
| " run: |", | ||
| " # Fix permissions on firewall logs so they can be uploaded as artifacts", | ||
| " # Fix permissions on firewall logs/audit dirs so they can be uploaded as artifacts", | ||
| " # AWF runs with sudo, creating files owned by root", | ||
| fmt.Sprintf(" sudo chmod -R a+r %s 2>/dev/null || true", firewallLogsDir), | ||
| fmt.Sprintf(" sudo chmod -R a+r %s 2>/dev/null || true", firewallDir), | ||
| " # Only run awf logs summary if awf command exists (it may not be installed if workflow failed before install step)", | ||
| " if command -v awf &> /dev/null; then", | ||
| " awf logs summary | tee -a \"$GITHUB_STEP_SUMMARY\"", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,8 +3,11 @@ | |
| package workflow | ||
|
|
||
| import ( | ||
| "path" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/github/gh-aw/pkg/constants" | ||
| ) | ||
|
|
||
| func TestHasNetworkRestrictions(t *testing.T) { | ||
|
|
@@ -267,3 +270,18 @@ func TestCheckFirewallDisable(t *testing.T) { | |
| } | ||
| }) | ||
| } | ||
|
|
||
| func TestGenerateFirewallLogParsingStepFixesFirewallPermissions(t *testing.T) { | ||
| step := generateFirewallLogParsingStep("test-workflow") | ||
| stepContent := strings.Join(step, "\n") | ||
| expectedLogsDir := constants.AWFProxyLogsDir | ||
| expectedFirewallDir := path.Dir(expectedLogsDir) | ||
|
|
||
| if !strings.Contains(stepContent, "AWF_LOGS_DIR: "+expectedLogsDir) { | ||
| t.Error("Expected firewall log parsing step to keep AWF_LOGS_DIR set to logs directory") | ||
| } | ||
|
|
||
| if !strings.Contains(stepContent, "sudo chmod -R a+r "+expectedFirewallDir+" 2>/dev/null || true") { | ||
| t.Error("Expected firewall log parsing step to chmod the parent firewall directory for logs and audit upload") | ||
| } | ||
|
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. Nice addition of a dedicated test for the chmod fix. The test cleanly verifies both that |
||
| } | ||
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.
Good fix! Using
path.Dir(firewallLogsDir)to get the parent firewall directory ensures bothlogs/andaudit/subdirectories get the correct permissions for artifact upload. This correctly addresses theEACCESissue.