7a0da7932b
Backwards Compatibility / Verify Encryption Constants (push) Waiting to run
Backwards Compatibility / PyPI Version Compatibility (push) Waiting to run
Backwards Compatibility / Database Migration Tests (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Blocked by required conditions
Docker Tests (Consolidated) / detect-changes (push) Waiting to run
Docker Tests (Consolidated) / Build Test Image (push) Waiting to run
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Blocked by required conditions
Docker Tests (Consolidated) / Accessibility Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Unit Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Example Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / Production Image Smoke Test (push) Blocked by required conditions
Docker Tests (Consolidated) / Infrastructure Tests (push) Blocked by required conditions
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Waiting to run
OSV-Scanner (Scheduled) / scan-scheduled (push) Failing after 0s
Create Release / test-gate (push) Has been cancelled
Create Release / release-gate (push) Has been cancelled
Create Release / ci-gate (push) Has been cancelled
Create Release / version-check (push) Has been cancelled
Create Release / e2e-test-gate (push) Has been cancelled
Create Release / responsive-test-gate (push) Has been cancelled
Create Release / compat-test-gate (push) Has been cancelled
Create Release / compose-integration-gate (push) Has been cancelled
Create Release / vulture-gate (push) Has been cancelled
Create Release / build (push) Has been cancelled
Create Release / provenance (push) Has been cancelled
Create Release / prerelease-docker (push) Has been cancelled
Create Release / publish-docker (push) Has been cancelled
Create Release / create-release (push) Has been cancelled
Create Release / cleanup-changelog (push) Has been cancelled
Create Release / trigger-pypi (push) Has been cancelled
Create Release / monitor-pypi (push) Has been cancelled
Create Release / Clean up orphan prerelease tags and signatures (push) Has been cancelled
89 lines
3.3 KiB
Python
89 lines
3.3 KiB
Python
# allow: no-sut-import — guardian; greps history_routes.py source to keep sensitive data out of logs
|
|
"""Tests for sensitive data logging changes in history_routes.
|
|
|
|
Verifies that PR #1896 changes are in place:
|
|
- logger.debug used instead of logger.info for research detail lookups
|
|
- Request headers are not logged
|
|
- Request URL is not logged
|
|
- Full research query results are not logged
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
# Resolve the source file path relative to this test file
|
|
_ROUTES_FILE = (
|
|
Path(__file__).resolve().parents[2]
|
|
/ "src"
|
|
/ "local_deep_research"
|
|
/ "web"
|
|
/ "routes"
|
|
/ "history_routes.py"
|
|
)
|
|
|
|
|
|
def _read_source() -> str:
|
|
"""Read the history_routes.py source file directly from disk."""
|
|
return _ROUTES_FILE.read_text(encoding="utf-8")
|
|
|
|
|
|
class TestSensitiveDataLogging:
|
|
"""Verify that sensitive data is not exposed through logging."""
|
|
|
|
def test_uses_debug_not_info_for_details_route(self):
|
|
"""logger.info should not be used for the details route access log."""
|
|
source = _read_source()
|
|
assert 'logger.info(f"Details route' not in source, (
|
|
"Details route log should use logger.debug, not logger.info"
|
|
)
|
|
assert "logger.debug" in source, (
|
|
"history_routes should contain at least one logger.debug call"
|
|
)
|
|
|
|
def test_no_request_headers_logging(self):
|
|
"""Request headers must not be logged as they may contain auth tokens."""
|
|
source = _read_source()
|
|
assert "request.headers" not in source, (
|
|
"request.headers should not appear in history_routes.py"
|
|
)
|
|
|
|
def test_no_request_url_logging(self):
|
|
"""Request URL must not be logged as it may contain sensitive params."""
|
|
source = _read_source()
|
|
assert "request.url" not in source, (
|
|
"request.url should not appear in history_routes.py"
|
|
)
|
|
|
|
def test_no_full_research_query_result_logging(self):
|
|
"""Full research query result objects should not be logged."""
|
|
source = _read_source()
|
|
assert 'logger.info(f"Research query result' not in source, (
|
|
"Full research query result should not be logged via logger.info"
|
|
)
|
|
|
|
def test_no_user_research_list_logging(self):
|
|
"""Full list of user research entries should not be logged."""
|
|
source = _read_source()
|
|
assert 'logger.info(f"All research for user' not in source, (
|
|
"Full user research list should not be logged via logger.info"
|
|
)
|
|
|
|
def test_research_count_uses_debug(self):
|
|
"""Research count log should use debug level."""
|
|
source = _read_source()
|
|
assert "All research count" in source, (
|
|
"Should log research count (not full list)"
|
|
)
|
|
assert 'logger.debug(f"All research count' in source, (
|
|
"Research count should be logged at debug level"
|
|
)
|
|
|
|
def test_research_found_uses_debug_with_id_only(self):
|
|
"""Research found log should use debug and only include the ID."""
|
|
source = _read_source()
|
|
assert 'logger.debug(f"Research found:' in source, (
|
|
"Research found log should use logger.debug"
|
|
)
|
|
assert "research.id if research else None" in source, (
|
|
"Should log only research.id, not the full object"
|
|
)
|