fix: parse PUSHER_USE_SSL env var as boolean string#6628
Open
sricursion wants to merge 1 commit into
Open
Conversation
PUSHER_USE_SSL was compared with `is False`, so any string value — including "false" set via docker-compose or k8s env — enabled SSL. Parse it with the same starlette `config(..., cast=bool)` idiom used across the codebase. Unrecognized values keep SSL enabled (fail-secure, matching pre-fix behavior) and log a warning. Fixes keephq#6582
ed97008 to
5c882ae
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked Issue
Fixes #6582
Description
get_pusher_clientevaluates the env var withssl=False if os.environ.get("PUSHER_USE_SSL", False) is False else True, so any string value — including"false"— enables SSL. docker-compose and Kubernetes can only pass env values as strings, soPUSHER_USE_SSL: falsein a compose file arrives as the string"false"and turns SSL on.The variable is now parsed with the same starlette
config(..., cast=bool)idiom already used across the codebase (SCHEDULER,REDIS_SSL,KEEP_DEBUG_TASKS, ...), acceptingtrue/false/1/0case-insensitively. The parse happens before the existingtry/except ValueError, so an invalid value is no longer misreported by the "PUSHER_APP_ID must be a numeric string" handler.Backward compatibility / fail-secure: before this change, every set value enabled SSL. Falling back to
Falsefor unrecognized values (yes,on, typos, empty string) would silently downgrade existing SSL deployments to plaintext, so unrecognized values keep SSL enabled and log a warning. The only behavior change is for the explicitly-false spellings — the bug being fixed.This was the only instance of this pattern in the repo (the issue suggested other cases might be affected — none found).
Test
Added
tests/test_pusher_client.pywith 11 cases:false/False/0→ SSL off,true/True/1→ SSL on, unset → off,yes/on/garbage/empty string → on (fail-secure).Reproduced against the real pusher client: on
main,PUSHER_USE_SSL=falseproduces a client withssl=True; with this change all cases wire through correctly. Fullpytest --non-integrationsuite passes with no regressions.ruff checkpasses.