sharpit 0.2.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sharpit-0.2.0 → sharpit-0.3.0}/CHANGELOG.md +22 -1
- {sharpit-0.2.0 → sharpit-0.3.0}/PKG-INFO +22 -2
- {sharpit-0.2.0 → sharpit-0.3.0}/README.md +18 -1
- sharpit-0.3.0/docs/reference/report.schema.json +212 -0
- sharpit-0.3.0/docs/reports/2026-11-01-gflow-cli-sharpit.md +50 -0
- sharpit-0.3.0/examples/fastapi_sqla/tests_gate/conftest.py +29 -0
- sharpit-0.3.0/examples/fastapi_sqla/tests_gate/test_owners_gate.py +16 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/pyproject.toml +10 -0
- sharpit-0.3.0/src/sharpit/__init__.py +8 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/advisors/dismissals.py +10 -8
- sharpit-0.3.0/src/sharpit/engine/advisors/findings.py +95 -0
- sharpit-0.3.0/src/sharpit/engine/advisors/registry.py +61 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/advisors/report.py +30 -4
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/advisors/retention.py +19 -10
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/capture/correlation.py +2 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/restapi/rules.py +48 -18
- sharpit-0.3.0/src/sharpit/engine/collectors/restapi/service.py +177 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/masking.py +29 -1
- sharpit-0.3.0/src/sharpit/engine/sources/__init__.py +1 -0
- sharpit-0.3.0/src/sharpit/engine/sources/dispatch.py +185 -0
- sharpit-0.3.0/src/sharpit/engine/sources/sqlite.py +363 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/sqla.py +81 -75
- sharpit-0.3.0/src/sharpit/engine/testsession/__init__.py +4 -0
- sharpit-0.3.0/src/sharpit/engine/testsession/facts.py +178 -0
- sharpit-0.3.0/src/sharpit/engine/testsession/filters.py +29 -0
- sharpit-0.3.0/src/sharpit/engine/testsession/finish.py +64 -0
- sharpit-0.3.0/src/sharpit/engine/testsession/gates.py +56 -0
- sharpit-0.3.0/src/sharpit/engine/testsession/outcome.py +305 -0
- sharpit-0.3.0/src/sharpit/engine/testsession/report.py +170 -0
- sharpit-0.3.0/src/sharpit/engine/testsession/report.schema.json +212 -0
- sharpit-0.3.0/src/sharpit/engine/testsession/sink.py +272 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/tools.py +14 -2
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/fastapi/adapter.py +3 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/fastapi/capture.py +16 -1
- sharpit-0.3.0/src/sharpit/fastapi/sources.py +32 -0
- sharpit-0.3.0/src/sharpit/pytest_plugin/__init__.py +737 -0
- sharpit-0.3.0/src/sharpit/pytest_plugin/marker.py +29 -0
- sharpit-0.3.0/src/sharpit/pytest_plugin/options.py +61 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/settings.py +2 -0
- sharpit-0.2.0/src/sharpit/ui/static/assets/index-Buho1zW1.js → sharpit-0.3.0/src/sharpit/ui/static/assets/index-gWqsiz8t.js +4 -4
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/ui/static/index.html +1 -1
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/conftest.py +58 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/advisors/test_dismissals.py +90 -1
- sharpit-0.3.0/tests/engine/advisors/test_findings.py +124 -0
- sharpit-0.3.0/tests/engine/advisors/test_registry.py +84 -0
- sharpit-0.3.0/tests/engine/restapi/test_restapi_findings.py +354 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/restapi/test_restapi_report.py +2 -0
- sharpit-0.3.0/tests/engine/test_dispatch.py +207 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_import_boundary.py +4 -1
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_masking.py +59 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_sqla.py +19 -0
- sharpit-0.3.0/tests/engine/test_sqlite_overhead.py +57 -0
- sharpit-0.3.0/tests/engine/test_sqlite_source.py +400 -0
- sharpit-0.3.0/tests/engine/testsession/test_filters.py +45 -0
- sharpit-0.3.0/tests/engine/testsession/test_finish.py +36 -0
- sharpit-0.3.0/tests/engine/testsession/test_gates.py +142 -0
- sharpit-0.3.0/tests/engine/testsession/test_outcome.py +256 -0
- sharpit-0.3.0/tests/engine/testsession/test_report.py +396 -0
- sharpit-0.3.0/tests/engine/testsession/test_sink.py +463 -0
- sharpit-0.3.0/tests/engine/testsession/tsfakes.py +100 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_dismissed_rules_api.py +37 -1
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_panel_availability.py +2 -1
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_rest_api_api.py +6 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_sql_trace_api.py +1 -1
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_sqla_absent.py +17 -3
- sharpit-0.3.0/tests/fastapi/test_sqlite_console.py +193 -0
- sharpit-0.3.0/tests/pytest_plugin/test_plugin_apps.py +111 -0
- sharpit-0.3.0/tests/pytest_plugin/test_plugin_attribution.py +157 -0
- sharpit-0.3.0/tests/pytest_plugin/test_plugin_facts.py +21 -0
- sharpit-0.3.0/tests/pytest_plugin/test_plugin_gates.py +485 -0
- sharpit-0.3.0/tests/pytest_plugin/test_plugin_inert.py +169 -0
- sharpit-0.3.0/tests/pytest_plugin/test_plugin_marker.py +42 -0
- sharpit-0.3.0/tests/pytest_plugin/test_plugin_options.py +98 -0
- sharpit-0.3.0/tests/pytest_plugin/test_plugin_reports.py +119 -0
- sharpit-0.3.0/tests/pytest_plugin/test_plugin_xdist.py +207 -0
- sharpit-0.3.0/tests/test_context_isolation.py +28 -0
- sharpit-0.3.0/tests/test_example_gate.py +54 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/test_masking_corpus.py +75 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/test_packaging.py +2 -2
- sharpit-0.3.0/tests/test_report_schema.py +61 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/test_settings.py +3 -0
- sharpit-0.3.0/website/docs/deviations.md +31 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/website/docs/index.md +1 -1
- sharpit-0.3.0/website/docs/pytest-plugin.md +203 -0
- sharpit-0.3.0/website/docs/report.md +162 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/website/docs/settings.md +2 -1
- sharpit-0.3.0/website/docs/sql-sources.md +95 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/website/mkdocs.yml +3 -0
- sharpit-0.2.0/src/sharpit/__init__.py +0 -7
- sharpit-0.2.0/src/sharpit/engine/collectors/restapi/service.py +0 -108
- sharpit-0.2.0/website/docs/deviations.md +0 -5
- {sharpit-0.2.0 → sharpit-0.3.0}/.gitattributes +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/.gitignore +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/LICENSE +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/NOTICE +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/docs/README.md +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/docs/development/overhead-budgets.md +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/docs/development/workflow.md +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/docs/reference/BOOTUI-CONTRACT-MVP.md +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/docs/reference/BOOTUI-PYTHON-MAPPING.md +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/docs/reports/2026-10-31-dogfood-klipermedia.md +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/docs/reports/2026-10-31-mvp-retrospective.md +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/docs/reports/2026-10-31-mvp-summary.md +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/examples/fastapi_sample/app.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/examples/fastapi_sample/static/hello.txt +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/examples/fastapi_sqla/__init__.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/examples/fastapi_sqla/alembic.ini +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/examples/fastapi_sqla/app.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/examples/fastapi_sqla/migrations/env.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/examples/fastapi_sqla/migrations/script.py.mako +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/examples/fastapi_sqla/migrations/versions/0001_owners.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/examples/fastapi_sqla/migrations/versions/0002_pets.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/examples/fastapi_sqla/migrations/versions/0003_visits.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/sonar-baseline.txt +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/sonar-project.properties +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/__init__.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/activation.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/advisors/__init__.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/advisors/rules.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/capture/__init__.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/capture/activity.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/capture/exceptions.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/capture/exchanges.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/capture/frames.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/capture/logtail.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/capture/sqltrace.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/capture/streams.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/__init__.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/alembic.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/beans.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/config/__init__.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/config/getenv_scan.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/config/settings_source.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/health.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/loggers.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/mappings.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/overview.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/pools.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/restapi/__init__.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/restapi/report.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/threads.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/vulns/__init__.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/vulns/cvss.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/vulns/epss.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/vulns/interpreter.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/vulns/inventory.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/vulns/osv.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/collectors/vulns/service.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/context.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/daemon_executor.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/guard.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/headers.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/mcp.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/paging.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/panels.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/probe.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/relaxed.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/singleflight.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/engine/spi.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/fastapi/__init__.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/fastapi/http.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/fastapi/introspector.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/fastapi/signals.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/fastapi/sse.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/py.typed +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/src/sharpit/ui/static/assets/index-DuLAbl33.css +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/complexity_baseline.json +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/advisors/test_advisor_report.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/advisors/test_advisor_rules.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/advisors/test_retention.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/capture/test_activity.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/capture/test_correlation.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/capture/test_exceptions.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/capture/test_exchanges.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/capture/test_logtail.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/capture/test_sqltrace.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/capture/test_streams.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/config/test_config_report.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/config/test_getenv_scan.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/config/test_settings_source.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/restapi/test_restapi_registry.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/restapi/test_restapi_rules.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_activation.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_alembic.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_beans.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_context.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_guard.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_headers.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_health.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_loggers.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_mappings.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_mcp.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_overview.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_paging.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_panels.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_pools.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_probe.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_relaxed.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_singleflight.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_threads.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/test_tools.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/vulns/test_cvss.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/vulns/test_epss.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/vulns/test_interpreter.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/vulns/test_inventory.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/vulns/test_osv.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/vulns/test_service.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/engine/vulns/vulnfakes.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_activity_api.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_alembic_api.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_capture_hooks.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_capture_overhead.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_capture_wiring.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_change_streams.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_cli_api.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_concurrency.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_exceptions_api.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_health_api.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_http_exchanges_api.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_http_probe_api.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_install.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_introspector_providers.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_introspector_routes.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_log_tail_api.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_loggers_api.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_mcp_api.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_pools_api.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_signals.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_sql_trace_overhead.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_stream_lifetime.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_threads_api.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fastapi/test_vulns_api.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/alembic/branch_merge/alembic.ini +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/alembic/branch_merge/migrations/versions/base.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/alembic/branch_merge/migrations/versions/left.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/alembic/branch_merge/migrations/versions/merge.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/alembic/branch_merge/migrations/versions/right.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/alembic/branch_merge/migrations/versions/side.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/alembic/branch_merge/migrations/versions/tip.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/alembic/broken/alembic.ini +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/alembic/broken/migrations/versions/not_a_revision.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/alembic/broken/migrations/versions/ok1_fine.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/alembic/linear/alembic.ini +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/alembic/linear/migrations/env.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/alembic/linear/migrations/versions/a1_create_owners.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/alembic/linear/migrations/versions/b2_add_pets.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/alembic/linear/migrations/versions/c3_add_visits.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/alembic/modern_template/alembic.ini +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/alembic/modern_template/migrations/versions/1f2e3d4c5b6a_initial.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/alembic/modern_template/migrations/versions/9a8b7c6d5e4f_add_index.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/alembic/package_dir/alembic.ini +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/alembic/package_dir/sharpit_alembic_fixture_pkg/__init__.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/alembic/package_dir/sharpit_alembic_fixture_pkg/migrations/versions/p1_first.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/bootui/beans.json +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/bootui/config.json +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/bootui/health.json +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/bootui/loggers.json +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/bootui/mappings.json +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/bootui/meta.json +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/bootui/overview.json +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/bootui/panels.json +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/bootui/vulnerabilities.json +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/bootui_tools_0_2_0.json +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/epss/CVE-2024-34064.json +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/getenv_corpus/pkg/__init__.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/getenv_corpus/pkg/forms.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/osv/GHSA-h75v-3vvj-5mfj.json +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/osv/PYSEC-2017-9999.json +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/osv/querybatch.json +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/fixtures/restapi/rest_api_check_ids.txt +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/overhead.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/pytest_speed_exceptions.json +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/test_code_shape.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/test_conformance.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/test_dogfood_sqla.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/test_durations.json +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/test_durations.meta.json +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/test_example_app.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/test_fixtures.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/test_overhead_check.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/test_overhead_harness.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/test_pytest_speed_check.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/test_release_workflow.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/test_safety_matrix.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/test_sanitize_golden.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/test_sonar_ratchet.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/tests/test_sqla_sample_smoke.py +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/website/docs/activation.md +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/website/docs/how-it-works.md +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/website/docs/installation.md +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/website/docs/mcp.md +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/website/docs/panels.md +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/website/docs/quickstart.md +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/website/docs/safety.md +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/website/requirements.in +0 -0
- {sharpit-0.2.0 → sharpit-0.3.0}/website/requirements.txt +0 -0
|
@@ -5,6 +5,26 @@ and the project uses [Semantic Versioning](https://semver.org/).
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [0.3.0] - 2026-11-01
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Finding contract (`Finding`, `AdvisorRun`) and advisor registry with pass/fail/unknown status semantics (#19).
|
|
13
|
+
- `pytest --sharpit` plugin with test-id tagging, unattributed bucket, phase split, xdist merge, and JSON (`sharpit-report/1`) and JUnit reports (#20). Count gates (queries per test with `--sharpit-max-queries`, N+1, swallowed exceptions) fail the test; advisor findings at or above `--sharpit-fail-on` fail the run; `unknown` fails it unless `--sharpit-allow-unknown` (limit for unattributed SQL: `--sharpit-max-unattributed`).
|
|
14
|
+
- Per-test budget marker `@pytest.mark.sharpit(max_queries=..., allow_n_plus_one=..., max_exceptions=...)` (#21).
|
|
15
|
+
- REST API advisor on the contract, per-finding dismissal via fingerprint in `sharpit.yml`, and panel detail action (#22).
|
|
16
|
+
- Raw `sqlite3` SQL source, unified source dispatcher, and public `attach_sql_sources()` / `detach_sql_sources()` helpers (#23).
|
|
17
|
+
- `SHARPIT_SQL_TRACE_SQLITE3_ENABLED` (`sql_trace_sqlite3_enabled`, default `true`) controls the raw `sqlite3` source in the console; `pytest --sharpit` always attaches it.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- REST API scanner evidence for an app with no routes reports `usable: false, coverageComplete: true` (confirmed-empty scope), matching BootUI.
|
|
22
|
+
- REST API finding targets now name the handler (`<METHOD> <path> <module:qualname>`), so two handlers on one route stay two findings; fingerprints of 0.3.0 REST API findings depend on it.
|
|
23
|
+
- The test-session SQL filter treats migration tables (`alembic_version`, `schema_migrations`, `flyway_schema_history`, `django_migrations`, `knex_migrations`) as noise, not only `alembic_version`.
|
|
24
|
+
- A rule whose every occurrence is dismissed by fingerprint stays `dismissed: false` with a count of 0.
|
|
25
|
+
- The JUnit report fails only non-dismissed findings at or above `--sharpit-fail-on`.
|
|
26
|
+
- Secret values matching vendor token prefixes (`sk_live_`, `sk_test_`, `ghp_`, `glpat-`, `xoxb-`, `AIza`, `sk-ant-`, `sk-proj-`, and related keys) are masked.
|
|
27
|
+
|
|
8
28
|
## [0.2.0] - 2026-10-31
|
|
9
29
|
|
|
10
30
|
### Added
|
|
@@ -89,6 +109,7 @@ Listed in section 14 of the design spec. The main ones:
|
|
|
89
109
|
- Behind a TLS-terminating proxy, uvicorn needs `--proxy-headers` for the Origin check to pass.
|
|
90
110
|
- Masking is name- and shape-based: vendor-prefixed tokens under harmless names (`sk_live_...`, `ghp_...`) can show.
|
|
91
111
|
|
|
92
|
-
[Unreleased]: https://github.com/ffroliva/sharpit/compare/v0.
|
|
112
|
+
[Unreleased]: https://github.com/ffroliva/sharpit/compare/v0.3.0...HEAD
|
|
113
|
+
[0.3.0]: https://github.com/ffroliva/sharpit/releases/tag/v0.3.0
|
|
93
114
|
[0.2.0]: https://github.com/ffroliva/sharpit/releases/tag/v0.2.0
|
|
94
115
|
[0.1.0]: https://github.com/ffroliva/sharpit/releases/tag/v0.1.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: sharpit
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Embedded, local-only developer console for Python apps (a port of BootUI).
|
|
5
5
|
Project-URL: Homepage, https://github.com/ffroliva/sharpit
|
|
6
6
|
Project-URL: Source, https://github.com/ffroliva/sharpit
|
|
@@ -36,8 +36,11 @@ Requires-Dist: aiosqlite>=0.20; extra == 'test'
|
|
|
36
36
|
Requires-Dist: alembic>=1.13; extra == 'test'
|
|
37
37
|
Requires-Dist: fastapi>=0.115; extra == 'test'
|
|
38
38
|
Requires-Dist: httpx>=0.27; extra == 'test'
|
|
39
|
+
Requires-Dist: jsonschema>=4.21; extra == 'test'
|
|
39
40
|
Requires-Dist: pydantic-settings>=2.4; extra == 'test'
|
|
41
|
+
Requires-Dist: pytest-asyncio>=0.24; extra == 'test'
|
|
40
42
|
Requires-Dist: pytest-cov>=5; extra == 'test'
|
|
43
|
+
Requires-Dist: pytest-rerunfailures>=14; extra == 'test'
|
|
41
44
|
Requires-Dist: pytest-timeout>=2.3; extra == 'test'
|
|
42
45
|
Requires-Dist: pytest-xdist>=3.6; extra == 'test'
|
|
43
46
|
Requires-Dist: pytest>=8; extra == 'test'
|
|
@@ -76,7 +79,7 @@ Spring Boot developer console. It ports BootUI's design goals, JSON contract and
|
|
|
76
79
|
|
|
77
80
|

|
|
78
81
|
|
|
79
|
-
> **Status: alpha (0.
|
|
82
|
+
> **Status: alpha (0.3.0, FastAPI only).** Django and Flask are not supported. See [CHANGELOG.md](https://github.com/ffroliva/sharpit/blob/main/CHANGELOG.md).
|
|
80
83
|
|
|
81
84
|
## Install
|
|
82
85
|
|
|
@@ -132,12 +135,29 @@ Other options are keyword arguments or environment variables, see [Settings](htt
|
|
|
132
135
|
|
|
133
136
|
If `/sharpit` answers 404, read [Activation](https://ffroliva.github.io/sharpit/activation/): sharpit stays off unless a dev signal turns it on.
|
|
134
137
|
|
|
138
|
+
## Gate CI on findings
|
|
139
|
+
|
|
140
|
+
sharpit turns runtime capture into automated test gates with `pytest --sharpit`. It tracks SQL
|
|
141
|
+
statements and observable exceptions per test, detects N+1 queries, checks query budgets, and runs
|
|
142
|
+
static analysis advisors. If a test exceeds its query budget, triggers an N+1 query, or swallows an
|
|
143
|
+
unhandled exception, the build fails. When capture cannot see enough to judge, the run status is
|
|
144
|
+
`unknown` and fails closed.
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
pytest --sharpit --sharpit-report=sharpit-report.json --sharpit-junit=sharpit-junit.xml
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Read [Pytest plugin](https://ffroliva.github.io/sharpit/pytest-plugin/) and [Test report](https://ffroliva.github.io/sharpit/report/) for options, gates, and CI examples.
|
|
151
|
+
|
|
135
152
|
## Documentation
|
|
136
153
|
|
|
137
154
|
The full documentation is at **<https://ffroliva.github.io/sharpit/>**:
|
|
138
155
|
|
|
139
156
|
- [Activation](https://ffroliva.github.io/sharpit/activation/): when sharpit turns on, and why a plain `uvicorn app:app` gives 404
|
|
140
157
|
- [Panels](https://ffroliva.github.io/sharpit/panels/): what each panel shows
|
|
158
|
+
- [Pytest plugin](https://ffroliva.github.io/sharpit/pytest-plugin/): CI gates for queries, N+1, exceptions, and advisors
|
|
159
|
+
- [Test report](https://ffroliva.github.io/sharpit/report/): the `sharpit-report/1` JSON schema and JUnit XML
|
|
160
|
+
- [SQL sources](https://ffroliva.github.io/sharpit/sql-sources/): tracing SQLAlchemy and raw `sqlite3`
|
|
141
161
|
- [MCP for AI agents](https://ffroliva.github.io/sharpit/mcp/): the read-only MCP endpoint and its 18 tools
|
|
142
162
|
- [Settings](https://ffroliva.github.io/sharpit/settings/): every environment variable and `install()` keyword
|
|
143
163
|
- [Safety model](https://ffroliva.github.io/sharpit/safety/): local-only guard, tokens, masking, proxies and workers
|
|
@@ -28,7 +28,7 @@ Spring Boot developer console. It ports BootUI's design goals, JSON contract and
|
|
|
28
28
|
|
|
29
29
|

|
|
30
30
|
|
|
31
|
-
> **Status: alpha (0.
|
|
31
|
+
> **Status: alpha (0.3.0, FastAPI only).** Django and Flask are not supported. See [CHANGELOG.md](https://github.com/ffroliva/sharpit/blob/main/CHANGELOG.md).
|
|
32
32
|
|
|
33
33
|
## Install
|
|
34
34
|
|
|
@@ -84,12 +84,29 @@ Other options are keyword arguments or environment variables, see [Settings](htt
|
|
|
84
84
|
|
|
85
85
|
If `/sharpit` answers 404, read [Activation](https://ffroliva.github.io/sharpit/activation/): sharpit stays off unless a dev signal turns it on.
|
|
86
86
|
|
|
87
|
+
## Gate CI on findings
|
|
88
|
+
|
|
89
|
+
sharpit turns runtime capture into automated test gates with `pytest --sharpit`. It tracks SQL
|
|
90
|
+
statements and observable exceptions per test, detects N+1 queries, checks query budgets, and runs
|
|
91
|
+
static analysis advisors. If a test exceeds its query budget, triggers an N+1 query, or swallows an
|
|
92
|
+
unhandled exception, the build fails. When capture cannot see enough to judge, the run status is
|
|
93
|
+
`unknown` and fails closed.
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
pytest --sharpit --sharpit-report=sharpit-report.json --sharpit-junit=sharpit-junit.xml
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Read [Pytest plugin](https://ffroliva.github.io/sharpit/pytest-plugin/) and [Test report](https://ffroliva.github.io/sharpit/report/) for options, gates, and CI examples.
|
|
100
|
+
|
|
87
101
|
## Documentation
|
|
88
102
|
|
|
89
103
|
The full documentation is at **<https://ffroliva.github.io/sharpit/>**:
|
|
90
104
|
|
|
91
105
|
- [Activation](https://ffroliva.github.io/sharpit/activation/): when sharpit turns on, and why a plain `uvicorn app:app` gives 404
|
|
92
106
|
- [Panels](https://ffroliva.github.io/sharpit/panels/): what each panel shows
|
|
107
|
+
- [Pytest plugin](https://ffroliva.github.io/sharpit/pytest-plugin/): CI gates for queries, N+1, exceptions, and advisors
|
|
108
|
+
- [Test report](https://ffroliva.github.io/sharpit/report/): the `sharpit-report/1` JSON schema and JUnit XML
|
|
109
|
+
- [SQL sources](https://ffroliva.github.io/sharpit/sql-sources/): tracing SQLAlchemy and raw `sqlite3`
|
|
93
110
|
- [MCP for AI agents](https://ffroliva.github.io/sharpit/mcp/): the read-only MCP endpoint and its 18 tools
|
|
94
111
|
- [Settings](https://ffroliva.github.io/sharpit/settings/): every environment variable and `install()` keyword
|
|
95
112
|
- [Safety model](https://ffroliva.github.io/sharpit/safety/): local-only guard, tokens, masking, proxies and workers
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://github.com/ffroliva/sharpit/blob/main/docs/reference/report.schema.json",
|
|
4
|
+
"title": "sharpit-report/1",
|
|
5
|
+
"description": "The report `pytest --sharpit --sharpit-report <path>` writes. Every key is emitted, nulls included. Adding a key is a minor change within /1: consumers must ignore unknown keys. Removing or renaming a key, or changing a meaning, is /2.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": true,
|
|
8
|
+
"required": [
|
|
9
|
+
"schema",
|
|
10
|
+
"tool",
|
|
11
|
+
"generatedAt",
|
|
12
|
+
"status",
|
|
13
|
+
"statusReasons",
|
|
14
|
+
"warnings",
|
|
15
|
+
"gates",
|
|
16
|
+
"sources",
|
|
17
|
+
"workers",
|
|
18
|
+
"severityCounts",
|
|
19
|
+
"totals",
|
|
20
|
+
"tests",
|
|
21
|
+
"unattributed",
|
|
22
|
+
"filtered",
|
|
23
|
+
"advisors",
|
|
24
|
+
"findings"
|
|
25
|
+
],
|
|
26
|
+
"properties": {
|
|
27
|
+
"schema": {"const": "sharpit-report/1"},
|
|
28
|
+
"tool": {
|
|
29
|
+
"type": "object",
|
|
30
|
+
"additionalProperties": true,
|
|
31
|
+
"required": ["name", "version"],
|
|
32
|
+
"properties": {"name": {"const": "sharpit"}, "version": {"type": "string"}}
|
|
33
|
+
},
|
|
34
|
+
"generatedAt": {"type": "integer", "description": "Epoch milliseconds."},
|
|
35
|
+
"status": {"enum": ["pass", "fail", "unknown"]},
|
|
36
|
+
"statusReasons": {"type": "array", "items": {"type": "string"}},
|
|
37
|
+
"warnings": {"type": "array", "items": {"type": "string"}},
|
|
38
|
+
"gates": {
|
|
39
|
+
"type": "object",
|
|
40
|
+
"additionalProperties": true,
|
|
41
|
+
"required": ["maxQueriesPerTest", "nPlusOneThreshold", "failOnSeverity", "allowUnknown", "maxUnattributedPercent"],
|
|
42
|
+
"properties": {
|
|
43
|
+
"maxQueriesPerTest": {"type": ["integer", "null"]},
|
|
44
|
+
"nPlusOneThreshold": {"type": "integer"},
|
|
45
|
+
"failOnSeverity": {"enum": ["CRITICAL", "HIGH", "MEDIUM", "LOW", "INFO"]},
|
|
46
|
+
"allowUnknown": {"type": "boolean"},
|
|
47
|
+
"maxUnattributedPercent": {"type": "number"}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"sources": {"type": "array", "items": {"$ref": "#/$defs/source"}},
|
|
51
|
+
"workers": {"type": "array", "items": {"$ref": "#/$defs/worker"}},
|
|
52
|
+
"severityCounts": {
|
|
53
|
+
"type": "array",
|
|
54
|
+
"description": "CRITICAL, HIGH, MEDIUM, LOW, INFO in that order, zeros included, after dismissal.",
|
|
55
|
+
"items": {"$ref": "#/$defs/severityCount"}
|
|
56
|
+
},
|
|
57
|
+
"totals": {
|
|
58
|
+
"type": "object",
|
|
59
|
+
"additionalProperties": true,
|
|
60
|
+
"required": ["tests", "queries", "filtered", "unattributed", "unattributedShare", "exceptions"],
|
|
61
|
+
"properties": {
|
|
62
|
+
"tests": {"type": "integer"},
|
|
63
|
+
"queries": {"type": "integer"},
|
|
64
|
+
"filtered": {"type": "integer"},
|
|
65
|
+
"unattributed": {"type": "integer"},
|
|
66
|
+
"unattributedShare": {"type": "number", "description": "Percent, one decimal."},
|
|
67
|
+
"exceptions": {"type": "integer"}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"tests": {"type": "array", "items": {"$ref": "#/$defs/test"}},
|
|
71
|
+
"unattributed": {
|
|
72
|
+
"type": "object",
|
|
73
|
+
"additionalProperties": true,
|
|
74
|
+
"required": ["queries", "topStatements"],
|
|
75
|
+
"properties": {
|
|
76
|
+
"queries": {"type": "integer"},
|
|
77
|
+
"topStatements": {"type": "array", "maxItems": 20, "items": {"$ref": "#/$defs/statement"}}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"filtered": {
|
|
81
|
+
"type": "object",
|
|
82
|
+
"additionalProperties": true,
|
|
83
|
+
"required": ["count", "rules"],
|
|
84
|
+
"properties": {"count": {"type": "integer"}, "rules": {"type": "array", "items": {"type": "string"}}}
|
|
85
|
+
},
|
|
86
|
+
"advisors": {"type": "array", "items": {"$ref": "#/$defs/advisor"}},
|
|
87
|
+
"findings": {"type": "array", "items": {"$ref": "#/$defs/finding"}}
|
|
88
|
+
},
|
|
89
|
+
"$defs": {
|
|
90
|
+
"source": {
|
|
91
|
+
"type": "object",
|
|
92
|
+
"additionalProperties": true,
|
|
93
|
+
"required": ["name", "attached", "reason", "limitations"],
|
|
94
|
+
"properties": {
|
|
95
|
+
"name": {"type": "string"},
|
|
96
|
+
"attached": {"type": "boolean"},
|
|
97
|
+
"reason": {"type": ["string", "null"]},
|
|
98
|
+
"limitations": {"type": "array", "items": {"type": "string"}}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"worker": {
|
|
102
|
+
"type": "object",
|
|
103
|
+
"additionalProperties": true,
|
|
104
|
+
"required": ["id", "status"],
|
|
105
|
+
"properties": {"id": {"type": "string"}, "status": {"enum": ["ok", "missing"]}}
|
|
106
|
+
},
|
|
107
|
+
"severityCount": {
|
|
108
|
+
"type": "object",
|
|
109
|
+
"additionalProperties": true,
|
|
110
|
+
"required": ["severity", "count"],
|
|
111
|
+
"properties": {
|
|
112
|
+
"severity": {"enum": ["CRITICAL", "HIGH", "MEDIUM", "LOW", "INFO"]},
|
|
113
|
+
"count": {"type": "integer", "minimum": 0}
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"statement": {
|
|
117
|
+
"type": "object",
|
|
118
|
+
"additionalProperties": true,
|
|
119
|
+
"required": ["sql", "count"],
|
|
120
|
+
"properties": {"sql": {"type": "string", "description": "Normalised and masked; never a parameter."}, "count": {"type": "integer"}}
|
|
121
|
+
},
|
|
122
|
+
"phase": {
|
|
123
|
+
"type": "object",
|
|
124
|
+
"additionalProperties": true,
|
|
125
|
+
"required": ["queries", "filtered", "exceptions"],
|
|
126
|
+
"properties": {
|
|
127
|
+
"queries": {"type": "integer"},
|
|
128
|
+
"filtered": {"type": "integer"},
|
|
129
|
+
"exceptions": {"type": "integer"}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"test": {
|
|
133
|
+
"type": "object",
|
|
134
|
+
"additionalProperties": true,
|
|
135
|
+
"required": ["nodeId", "worker", "attempt", "outcome", "budget", "phases", "nPlusOne", "findings"],
|
|
136
|
+
"properties": {
|
|
137
|
+
"nodeId": {"type": "string"},
|
|
138
|
+
"worker": {"type": "string"},
|
|
139
|
+
"attempt": {"type": "integer", "minimum": 1},
|
|
140
|
+
"outcome": {"enum": ["passed", "failed", "skipped", "error", null]},
|
|
141
|
+
"budget": {
|
|
142
|
+
"oneOf": [
|
|
143
|
+
{"type": "null"},
|
|
144
|
+
{
|
|
145
|
+
"type": "object",
|
|
146
|
+
"additionalProperties": true,
|
|
147
|
+
"required": ["maxQueries", "allowNPlusOne", "maxExceptions"],
|
|
148
|
+
"properties": {
|
|
149
|
+
"maxQueries": {"type": ["integer", "null"]},
|
|
150
|
+
"allowNPlusOne": {"type": "boolean"},
|
|
151
|
+
"maxExceptions": {"type": "integer"}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
"phases": {
|
|
157
|
+
"type": "object",
|
|
158
|
+
"additionalProperties": true,
|
|
159
|
+
"required": ["setup", "call", "teardown"],
|
|
160
|
+
"properties": {
|
|
161
|
+
"setup": {"$ref": "#/$defs/phase"},
|
|
162
|
+
"call": {"$ref": "#/$defs/phase"},
|
|
163
|
+
"teardown": {"$ref": "#/$defs/phase"}
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
"nPlusOne": {"type": "array", "maxItems": 10, "items": {"$ref": "#/$defs/statement"}},
|
|
167
|
+
"findings": {"type": "array", "items": {"type": "string", "description": "A fingerprint listed in the top-level findings."}}
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
"evidence": {"type": "object", "additionalProperties": true},
|
|
171
|
+
"advisor": {
|
|
172
|
+
"type": "object",
|
|
173
|
+
"additionalProperties": true,
|
|
174
|
+
"required": ["advisor", "status", "reason", "apps", "findings"],
|
|
175
|
+
"properties": {
|
|
176
|
+
"advisor": {"type": "string"},
|
|
177
|
+
"status": {"enum": ["PASSED", "FAILED", "UNKNOWN"]},
|
|
178
|
+
"reason": {"type": ["string", "null"]},
|
|
179
|
+
"apps": {
|
|
180
|
+
"type": "array",
|
|
181
|
+
"items": {
|
|
182
|
+
"type": "object",
|
|
183
|
+
"additionalProperties": true,
|
|
184
|
+
"required": ["app", "status", "reason", "evidence"],
|
|
185
|
+
"properties": {
|
|
186
|
+
"app": {"type": ["string", "null"], "description": "<title>#<8 hex>: the app's content identity."},
|
|
187
|
+
"status": {"enum": ["PASSED", "FAILED", "UNKNOWN"]},
|
|
188
|
+
"reason": {"type": ["string", "null"]},
|
|
189
|
+
"evidence": {"$ref": "#/$defs/evidence"}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
"findings": {"type": "array", "items": {"$ref": "#/$defs/finding"}}
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
"finding": {
|
|
197
|
+
"type": "object",
|
|
198
|
+
"additionalProperties": true,
|
|
199
|
+
"required": ["ruleId", "advisor", "severity", "target", "message", "fingerprint", "testNodeId", "dismissed"],
|
|
200
|
+
"properties": {
|
|
201
|
+
"ruleId": {"type": "string"},
|
|
202
|
+
"advisor": {"type": "string"},
|
|
203
|
+
"severity": {"enum": ["CRITICAL", "HIGH", "MEDIUM", "LOW", "INFO"]},
|
|
204
|
+
"target": {"type": "string"},
|
|
205
|
+
"message": {"type": "string"},
|
|
206
|
+
"fingerprint": {"type": "string", "pattern": "^[A-Za-z0-9._:-]{1,200}$"},
|
|
207
|
+
"testNodeId": {"type": ["string", "null"]},
|
|
208
|
+
"dismissed": {"type": "boolean"}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# gflow-cli under `pytest --sharpit` (0.3.0 proof, 2026-11-01)
|
|
2
|
+
|
|
3
|
+
gflow-cli is a public FastAPI daemon that stores everything in raw `sqlite3` (no SQLAlchemy). It was run with the
|
|
4
|
+
0.3.0 integration branch to prove the out-of-code use (spec §12, plan Task 10).
|
|
5
|
+
|
|
6
|
+
## Setup
|
|
7
|
+
|
|
8
|
+
- gflow-cli worktree `.worktrees/sharpit-proof`, branch `chore/sharpit-dev-wrapper` from gflow-cli's default branch at 592f988d.
|
|
9
|
+
- `dev/sharpit_app.py` (outside the wheel; hatch packages only `src/gflow_cli`): `sharpit.attach_sql_sources()`, then
|
|
10
|
+
`from gflow_cli.ui.app import app`, then `sharpit.install(app)`. Shipped code never imports sharpit.
|
|
11
|
+
- `tests/dev/test_sharpit_wrapper_outside_wheel.py` pins hardening row A1: wheel packages, wrapper location, no runtime
|
|
12
|
+
dependency, no `import sharpit` under `src/`. Red first (wrapper moved away: `test_wrapper_lives_outside_the_package`
|
|
13
|
+
failed on its assertion), then green (4 passed).
|
|
14
|
+
- Run: `uv run --with-editable <sharpit 0.3.0 integration> pytest -q -n 4 --sharpit --sharpit-app dev.sharpit_app:app`.
|
|
15
|
+
|
|
16
|
+
## Result
|
|
17
|
+
|
|
18
|
+
| | |
|
|
19
|
+
|---|---|
|
|
20
|
+
| Tests | 5,662 (5,646 passed, 11 skipped, 5 failed by sharpit gates only) |
|
|
21
|
+
| Wall time | 5 min 27 s with `-n 4` |
|
|
22
|
+
| SQL statements | 27,997 attributed, 25,092 filtered (PRAGMAs and schema reads), **0 unattributed** |
|
|
23
|
+
| Sources | `sqlite3` attached, exceptions attached, no SQLAlchemy |
|
|
24
|
+
| Status | `fail`: "5 tests failed sharpit gates" |
|
|
25
|
+
| Swallowed exceptions | 0 |
|
|
26
|
+
|
|
27
|
+
The 5 failing tests pass without `--sharpit` (22 passed in those two files), so every failure is a sharpit gate.
|
|
28
|
+
|
|
29
|
+
Heaviest tests by call-phase queries: `test_cli_run.py` resume tests (101, 90, 88, 81),
|
|
30
|
+
`test_reference_uploads.py::test_a_recorded_image_deleted_from_the_project_is_uploaded_again` (71), the
|
|
31
|
+
`TestGflowRunCommand` happy paths (65).
|
|
32
|
+
|
|
33
|
+
## Findings
|
|
34
|
+
|
|
35
|
+
| Rule | Test | Statement | Read |
|
|
36
|
+
|---|---|---|---|
|
|
37
|
+
| `sharpit.n-plus-one` ×2 | `tests/mcp/test_wait_false_runs.py::test_a_detached_job_and_a_waiting_call_share_the_profile` | `SELECT version FROM schema_migrations`, `SELECT version, checksum FROM schema_migrations` | noise: gflow's own migration table, opened per connection. The built-in filter knows only `alembic_version` |
|
|
38
|
+
| `sharpit.n-plus-one` ×3 | the three cancel/status tests in `test_wait_false_runs.py` | `SELECT task_id, ... FROM` the queue table | polling a job row until it changes state: expected in these tests (`allow_n_plus_one` on them), worth a look in the waiter |
|
|
39
|
+
| `sharpit.n-plus-one` | `tests/data/test_repository.py::test_get_asset_by_any_id_resolves_media_workflow_and_asset_ids` | `SELECT ... FROM assets` | a real repeated lookup in `get_asset_by_any_id` |
|
|
40
|
+
| REST API (INFO ×7) | app-wide | `RAPI-DOC-001/002`, `RAPI-ERR-001`, `RAPI-MAP-005`, `RAPI-VER-001` | below the HIGH gate; reported, not failing |
|
|
41
|
+
|
|
42
|
+
The `rest-api` advisor reported `UNKNOWN`: "Mounted application at /mcp/messages has no inspectable routes" (the MCP
|
|
43
|
+
SSE sub-app). With no gate failures that alone would make the run `unknown`; gflow would pass
|
|
44
|
+
`--sharpit-no-advisors` or accept unknown until mounted sub-apps are inspectable.
|
|
45
|
+
|
|
46
|
+
## What this changed in sharpit
|
|
47
|
+
|
|
48
|
+
- The `schema_migrations` noise led to widening the built-in filter to common migration tables (see the 0.3.0 review
|
|
49
|
+
fixes).
|
|
50
|
+
- No gflow-cli PR is opened without the owner's yes; the proposed CI job is in this report's companion branch only.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Fixtures for the sharpit CI gate demo: the sample app on a fresh, migrated-by-hand SQLite file."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import sqlite3
|
|
6
|
+
from collections.abc import Iterator
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
import pytest
|
|
10
|
+
from examples.fastapi_sqla.app import create_app
|
|
11
|
+
from fastapi.testclient import TestClient
|
|
12
|
+
|
|
13
|
+
SCHEMA = """
|
|
14
|
+
CREATE TABLE owners (id INTEGER PRIMARY KEY, name VARCHAR(100) NOT NULL, email VARCHAR(200));
|
|
15
|
+
CREATE TABLE pets (id INTEGER PRIMARY KEY, owner_id INTEGER NOT NULL REFERENCES owners(id),
|
|
16
|
+
name VARCHAR(100) NOT NULL, species VARCHAR(50) NOT NULL);
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@pytest.fixture
|
|
21
|
+
def client(tmp_path: Path) -> Iterator[TestClient]:
|
|
22
|
+
with sqlite3.connect(tmp_path / "sample.db") as db:
|
|
23
|
+
db.executescript(SCHEMA)
|
|
24
|
+
app = create_app(db_dir=tmp_path, show_banner=False)
|
|
25
|
+
try:
|
|
26
|
+
with TestClient(app, base_url="http://localhost", client=("127.0.0.1", 50000)) as test_client:
|
|
27
|
+
yield test_client
|
|
28
|
+
finally:
|
|
29
|
+
app.state.sharpit.uninstall_capture()
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""One planted N+1 (red) and its fix (green): what `pytest --sharpit` gates on in CI.
|
|
2
|
+
|
|
3
|
+
CI runs the `fixed` test and requires it to pass, then runs the `n_plus_one` test and requires it to fail.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from fastapi.testclient import TestClient
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_owners_list_n_plus_one(client: TestClient) -> None:
|
|
12
|
+
assert client.get("/owners/n-plus-one").status_code == 200
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_owners_list_fixed(client: TestClient) -> None:
|
|
16
|
+
assert client.get("/owners").status_code == 200
|
|
@@ -29,6 +29,9 @@ classifiers = [
|
|
|
29
29
|
]
|
|
30
30
|
dependencies = ["starlette>=0.44", "packaging>=23"]
|
|
31
31
|
|
|
32
|
+
[project.entry-points.pytest11]
|
|
33
|
+
sharpit = "sharpit.pytest_plugin"
|
|
34
|
+
|
|
32
35
|
[project.urls]
|
|
33
36
|
Homepage = "https://github.com/ffroliva/sharpit"
|
|
34
37
|
Source = "https://github.com/ffroliva/sharpit"
|
|
@@ -51,6 +54,9 @@ test = [
|
|
|
51
54
|
"sqlalchemy[asyncio]>=2.0.38",
|
|
52
55
|
"aiosqlite>=0.20",
|
|
53
56
|
"alembic>=1.13",
|
|
57
|
+
"jsonschema>=4.21",
|
|
58
|
+
"pytest-asyncio>=0.24",
|
|
59
|
+
"pytest-rerunfailures>=14",
|
|
54
60
|
]
|
|
55
61
|
|
|
56
62
|
[dependency-groups]
|
|
@@ -105,3 +111,7 @@ timeout = 60
|
|
|
105
111
|
markers = [
|
|
106
112
|
"needs_sqlalchemy: needs SQLAlchemy, aiosqlite or greenlet installed (the no-sqlalchemy CI job deselects it)",
|
|
107
113
|
]
|
|
114
|
+
|
|
115
|
+
[tool.coverage.run]
|
|
116
|
+
# the pytest plugin tests run pytest in a subprocess (pytester.runpytest_subprocess); measure those too
|
|
117
|
+
patch = ["subprocess"]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""sharpit: embedded, local-only developer console for Python apps."""
|
|
2
|
+
|
|
3
|
+
__version__ = "0.3.0"
|
|
4
|
+
|
|
5
|
+
from sharpit.fastapi.adapter import install # noqa: E402 - after __version__, which the adapter's modules read
|
|
6
|
+
from sharpit.fastapi.sources import attach_sql_sources, detach_sql_sources # noqa: E402
|
|
7
|
+
|
|
8
|
+
__all__ = ["__version__", "attach_sql_sources", "detach_sql_sources", "install"]
|
|
@@ -18,15 +18,14 @@ import tempfile
|
|
|
18
18
|
import threading
|
|
19
19
|
from pathlib import Path
|
|
20
20
|
|
|
21
|
-
from sharpit.engine.
|
|
21
|
+
from sharpit.engine.advisors.registry import advisor_for
|
|
22
22
|
from sharpit.engine.paging import BadRequest
|
|
23
23
|
|
|
24
24
|
FILE_NAME = "sharpit.yml"
|
|
25
25
|
_KEY = "dismissedRules"
|
|
26
26
|
_HEADER = "# sharpit configuration (developer-local; safe to delete)."
|
|
27
|
+
NO_PANEL_MESSAGE = "Findings of advisor '{advisor}' are dismissed in sharpit.yml"
|
|
27
28
|
_RULE_ID = re.compile(r"[A-Za-z0-9._:-]{1,200}")
|
|
28
|
-
# the vulnerability shape is exactly what rule_id() builds from a PEP 503 name
|
|
29
|
-
_VULNERABILITY = re.compile(r"[A-Za-z0-9._:-]+::pypi:[a-z0-9._-]+")
|
|
30
29
|
|
|
31
30
|
|
|
32
31
|
def rule_id(vuln_id: str, package_name: str) -> str:
|
|
@@ -37,9 +36,8 @@ def owning_panel(rule_id: str) -> str | None:
|
|
|
37
36
|
"""The panel whose gate covers dismissing ``rule_id``; None for an id no advisor owns (refused with a 400)."""
|
|
38
37
|
if not _RULE_ID.fullmatch(rule_id):
|
|
39
38
|
return None
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return "vulnerabilities" if _VULNERABILITY.fullmatch(rule_id) else None
|
|
39
|
+
spec = advisor_for(rule_id) # an unported or unknown RAPI- id has no owner
|
|
40
|
+
return spec.panel if spec else None
|
|
43
41
|
|
|
44
42
|
|
|
45
43
|
class DismissalStore:
|
|
@@ -129,8 +127,12 @@ class DismissalStore:
|
|
|
129
127
|
|
|
130
128
|
|
|
131
129
|
def _validate(rule_id: str) -> None:
|
|
132
|
-
if
|
|
133
|
-
|
|
130
|
+
spec = advisor_for(rule_id) if _RULE_ID.fullmatch(rule_id) else None
|
|
131
|
+
if spec is not None and spec.panel is not None:
|
|
132
|
+
return
|
|
133
|
+
if spec is not None: # owned, but by an advisor with no panel whose gate covers the HTTP route
|
|
134
|
+
raise BadRequest(NO_PANEL_MESSAGE.format(advisor=spec.id))
|
|
135
|
+
raise BadRequest(f"Invalid rule id '{rule_id}'")
|
|
134
136
|
|
|
135
137
|
|
|
136
138
|
def _is_top_level_key(line: str) -> bool:
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"""The finding contract (0.3.0 spec §5.2-5.3): ``Finding``, ``AdvisorRun`` and ``severity_counts_of``."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import hashlib
|
|
6
|
+
from collections.abc import Iterable
|
|
7
|
+
from dataclasses import dataclass
|
|
8
|
+
from typing import Any, Literal
|
|
9
|
+
|
|
10
|
+
from sharpit.engine.advisors.report import severity_counts
|
|
11
|
+
from sharpit.engine.advisors.rules import SEVERITIES, Severity, severity_rank
|
|
12
|
+
|
|
13
|
+
_FALLBACK_REASON = "assessment evidence is incomplete"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass(frozen=True)
|
|
17
|
+
class Finding:
|
|
18
|
+
rule_id: str
|
|
19
|
+
advisor: str
|
|
20
|
+
severity: Severity
|
|
21
|
+
target: str
|
|
22
|
+
message: str
|
|
23
|
+
test_node_id: str | None = None
|
|
24
|
+
dismissed: bool = False
|
|
25
|
+
identity: str | None = None
|
|
26
|
+
|
|
27
|
+
@property
|
|
28
|
+
def fingerprint(self) -> str:
|
|
29
|
+
"""``<advisor>:<rule>:<16 hex>``; the hash input holds no path or timestamp, so it survives reformatting."""
|
|
30
|
+
material = "\x1f".join((self.rule_id, self.identity or self.target, self.test_node_id or ""))
|
|
31
|
+
digest = hashlib.sha256(material.encode("utf-8")).hexdigest()[:16]
|
|
32
|
+
return f"{self.advisor}:{self.rule_id}:{digest}"
|
|
33
|
+
|
|
34
|
+
def to_dto(self) -> dict[str, Any]:
|
|
35
|
+
return {
|
|
36
|
+
"ruleId": self.rule_id,
|
|
37
|
+
"advisor": self.advisor,
|
|
38
|
+
"severity": self.severity,
|
|
39
|
+
"target": self.target,
|
|
40
|
+
"message": self.message,
|
|
41
|
+
"fingerprint": self.fingerprint,
|
|
42
|
+
"testNodeId": self.test_node_id,
|
|
43
|
+
"dismissed": self.dismissed,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@dataclass(frozen=True)
|
|
48
|
+
class AdvisorRun:
|
|
49
|
+
advisor: str
|
|
50
|
+
status: Literal["PASSED", "FAILED", "UNKNOWN"]
|
|
51
|
+
findings: tuple[Finding, ...]
|
|
52
|
+
evidence: dict[str, Any]
|
|
53
|
+
reason: str | None
|
|
54
|
+
app: str | None = None
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def of(
|
|
58
|
+
cls,
|
|
59
|
+
advisor: str,
|
|
60
|
+
findings: Iterable[Finding],
|
|
61
|
+
evidence: dict[str, Any],
|
|
62
|
+
*,
|
|
63
|
+
scan_status: str | None = None,
|
|
64
|
+
fail_on: Severity = "HIGH",
|
|
65
|
+
app: str | None = None,
|
|
66
|
+
) -> AdvisorRun:
|
|
67
|
+
"""Derive the status (spec §5.3); it is never set by hand."""
|
|
68
|
+
found = tuple(findings)
|
|
69
|
+
gate = severity_rank(fail_on)
|
|
70
|
+
if any(not f.dismissed and severity_rank(f.severity) <= gate for f in found):
|
|
71
|
+
return cls(advisor, "FAILED", found, evidence, None, app)
|
|
72
|
+
limitations: list[str] = evidence.get("limitations") or []
|
|
73
|
+
incomplete = (
|
|
74
|
+
not evidence.get("coverageComplete")
|
|
75
|
+
or (not evidence.get("usable") and bool(limitations))
|
|
76
|
+
or scan_status in ("PARTIAL", "ERROR")
|
|
77
|
+
)
|
|
78
|
+
if incomplete:
|
|
79
|
+
return cls(advisor, "UNKNOWN", found, evidence, limitations[0] if limitations else _FALLBACK_REASON, app)
|
|
80
|
+
return cls(advisor, "PASSED", found, evidence, None, app)
|
|
81
|
+
|
|
82
|
+
def to_dto(self) -> dict[str, Any]:
|
|
83
|
+
return {
|
|
84
|
+
"advisor": self.advisor,
|
|
85
|
+
"status": self.status,
|
|
86
|
+
"reason": self.reason,
|
|
87
|
+
"app": self.app,
|
|
88
|
+
"evidence": self.evidence,
|
|
89
|
+
"findings": [f.to_dto() for f in self.findings],
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def severity_counts_of(findings: Iterable[Finding]) -> list[dict[str, Any]]:
|
|
94
|
+
"""BootUI's ``severityCounts`` form over the non-dismissed findings, one occurrence each."""
|
|
95
|
+
return severity_counts(((f.severity, 1) for f in findings if not f.dismissed), SEVERITIES)
|