Commit 6f3dc8a
committed
feat: differentiated exit code 3 for infrastructure errors
Adds explicit handling and structured logging for API/infrastructure failures
so they are distinguishable from real blocking security findings in CI.
Exit code semantics (NEW for 2.3.0):
0 - Clean scan, no blocking issues (or --disable-blocking)
1 - Blocking security finding(s) detected
2 - Process interrupted (SIGINT) -- already in place
3 - Infrastructure / API error -- NEW
5 - Warning-level alerts only -- preserved
This is a BREAKING change for any pipeline that previously caught exit 1 to
mean "anything went wrong." Such pipelines now need to handle 3 separately
for infrastructure failures, or use --exit-code-on-api-error to remap.
Changes:
- socketsecurity/core/__init__.py
* Import RequestTimeoutExceeded and `requests`
* Wrap fullscans.stream_diff with requests.exceptions.Timeout ->
RequestTimeoutExceeded
* Wrap fullscans.post (create_full_scan) with the same pattern
- socketsecurity/socketcli.py
* Import RequestTimeoutExceeded + APIFailure
* IS_BUILDKITE constant (gates BK-specific markers per spec §3)
* New _emit_infrastructure_error helper emits Buildkite log section
markers (^^^ +++ and ---) when BUILDKITE=true, plus a soft_fail hint;
bare log.error otherwise. Markers go to stdout via print() so they
aren't prefixed with log formatting; markers are literal strings on
other CI platforms so the gate is required.
* Explicit RequestTimeoutExceeded and APIFailure handlers added before
the generic Exception handler, all using config.exit_code_on_api_error
- socketsecurity/config.py
* New CliConfig field: exit_code_on_api_error (default 3)
* New flag: --exit-code-on-api-error <int>
Customers can remap to 0 (swallow), 100 (Buildkite soft_fail), etc.
Note: --disable-blocking now only zeroes out exit 1 (security findings),
not exit 3 (infrastructure). This separation is the whole point of the
new code -- callers who want to also swallow infra errors should use
--exit-code-on-api-error 0.
Motivated by customer incidents (Plaid 413s and timeouts; Anthropic
'other' SocketCategory crash).
Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>1 parent d727dcc commit 6f3dc8a
3 files changed
Lines changed: 90 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| |||
224 | 225 | | |
225 | 226 | | |
226 | 227 | | |
| 228 | + | |
227 | 229 | | |
228 | 230 | | |
229 | 231 | | |
| |||
754 | 756 | | |
755 | 757 | | |
756 | 758 | | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
757 | 773 | | |
758 | 774 | | |
759 | 775 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | | - | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
538 | 539 | | |
539 | 540 | | |
540 | 541 | | |
541 | | - | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
542 | 549 | | |
543 | 550 | | |
544 | 551 | | |
| |||
945 | 952 | | |
946 | 953 | | |
947 | 954 | | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
948 | 960 | | |
949 | 961 | | |
950 | 962 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| |||
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
31 | 38 | | |
32 | 39 | | |
33 | 40 | | |
| |||
43 | 50 | | |
44 | 51 | | |
45 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
46 | 86 | | |
47 | 87 | | |
48 | 88 | | |
| |||
53 | 93 | | |
54 | 94 | | |
55 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
56 | 110 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
65 | 117 | | |
66 | 118 | | |
67 | 119 | | |
| |||
0 commit comments