-
Notifications
You must be signed in to change notification settings - Fork 96
222 lines (190 loc) · 8.21 KB
/
test_security.yml
File metadata and controls
222 lines (190 loc) · 8.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# Copyright(C) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
# SPDX-License-Identifier: MIT
# This workflow tests GAIA security features
# Tests include: Path validation, shell injection prevention, argument sanitization
# Platform: Cross-platform (Linux and Windows)
name: Security Tests
on:
workflow_call:
push:
branches: [ main ]
paths:
- 'src/gaia/agents/**'
- 'src/gaia/rag/**'
- 'tests/verify_*.py'
- 'setup.py'
- '.github/workflows/test_security.yml'
pull_request:
branches: [ main ]
types: [opened, synchronize, reopened, ready_for_review]
paths:
- 'src/gaia/agents/**'
- 'src/gaia/rag/**'
- 'tests/verify_*.py'
- 'setup.py'
- '.github/workflows/test_security.yml'
merge_group:
workflow_dispatch:
# Cancel in-progress runs when a new run is triggered
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
test-security-linux:
name: Security Tests (Linux)
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'ready_for_ci')
steps:
- uses: actions/checkout@v6
- name: Free disk space
uses: ./.github/actions/free-disk-space
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install dependencies
run: uv pip install --system -e .[dev,rag]
- name: Run Path Validator Security Tests
run: |
echo "================================================================"
echo " PATH VALIDATOR SECURITY TESTS"
echo "================================================================"
echo "Testing path traversal prevention and access control..."
echo ""
python tests/verify_path_validator.py
PATH_TEST_EXIT=$?
echo ""
if [ $PATH_TEST_EXIT -eq 0 ]; then
echo "[SUCCESS] All path validator tests passed"
else
echo "[FAILURE] Path validator tests failed with exit code $PATH_TEST_EXIT"
exit 1
fi
- name: Run Shell Security Tests
run: |
echo ""
echo "================================================================"
echo " SHELL INJECTION SECURITY TESTS"
echo "================================================================"
echo "Testing shell command injection prevention..."
echo ""
python tests/verify_shell_security.py
SHELL_TEST_EXIT=$?
echo ""
if [ $SHELL_TEST_EXIT -eq 0 ]; then
echo "[SUCCESS] All shell security tests passed"
else
echo "[FAILURE] Shell security tests failed with exit code $SHELL_TEST_EXIT"
exit 1
fi
- name: Test Summary
if: always()
run: |
echo ""
echo "================================================================"
echo " SECURITY TEST SUMMARY"
echo "================================================================"
echo "Test Categories:"
echo " ✅ Path Validator Tests: Prevents path traversal attacks"
echo " ✅ Shell Security Tests: Prevents command injection"
echo ""
echo "Security Coverage:"
echo " - PathValidator: Direct validation testing"
echo " - DockerAgent: Path validation integration"
echo " - ChatAgent: add_watch_directory security"
echo " - CodeAgent: read_file security"
echo " - RAGSDK: _safe_open security"
echo " - Shell Injection: Command chaining prevention"
echo " - Shell Injection: Pipe operator prevention"
echo " - Shell Injection: Argument path traversal prevention"
echo ""
echo "These tests ensure that:"
echo " - Users cannot access files outside allowed directories"
echo " - Shell commands cannot be chained or piped"
echo " - Command arguments are properly validated"
echo " - All agents enforce security boundaries"
echo "================================================================"
test-security-windows:
name: Security Tests (Windows)
runs-on: windows-latest
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'ready_for_ci')
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install uv
run: |
irm https://astral.sh/uv/install.ps1 | iex
echo "$env:USERPROFILE\.local\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
shell: pwsh
- name: Install dependencies
run: uv pip install --system -e .[dev,rag]
- name: Run Path Validator Security Tests
shell: pwsh
run: |
Write-Host "================================================================"
Write-Host " PATH VALIDATOR SECURITY TESTS"
Write-Host "================================================================"
Write-Host "Testing path traversal prevention and access control..."
Write-Host ""
python tests/verify_path_validator.py
if ($LASTEXITCODE -eq 0) {
Write-Host ""
Write-Host "[SUCCESS] All path validator tests passed"
} else {
Write-Host ""
Write-Host "[FAILURE] Path validator tests failed with exit code $LASTEXITCODE"
exit 1
}
- name: Run Shell Security Tests
shell: pwsh
run: |
Write-Host ""
Write-Host "================================================================"
Write-Host " SHELL INJECTION SECURITY TESTS"
Write-Host "================================================================"
Write-Host "Testing shell command injection prevention..."
Write-Host ""
python tests/verify_shell_security.py
if ($LASTEXITCODE -eq 0) {
Write-Host ""
Write-Host "[SUCCESS] All shell security tests passed"
} else {
Write-Host ""
Write-Host "[FAILURE] Shell security tests failed with exit code $LASTEXITCODE"
exit 1
}
- name: Test Summary
if: always()
shell: pwsh
run: |
Write-Host ""
Write-Host "================================================================"
Write-Host " SECURITY TEST SUMMARY"
Write-Host "================================================================"
Write-Host "Test Categories:"
Write-Host " ✅ Path Validator Tests: Prevents path traversal attacks"
Write-Host " ✅ Shell Security Tests: Prevents command injection"
Write-Host ""
Write-Host "Security Coverage:"
Write-Host " - PathValidator: Direct validation testing"
Write-Host " - DockerAgent: Path validation integration"
Write-Host " - ChatAgent: add_watch_directory security"
Write-Host " - CodeAgent: read_file security"
Write-Host " - RAGSDK: _safe_open security"
Write-Host " - Shell Injection: Command chaining prevention"
Write-Host " - Shell Injection: Pipe operator prevention"
Write-Host " - Shell Injection: Argument path traversal prevention"
Write-Host ""
Write-Host "These tests ensure that:"
Write-Host " - Users cannot access files outside allowed directories"
Write-Host " - Shell commands cannot be chained or piped"
Write-Host " - Command arguments are properly validated"
Write-Host " - All agents enforce security boundaries"
Write-Host "================================================================"