Commit eab98ed
authored
rust-guard: remove dead
Two small cleanups to the Rust guard: delete a 426-line module that was
never wired into production code paths, and collapse three structurally
identical username-membership functions into a single private helper.
## Remove dead `permissions.rs`
`permissions.rs` was explicitly annotated as scaffolding
(`#![allow(dead_code)]`), never imported beyond `mod permissions;` in
`lib.rs`, and has no effect on the compiled WASM. Deletes the file and
removes the `mod` declaration.
## Deduplicate case-insensitive username lookup
`is_blocked_user`, `is_configured_trusted_bot`, and `is_trusted_user`
all had identical bodies. Extracted into a private helper that also
avoids per-item `String` allocations by using `eq_ignore_ascii_case`:
```rust
// Before — repeated three times with local allocation per list item
let lower = username.to_lowercase();
ctx.blocked_users.iter().any(|u| u.to_lowercase() == lower)
// After
fn username_in_list(username: &str, list: &[String]) -> bool {
list.iter().any(|u| u.eq_ignore_ascii_case(username))
}
pub fn is_blocked_user(username: &str, ctx: &PolicyContext) -> bool {
username_in_list(username, &ctx.blocked_users)
}
// …same for is_configured_trusted_bot, is_trusted_user
```
Public API and all existing tests are unchanged.
> [!WARNING]
>
> <details>
> <summary>Firewall rules blocked me from connecting to one or more
addresses (expand for details)</summary>
>
> #### I tried to connect to the following addresses, but was blocked by
firewall rules:
>
> - `example.com`
> - Triggering command: `/tmp/go-build3156076384/b338/launcher.test
/tmp/go-build3156076384/b338/launcher.test
-test.testlogfile=/tmp/go-build3156076384/b338/testlog.txt
-test.paniconexit0 -test.timeout=10m0s ache�� -Wl,--no-undefined-version
13ODHFGfB x_amd64/vet gci-lint failed
/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet
/home/REDACTED/wor-atomic` (dns block)
> - `invalid-host-that-does-not-exist-12345.com`
> - Triggering command: `/tmp/go-build3156076384/b320/config.test
/tmp/go-build3156076384/b320/config.test
-test.testlogfile=/tmp/go-build3156076384/b320/testlog.txt
-test.paniconexit0 -test.timeout=10m0s c4d6�� ternal/engine/wa-p
ternal/engine/wagithub.com/stretchr/testify/require x_amd64/compile
-gnu/lib/libobje/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet
-gnu/lib/libmemc-unsafeptr=false -gnu/lib/libaddr-unreachable=false
x_amd64/compile -gnu�� ache/go/1.25.8/x-c=4 _cgo_.o x_amd64/vet
-gnu/lib/librust/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet
zevo/backend de/node/bin/git x_amd64/vet` (dns block)
> - `nonexistent.local`
> - Triggering command: `/tmp/go-build3156076384/b338/launcher.test
/tmp/go-build3156076384/b338/launcher.test
-test.testlogfile=/tmp/go-build3156076384/b338/testlog.txt
-test.paniconexit0 -test.timeout=10m0s ache�� -Wl,--no-undefined-version
13ODHFGfB x_amd64/vet gci-lint failed
/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet
/home/REDACTED/wor-atomic` (dns block)
> - `slow.example.com`
> - Triggering command: `/tmp/go-build3156076384/b338/launcher.test
/tmp/go-build3156076384/b338/launcher.test
-test.testlogfile=/tmp/go-build3156076384/b338/testlog.txt
-test.paniconexit0 -test.timeout=10m0s ache�� -Wl,--no-undefined-version
13ODHFGfB x_amd64/vet gci-lint failed
/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet
/home/REDACTED/wor-atomic` (dns block)
> - `this-host-does-not-exist-12345.com`
> - Triggering command: `/tmp/go-build3156076384/b347/mcp.test
/tmp/go-build3156076384/b347/mcp.test
-test.testlogfile=/tmp/go-build3156076384/b347/testlog.txt
-test.paniconexit0 -test.timeout=10m0s 3791�� 64/src/net -trimpath
x_amd64/vet -p crypto/internal//usr/bin/runc -lang=go1.25 x_amd64/vet
-qui�� -I o_.o x_amd64/vet 01.o 02.o 03.o x_amd64/vet` (dns block)
>
> If you need me to access, download, or install something from one of
these locations, you can either:
>
> - Configure [Actions setup
steps](https://gh.io/copilot/actions-setup-steps) to set up my
environment, which run before the firewall is enabled
> - Add the appropriate URLs or hosts to the custom allowlist in this
repository's [Copilot coding agent
settings](https://github.com/github/gh-aw-mcpg/settings/copilot/coding_agent)
(admins only)
>
> </details>permissions.rs and deduplicate username lookup (#2851)3 files changed
Lines changed: 8 additions & 442 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
230 | 235 | | |
231 | 236 | | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
| 237 | + | |
237 | 238 | | |
238 | 239 | | |
239 | 240 | | |
| |||
1353 | 1354 | | |
1354 | 1355 | | |
1355 | 1356 | | |
1356 | | - | |
1357 | | - | |
1358 | | - | |
1359 | | - | |
1360 | | - | |
| 1357 | + | |
1361 | 1358 | | |
1362 | 1359 | | |
1363 | 1360 | | |
| |||
1367 | 1364 | | |
1368 | 1365 | | |
1369 | 1366 | | |
1370 | | - | |
1371 | | - | |
1372 | | - | |
1373 | | - | |
1374 | | - | |
| 1367 | + | |
1375 | 1368 | | |
1376 | 1369 | | |
1377 | 1370 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
0 commit comments