Skip to content

fix: 입금 입력 강화 — NaN/Infinity 차단 + note 절단 + 배치율 클램프#445

Merged
easygap merged 1 commit into
mainfrom
fix/deposit-input-hardening
Jul 7, 2026
Merged

fix: 입금 입력 강화 — NaN/Infinity 차단 + note 절단 + 배치율 클램프#445
easygap merged 1 commit into
mainfrom
fix/deposit-input-hardening

Conversation

@easygap

@easygap easygap commented Jul 7, 2026

Copy link
Copy Markdown
Owner

무엇

웹 입금 경로(적대적 리뷰 없이 나갔던 표면)를 자체 점검하다 발견한 실제 입력 검증 구멍 수정.

구멍 (실측 확인)

python json.loadsInfinity/NaN 리터럴을 기본 허용합니다. 그런데:

  • float('inf') > 0 = True → 무한대 입금이 기록됨
  • nan <= 0 = False → NaN이 양수 검사를 그대로 통과

기록되는 순간 현금·원금·TWR 합산이 통째로 오염됩니다. CLI --amount inf도 같은 구멍이었습니다.

수정 (심층 방어 3겹)

  1. record_basket_deposit(웹·CLI 공유 검증): math.isfinite 필수 + note 200자 서버측 절단(SQLite는 String(200) 미강제)
  2. record_cash_flow(repo 최종 방어선): 비유한값 ValueError — NaN은 truthy라 기존 if not amount도 통과했음
  3. CLI --account-key 직접 경로에도 isfinite

일관성: get_baskets_json 배치율 음수 클램프(헬스 점검과 동일 규칙).

회귀 고정

  • 실제 Infinity/NaN/-Infinity JSON 페이로드 → 400 + 기록 0건 (엔드포인트 테스트)
  • repo 계층 ValueError 3종, 500자 note → 200자 절단
  • 전체 스위트 1646 통과

웹 입금 경로(미리뷰 표면) 자체 점검에서 실제 구멍 발견:
python json.loads는 Infinity/NaN 리터럴을 기본 허용하는데,
float(inf) > 0 은 True, nan <= 0 은 False라 기존 양수 검사를
둘 다 통과 — 무한대/NaN 입금이 기록되면 현금·원금·TWR 합산이
통째로 오염된다. CLI --amount inf 도 같은 구멍.

수정(심층 방어 3겹):
- record_basket_deposit(공유 검증): math.isfinite 필수 + note 200자
  서버측 절단(SQLite는 String(200) 미강제)
- repositories.record_cash_flow(최종 방어선): 비유한값 ValueError
  (NaN은 truthy라 기존 `if not amount`도 통과했음)
- CLI --account-key 직접 경로: isfinite 검증

일관성: get_baskets_json 배치율 음수 클램프(헬스와 동일 규칙).

회귀 고정: 실제 Infinity/NaN JSON 페이로드 → 400 + 기록 0건,
repo 계층 ValueError, 500자 note → 200자 절단. 전체 스위트 1646 통과.
@easygap easygap merged commit 2b3ec35 into main Jul 7, 2026
1 check passed
@easygap easygap deleted the fix/deposit-input-hardening branch July 7, 2026 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant