
Security News
Security Community Slams MIT-linked Report Claiming AI Powers 80% of Ransomware
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.
flask-guard
Advanced tools
Flask Request Guard is a Python library for validating incoming HTTP requests in Flask web applications. It provides a simple yet flexible way to define request rules and enforce them automatically on incoming requests, ensuring that only requests that meet the specified requirements are allowed to proceed.
Use the package manager pip to intall flask-request-gaurd.
pip install flask-guard
from FlaskGuard import RequestParameter
# Creates a key that has the name "name" and type str with a minimum length of 0 and 
# a maximum length of 10
name_key =  RequestParameter("name", str, 0, 10)
# Creates a key that has the name "range" and type int with a minimum value of -10 and
#  a maximum value of 10
range_key = RequestParameter("range", int, -10, 10)
from FlaskGuard import  FlaskGuard
# Init FlaskRequestGuard
guard = FlaskRequestGuard("myapp")
# Keys from the code snippet above
required_keys = [range_key, name_key] 
# Returns a function that is used to check a request
validate_user_request = guard.create_validate_function(required_keys)
request = {"name": "erik", "age": 23, "range": 2}
# Returns (True, {"error_messages": []}) 
is_valid, error_messages = validate_user_request(request)
request = {"name": "eeeeeeeeeee", "age": 23, "range": 2}
# Returns (False, {"error_messages": ["The 'name' field must be 10 size or less,
#  and at least 0 size or more, but is actually 11 characters long."]})
is_valid, error_messages = validate_user_request(request)
request = {"age": 23, "range": 2}
# Returns False, {"error_messages": ["Missing name field in request body."]}
is_valid, error_messages = validate_user_request(request)
For an example where it's used with Flask, check out FlaskGuard-example repo.
Run this commad in FlaskGuard directory to run the tests
python -m unittest discover tests
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
FAQs
A library for checking if JSON requests have valid data.
We found that flask-guard demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.

Research
/Security News
Socket researchers found 10 typosquatted npm packages that auto-run on install, show fake CAPTCHAs, fingerprint by IP, and deploy a credential stealer.