Skip to content
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

fix: add fallback value for cypress migration #2355

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ADMIN_CLIENT_SECRET=dev-notify-secret-key
SRE_CLIENT_SECRET=dev-notify-secret-key
SECRET_KEY=dev-notify-secret-key
DANGEROUS_SALT=dev-notify-salt
CYPRESS_USER_PW_SECRET=

NOTIFICATION_QUEUE_PREFIX='notification-canada-ca'

Expand Down
11 changes: 6 additions & 5 deletions migrations/versions/0466_add_cypress_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@


def upgrade():
password = hashpw(
hashlib.sha256(
(current_app.config["CYPRESS_USER_PW_SECRET"] + current_app.config["DANGEROUS_SALT"]).encode("utf-8")
).hexdigest()
)
cypress_user_pw = current_app.config.get("CYPRESS_USER_PW_SECRET")
if not cypress_user_pw:
cypress_user_pw = uuid.uuid4().hex[:32]
current_app.logger.warning(f"CYPRESS_USER_PW_SECRET not set, using random password")

password = hashpw(hashlib.sha256((cypress_user_pw + current_app.config["DANGEROUS_SALT"]).encode("utf-8")).hexdigest())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hashpw function call is missing a closing parenthesis. It should be hashpw(hashlib.sha256((cypress_user_pw + current_app.config["DANGEROUS_SALT"]).encode("utf-8")).hexdigest()).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny, the suggestion is exactly what is in the code.

current_year = get_current_financial_year_start_year()
default_limit = 250000

Expand Down
Loading