Skip to content

Refactor: 파일 구조 변경 - #24

Merged
pearseona merged 1 commit into
developfrom
refactor/directory-structure
Jul 27, 2026
Merged

Refactor: 파일 구조 변경#24
pearseona merged 1 commit into
developfrom
refactor/directory-structure

Conversation

@pearseona

@pearseona pearseona commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

📝 개요

기존 기술 계층 중심 구조를 기능 중심 구조로 개편했습니다.

app/
├── main.py                             # FastAPI 앱 생성 및 라우터 등록
│
├── core/                               # 애플리케이션 전역 설정
│   └── config.py                       # 환경변수와 API Key 등 설정 관리
│
├── analysis/                           # 스미싱 통합 분석 기능
│   ├── router.py                       # POST /api/analyze 엔드포인트
│   ├── schemas.py                      # 분석 API 요청·응답 Pydantic 스키마
│   ├── service.py                      # 텍스트·URL·규칙 분석 파이프라인 조율
│   ├── ports.py                        # 외부 URL 보안 Provider 인터페이스
│   ├── scoring.py                      # 3중 분석 결과 가중치 합산 및 최종 점수 계산
│   ├── risk_policy.py                  # 점수에 따른 텍스트 위험 등급 결정
│   │
│   ├── text/                           # 문자 본문 분석
│   │   ├── gemini_analyzer.py          # Gemini 기반 문맥·어조·위험 근거 분석
│   │   └── naive_bayes_analyzer.py     # 사전 학습된 NB 모델 기반 1차 위험 분석
│   │
│   ├── url/                            # 문자에 포함된 URL 분석
│   │   ├── analyzer.py                 # GSB와 VirusTotal을 조합한 URL 위험 판정
│   │   └── tracker.py                  # URL 추출, 리디렉션 추적 및 SSRF 방어
│   │
│   └── rules/                          # 외부 API를 사용하지 않는 로컬 규칙 분석
│       └── analyzer.py                 # 금융 키워드·계좌번호·악성 도메인 패턴 분석
│
└── infrastructure/                     # 외부 서비스 및 기술 연동 구현
    ├── gemini/
    │   └── client.py                   # Gemini API HTTP 요청·응답 처리
    │
    ├── google_safe_browsing/
    │   └── client.py                   # Google Safe Browsing API 연동
    │
    ├── virustotal/
    │   └── client.py                   # VirusTotal URL 평판 API 연동
    │
    └── mock_provider.py                # 외부 보안 API를 대체하는 개발·테스트용 구현

Summary by CodeRabbit

  • New Features

    • Added hybrid smishing analysis combining text, URL, and rule-based signals.
    • Added detection for suspicious links, financial information, institution mentions, and urgency language.
    • Added secure URL extraction and redirect tracking with protection against unsafe destinations.
    • Added Gemini-powered analysis support and improved fallback risk handling.
  • Refactor

    • Updated analysis responses and risk grading for clearer, consistent results.
  • Chores

    • Added development tooling configuration and improved environment setup.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 61b06268-5425-42d2-ac20-71a4d8833694

📥 Commits

Reviewing files that changed from the base of the PR and between 6d5fd42 and 4c0d9d5.

📒 Files selected for processing (51)
  • .gitignore
  • app/__init__.py
  • app/analysis/__init__.py
  • app/analysis/ports.py
  • app/analysis/risk_policy.py
  • app/analysis/router.py
  • app/analysis/rules/__init__.py
  • app/analysis/rules/analyzer.py
  • app/analysis/schemas.py
  • app/analysis/scoring.py
  • app/analysis/service.py
  • app/analysis/text/__init__.py
  • app/analysis/text/gemini_analyzer.py
  • app/analysis/text/naive_bayes_analyzer.py
  • app/analysis/url/__init__.py
  • app/analysis/url/analyzer.py
  • app/analysis/url/tracker.py
  • app/core/__init__.py
  • app/core/config.py
  • app/dto/request.py
  • app/dto/response.py
  • app/infrastructure/__init__.py
  • app/infrastructure/gemini/__init__.py
  • app/infrastructure/gemini/client.py
  • app/infrastructure/google_safe_browsing/__init__.py
  • app/infrastructure/google_safe_browsing/client.py
  • app/infrastructure/mock_provider.py
  • app/infrastructure/virustotal/__init__.py
  • app/infrastructure/virustotal/client.py
  • app/main.py
  • app/service/security/base.py
  • requirements-dev.txt
  • requirements.txt
  • tests/__init__.py
  • tests/analysis/__init__.py
  • tests/analysis/rules/__init__.py
  • tests/analysis/rules/test_analyzer.py
  • tests/analysis/test_router.py
  • tests/analysis/test_scoring.py
  • tests/analysis/test_service.py
  • tests/analysis/text/__init__.py
  • tests/analysis/text/test_gemini_analyzer.py
  • tests/analysis/text/test_naive_bayes_analyzer.py
  • tests/analysis/url/__init__.py
  • tests/analysis/url/test_analyzer.py
  • tests/analysis/url/test_extractor.py
  • tests/analysis/url/test_tracker.py
  • tests/infrastructure/__init__.py
  • tests/infrastructure/test_virustotal_client.py
  • tests/integration/__init__.py
  • tests/integration/test_url_tracker.py

📝 Walkthrough

Walkthrough

The PR reorganizes smishing analysis into app.analysis, adds injected text and URL analyzers, introduces SSRF-protected URL tracing, centralizes risk policy, updates FastAPI wiring, renames infrastructure clients, and migrates tests and development dependencies.

Changes

Analysis pipeline

Layer / File(s) Summary
Contracts and infrastructure adapters
app/analysis/ports.py, app/analysis/schemas.py, app/analysis/risk_policy.py, app/core/config.py, app/infrastructure/...
Adds shared analysis contracts and schemas, centralizes risk grading, makes external API keys optional, and renames provider implementations to clients.
SSRF-protected URL analysis
app/analysis/url/..., tests/analysis/url/..., tests/integration/test_url_tracker.py
Adds URL extraction and redirect tracing with public-host validation, pinned connections, redirect handling, and injected Safe Browsing/VirusTotal clients.
Rule, text, and scoring analysis
app/analysis/rules/..., app/analysis/text/..., app/analysis/scoring.py, tests/analysis/rules/..., tests/analysis/text/..., tests/analysis/test_scoring.py
Adds deterministic rule scoring, moves shared text grading, routes Gemini requests through GeminiClient, and renames the scoring engine.
Service and application wiring
app/analysis/service.py, app/analysis/router.py, app/main.py, tests/analysis/test_router.py, tests/analysis/test_service.py
Replaces ScanService with injected SmishingAnalysisService, connects URL/rule/text analyzers to final scoring, and adds a FastAPI application factory.
Repository support
.gitignore, requirements*.txt, tests/**/__init__.py
Adds development dependency constraints, ignores Python artifacts, and documents package boundaries.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • SafeFam/SafeFam_AI#5: Removes the earlier shared DTOs that this PR replaces with analysis-layer schemas and services.
  • SafeFam/SafeFam_AI#20: Introduces the hybrid text scoring and SSRF-protected URL pipeline migrated by this PR.

Suggested labels: chore

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/directory-structure

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pearseona
pearseona merged commit 009162c into develop Jul 27, 2026
1 check was pending
@pearseona pearseona self-assigned this Jul 27, 2026
@pearseona pearseona added the refactor Code changes that neither fix a bug nor add a feature label Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code changes that neither fix a bug nor add a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant