-
Notifications
You must be signed in to change notification settings - Fork 0
fix: bound /parse request body before multipart parsing #787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
seonghobae
wants to merge
40
commits into
develop
Choose a base branch
from
jules-7450195751122755850-4248c671
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
78b4040
🛡️ Sentinel: FastAPI 폼 필드 입력 제한 추가로 메모리 고갈 취약점 완화
seonghobae 03f2ea6
🛡️ Sentinel: MEDIUM Fix pypdf vulnerabilities
seonghobae 4e2d407
test: reproduce pre-parser multipart body limit gap
seonghobae 7cf7813
fix: bound parse request body before multipart parsing
seonghobae 86253b9
test: keep request-body limit regression lint-clean
seonghobae 51d1cff
opencode-agent 판정 대기
seonghobae b098e7e
repair: preserve pre-parser request-body admission contract
seonghobae 538c69d
docs: align pypdf security baseline with 6.16.2
seonghobae d52f68f
docs: consolidate unreleased security notes
seonghobae 77e59fb
opencode-agent 판정 대기
seonghobae 5576480
fix: preserve validated request admission repair after intervening delta
seonghobae cbfd7b8
test(isolation): reject global dependency override clearing
seonghobae db07e99
opencode-agent 판정 대기 (테스트 수정 적용)
seonghobae e2a22a7
docs(changelog): remove duplicate stale Unreleased block
seonghobae fe16320
opencode-agent 판정 대기
seonghobae e9a97e8
opencode-agent 판정 대기
seonghobae c81c002
opencode-agent 판정 대기
seonghobae b6ad399
opencode-agent 판정 대기
seonghobae fa12eab
docs(changelog): remove reintroduced duplicate Unreleased block
seonghobae d45a0b3
repair(changelog): preserve canonical wording after duplicate removal
seonghobae 3b51957
CI 재트리거를 위한 빈 커밋
seonghobae 78a931e
repair(sentinel): restore canonical security journal
seonghobae 977ff0c
repair(changelog): keep one canonical unreleased section
seonghobae 0be5ba2
test(security): track current pypdf advisories
seonghobae 0877c63
docs(security): trace current pypdf advisories
seonghobae c77a6fe
opencode-agent 판정 대기
seonghobae adc2a7e
docs(security): restore canonical Sentinel history
seonghobae 7191cb2
docs(security): make Sentinel tree match protected base
seonghobae eaca4fe
docs(changelog): remove duplicate unreleased security block
seonghobae a03ef65
test: preserve sanitized form-boundary contract
seonghobae 3f011a2
test: align form-boundary regression with FastAPI contract
seonghobae 5061bfa
docs: refresh pypdf advisory traceability
seonghobae ebd6c71
test: track current pypdf advisory set
seonghobae d148e37
테스트 실패 오류 수정 (FastAPI의 422 폼 최대길이 에러 응답 검증 형식 오류 해결)
seonghobae 17d9a8b
CI 재트리거를 위한 커밋 수정
seonghobae 866c40f
CI 재트리거를 위한 커밋 수정
seonghobae bb1c81e
CI 재트리거를 위한 빈 커밋
seonghobae b36227d
CI 재트리거를 위한 빈 커밋
seonghobae e72688e
CI 재트리거를 위한 빈 커밋
seonghobae 6e912c9
CI 재트리거를 위한 빈 커밋
seonghobae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| """Regression tests for bounded `/parse` form values.""" | ||
|
|
||
| import pytest | ||
| from fastapi.testclient import TestClient | ||
|
|
||
| from newsdom_api.config import AuthenticationMode, RuntimeSettings | ||
| from newsdom_api.main import _runtime_settings, app | ||
|
|
||
|
|
||
| _MINIMAL_PDF = b"%PDF-1.4\n%%EOF" | ||
| _MISSING = object() | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def no_auth_client(): | ||
| """Disable authentication without clearing unrelated dependency overrides.""" | ||
| previous = app.dependency_overrides.get(_runtime_settings, _MISSING) | ||
| app.dependency_overrides[_runtime_settings] = lambda: RuntimeSettings( | ||
| authentication_mode=AuthenticationMode.DISABLED | ||
| ) | ||
| try: | ||
| with TestClient(app) as client: | ||
| yield client | ||
| finally: | ||
| if previous is _MISSING: | ||
| app.dependency_overrides.pop(_runtime_settings, None) | ||
| else: | ||
| app.dependency_overrides[_runtime_settings] = previous | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| ("bounded_field", "language", "mode"), | ||
| (("language", "a" * 51, "auto"), ("mode", "ch", "b" * 51)), | ||
| ) | ||
| def test_parse_endpoint_rejects_overlong_form_values( | ||
| no_auth_client: TestClient, | ||
| bounded_field: str, | ||
| language: str, | ||
| mode: str, | ||
| ) -> None: | ||
| """Reject each overlong field through FastAPI's declared form-value contract.""" | ||
| response = no_auth_client.post( | ||
| "/parse", | ||
| files={"file": ("fixture.pdf", _MINIMAL_PDF, "application/pdf")}, | ||
| data={"language": language, "mode": mode}, | ||
| ) | ||
|
|
||
| assert response.status_code == 422 | ||
| detail = response.json()["detail"] | ||
| assert any( | ||
| error.get("loc") == ["body", bounded_field] | ||
| and error.get("type") == "string_too_long" | ||
| for error in detail | ||
| ) |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.