Skip to content

Implement Reddit feedback/ideas#77

Merged
rennf93 merged 1 commit intomasterfrom
feature/reddit-ideas-enhancement
Mar 14, 2026
Merged

Implement Reddit feedback/ideas#77
rennf93 merged 1 commit intomasterfrom
feature/reddit-ideas-enhancement

Conversation

@rennf93
Copy link
Owner

@rennf93 rennf93 commented Mar 14, 2026

Description

Adds 5 new features to fastapi-guard v4.4.0: configurable cloud IP refresh interval, change detection logging for cloud refreshes, context-aware suspicious pattern detection, structured JSON logging, and per-provider last_updated timestamps on CloudManager. Both example apps (simple_app, advanced_app) are updated to showcase all new features via SecurityConfig options and a new /admin/cloud-status endpoint.


Related Issue

N/A


Motivation and Context

  • Cloud IP refresh was hardcoded at 1 hour with no visibility into what changed — operators need tunable intervals and diff logging.
  • The detection engine evaluated every pattern against every input source, causing false positives (e.g., SQL patterns matching URL paths). Context tagging fixes this.
  • Plain text logs don't integrate with log aggregation systems (ELK, Datadog, CloudWatch). Structured JSON output enables this.
  • No way to know when each cloud provider's IP ranges were last refreshed — last_updated makes this observable.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation change
  • Performance improvement
  • Code cleanup or refactoring

How Has This Been Tested

  • tests/test_features/test_configurable_cloud_refresh.py: validates interval range enforcement, propagation to Redis TTL, and refresh behavior
  • tests/test_features/test_context_aware_detection.py: verifies patterns only match relevant input contexts and skip irrelevant ones
  • tests/test_features/test_structured_json_logging.py: confirms JSON formatter output structure and fallback to text format
  • tests/test_features/test_last_updated_cloud.py: checks per-provider datetime tracking after refresh
  • All existing tests pass with no regressions

Screenshots (if appropriate)


Checklist

  • My code follows the code style of this project (Mypy, Ruff)
  • I have added tests to cover my changes
  • All new and existing tests passed
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have checked that my changes don't introduce any new warnings or errors
  • I have updated the version number if necessary
  • I have added any new dependencies to the appropriate requirements file

…e detection, and per-provider last_updated tracking
@rennf93 rennf93 self-assigned this Mar 14, 2026
@rennf93 rennf93 added the enhancement New feature or request label Mar 14, 2026
@rennf93 rennf93 merged commit b17164d into master Mar 14, 2026
8 of 9 checks passed
@rennf93 rennf93 deleted the feature/reddit-ideas-enhancement branch March 14, 2026 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant