test(backend): pin rate-limit identity and HSTS/origin rules #247
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 331 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.347
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #247"
general
weight: 0.35
mangeshraut712
Two security-relevant backend modules had no tests.
app/client_identity.pydecides the rate-limit bucket for every request. The new tests check that:- bearer tokens are hashed and never appear in the bucket id;
- an empty
Bearerfalls back to the IP;- API keys go through the slow KDF, not plain sha256, and map to a stable bucket;
-
X-Forwarded-Foris ignored unlesstrust_proxyis set, and then the rightmost non-blank hop is used, so prepended fake hops can't dodge the limit;- the
ip:unknownfallback works.app/origins.py: HSTS is sent only when the effective scheme is https,X-Forwarded-Proto(first hop) takes precedence, and blank schemes are a no-op. Origin normalisation strips trailing slashes, qualifies bare hosts, and dedupes env origins.These are tests only, with no behaviour change: 14 new tests, all passing locally. A plausible "simplification" such as
parts[0], dropping the proxy gate, or sending HSTS on http would now fail CI.<!-- devin-review-badge-begin -->
---
<a href="https://app.devin.ai/review/mangeshraut712/assistme-virtualassistant/pull/247" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->
<!-- CURSOR_SUMMARY -->
---
<!-- /CURSOR_SUMMARY -->