Commit 46022c4
feat(actix): capture HTTP request body (#731)
* Add request body size control options
Add MaxRequestBodySize enum to control request body capture with options:
- None: Don't capture request body (default)
- Small: Capture up to 1000 bytes
- Medium: Capture up to 10000 bytes
- Always: Capture entire body
Add max_request_body_size field to ClientOptions struct with default value of None
* feat(sentry-actix): Add request body capture functionality
Add support for capturing request bodies in the Sentry middleware for Actix-Web.
This includes:
- Configurable request body size limits (Small/Medium/Always)
- Support for JSON and form-urlencoded content types
- Body capture and restoration logic to maintain request integrity
- Additional span data enrichment
Updates dependencies:
- Add serde_json, actix-http, futures dependencies
* remove unused futures dependency
* remove useless code and dependency, address clippy lints
* remove unnecessary async for should_capture_request_body
* feat: Add MaxRequestBodySize check for request body limits
Implements a method to validate request body sizes against predefined limits:
- None: Don't capture request bodies (default)
- Small: Capture up to 1000 bytes
- Medium: Capture up to 10000 bytes
- Always: Capture entire body
* feat(sentry-actix): Improve request body capture logic
- Add chunked transfer encoding check to prevent capturing chunked requests
- Add strict content-type validation for JSON and form-urlencoded
- Implement content length validation against size limits
* clippy
* feat(core): add explicit size limit option for request body capture
Add new `Explicit(usize)` variant to `MaxRequestBodySize` enum, allowing users
to specify custom maximum request body size limits for event capture.
* remove unnecessary async for should_capture_request_body
* Add copy trait on MaxRequestBodySize
* Remove MaxRequestBodySize::None check
It's already handle by the is_within_size_limit.
* replace unwrap by empty string
* use copy instead of clone for max_request_body_size
* set default max_request_body_size to medium
---------
Co-authored-by: lcian <lorenzo.cian@sentry.io>1 parent 1ea3664 commit 46022c4
File tree
4 files changed
+126
-19
lines changed- sentry-actix
- src
- sentry-core/src
4 files changed
+126
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
| 79 | + | |
78 | 80 | | |
| 81 | + | |
79 | 82 | | |
80 | | - | |
| 83 | + | |
| 84 | + | |
81 | 85 | | |
82 | 86 | | |
83 | 87 | | |
84 | 88 | | |
| 89 | + | |
85 | 90 | | |
86 | 91 | | |
87 | 92 | | |
| |||
180 | 185 | | |
181 | 186 | | |
182 | 187 | | |
183 | | - | |
| 188 | + | |
184 | 189 | | |
185 | 190 | | |
186 | 191 | | |
| |||
191 | 196 | | |
192 | 197 | | |
193 | 198 | | |
194 | | - | |
| 199 | + | |
195 | 200 | | |
196 | 201 | | |
197 | 202 | | |
198 | 203 | | |
199 | 204 | | |
200 | 205 | | |
201 | 206 | | |
202 | | - | |
| 207 | + | |
203 | 208 | | |
204 | 209 | | |
205 | 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 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
206 | 265 | | |
207 | 266 | | |
208 | | - | |
| 267 | + | |
209 | 268 | | |
210 | 269 | | |
211 | 270 | | |
| |||
230 | 289 | | |
231 | 290 | | |
232 | 291 | | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
233 | 296 | | |
234 | 297 | | |
235 | 298 | | |
236 | 299 | | |
237 | 300 | | |
238 | 301 | | |
239 | 302 | | |
240 | | - | |
| 303 | + | |
241 | 304 | | |
242 | 305 | | |
243 | 306 | | |
| |||
258 | 321 | | |
259 | 322 | | |
260 | 323 | | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
271 | 327 | | |
272 | | - | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
273 | 331 | | |
274 | | - | |
275 | | - | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
276 | 343 | | |
277 | 344 | | |
278 | 345 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
43 | 76 | | |
44 | 77 | | |
45 | 78 | | |
| |||
148 | 181 | | |
149 | 182 | | |
150 | 183 | | |
| 184 | + | |
| 185 | + | |
151 | 186 | | |
152 | 187 | | |
153 | 188 | | |
| |||
256 | 291 | | |
257 | 292 | | |
258 | 293 | | |
| 294 | + | |
259 | 295 | | |
260 | 296 | | |
261 | 297 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
147 | 150 | | |
148 | 151 | | |
149 | 152 | | |
| |||
0 commit comments