Commit 3ad1531
authored
Two small cleanups in the Rust WASM guard: remove a dead exported
function and eliminate per-iteration heap allocations in a hot path.
## Changes
- **Remove `is_bot`** (`helpers.rs`, `mod.rs`): Zero call sites,
`#[allow(dead_code)]`-annotated, not reachable from outside a `cdylib`.
Removed the function and its `pub use` re-export. Updated `README.md` to
reflect the actual user classification helpers.
- **Eliminate `format!` in `check_file_secrecy`** (`tool_rules.rs`):
Replace per-iteration `format!("/{}", pattern)` allocation with
`split('/').any(|seg| seg == *pattern)`. Cuts up to 9 heap allocations
per call through WASM's linear-memory allocator.
```rust
// Before
if path_lower.ends_with(pattern) || path_lower.contains(&format!("/{}", pattern)) {
// After — no allocation, semantically equivalent for all patterns in SENSITIVE_FILE_PATTERNS
if path_lower.ends_with(pattern) || path_lower.split('/').any(|seg| seg == *pattern) {
```
`SENSITIVE_FILE_PATTERNS` contains only file extensions (`.env`, `.pem`,
etc.) and SSH key names (`id_rsa`, etc.), so the segment-equality check
is a precise match with no risk of false negatives.
> [!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-build3145033519/b514/launcher.test
/tmp/go-build3145033519/b514/launcher.test
-test.testlogfile=/tmp/go-build3145033519/b514/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -qui�� .cfg
olang.org/protob-ifaceassert x_amd64/vet . ions =0 x_amd64/vet om/s��
.cfg 886553/b286/ x_amd64/vet --gdwarf-5 .io/otel/exporte-qE
p=/opt/hostedtoo(create|run) x_amd64/vet` (dns block)
> - `invalid-host-that-does-not-exist-12345.com`
> - Triggering command: `/tmp/go-build3145033519/b496/config.test
/tmp/go-build3145033519/b496/config.test
-test.testlogfile=/tmp/go-build3145033519/b496/testlog.txt
-test.paniconexit0 -test.timeout=10m0s
/tmp/go-build3145033519/b315/vet.cfg 1.80.0/status/stgo1.25.8 -I
x_amd64/vet --gdwarf-5 nal/descopts -o x_amd64/vet -I _.a -I x_amd64/vet
--gdwarf-5 telabs/wazero/in-atomic -o x_amd64/vet` (dns block)
> - `nonexistent.local`
> - Triggering command: `/tmp/go-build3145033519/b514/launcher.test
/tmp/go-build3145033519/b514/launcher.test
-test.testlogfile=/tmp/go-build3145033519/b514/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -qui�� .cfg
olang.org/protob-ifaceassert x_amd64/vet . ions =0 x_amd64/vet om/s��
.cfg 886553/b286/ x_amd64/vet --gdwarf-5 .io/otel/exporte-qE
p=/opt/hostedtoo(create|run) x_amd64/vet` (dns block)
> - `slow.example.com`
> - Triggering command: `/tmp/go-build3145033519/b514/launcher.test
/tmp/go-build3145033519/b514/launcher.test
-test.testlogfile=/tmp/go-build3145033519/b514/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -qui�� .cfg
olang.org/protob-ifaceassert x_amd64/vet . ions =0 x_amd64/vet om/s��
.cfg 886553/b286/ x_amd64/vet --gdwarf-5 .io/otel/exporte-qE
p=/opt/hostedtoo(create|run) x_amd64/vet` (dns block)
> - `this-host-does-not-exist-12345.com`
> - Triggering command: `/tmp/go-build3145033519/b523/mcp.test
/tmp/go-build3145033519/b523/mcp.test
-test.testlogfile=/tmp/go-build3145033519/b523/testlog.txt
-test.paniconexit0 -test.timeout=10m0s .cfg��
om/spf13/pflag@v1.0.9/bool.go om/spf13/pflag@v1.0.9/bool_func.go
x_amd64/vet --gdwarf-5 g/grpc/grpclog -o x_amd64/vet .cfg��
886553/b442/_pkg_.a -trimpath x_amd64/vet -p
contextprotocol/docker-cli-plugin-metadata -lang=go1.25 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>
5 files changed
Lines changed: 4 additions & 31 deletions
File tree
- guards/github-guard
- docs
- rust-guard/src/labels
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | 114 | | |
129 | 115 | | |
130 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1323 | 1323 | | |
1324 | 1324 | | |
1325 | 1325 | | |
1326 | | - | |
1327 | | - | |
1328 | | - | |
1329 | | - | |
1330 | | - | |
1331 | | - | |
1332 | | - | |
1333 | | - | |
1334 | | - | |
1335 | | - | |
1336 | | - | |
1337 | | - | |
1338 | | - | |
1339 | | - | |
1340 | 1326 | | |
1341 | 1327 | | |
1342 | 1328 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
682 | 682 | | |
683 | 683 | | |
684 | 684 | | |
685 | | - | |
| 685 | + | |
686 | 686 | | |
687 | 687 | | |
688 | 688 | | |
| |||
0 commit comments