Commit 7280ef4
feat: add skip-unset mode to one-shot token library with value preview (enabled by default) (#640)
* Initial plan
* feat: add AWF_ONE_SHOT_SKIP_UNSET flag to skip clearing tokens
- Add skip_unset flag controlled by AWF_ONE_SHOT_SKIP_UNSET env var
- When enabled, tokens are logged but not cleared after access
- Allow multiple reads of tokens in skip-unset mode
- Update README with skip-unset mode documentation
- Add tests for skip-unset mode in both container and chroot modes
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
* test: verify skip-unset functionality works correctly
- Built one-shot-token library successfully
- Verified normal mode clears tokens after first access
- Verified skip-unset mode preserves tokens and logs accesses
- Unit tests pass (736/737)
- Lint passes with no new errors
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
* fix: always strdup result in skip-unset mode for safety
- Call strdup() on result in both normal and skip-unset modes
- Prevents potential use-after-free if environment is modified
- Applies to both first access and subsequent accesses in skip-unset mode
- Addresses code review feedback about pointer safety
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
* feat: enable skip-unset mode by default
Set AWF_ONE_SHOT_SKIP_UNSET=1 in entrypoint.sh to skip variable
unsetting while still logging token accesses. This applies to both
container mode and chroot mode.
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
* feat: add token value preview to log messages
Show first 4 characters of token value plus "..." in log messages
to provide debugging context while protecting sensitive data.
Updates both getenv and secure_getenv interceptors.
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
* feat: replace skip-unset with in-memory caching strategy
Cache token values in memory on first access, then unset from
environment. Subsequent getenv() calls return the cached value,
allowing programs to read tokens multiple times while
/proc/self/environ is cleared.
Remove AWF_ONE_SHOT_SKIP_UNSET - caching makes it unnecessary.
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>1 parent 836ea5c commit 7280ef4
4 files changed
Lines changed: 186 additions & 86 deletions
File tree
- containers/agent
- one-shot-token
- tests/integration
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
406 | 406 | | |
407 | 407 | | |
408 | 408 | | |
409 | | - | |
| 409 | + | |
| 410 | + | |
410 | 411 | | |
411 | 412 | | |
412 | 413 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
122 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
123 | 124 | | |
124 | | - | |
| 125 | + | |
125 | 126 | | |
126 | | - | |
| 127 | + | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
130 | | - | |
| 131 | + | |
131 | 132 | | |
132 | 133 | | |
133 | 134 | | |
| |||
209 | 210 | | |
210 | 211 | | |
211 | 212 | | |
212 | | - | |
| 213 | + | |
213 | 214 | | |
214 | | - | |
| 215 | + | |
215 | 216 | | |
216 | 217 | | |
217 | 218 | | |
| |||
236 | 237 | | |
237 | 238 | | |
238 | 239 | | |
239 | | - | |
| 240 | + | |
240 | 241 | | |
241 | | - | |
242 | | - | |
| 242 | + | |
| 243 | + | |
243 | 244 | | |
244 | | - | |
| 245 | + | |
245 | 246 | | |
246 | 247 | | |
247 | 248 | | |
| |||
263 | 264 | | |
264 | 265 | | |
265 | 266 | | |
266 | | - | |
267 | | - | |
| 267 | + | |
| 268 | + | |
268 | 269 | | |
269 | 270 | | |
270 | 271 | | |
271 | | - | |
| 272 | + | |
272 | 273 | | |
| 274 | + | |
273 | 275 | | |
274 | 276 | | |
275 | 277 | | |
| |||
279 | 281 | | |
280 | 282 | | |
281 | 283 | | |
282 | | - | |
| 284 | + | |
283 | 285 | | |
284 | 286 | | |
285 | 287 | | |
286 | 288 | | |
287 | 289 | | |
288 | | - | |
| 290 | + | |
289 | 291 | | |
290 | 292 | | |
291 | 293 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
56 | 62 | | |
57 | 63 | | |
58 | 64 | | |
| |||
199 | 205 | | |
200 | 206 | | |
201 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
202 | 236 | | |
203 | 237 | | |
204 | 238 | | |
205 | 239 | | |
206 | | - | |
207 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
208 | 245 | | |
209 | 246 | | |
210 | 247 | | |
| |||
226 | 263 | | |
227 | 264 | | |
228 | 265 | | |
229 | | - | |
| 266 | + | |
230 | 267 | | |
231 | 268 | | |
232 | 269 | | |
233 | | - | |
| 270 | + | |
234 | 271 | | |
235 | 272 | | |
236 | 273 | | |
237 | | - | |
| 274 | + | |
238 | 275 | | |
239 | | - | |
240 | | - | |
| 276 | + | |
| 277 | + | |
241 | 278 | | |
242 | | - | |
| 279 | + | |
243 | 280 | | |
244 | 281 | | |
245 | | - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
246 | 286 | | |
247 | 287 | | |
248 | 288 | | |
249 | 289 | | |
250 | 290 | | |
251 | | - | |
252 | | - | |
| 291 | + | |
| 292 | + | |
253 | 293 | | |
254 | 294 | | |
255 | 295 | | |
| |||
261 | 301 | | |
262 | 302 | | |
263 | 303 | | |
264 | | - | |
| 304 | + | |
265 | 305 | | |
266 | 306 | | |
267 | | - | |
268 | | - | |
| 307 | + | |
| 308 | + | |
269 | 309 | | |
270 | 310 | | |
271 | 311 | | |
| |||
285 | 325 | | |
286 | 326 | | |
287 | 327 | | |
288 | | - | |
| 328 | + | |
289 | 329 | | |
290 | 330 | | |
291 | 331 | | |
| |||
295 | 335 | | |
296 | 336 | | |
297 | 337 | | |
298 | | - | |
| 338 | + | |
299 | 339 | | |
300 | | - | |
301 | | - | |
| 340 | + | |
| 341 | + | |
302 | 342 | | |
303 | | - | |
| 343 | + | |
304 | 344 | | |
305 | 345 | | |
306 | | - | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
307 | 350 | | |
308 | 351 | | |
309 | 352 | | |
310 | 353 | | |
311 | 354 | | |
312 | | - | |
313 | | - | |
| 355 | + | |
| 356 | + | |
314 | 357 | | |
315 | 358 | | |
316 | 359 | | |
| |||
0 commit comments