refactor: consolidate duplicated security HTTP client logic#126
Conversation
|
@trivikramkalagi91-commits is attempting to deploy a commit to the Deekshith Gowda HS's projects Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughA new shared module ChangesShared HTTP client consolidation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lib/utils/securityHttpClient.ts`:
- Around line 54-55: The fallback handling for the set-cookie header at line 55
in securityHttpClient.ts pushes the entire header value as a single string, but
the downstream parseCookies function expects one cookie per array entry. When a
set-cookie header contains multiple cookies (typically comma-separated), they
need to be split into individual entries. Modify the code to split the
set-cookie header value by comma and push each cookie as a separate entry into
the setCookies array instead of pushing the entire header as one string.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7050ad9d-d455-4990-9481-70052211970f
📒 Files selected for processing (3)
lib/attack-pipeline/utils/httpClient.tslib/security-agent/utils/http-client.tslib/utils/securityHttpClient.ts
|
@deekshithgowda85 please review thr PR and it is ready for merge |
|
@deekshithgowda85 itsbeen 4 days can u please look over the PR and merge as there is no base confl_ct with base branch |
|
@deekshithgowda85 i have solved the issue suggested by coderabbitai please review as it is ready to merge |
|
@deekshithgowda85 it has been almost 1 week and i have solved the issue suggested by coderabbitai please review as it is ready to merge |
|
/coderabbitai review |
Pull Request
Summary
This PR addresses Issue #119 by consolidating duplicated HTTP request execution logic used by the security scanning modules.
A new shared utility (
lib/utils/securityHttpClient.ts) has been introduced to centralize common functionality such as request execution, timeout handling, latency measurement, response header collection, body truncation, Set-Cookie extraction, and error mapping.The existing public APIs remain unchanged through compatibility wrappers, ensuring no consumer code needs to be modified.
Related Issue
Closes: #119
What Changed
lib/utils/securityHttpClient.tsas a shared internal implementation for security HTTP requestslib/attack-pipeline/utils/httpClient.tsto use the shared implementation while preservingHttpSessionand existing behaviorlib/security-agent/utils/http-client.tsto use the shared implementation while preserving its public API and defaultsVerification
pnpm lint(equivalent ESLint validation completed successfully)Additional Validation
HttpSessionbehavior preservedChecklist
Summary by CodeRabbit