Fix(#50): GSB API 키가 httpx INFO 로그에 노출되는 문제 - #51
Conversation
Google Safe Browsing API는 키를 URL 쿼리 파라미터로 요구하는데, httpx는 INFO 레벨에서 요청 URL 전체를 그대로 로깅한다. INFO 이상 로깅이 켜지는 환경(로컬 디버깅, 임시 스크립트 등)에서 키가 로그에 그대로 노출될 수 있어, 이 클라이언트를 임포트하는 시점에 httpx/httpcore 로거를 WARNING 이상으로 고정한다. VirusTotal은 헤더 인증(x-apikey)이라 해당 없음.
📝 WalkthroughWalkthroughThe Safe Browsing client now sets ChangesSafe Browsing logging control
Estimated code review effort: 1 (Trivial) | ~5 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
app/infrastructure/google_safe_browsing/client.py (2)
13-14: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift프로세스 전체 HTTPX 로그 억제의 범위를 확인해 주세요.
Line 13-14는 프로세스 전체의
httpx와httpcore로거를 변경합니다. 따라서GoogleSafeBrowsingClient뿐 아니라 다른 HTTP 클라이언트의 INFO 요청 로그도 사라집니다. VirusTotal을 포함한 다른 연동의 관측성이 감소할 수 있습니다. 이 전역 동작이 의도된 것인지 확인해 주세요. 의도되지 않았다면key쿼리 파라미터만 제거하는 로그 필터를 사용해 주세요.🤖 Prompt for 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. In `@app/infrastructure/google_safe_browsing/client.py` around lines 13 - 14, Remove the global logger-level changes for “httpx” and “httpcore” near GoogleSafeBrowsingClient, and replace them with a client-scoped logging filter that removes only the key query parameter from Google Safe Browsing request logs. Preserve INFO-level logging for other HTTP clients and integrations, including VirusTotal.
13-14: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winAPI 키 누출 방지에 대한 회귀 테스트를 추가해 주세요.
가짜 API 키를 사용하고 네트워크 전송은 mock transport로 대체한 뒤,
httpx와httpcore로그에 해당 키가 포함되지 않는지 검증해 주세요. 로거 레벨만 확인하지 말고 실제AsyncClient.post경로를 검증해야 합니다. HTTPX 0.27.0은 sync/async INFO 요청 로그에request.url을 포함합니다. (raw.githubusercontent.com)🤖 Prompt for 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. In `@app/infrastructure/google_safe_browsing/client.py` around lines 13 - 14, 애플리케이션의 HTTP 요청 테스트에 가짜 API 키와 mock transport를 적용하고, 실제 AsyncClient.post 경로를 실행해 검증하는 회귀 테스트를 추가하세요. 요청 처리 중 httpx 및 httpcore 로그를 캡처한 뒤 모든 로그 메시지에 가짜 키가 포함되지 않는지 확인하고, 로거 레벨만 검사하는 테스트는 작성하지 마세요.Source: MCP tools
🤖 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.
Nitpick comments:
In `@app/infrastructure/google_safe_browsing/client.py`:
- Around line 13-14: Remove the global logger-level changes for “httpx” and
“httpcore” near GoogleSafeBrowsingClient, and replace them with a client-scoped
logging filter that removes only the key query parameter from Google Safe
Browsing request logs. Preserve INFO-level logging for other HTTP clients and
integrations, including VirusTotal.
- Around line 13-14: 애플리케이션의 HTTP 요청 테스트에 가짜 API 키와 mock transport를 적용하고, 실제
AsyncClient.post 경로를 실행해 검증하는 회귀 테스트를 추가하세요. 요청 처리 중 httpx 및 httpcore 로그를 캡처한 뒤
모든 로그 메시지에 가짜 키가 포함되지 않는지 확인하고, 로거 레벨만 검사하는 테스트는 작성하지 마세요.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: fcdb1af3-31ef-47c7-bef4-50a1173aa95d
📒 Files selected for processing (1)
app/infrastructure/google_safe_browsing/client.py
📝 개요
Google Safe Browsing API 키가 httpx의 INFO 레벨 요청 로그를 통해 그대로 노출되는 문제를 수정합니다. GSB API는 키를 URL 쿼리 파라미터로 요구하는데, 저장소에 httpx 로거를 억제하는 설정이 없어 INFO 이상 로깅이 켜지는 환경(로컬 디버깅, 임시 스크립트 등)에서 키가 로그에 그대로 찍힙니다. 벤치마크 테스트 스크립트 작업 중 실제로 발견했습니다.
🔗 관련 이슈
🎯 주요 변경 사항
app/infrastructure/google_safe_browsing/client.py: 모듈 임포트 시점에httpx/httpcore로거를 WARNING 이상으로 고정. 앱 진입점(app.main)뿐 아니라 이 클라이언트를 직접 임포트하는 임시 스크립트에서도 동일하게 보호되도록 클라이언트 모듈 자체에 배치.x-apikey)이라 해당 없음, 별도 수정 불필요.📸 사진
생략
✅ PR 체크리스트
uvicorn구동 또는 테스트 코드)를 통과했습니다. (215건 통과)이미 노출된
GOOGLE_SAFE_BROWSING_API_KEY는 이 PR과 별개로 재발급(rotate)이 필요합니다.Summary by CodeRabbit