diff --git a/.secrets.baseline b/.secrets.baseline index d21ca5310..983de6954 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -72,6 +72,10 @@ { "path": "detect_secrets.filters.allowlist.is_line_allowlisted" }, + { + "path": "detect_secrets.filters.common.is_baseline_file", + "filename": ".secrets.baseline" + }, { "path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies", "min_level": 2 @@ -127,7 +131,7 @@ "filename": "app/config.py", "hashed_secret": "577a4c667e4af8682ca431857214b3a920883efc", "is_verified": false, - "line_number": 432 + "line_number": 429 } ], "app/models.py": [ @@ -179,7 +183,7 @@ "filename": "sample.env", "hashed_secret": "5b98cf4c3d794c8af1fcd7991e89cd4e52fb42a4", "is_verified": false, - "line_number": 33 + "line_number": 36 } ], "tests/app/authentication/test_authentication.py": [ @@ -374,5 +378,5 @@ } ] }, - "generated_at": "2022-06-27T21:40:11Z" + "generated_at": "2022-06-29T15:41:33Z" } diff --git a/app/config.py b/app/config.py index d117ddda0..f5f7f9325 100644 --- a/app/config.py +++ b/app/config.py @@ -103,9 +103,6 @@ class Config(object): # DB conection string SQLALCHEMY_DATABASE_URI = os.getenv('SQLALCHEMY_DATABASE_URI') - # Redis conection string - REDIS_URL = os.getenv('REDIS_URL') - # AWS SMS AWS_PINPOINT_REGION = os.getenv("AWS_PINPOINT_REGION", "us-west-2") AWS_US_TOLL_FREE_NUMBER = os.getenv("AWS_US_TOLL_FREE_NUMBER", "+18446120782") @@ -122,7 +119,7 @@ class Config(object): # URL of redis instance REDIS_URL = os.getenv('REDIS_URL') - REDIS_ENABLED = True + REDIS_ENABLED = 1 EXPIRE_CACHE_TEN_MINUTES = 600 EXPIRE_CACHE_EIGHT_DAYS = 8 * 24 * 60 * 60 @@ -548,8 +545,13 @@ class Live(Config): API_RATE_LIMIT_ENABLED = True CHECK_PROXY_HEADER = True SES_STUB_URL = None - CRONITOR_ENABLED = True + + # DEBUG = True + REDIS_ENABLED = os.getenv('REDIS_ENABLED') == '1' + + NOTIFY_LOG_PATH = os.getenv('NOTIFY_LOG_PATH', 'application.log') + REDIS_URL = os.getenv('REDIS_URL', 'redis://localhost:6379/0') class CloudFoundryConfig(Config): diff --git a/devcontainer-api/.devcontainer.json b/devcontainer-api/.devcontainer.json index cf46cba59..3126c6d12 100644 --- a/devcontainer-api/.devcontainer.json +++ b/devcontainer-api/.devcontainer.json @@ -13,7 +13,8 @@ }, "python.linting.enabled": true, "python.linting.pylintEnabled": true, - "python.pythonPath": "/usr/local/bin/python" + "python.pythonPath": "/usr/local/bin/python", + "python.linting.pylintPath": "/usr/local/share/pip-global/bin/pylint" }, "features": { "docker-from-docker": { @@ -22,7 +23,7 @@ } }, "extensions": [ - "ms-python.black-formatter", + "ms-python.python", "donjayamanne.python-extension-pack", "ms-azuretools.vscode-docker", "ms-python.vscode-pylance", @@ -35,7 +36,7 @@ "GitHub.copilot", "ms-vsliveshare.vsliveshare", "mtxr.sqltools", - "mtxr.sqltools-driver-pg", + "mtxr.sqltools-driver-pg" ], "postCreateCommand": "notify-dev-entrypoint.sh", "remoteUser": "vscode" diff --git a/devcontainer-api/scripts/notify-dev-entrypoint.sh b/devcontainer-api/scripts/notify-dev-entrypoint.sh index 7ae62f240..bd7b7a30b 100755 --- a/devcontainer-api/scripts/notify-dev-entrypoint.sh +++ b/devcontainer-api/scripts/notify-dev-entrypoint.sh @@ -23,7 +23,7 @@ echo -e "alias lt='exa -al -T -L 2'" >> ~/.zshrc # echo -e "source <(kubectl completion zsh)" >> ~/.zshrc # echo -e "complete -F __start_kubectl k" >> ~/.zshrc -cd /workspace +cd /workspace # Warm up git index prior to display status in prompt else it will # be quite slow on every invocation of starship. diff --git a/dump.rdb b/dump.rdb new file mode 100644 index 000000000..6ec88245c Binary files /dev/null and b/dump.rdb differ diff --git a/logs/app.log.json b/logs/app.log.json new file mode 100644 index 000000000..2ac3ecd7b --- /dev/null +++ b/logs/app.log.json @@ -0,0 +1,25 @@ +{"name": "app", "levelname": "INFO", "message": "Logging configured", "pathname": "/home/vscode/.local/lib/python3.9/site-packages/notifications_utils/logging.py", "lineno": 37, "time": "2022-06-29T05:41:53", "requestId": "no-request-id", "application": "app", "service_id": "no-service-id", "logType": "application"} +{"name": "app", "levelname": "INFO", "message": "Logging configured", "pathname": "/home/vscode/.local/lib/python3.9/site-packages/notifications_utils/logging.py", "lineno": 37, "time": "2022-06-29T05:42:30", "requestId": "no-request-id", "application": "app", "service_id": "no-service-id", "logType": "application"} +{"name": "delivery", "levelname": "INFO", "message": "Logging configured", "pathname": "/home/vscode/.local/lib/python3.9/site-packages/notifications_utils/logging.py", "lineno": 37, "time": "2022-06-29T05:43:02", "requestId": "no-request-id", "application": "delivery", "service_id": "no-service-id", "logType": "application"} +{"name": "delivery", "levelname": "INFO", "message": "Logging configured", "pathname": "/home/vscode/.local/lib/python3.9/site-packages/notifications_utils/logging.py", "lineno": 37, "time": "2022-06-29T05:43:05", "requestId": "no-request-id", "application": "delivery", "service_id": "no-service-id", "logType": "application"} +{"name": "app", "levelname": "INFO", "message": "Logging configured", "pathname": "/home/vscode/.local/lib/python3.9/site-packages/notifications_utils/logging.py", "lineno": 37, "time": "2022-06-29T05:59:55", "requestId": "no-request-id", "application": "app", "service_id": "no-service-id", "logType": "application"} +{"name": "app", "levelname": "INFO", "message": "Logging configured", "pathname": "/home/vscode/.local/lib/python3.9/site-packages/notifications_utils/logging.py", "lineno": 37, "time": "2022-06-29T06:00:38", "requestId": "no-request-id", "application": "app", "service_id": "no-service-id", "logType": "application"} +{"name": "delivery", "levelname": "INFO", "message": "Logging configured", "pathname": "/home/vscode/.local/lib/python3.9/site-packages/notifications_utils/logging.py", "lineno": 37, "time": "2022-06-29T06:00:52", "requestId": "no-request-id", "application": "delivery", "service_id": "no-service-id", "logType": "application"} +{"name": "delivery", "levelname": "INFO", "message": "Logging configured", "pathname": "/home/vscode/.local/lib/python3.9/site-packages/notifications_utils/logging.py", "lineno": 37, "time": "2022-06-29T06:00:56", "requestId": "no-request-id", "application": "delivery", "service_id": "no-service-id", "logType": "application"} +{"name": "app", "levelname": "INFO", "message": "Email already registered for user 7796f6d5-4fba-48d5-bfa1-80c5b3465d24", "pathname": "/workspace/app/user/rest.py", "lineno": 415, "time": "2022-06-29T06:07:57", "requestId": null, "application": "app", "service_id": "notify-admin", "logType": "application"} +{"name": "app", "levelname": "INFO", "message": "To email is testreceiver@dispostable.com", "pathname": "/workspace/app/user/rest.py", "lineno": 418, "time": "2022-06-29T06:07:57", "requestId": null, "application": "app", "service_id": "notify-admin", "logType": "application"} +{"name": "app", "levelname": "INFO", "message": "template.id is 0880fbb1-a0c6-46f0-9a8e-36c986381ceb", "pathname": "/workspace/app/user/rest.py", "lineno": 423, "time": "2022-06-29T06:07:57", "requestId": null, "application": "app", "service_id": "notify-admin", "logType": "application"} +{"name": "app", "levelname": "INFO", "message": "service.id is d6aa2c68-a2d9-4437-ab19-3ae8eb202553", "pathname": "/workspace/app/user/rest.py", "lineno": 424, "time": "2022-06-29T06:07:57", "requestId": null, "application": "app", "service_id": "notify-admin", "logType": "application"} +{"name": "app", "levelname": "INFO", "message": "Presisting notification", "pathname": "/workspace/app/notifications/process_notifications.py", "lineno": 108, "time": "2022-06-29T06:07:57", "requestId": null, "application": "app", "service_id": "notify-admin", "logType": "application"} +{"name": "app", "levelname": "INFO", "message": "Presisting notification with id 6bc43c9a-79d2-4b6e-b9cf-4fb6ec5a10c4", "pathname": "/workspace/app/notifications/process_notifications.py", "lineno": 114, "time": "2022-06-29T06:07:57", "requestId": null, "application": "app", "service_id": "notify-admin", "logType": "application"} +{"name": "app", "levelname": "INFO", "message": "Presisting notification with to address: testreceiver@dispostable.com", "pathname": "/workspace/app/notifications/process_notifications.py", "lineno": 139, "time": "2022-06-29T06:07:57", "requestId": null, "application": "app", "service_id": "notify-admin", "logType": "application"} +{"name": "app", "levelname": "INFO", "message": "Presisting notification with type: email", "pathname": "/workspace/app/notifications/process_notifications.py", "lineno": 149, "time": "2022-06-29T06:07:57", "requestId": null, "application": "app", "service_id": "notify-admin", "logType": "application"} +{"name": "app", "levelname": "INFO", "message": "Presisting notification to formatted email: testreceiver@dispostable.com", "pathname": "/workspace/app/notifications/process_notifications.py", "lineno": 151, "time": "2022-06-29T06:07:57", "requestId": null, "application": "app", "service_id": "notify-admin", "logType": "application"} +{"name": "app", "levelname": "INFO", "message": "Firing dao_create_notification", "pathname": "/workspace/app/notifications/process_notifications.py", "lineno": 159, "time": "2022-06-29T06:07:57", "requestId": null, "application": "app", "service_id": "notify-admin", "logType": "application"} +{"name": "app", "levelname": "INFO", "message": "Redis enabled, querying cache key for service id: d6aa2c68-a2d9-4437-ab19-3ae8eb202553", "pathname": "/workspace/app/notifications/process_notifications.py", "lineno": 162, "time": "2022-06-29T06:07:57", "requestId": null, "application": "app", "service_id": "notify-admin", "logType": "application"} +{"name": "app", "levelname": "INFO", "message": "Redis daily limit cache key: d6aa2c68-a2d9-4437-ab19-3ae8eb202553-2022-06-29-count", "pathname": "/workspace/app/notifications/process_notifications.py", "lineno": 164, "time": "2022-06-29T06:07:57", "requestId": null, "application": "app", "service_id": "notify-admin", "logType": "application"} +{"name": "app", "levelname": "INFO", "message": "Redis daily limit cache key does not exist", "pathname": "/workspace/app/notifications/process_notifications.py", "lineno": 166, "time": "2022-06-29T06:07:57", "requestId": null, "application": "app", "service_id": "notify-admin", "logType": "application"} +{"name": "app", "levelname": "INFO", "message": "Set redis daily limit cache key to 1", "pathname": "/workspace/app/notifications/process_notifications.py", "lineno": 172, "time": "2022-06-29T06:07:57", "requestId": null, "application": "app", "service_id": "notify-admin", "logType": "application"} +{"name": "app", "levelname": "INFO", "message": "email 6bc43c9a-79d2-4b6e-b9cf-4fb6ec5a10c4 created at 2022-06-29 06:07:57.373123", "pathname": "/workspace/app/notifications/process_notifications.py", "lineno": 177, "time": "2022-06-29T06:07:57", "requestId": null, "application": "app", "service_id": "notify-admin", "logType": "application"} +{"name": "app", "levelname": "INFO", "message": "Sending notification to queue", "pathname": "/workspace/app/user/rest.py", "lineno": 442, "time": "2022-06-29T06:07:57", "requestId": null, "application": "app", "service_id": "notify-admin", "logType": "application"} +{"name": "app", "levelname": "INFO", "message": "Sent notification to queue", "pathname": "/workspace/app/user/rest.py", "lineno": 446, "time": "2022-06-29T06:07:57", "requestId": null, "application": "app", "service_id": "notify-admin", "logType": "application"} diff --git a/sample.env b/sample.env index fec9cba17..9e9ccedd1 100644 --- a/sample.env +++ b/sample.env @@ -1,3 +1,5 @@ +### REBUILD THE DEVCONTAINER WHEN YOU MODIFY .ENV ### + # Debug DEBUG=True ANTIVIRUS_ENABLED=0 @@ -7,6 +9,7 @@ STATSD_HOST=localhost SES_STUB_URL=None NOTIFY_APP_NAME=api NOTIFY_EMAIL_DOMAIN=dispostable.com +NOTIFY_LOG_PATH=/workspace/logs/app.log # secrets that internal apps, such as the admin app or document download, must use to authenticate with the API ADMIN_CLIENT_ID=notify-admin