Repository navigation
Commit 60bef18
fix: reject over-deep nesting before parsing; make CI shell-agnostic
Two genuine defects found from the CI logs:
1. Deeply nested input crashed the parser instead of being refused. On
CPython 3.8, ast.parse('[' * 150 + ']' * 150) overflows the C parser's
stack and raises a bare MemoryError ('s_push: parser stack overflow')
straight out of safe_eval, so callers got an unrelated internal error
rather than a security rejection. Later versions raise SyntaxError.
_reject_excessive_nesting now scans the expression before parsing and
rejects more than 64 levels of bracket nesting with
UnsafeExpressionError; string literals are skipped so brackets inside
them are unaffected. Rejection takes ~0.05ms even at 20k levels, and
ast.parse is still wrapped so MemoryError/RecursionError from any
remaining path is reported as a rejected expression.
2. The Windows job never ran the suite. The temporary debugging step piped
through tee and used ${PIPESTATUS[0]}, which PowerShell cannot parse, so
the job failed on shell syntax instead of on a test. Reverted to a plain
'python -m unittest' invocation, which works in every runner shell.
Removed the temporary diag_test.py scaffolding. Local suite: 111 tests, OK.
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>1 parent 2633916 commit 60bef18
4 files changed
Lines changed: 89 additions & 106 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | 45 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
170 | 219 | | |
171 | 220 | | |
172 | 221 | | |
| |||
175 | 224 | | |
176 | 225 | | |
177 | 226 | | |
| 227 | + | |
| 228 | + | |
178 | 229 | | |
179 | 230 | | |
180 | 231 | | |
181 | 232 | | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
182 | 242 | | |
183 | 243 | | |
184 | 244 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
914 | 914 | | |
915 | 915 | | |
916 | 916 | | |
917 | | - | |
| 917 | + | |
918 | 918 | | |
919 | | - | |
920 | | - | |
921 | | - | |
922 | | - | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
923 | 924 | | |
924 | 925 | | |
925 | | - | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
926 | 936 | | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
927 | 944 | | |
928 | 945 | | |
929 | 946 | | |
| |||
0 commit comments