You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "suvodeep-pyne (via GitHub)" <gi...@apache.org> on 2025/09/03 23:59:48 UTC
[PR] [audit] Implement request body handling with payload size limits and truncation support [pinot]
suvodeep-pyne opened a new pull request, #16747:
URL: https://github.com/apache/pinot/pull/16747
## Summary
This PR implements request body capturing functionality for the audit logging system in Pinot. The implementation safely captures HTTP request bodies while preserving the input stream for downstream consumers.
## Changes
### Core Implementation (`AuditRequestProcessor.java`)
- Added `readRequestBody` method to capture request bodies from Jersey `ContainerRequestContext`
- Uses `BufferedInputStream` with mark/reset pattern for non-destructive stream reading
- Implements payload size limits with graceful truncation (adds `...[truncated]` marker when exceeded)
- Leverages Guava's `ByteStreams` utilities for efficient stream handling
- Ensures stream remains readable for downstream consumers even on audit failures
- Proper UTF-8 encoding support
### Configuration (`AuditConfig.java`)
- Added `MAX_AUDIT_PAYLOAD_SIZE_BYTES` constant (65536 bytes) as hard limit
- Updated default `maxPayloadSize` to 8192 bytes
- Fixed JSON property name to `request.payload.size.max.bytes`
### Testing (`AuditRequestProcessorTest.java`)
- Comprehensive test suite with 15 test methods covering:
- Stream preservation for downstream consumers
- Payload truncation at configured limits
- Error handling and recovery scenarios
- UTF-8 character encoding
- JSON payload handling (simple, large, nested)
- Edge cases (null stream, empty body, no entity)
## Key Design Decisions
1. **Stream Preservation**: Uses `BufferedInputStream` with mark/reset to ensure the original request can still be processed even if audit logging fails
2. **Efficient Truncation**: Directly appends truncation marker without unnecessary string copying
3. **Graceful Degradation**: Audit failures never impact the main request processing
4. **Package-Private Testing**: Method is package-private with `@VisibleForTesting` annotation for clean testing without reflection
## Testing
All tests pass successfully. The implementation has been tested with various payload types including plain text, JSON, and UTF-8 encoded content.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] [audit] Implement request body handling with payload size limits and truncation support [pinot]
Posted by "somandal (via GitHub)" <gi...@apache.org>.
somandal merged PR #16747:
URL: https://github.com/apache/pinot/pull/16747
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] [audit] Implement request body handling with payload size limits and truncation support [pinot]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #16747:
URL: https://github.com/apache/pinot/pull/16747#issuecomment-3251289203
## [Codecov](https://app.codecov.io/gh/apache/pinot/pull/16747?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `83.33333%` with `4 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 56.45%. Comparing base ([`a58ec4c`](https://app.codecov.io/gh/apache/pinot/commit/a58ec4c7522e78e508f0060fcb31ff36d735e006?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`ddb8e80`](https://app.codecov.io/gh/apache/pinot/commit/ddb8e803f7631d6f7158e021f6f0578e7dd2c692?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 1 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/pinot/pull/16747?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...ache/pinot/common/audit/AuditRequestProcessor.java](https://app.codecov.io/gh/apache/pinot/pull/16747?src=pr&el=tree&filepath=pinot-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpinot%2Fcommon%2Faudit%2FAuditRequestProcessor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vYXVkaXQvQXVkaXRSZXF1ZXN0UHJvY2Vzc29yLmphdmE=) | 82.60% | [4 Missing :warning: ](https://app.codecov.io/gh/apache/pinot/pull/16747?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
> :exclamation: There is a different number of reports uploaded between BASE (a58ec4c) and HEAD (ddb8e80). Click for more details.
>
> <details><summary>HEAD has 36 uploads less than BASE</summary>
>
>| Flag | BASE (a58ec4c) | HEAD (ddb8e80) |
>|------|------|------|
>|unittests2|2|0|
>|unittests|4|1|
>|java-21|5|1|
>|temurin|10|1|
>|unittests1|2|1|
>|java-11|5|0|
>|integration|6|0|
>|integration1|2|0|
>|custom-integration1|2|0|
>|integration2|2|0|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #16747 +/- ##
============================================
- Coverage 63.43% 56.45% -6.99%
+ Complexity 1384 699 -685
============================================
Files 3044 2387 -657
Lines 177845 132487 -45358
Branches 27251 21091 -6160
============================================
- Hits 112820 74797 -38023
+ Misses 56367 51474 -4893
+ Partials 8658 6216 -2442
```
| [Flag](https://app.codecov.io/gh/apache/pinot/pull/16747/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [custom-integration1](https://app.codecov.io/gh/apache/pinot/pull/16747/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [integration](https://app.codecov.io/gh/apache/pinot/pull/16747/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [integration1](https://app.codecov.io/gh/apache/pinot/pull/16747/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [integration2](https://app.codecov.io/gh/apache/pinot/pull/16747/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [java-11](https://app.codecov.io/gh/apache/pinot/pull/16747/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [java-21](https://app.codecov.io/gh/apache/pinot/pull/16747/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `56.45% <83.33%> (-6.96%)` | :arrow_down: |
| [temurin](https://app.codecov.io/gh/apache/pinot/pull/16747/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `56.45% <83.33%> (-6.99%)` | :arrow_down: |
| [unittests](https://app.codecov.io/gh/apache/pinot/pull/16747/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `56.45% <83.33%> (-6.98%)` | :arrow_down: |
| [unittests1](https://app.codecov.io/gh/apache/pinot/pull/16747/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `56.45% <83.33%> (-0.06%)` | :arrow_down: |
| [unittests2](https://app.codecov.io/gh/apache/pinot/pull/16747/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/pinot/pull/16747?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org