fix: coerce is_strictly_forces_https return value to bool - #270
Merged
jsf9k merged 2 commits intoJul 9, 2026
Merged
Conversation
`down_or_redirects` evaluated `False or endpoint.redirect_immediately_to_https` which, when the attribute holds its default value of None, returns None instead of False. That None then propagated through the `and` chain so `is_strictly_forces_https` — and therefore the "Strictly Forces HTTPS" JSON field — could be null rather than true/false. Fix: wrap `endpoint.redirect_immediately_to_https` in `bool()` in the inner helper and coerce `https_somewhere` the same way, so the function always returns a proper boolean regardless of how far each endpoint scan has progressed. Add three unit tests in `TestStrictlyForcesHttps` that cover the null- propagation regression (all-None state, live HTTP with unset redirect) and the positive case (HTTP endpoints that do redirect to HTTPS). Fixes cisagov#176 Signed-off-by: Mike German <mike@stepsventures.com>
steps-re
requested review from
IanLee1521,
dav3r,
felddy,
jsf9k and
mcdonnnj
as code owners
July 8, 2026 16:21
jsf9k
approved these changes
Jul 8, 2026
jsf9k
enabled auto-merge
July 8, 2026 19:46
Member
|
Thank you for the contribution @steps-re! |
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.
Fixes #176.
Problem
is_strictly_forces_httpscould returnNoneinstead ofTrue/False, which caused the "Strictly Forces HTTPS" JSON field to benullfor some domains.The root cause was in the
down_or_redirectsinner helper:redirect_immediately_to_httpsdefaults toNoneinmodels.py(line 58). Whenendpoint.liveisTrue, Python evaluatesFalse or NoneasNone. ThatNonethen propagates through theandchain on line 1280, so the final return value isNonerather than a bool.Fix
Wrap the attribute in
bool()in the helper, and apply the same treatment tohttps_somewhere:Both
bool(None)→Falseandbool(True)→True, so the semantics are unchanged for any non-None value.Tests
Adds
TestStrictlyForcesHttpswith three cases:False, notNoneredirect_immediately_to_https=None→ returnsFalse, notNoneTrue