Fail secure default + agent version persistance#12
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adopts
guard-core >= 3.0.0and tracks itsfail_securedefault flip with amatching major bump (3.0.0 → 4.0.0). Adds two purely additive surfaces on the
adapter:
FlaskAPIGuard.agent_statsread-only@propertyexposing the agent's bufferdrop counters and transport circuit-breaker state.
flaskapi_guard.__version__exported viaimportlib.metadata, with a"0.0.0+unknown"fallback when the package is not installed (developmentfrom source).
Mirrors fastapi-guard 7.0.0.
Related Issue
N/A — release tracking the upstream
guard-core3.0.0 default flip.Fixes #
Motivation and Context
guard-core >= 3.0.0flippedSecurityConfig.fail_securetoTruebydefault. Bugs in security checks that previously slipped past as silent
fail-open responses now surface as HTTP 500. Tracking the upstream change as a
flaskapi-guard major bump gives users a clear migration signal.
The two additive surfaces close existing gaps:
enable_agent=Truehad no first-class way to surfacebuffer drops or circuit-breaker trips on a Flask health endpoint without
reaching into
guard.agent_handler.get_stats().FlaskAPIGuard.agent_statsfixes that with a read-only property that returns
{"enabled": False}whenno agent is wired and
{"enabled": True, **agent.get_stats()}otherwise.from flaskapi_guard import __version__pairs withguard-core >= 3.0.0'snew
SecurityConfig.agent_guard_versionfield so SaaS-side telemetry canattribute events to the exact adapter release.
Type of change
The breaking change is upstream-only:
SecurityConfig.fail_securedefaultflips to
Trueviaguard-core >= 3.0.0. flaskapi-guard's own public surfaceadds two members and changes nothing.
How Has This Been Tested
Five new tests added:
tests/test_extension/test_agent_stats.pytest_agent_stats_returns_disabled_when_agent_handler_unsettest_agent_stats_returns_enabled_with_agent_handler_statstest_agent_stats_reflects_live_drop_counter_incrementstests/test_reexports.pytest_version_exported_matches_package_metadatatest_version_falls_back_when_package_metadata_missingQuality gates run locally:
uv run ruff format --check flaskapi_guard tests— cleanuv run ruff check flaskapi_guard tests— cleanuv run mypy flaskapi_guard tests— cleanuv run vulture flaskapi_guard tests vulture_whitelist.py— cleanuv run xenon --max-absolute B --max-modules A --max-average A flaskapi_guard— cleanuv run pymarkdown scan CHANGELOG.md docs/release-notes.md README.md— cleanREDIS_URL=redis://localhost:6379 uv run pytest -W error --cov=flaskapi_guard --cov-branch— 221 passed, zero warningsCoverage on touched files:
flaskapi_guard/__init__.py— 100% line, 100% branchflaskapi_guard/extension.py— 100% line, 100% branchScreenshots (if appropriate)
Checklist
importlib.metadatais stdlib)