Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pkg/workflow/engine_firewall_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
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.

Good fix! Using path.Dir(firewallLogsDir) to get the parent firewall directory ensures both logs/ and audit/ subdirectories get the correct permissions for artifact upload. This correctly addresses the EACCES issue.

firewallLogsDir := "/tmp/gh-aw/sandbox/firewall/logs"
firewallLogsDir := constants.AWFProxyLogsDir
firewallDir := path.Dir(firewallLogsDir)

Comment on lines 122 to 125
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

generateFirewallLogParsingStep hard-codes both firewallLogsDir and the new firewallDir. Since these paths already exist as constants (constants.AWFProxyLogsDir, constants.AWFAuditDir) and firewallDir is just the parent of the logs dir, consider deriving firewallDir from the logs constant (e.g., via path.Dir) to avoid future drift if the sandbox layout changes.

Copilot uses AI. Check for mistakes.
stepLines := []string{
" - name: Print firewall logs",
Expand All @@ -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\"",
Expand Down
18 changes: 18 additions & 0 deletions pkg/workflow/engine_firewall_support_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
package workflow

import (
"path"
"strings"
"testing"

"github.com/github/gh-aw/pkg/constants"
)

func TestHasNetworkRestrictions(t *testing.T) {
Expand Down Expand Up @@ -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")
}
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.

Nice addition of a dedicated test for the chmod fix. The test cleanly verifies both that AWF_LOGS_DIR still points to the logs subdirectory and that the chmod targets the parent firewall/ directory.

}
Original file line number Diff line number Diff line change
Expand Up @@ -505,9 +505,9 @@ jobs:
env:
AWF_LOGS_DIR: /tmp/gh-aw/sandbox/firewall/logs
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
sudo chmod -R a+r /tmp/gh-aw/sandbox/firewall/logs 2>/dev/null || true
sudo chmod -R a+r /tmp/gh-aw/sandbox/firewall 2>/dev/null || true
# 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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,9 @@ jobs:
env:
AWF_LOGS_DIR: /tmp/gh-aw/sandbox/firewall/logs
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
sudo chmod -R a+r /tmp/gh-aw/sandbox/firewall/logs 2>/dev/null || true
sudo chmod -R a+r /tmp/gh-aw/sandbox/firewall 2>/dev/null || true
# 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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,9 +673,9 @@ jobs:
env:
AWF_LOGS_DIR: /tmp/gh-aw/sandbox/firewall/logs
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
sudo chmod -R a+r /tmp/gh-aw/sandbox/firewall/logs 2>/dev/null || true
sudo chmod -R a+r /tmp/gh-aw/sandbox/firewall 2>/dev/null || true
# 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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,9 +572,9 @@ jobs:
env:
AWF_LOGS_DIR: /tmp/gh-aw/sandbox/firewall/logs
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
sudo chmod -R a+r /tmp/gh-aw/sandbox/firewall/logs 2>/dev/null || true
sudo chmod -R a+r /tmp/gh-aw/sandbox/firewall 2>/dev/null || true
# 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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,9 @@ jobs:
env:
AWF_LOGS_DIR: /tmp/gh-aw/sandbox/firewall/logs
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
sudo chmod -R a+r /tmp/gh-aw/sandbox/firewall/logs 2>/dev/null || true
sudo chmod -R a+r /tmp/gh-aw/sandbox/firewall 2>/dev/null || true
# 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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,9 @@ jobs:
env:
AWF_LOGS_DIR: /tmp/gh-aw/sandbox/firewall/logs
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
sudo chmod -R a+r /tmp/gh-aw/sandbox/firewall/logs 2>/dev/null || true
sudo chmod -R a+r /tmp/gh-aw/sandbox/firewall 2>/dev/null || true
# 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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,9 @@ jobs:
env:
AWF_LOGS_DIR: /tmp/gh-aw/sandbox/firewall/logs
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
sudo chmod -R a+r /tmp/gh-aw/sandbox/firewall/logs 2>/dev/null || true
sudo chmod -R a+r /tmp/gh-aw/sandbox/firewall 2>/dev/null || true
# 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"
Expand Down
Loading