Repository navigation
Fix Python 3.13 cert tests, add --insecure, and bound DNS threads - #4
Merged
Merged
Conversation
Python 3.13 rejects a CA certificate with no key usage extension, so the pinned-HTTPS test now mints a real CA and a serverAuth leaf. CI runs the suite on 3.13 as well as 3.11 and 3.12. --insecure (default off) disables TLS certificate verification for HTTPS fetches and the TLS handshake. Certificate failures are still not retried over plain HTTP, and the report records that verification was disabled. resolve_ips keeps its deadline and the system resolver, caches answers for the scan, and will not start more than a few hung getaddrinfo threads. Co-authored-by: Kamal Choubey <Phantom9869@users.noreply.github.com>
An empty getaddrinfo answer was cached for the rest of the scan, so one transient EAI_AGAIN made a host look unresolvable. Cache only non-empty answers. Raise the resolver cap to 16 and log a skip when the pool is full, without caching it, so saturation is not reported as NXDOMAIN. crt.sh always verifies. The TLS module still classifies a bad certificate when --insecure is set. set_tls_verification no longer stacks a warnings filter on every call. Co-authored-by: Kamal Choubey <Phantom9869@users.noreply.github.com>
A leftover getaddrinfo sleeper from an earlier test held one shared semaphore slot. On Windows that slot freed between the two saturation probes, so the second probe started a real lookup and cleared the saturated flag. Join those threads and hold the pool full until both probes finish. Co-authored-by: Kamal Choubey <Phantom9869@users.noreply.github.com>
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.
Summary
Follow-ups after the redirect/DNS/TLS hardening on main (
a8e4529).Python 3.13 CA fixture
test_pinned_https_honours_requests_ca_bundle_and_rejects_hostname_mismatchminted a bare self-signed certificate and trusted it as its own CA. Python 3.13's defaultVERIFY_X509_STRICTrejects that withCA cert does not include key usage extension. The helper now builds a CA (basicConstraints=critical,CA:TRUE,keyUsage=critical,keyCertSign,cRLSign) and signs a leaf that has a SAN andserverAuth. CI runs 3.11, 3.12, and 3.13.pip-auditis unchanged.--insecureHTTPS certificate failures still stop the web modules (
Could not fetch site ... not retrying over HTTP), which blocks pentests against self-signed appliances.--insecureis off by default and disables certificate verification for HTTPS fetches. It does not retry a certificate failure over plain HTTP. A protocol mismatch (plain HTTP on the HTTPS port) still falls back. The choice is printed on stderr, prefixed on text and Markdown reports, and stored as an INFO finding (including JSON). Documented in--helpand the README.crt.sh is a third party, so that request passes
verify=Trueeven when--insecureis set. The TLS module still does a verified handshake first to classify hostname mismatch, self-signed, and untrusted-chain findings, then an unverified handshake for expiry and protocol details.DNS thread lifetime
resolve_ipsstill uses one systemgetaddrinfo(so/etc/hostsworks) and still returns when the deadline hits. Hung lookups cannot be cancelled. A shared semaphore allows at most 16 daemon threads in libc at once, enough that a burst of slow healthy lookups finishes inside one deadline. Extra hosts wait only until their own deadline, then return[]. That skip is logged and exposed asresolution_saturated/ResolverSaturated(the pipeline and the port check report it). It is not cached. Only non-empty answers are cached, so a transientEAI_AGAINis retried on the next lookup.set_tls_verificationinstalls the urllib3 warning filter once per transition instead of stacking a new filter on every call.Windows CI on
72df5adAll six Windows jobs failed
test_saturated_resolver_is_signalled_and_not_cached. An earlier test left agetaddrinfosleeper holding one process-wide resolver slot. On Windows that slot freed between the two saturation probes, so the second probe acquired it, started a real lookup, and cleared the saturated flag. Ubuntu was fast enough that the sleeper had already exited.a490bd6joins leftover resolver threads and keeps the pool full until both probes finish. Product saturation behavior is unchanged.Tests
198 passed(local, before the Windows-only test change)198 passed198 passedtests/test_net.pyafter the isolation fix:12 passedpip-audit --requirement requirements.txt: no known vulnerabilitiesCommit dates (
git log main..HEAD --format='%H %ad | %cd' --date=iso)