pryscraper/routers/compliance.py
cryptorugmunch 9fee12796e
Some checks failed
CI / Security audit (bandit) (pull_request) Successful in 36s
CI / test (pull_request) Successful in 1m19s
CI / lint (pull_request) Failing after 49s
CI / typecheck (pull_request) Successful in 54s
CI / Secret scan (gitleaks) (pull_request) Successful in 34s
feat(routers): split remaining 174 api.py routes into per-tag routers
- AST-extract all remaining routes from api.py into routers/*.py
- Group routes by OpenAPI tag (AI, Advanced, Agency, ..., x402)
- Keep existing auth/health/scraping/templates routers; add *_api.py for remaining routes of those tags
- Move shared helpers/models/variables with the routes that need them
- Update tests/test_api.py to import vision helpers from routers.vision
- Regenerate openapi.json (186 paths)
- All 497 tests pass; ruff clean
2026-07-03 03:42:36 +02:00

57 lines
1.9 KiB
Python

"""Pry — Compliance router (remaining api.py routes).
Auto-extracted from api.py during the router-split refactor.
"""
# SPDX-License-Identifier: MIT
# Copyright (c) 2026 Rug Munch Media LLC
from __future__ import annotations
import logging
from typing import Any
from fastapi import APIRouter, Body
logger = logging.getLogger(__name__)
router = APIRouter(tags=["Compliance"])
@router.post("/v1/compliance/check", tags=["Compliance"], summary="Run full compliance check on a URL")
async def compliance_check(url: str = Body(...)) -> dict[str, Any]:
"""Run a full legal compliance check on a target URL.
Analyzes:
- robots.txt crawl permissions
- Terms of Service classification (restrictive/permissive/moderate)
- Jurisdiction detection (GDPR, CCPA, LGPD)
- Sensitive data detection (PII, financial, health, contact)
Returns a green/yellow/red risk score with recommendations.
"""
from compliance import run_compliance_check
result = await run_compliance_check(url)
return {"success": True, "data": result}
@router.get("/v1/compliance/check", tags=["Compliance"], summary="Get compliance check documentation")
async def compliance_docs() -> dict[str, Any]:
"""Get information about the compliance check endpoint."""
return {
"success": True,
"data": {
"description": "Legal compliance engine for web scraping targets",
"risk_levels": {
"green": "Low risk — standard scraping practices",
"yellow": "Moderate risk — proceed with caution",
"red": "High risk — legal review required",
},
"factors_checked": [
"robots.txt crawl permissions",
"Terms of Service classification",
"Jurisdiction detection (GDPR/CCPA/LGPD)",
"Sensitive data categories (PII, financial, health, contact)",
],
},
}