Commit c52441a
authored
fix: gojq module review — permissions, collision, rename, upgrade (#3451)
Addresses findings from the Go Fan gojq module review.
### Security
- **Payload file permissions `0644` → `0600`** — payloads may contain
sensitive API responses; no reason for world-readable
### Bug fix
- **`generateRandomID` fallback collision** — when `crypto/rand.Read`
fails, the fallback was `fmt.Sprintf("fallback-%d", os.Getpid())` which
is identical for every call in the same process. Added
`time.Now().UnixNano()`:
```go
return fmt.Sprintf("fallback-%d-%d", os.Getpid(), time.Now().UnixNano())
```
### Maintenance
- **Rename `def walk(f)` → `def walk_schema`** — avoids shadowing gojq's
built-in `walk/1`. Now a zero-arity recursive def since the `f`
parameter was never meaningfully used (always called as `walk(.)`)
- **Upgrade `github.com/itchyny/gojq` v0.12.18 → v0.12.19**
### Tests
- **`TestApplyJqSchema_SingleOutputContract`** — asserts the jq filter
iterator yields exactly one value across multiple input shapes,
documenting the invariant
- Updated `TestPayloadStorage_FilePermissions` expectation to `0600`
> [!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-build511967270/b514/launcher.test
/tmp/go-build511967270/b514/launcher.test
-test.testlogfile=/tmp/go-build511967270/b514/testlog.txt
-test.paniconexit0 -test.timeout=10m0s
/tmp/go-build511967270/b211/vet.cfg 6718451/b186/_pkg_.a
ache/go/1.25.8/x64/src/vendor/golang.org/x/text/-Wl,--no-gc-sections
x_amd64/vet . --gdwarf2 --64 x_amd64/vet` (dns block)
> - `invalid-host-that-does-not-exist-12345.com`
> - Triggering command: `/tmp/go-build511967270/b496/config.test
/tmp/go-build511967270/b496/config.test
-test.testlogfile=/tmp/go-build511967270/b496/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -o ache/go/1.25.8/x64/src/net
-trimpath x_amd64/vet -p net/url -lang=go1.25 x_amd64/vet` (dns block)
> - `nonexistent.local`
> - Triggering command: `/tmp/go-build511967270/b514/launcher.test
/tmp/go-build511967270/b514/launcher.test
-test.testlogfile=/tmp/go-build511967270/b514/testlog.txt
-test.paniconexit0 -test.timeout=10m0s
/tmp/go-build511967270/b211/vet.cfg 6718451/b186/_pkg_.a
ache/go/1.25.8/x64/src/vendor/golang.org/x/text/-Wl,--no-gc-sections
x_amd64/vet . --gdwarf2 --64 x_amd64/vet` (dns block)
> - `slow.example.com`
> - Triggering command: `/tmp/go-build511967270/b514/launcher.test
/tmp/go-build511967270/b514/launcher.test
-test.testlogfile=/tmp/go-build511967270/b514/testlog.txt
-test.paniconexit0 -test.timeout=10m0s
/tmp/go-build511967270/b211/vet.cfg 6718451/b186/_pkg_.a
ache/go/1.25.8/x64/src/vendor/golang.org/x/text/-Wl,--no-gc-sections
x_amd64/vet . --gdwarf2 --64 x_amd64/vet` (dns block)
> - `this-host-does-not-exist-12345.com`
> - Triggering command: `/tmp/go-build511967270/b523/mcp.test
/tmp/go-build511967270/b523/mcp.test
-test.testlogfile=/tmp/go-build511967270/b523/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -plu�� g_.a
-plugin-opt=/usrgithub.qkg1.top/github/gh-aw-mcpg/internal/launcher
x_amd64/vet -plugin-opt=-pasbash rs/otlp/otlptrac/usr/bin/runc
-plugin-opt=-pas--version x_amd64/vet -uns�� .cfg
elemetry.io/otel-nolocalimports x_amd64/vet -m elf_x86_64
--hash-style=gnu--version 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>File tree
5 files changed
+66
-27
lines changed- internal/middleware
5 files changed
+66
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
66 | 67 | | |
67 | | - | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | | - | |
| 71 | + | |
71 | 72 | | |
72 | | - | |
| 73 | + | |
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
76 | | - | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| |||
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
110 | | - | |
| 111 | + | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| |||
135 | 136 | | |
136 | 137 | | |
137 | 138 | | |
138 | | - | |
| 139 | + | |
139 | 140 | | |
140 | 141 | | |
141 | 142 | | |
| |||
152 | 153 | | |
153 | 154 | | |
154 | 155 | | |
155 | | - | |
| 156 | + | |
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
| |||
177 | 178 | | |
178 | 179 | | |
179 | 180 | | |
180 | | - | |
| 181 | + | |
181 | 182 | | |
182 | 183 | | |
183 | 184 | | |
| |||
209 | 210 | | |
210 | 211 | | |
211 | 212 | | |
212 | | - | |
| 213 | + | |
213 | 214 | | |
214 | 215 | | |
215 | 216 | | |
216 | 217 | | |
217 | 218 | | |
218 | | - | |
219 | | - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
220 | 225 | | |
221 | | - | |
| 226 | + | |
222 | 227 | | |
223 | 228 | | |
| 229 | + | |
| 230 | + | |
224 | 231 | | |
| 232 | + | |
| 233 | + | |
225 | 234 | | |
226 | 235 | | |
227 | 236 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 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 | + | |
111 | 141 | | |
112 | 142 | | |
113 | 143 | | |
| |||
517 | 547 | | |
518 | 548 | | |
519 | 549 | | |
520 | | - | |
| 550 | + | |
521 | 551 | | |
522 | 552 | | |
523 | 553 | | |
| |||
0 commit comments