Commit e9734c1
authored
Fix pre-receive hook hangs and missing logs by flushing logs on signal and using CommandContext for git commands (#4714)
When TruffleHog times out in pre-receive hooks, it fails to output
diagnostic logs.
Changes:
- Ensure log output is flushed before process termination in all exit paths:
* Defer log sync in run() function for normal exits
* Sync logs in signal handler before os.Exit(0)
* Sync logs before os.Exit(183) when results are found
* Sync logs in logFatalFunc before os.Exit() calls
- Use exec.CommandContext instead of exec.Command for git log/diff
to ensure processes are killed when context is cancelled
- Add WaitDelay to git commands to provide grace period for cleanup
This ensures diagnostic output is captured when git operations block in
pre-receive hook environments and logs are visible when process is killed.1 parent 7635b24 commit e9734c1
3 files changed
+62
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| |||
347 | 346 | | |
348 | 347 | | |
349 | 348 | | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
350 | 356 | | |
351 | 357 | | |
352 | 358 | | |
| |||
358 | 364 | | |
359 | 365 | | |
360 | 366 | | |
361 | | - | |
| 367 | + | |
362 | 368 | | |
363 | 369 | | |
364 | 370 | | |
365 | | - | |
366 | | - | |
| 371 | + | |
367 | 372 | | |
368 | 373 | | |
369 | | - | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
370 | 377 | | |
371 | 378 | | |
372 | 379 | | |
| |||
387 | 394 | | |
388 | 395 | | |
389 | 396 | | |
390 | | - | |
391 | | - | |
| 397 | + | |
392 | 398 | | |
393 | 399 | | |
| 400 | + | |
394 | 401 | | |
395 | 402 | | |
396 | 403 | | |
| |||
399 | 406 | | |
400 | 407 | | |
401 | 408 | | |
402 | | - | |
| 409 | + | |
403 | 410 | | |
404 | 411 | | |
405 | 412 | | |
| |||
413 | 420 | | |
414 | 421 | | |
415 | 422 | | |
| 423 | + | |
| 424 | + | |
416 | 425 | | |
417 | 426 | | |
418 | 427 | | |
| |||
606 | 615 | | |
607 | 616 | | |
608 | 617 | | |
| 618 | + | |
609 | 619 | | |
610 | 620 | | |
611 | 621 | | |
| |||
1165 | 1175 | | |
1166 | 1176 | | |
1167 | 1177 | | |
1168 | | - | |
| 1178 | + | |
1169 | 1179 | | |
1170 | 1180 | | |
| 1181 | + | |
1171 | 1182 | | |
1172 | 1183 | | |
1173 | 1184 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
| |||
124 | 127 | | |
125 | 128 | | |
126 | 129 | | |
| 130 | + | |
127 | 131 | | |
128 | 132 | | |
129 | 133 | | |
| |||
204 | 208 | | |
205 | 209 | | |
206 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
207 | 219 | | |
208 | 220 | | |
209 | 221 | | |
| |||
213 | 225 | | |
214 | 226 | | |
215 | 227 | | |
| 228 | + | |
216 | 229 | | |
217 | 230 | | |
218 | 231 | | |
| |||
253 | 266 | | |
254 | 267 | | |
255 | 268 | | |
256 | | - | |
| 269 | + | |
257 | 270 | | |
258 | 271 | | |
259 | 272 | | |
| |||
273 | 286 | | |
274 | 287 | | |
275 | 288 | | |
276 | | - | |
| 289 | + | |
277 | 290 | | |
278 | 291 | | |
279 | 292 | | |
280 | 293 | | |
281 | 294 | | |
282 | 295 | | |
283 | 296 | | |
284 | | - | |
| 297 | + | |
285 | 298 | | |
286 | 299 | | |
287 | 300 | | |
288 | 301 | | |
289 | 302 | | |
290 | 303 | | |
291 | | - | |
| 304 | + | |
292 | 305 | | |
293 | 306 | | |
294 | 307 | | |
295 | | - | |
| 308 | + | |
| 309 | + | |
296 | 310 | | |
297 | 311 | | |
298 | 312 | | |
| |||
304 | 318 | | |
305 | 319 | | |
306 | 320 | | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
307 | 324 | | |
308 | 325 | | |
309 | 326 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1478 | 1478 | | |
1479 | 1479 | | |
1480 | 1480 | | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
1481 | 1501 | | |
1482 | 1502 | | |
1483 | 1503 | | |
| |||
0 commit comments