Commit 9fa86b3
committed
gh-XXXXX: Add audit hooks for pickle.load, pickle.loads, and pickle.Unpickler
Add sys.audit() calls to raise audit events when pickle deserializes data,
enabling security monitoring and access control via Python's audit hook system.
New audit events:
- pickle.load(file): raised by pickle.load()
- pickle.loads(data): raised by pickle.loads()
- pickle.Unpickler(file): raised when pickle.Unpickler() is instantiated
Both the C extension (_pickle) and the pure Python fallback (pickle)
emit the same events, ensuring consistent behavior regardless of which
implementation is active.
https://claude.ai/code/session_01BWEWpGi5yZzcLHwjh9FWtP1 parent 149c465 commit 9fa86b3
4 files changed
Lines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| 243 | + | |
| 244 | + | |
243 | 245 | | |
244 | 246 | | |
245 | 247 | | |
| |||
255 | 257 | | |
256 | 258 | | |
257 | 259 | | |
| 260 | + | |
| 261 | + | |
258 | 262 | | |
259 | 263 | | |
260 | 264 | | |
| |||
430 | 434 | | |
431 | 435 | | |
432 | 436 | | |
| 437 | + | |
| 438 | + | |
433 | 439 | | |
434 | 440 | | |
435 | 441 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1314 | 1314 | | |
1315 | 1315 | | |
1316 | 1316 | | |
| 1317 | + | |
1317 | 1318 | | |
1318 | 1319 | | |
1319 | 1320 | | |
| |||
1909 | 1910 | | |
1910 | 1911 | | |
1911 | 1912 | | |
| 1913 | + | |
1912 | 1914 | | |
1913 | 1915 | | |
1914 | 1916 | | |
1915 | 1917 | | |
1916 | 1918 | | |
1917 | 1919 | | |
1918 | 1920 | | |
| 1921 | + | |
1919 | 1922 | | |
1920 | 1923 | | |
1921 | 1924 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
139 | 140 | | |
140 | 141 | | |
141 | 142 | | |
| |||
155 | 156 | | |
156 | 157 | | |
157 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
158 | 177 | | |
159 | 178 | | |
160 | 179 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7515 | 7515 | | |
7516 | 7516 | | |
7517 | 7517 | | |
| 7518 | + | |
| 7519 | + | |
| 7520 | + | |
| 7521 | + | |
7518 | 7522 | | |
7519 | 7523 | | |
7520 | 7524 | | |
| |||
8043 | 8047 | | |
8044 | 8048 | | |
8045 | 8049 | | |
| 8050 | + | |
| 8051 | + | |
| 8052 | + | |
8046 | 8053 | | |
8047 | 8054 | | |
8048 | 8055 | | |
| |||
8104 | 8111 | | |
8105 | 8112 | | |
8106 | 8113 | | |
| 8114 | + | |
| 8115 | + | |
| 8116 | + | |
8107 | 8117 | | |
8108 | 8118 | | |
8109 | 8119 | | |
| |||
0 commit comments