Skip to content

Commit fdddb7f

Browse files
committed
docs: [#147] add specification for configuring Copilot agent firewall
- Add comprehensive specification document for issue #147 - Configure firewall to allow opentofu.org domain access - Update EPIC #112 with new sub-issue 1-7 and time estimate - Add 'exfiltration' to project dictionary for spell checking - Total EPIC estimate updated: 22.75-35 hours (was 22-33.5 hours) Phase 1 (repository settings configuration) completed manually by admin. Remaining phases: documentation and verification. Related to #112, #146
1 parent f86fcb9 commit fdddb7f

File tree

3 files changed

+257
-1
lines changed

3 files changed

+257
-1
lines changed

docs/issues/112-epic-refactor-and-improve-e2e-test-execution.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ This epic is broken down into sub-issues:
1818
1-4. #120 - Configure GitHub Copilot Agent Environment (2-3 hours)
1919
1-5. #121 - Install Git Pre-Commit Hooks for Copilot Agent (2-3 hours)
2020
1-6. #146 - Update Pre-Commit Script for GitHub Runner-Compatible E2E Tests (1-1.5 hours)
21+
1-7. #147 - Configure Copilot Agent Firewall for Dependency Installer (0.75-1.5 hours)
2122
```
2223

23-
**Total Estimated Time**: 22-33.5 hours split across multiple focused sub-issues
24+
**Total Estimated Time**: 22.75-35 hours split across multiple focused sub-issues
2425

2526
## Overview
2627

Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
# Configure Copilot Agent Firewall for Dependency Installer
2+
3+
**Issue**: [#147](https://github.com/torrust/torrust-tracker-deployer/issues/147)
4+
**Parent Epic**: [#112 - Refactor and Improve E2E Test Execution](https://github.com/torrust/torrust-tracker-deployer/issues/112)
5+
**Related**: [#146 - Update Pre-Commit Script for GitHub Runner-Compatible E2E Tests](https://github.com/torrust/torrust-tracker-deployer/issues/146)
6+
7+
## Overview
8+
9+
Configure GitHub Copilot agent's firewall to allow network access to domains required by the dependency installer binaries. The Copilot agent environment has a restricted firewall that blocks access to external domains by default. This task involves identifying all required domains and configuring repository settings to whitelist them.
10+
11+
## Problem Statement
12+
13+
When GitHub Copilot agent attempts to install dependencies using the `dependency-installer` binary, network requests are blocked by the agent's firewall:
14+
15+
```bash
16+
$ cargo run -p torrust-dependency-installer --bin dependency-installer -- install --dependency opentofu
17+
2025-11-05T19:46:23.668278Z ERROR torrust_dependency_installer::app: Command failed error=Install command failed: Failed to install specific dependency: Installation failed: Failed to install dependency 'opentofu': Failed to download installer: curl: (6) Could not resolve host: get.opentofu.org
18+
```
19+
20+
This prevents the agent from:
21+
22+
- Installing OpenTofu via the installer script
23+
- Running pre-commit checks that depend on installed tools
24+
- Executing E2E tests that require infrastructure dependencies
25+
26+
## Goals
27+
28+
- [ ] Identify all domains required by dependency installers
29+
- [ ] Configure Copilot agent firewall allowlist in repository settings
30+
- [ ] Document firewall configuration for future maintainers
31+
- [ ] Verify that dependency installation works in Copilot agent environment
32+
33+
## 🏗️ Architecture Requirements
34+
35+
**DDD Layer**: Infrastructure (configuration, not code changes)
36+
**Module Path**: N/A (repository settings configuration)
37+
**Pattern**: Repository Configuration
38+
39+
### Configuration Requirements
40+
41+
- [ ] Repository settings must be configured by repository admin
42+
- [ ] Firewall rules should be minimal (only required domains)
43+
- [ ] Configuration should be documented for reproducibility
44+
45+
### Anti-Patterns to Avoid
46+
47+
- ❌ Disabling the firewall entirely (increases security risks)
48+
- ❌ Whitelisting overly broad domains
49+
- ❌ Not documenting why each domain is needed
50+
51+
## Specifications
52+
53+
### Required Domains Analysis
54+
55+
Based on analysis of `packages/dependency-installer/src/installer/` modules:
56+
57+
#### OpenTofu Installer
58+
59+
**File**: `packages/dependency-installer/src/installer/opentofu.rs`
60+
61+
```rust
62+
// Downloads installer script from:
63+
"https://get.opentofu.org/install-opentofu.sh"
64+
```
65+
66+
**Required Domain**: `opentofu.org`
67+
68+
- **Why**: Downloads OpenTofu installer script and packages
69+
- **Subdomain Coverage**: Using `opentofu.org` allows both `get.opentofu.org` and any other subdomains the installer script may use for package downloads
70+
71+
#### Ansible Installer
72+
73+
**File**: `packages/dependency-installer/src/installer/ansible.rs`
74+
75+
```rust
76+
// Uses system package manager:
77+
sudo apt-get install -y ansible
78+
```
79+
80+
**Required Domain**: None (covered by recommended allowlist)
81+
82+
- **Why**: Ubuntu package repositories are included in the default "recommended allowlist"
83+
84+
#### cargo-machete Installer
85+
86+
**File**: `packages/dependency-installer/src/installer/cargo_machete.rs`
87+
88+
```rust
89+
// Uses Rust package registry:
90+
cargo install cargo-machete
91+
```
92+
93+
**Required Domain**: None (covered by recommended allowlist)
94+
95+
- **Why**: Rust package registry (crates.io) is included in the default "recommended allowlist"
96+
97+
#### LXD Installer
98+
99+
**File**: `packages/dependency-installer/src/installer/lxd.rs`
100+
101+
```rust
102+
// Uses snap package manager:
103+
sudo snap install lxd
104+
```
105+
106+
**Required Domain**: None (covered by recommended allowlist)
107+
108+
- **Why**: Snap store is included in the default "recommended allowlist"
109+
110+
### Firewall Configuration Summary
111+
112+
**Domains to Whitelist**:
113+
114+
1. `opentofu.org` - Required for OpenTofu installation
115+
116+
**Domains Already Covered**:
117+
118+
- Ubuntu/Debian package repositories (apt)
119+
- Rust package registry (crates.io)
120+
- Snap store
121+
122+
## Implementation Plan
123+
124+
### Phase 1: Repository Settings Configuration (15-30 minutes)
125+
126+
**Prerequisites**:
127+
128+
- Repository admin access required
129+
- Must be logged into GitHub
130+
131+
**Steps**:
132+
133+
- [ ] Navigate to repository settings: `https://github.com/torrust/torrust-tracker-deployer/settings`
134+
- [ ] In the "Code & automation" section, click **Copilot****coding agent**
135+
- [ ] Verify **Enable firewall** is toggled ON
136+
- [ ] Verify **Recommended allowlist** is toggled ON (default)
137+
- [ ] Click **Custom allowlist**
138+
- [ ] Add domain: `opentofu.org`
139+
- This allows traffic to `opentofu.org` and all subdomains (e.g., `get.opentofu.org`)
140+
- [ ] Click **Add Rule**
141+
- [ ] Click **Save changes**
142+
143+
### Phase 2: Documentation (15-30 minutes)
144+
145+
- [ ] Create new document: `docs/contributing/copilot-agent-firewall.md`
146+
- [ ] Document configured domains and their purposes
147+
- [ ] Document configuration steps for future reference
148+
- [ ] Link to GitHub documentation on firewall customization
149+
- [ ] Update related documentation:
150+
- [ ] Add reference in `docs/contributing/roadmap-issues.md` if relevant
151+
- [ ] Add reference in `packages/dependency-installer/README.md`
152+
153+
### Phase 3: Verification (15-30 minutes)
154+
155+
- [ ] Trigger a Copilot agent workflow that uses dependency-installer
156+
- [ ] Verify OpenTofu installation succeeds
157+
- [ ] Check for any new firewall warnings in agent logs
158+
- [ ] Update documentation if additional domains are needed
159+
160+
**Total Estimated Time**: 45 minutes - 1.5 hours
161+
162+
## Acceptance Criteria
163+
164+
> **Note for Contributors**: These criteria define what the PR reviewer will check. Use this as your pre-review checklist before submitting the PR to minimize back-and-forth iterations.
165+
166+
**Configuration Checks**:
167+
168+
- [ ] Repository firewall settings show `opentofu.org` in custom allowlist
169+
- [ ] Recommended allowlist remains enabled
170+
- [ ] Firewall remains enabled (not disabled)
171+
172+
**Documentation Checks**:
173+
174+
- [ ] New document `docs/contributing/copilot-agent-firewall.md` exists
175+
- [ ] Document includes all configured domains with rationale
176+
- [ ] Document includes step-by-step configuration instructions
177+
- [ ] Links to official GitHub documentation included
178+
179+
**Verification Checks**:
180+
181+
- [ ] Copilot agent can successfully run: `cargo run --bin dependency-installer install --dependency opentofu`
182+
- [ ] No firewall warnings appear for configured domains
183+
- [ ] Pre-commit checks pass after configuration
184+
185+
**Quality Checks**:
186+
187+
- [ ] Pre-commit checks pass: `./scripts/pre-commit.sh` (for documentation changes only)
188+
189+
## Related Documentation
190+
191+
### GitHub Documentation
192+
193+
- [GitHub Docs: Customizing the agent firewall](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/customize-the-agent-firewall)
194+
- [GitHub Docs: Preinstalling tools in Copilot's environment](https://docs.github.com/en/copilot/customizing-copilot/customizing-the-development-environment-for-copilot-coding-agent#preinstalling-tools-in-copilots-environment)
195+
196+
### Project Documentation
197+
198+
- [Dependency Installer Package](../../packages/dependency-installer/README.md)
199+
- [E2E Testing Guide](../e2e-testing.md)
200+
- [Issue #146 - Update Pre-Commit Script](./146-1-6-update-precommit-script-for-github-runner-compatible-e2e-tests.md)
201+
202+
### Firewall Documentation
203+
204+
The GitHub Copilot agent firewall has the following characteristics:
205+
206+
- **Default Policy**: Blocks all external network access except GitHub hosts
207+
- **Recommended Allowlist**: Pre-configured list of common package repositories, container registries, and certificate authorities
208+
- **Custom Allowlist**: Repository-specific additions for domains not covered by recommended list
209+
- **Domain vs URL Rules**:
210+
- **Domain** (e.g., `opentofu.org`): Allows traffic to domain and all subdomains
211+
- **URL** (e.g., `https://get.opentofu.org/installer/`): Only allows specified scheme, host, and path
212+
213+
### Limitations
214+
215+
From GitHub documentation:
216+
217+
- Only applies to processes started by the agent via its Bash tool
218+
- Does not apply to Model Context Protocol (MCP) servers
219+
- Does not apply to processes started in configured Copilot setup steps
220+
- Sophisticated attacks may bypass the firewall
221+
- Only operates within GitHub Actions appliance environment
222+
223+
## Notes
224+
225+
### Why This Issue Cannot Be Implemented by Copilot Agent
226+
227+
This issue requires **repository admin access** to modify repository settings. GitHub Copilot agents do not have permission to:
228+
229+
- Access repository settings pages
230+
- Modify firewall configuration
231+
- Change Copilot agent settings
232+
233+
Therefore, this must be implemented manually by a repository administrator (user with admin role).
234+
235+
### Security Considerations
236+
237+
The recommended approach is to:
238+
239+
1. ✅ Keep firewall enabled
240+
2. ✅ Keep recommended allowlist enabled
241+
3. ✅ Only add specific domains needed (minimal whitelist)
242+
4. ❌ Avoid disabling the firewall entirely
243+
244+
This balances functionality with security, minimizing data exfiltration risks while allowing necessary tool installations.
245+
246+
### Future Maintenance
247+
248+
When adding new dependency installers:
249+
250+
1. Check if the installer downloads from external hosts
251+
2. Test in Copilot agent environment first
252+
3. If network access is blocked, update firewall configuration
253+
4. Document the new domain in `docs/contributing/copilot-agent-firewall.md`
254+
5. Update this issue specification with new domains

project-words.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ ehthumbs
4545
elif
4646
Émojis
4747
endfor
48+
exfiltration
4849
endraw
4950
epel
5051
EPEL

0 commit comments

Comments
 (0)