Fix/ssrf secrets openapi - #85
Merged
Merged
Conversation
Contributor
|
👋 Thanks for your contribution, @NEFORCEO! Please make sure:
Maintainers will review it soon. |
Contributor
Merging this PR will improve performance by 42.38%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_response_req_text_from_json |
213.2 µs | 135.3 µs | +57.56% |
| ⚡ | test_response_repr |
196.4 µs | 131.6 µs | +49.22% |
| ⚡ | test_response_property_access |
194.5 µs | 131.2 µs | +48.25% |
| ⚡ | test_response_json_parsing |
205.6 µs | 141.6 µs | +45.22% |
| ⚡ | test_response_creation |
201.3 µs | 140.3 µs | +43.49% |
| ⚡ | test_middleware_after_response |
403.1 µs | 351.4 µs | +14.71% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing fix/ssrf-secrets-openapi (3b65f26) with master (6f3d441)1
Footnotes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
x## 🚀 Description
Fixes a handful of correctness and security bugs found during a repo audit:
openapi/generator.py:BasicAuth/BearerAuth/DigestAuth/OAuth2ClientCredentialswere imported only underTYPE_CHECKINGbut used at runtime inisinstance()checks — this raisedNameErrorwhenever OpenAPI generation hit a route withauthset. Moved the import to module level.security/ssrf.py:check_url()failed open (allowed the request) when DNS resolution raisedsocket.gaierror. Changed to fail closed (block), consistent with the other exception branch.security/secrets.py:SecretsMasking.mask_url()was a no-op in the pure-Python fallback (no compiledfasthttp._core), silently leaving secrets in query strings (?api_key=...,?token=...) unmasked. Implemented a real fallback using the existingSECRET_PARAM_REGEX.app.py: split_run_sseinto_run_sse(reconnect/backoff loop) +_stream_sse(connection + event parsing) to remove duplicated retry code and drop cyclomatic complexity below the lint threshold; narrowed the blindexcept Exceptionwith an explicit# noqa: BLE001.routing.py: added# noqa: TC001to theauthimport — it looks type-only to ruff, butRouteis a pydantic model and the field is resolved at runtime, so the import can't move intoTYPE_CHECKING.response.py: removed an unusedhttpximport; moveddatetimeunderTYPE_CHECKING(used only in annotations).dependencies/dependencies.py: minor comment cleanup.examples/middleware/retry_middleware 2.py.No documentation changes in this PR.
🧩 Type of Change
Please select one:
✅ Checklist
ruff check fasthttp/is clean and the full test suite passes (559 passed).🔗 Related Issues
Fixes #
📸 Additional Context
Found via a manual security/lint audit of
fasthttp/, not tied to a filed issue. Theopenapi/generator.pyandsecurity/secrets.pyfixes are the most impactful — both are silent runtime bugs with no existing test coverage.