-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check and hit if Flask endpoints are reachable by WAF #107
Conversation
This pull request introduces 4 alerts when merging 28b6f1f into 1998883 - view on LGTM.com new alerts:
|
This pull request introduces 4 alerts when merging 0e46fa7 into 1998883 - view on LGTM.com new alerts:
|
scripts/waffles.py
Outdated
@@ -169,6 +176,9 @@ def _load_sys(path: Path) -> None: | |||
|
|||
|
|||
def _request(endpoint: URL) -> ValidationResult: | |||
endpoint = re.sub(r"<uuid:[^>]*>", create_uuid(), endpoint) | |||
endpoint = endpoint.replace("<path:filename>", "filename.txt") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🖖
… feat/add-waffles-api-tests
from my rudimentary understanding this seems good to me. In regards to your q:
Lets do 2? But I am assuming you suggested 1 as you couldn't debug 2. Have you tested with 1 at all? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let’s test this out!
Summary | Résumé
Added Python script that checks if all Flask endpoints are accessible through AWS WAF. If it is not, it should get a
204
response. The script is meant to be executed on any Flask project, given that proper command line parameters are provided and the Flask app can list its endpoints with the default configuration.Examples
Test instructions | Instructions pour tester la modification
Via the CLI
Via VSCode
Example of VS code launcher configuration:
Help wanted | Aide requise
I ran successfully this command for the
notification-document-api-download
but it offers some challenges for other projects such asnotification-api
andnotification-admin
. Namely, the blinker dependency required by both Sentry and flask-signal triggers a load problem when the waffles logic tries to dynamically load the dependencies and evaluate the Flask application object. It seems the blinker dependency can't be found even though it is present in thesite-packages
folder.It's easy to fix within the
notification-api
component as we can disable sentry if notSENTRY_URL
environment variable was defined. At the moment, it always loads even though no such required URL exists. Hence we can avoid code paths that goes down the blinker rabbit hole by avoiding an unnecessary Sentry configuration.The
notification-admin
component is more of a challenge though. It uses flask-signal in an integral manner to the web application to signal events. These signals are auto-registered on application start up. There are two actions I see to resolve this at the moment of this writing:1- Introduce a basic configuration mode within
notification-admin
that will avoid extra initializations such as the signal libraries that depend on blinker.2- Find the root cause and fix properly: debug the loading mechanism and trace back the origin on why it cannot find a dependency that should be on the Python system path.
Reviewer checklist | Liste de vérification du réviseur
This is a suggested checklist of questions reviewers might ask during their
review | Voici une suggestion de liste de vérification comprenant des questions
que les réviseurs pourraient poser pendant leur examen :
langues officielles?
une baisse de la quantité de code couvert par les tests automatisés?
fonctionnalité existante?
que ça devrait être divisé en de plus petites demandes de tirage (« pull
requests ») afin de réduire le risque lié aux modifications?
modification de la politique de confidentialité?
préoccupations liées à la sécurité?
façon importante la performance?
risque d’utiliser des dépendances ajoutées?
setup, etc.) | Faudra-t-il mettre à jour la documentation à la suite de ce
changement (fichier README, etc.)?