fix: verify TLS certificates by default in the library - #26
Merged
Conversation
Using this package as a library meant unverified TLS, silently. `Connection.__init__` took `verify=False`, and the value that actually governs the normal path, `config.assume_untrusted`, defaulted to `True`. So `Page(...)` built a connection with verification off, and the constructor then called `disable_warnings()` so nothing said as much. A library that talks to an Ascender over HTTPS was not checking who answered. Two defaults flip: - `Connection(server, verify=True)`. - `config.assume_untrusted` now defaults to `False`, and reads `ASCENDERKIT_ASSUME_UNTRUSTED` for the opt-out, following the same pattern as `ASCENDERKIT_SESSIONS` and `ASCENDERKIT_PREVENT_TEARDOWN`. There was no environment variable for it before, only the config dictionary. This is a behaviour change for library consumers and is in the changelog as one. Anyone pointed at an Ascender with a self-signed certificate sets the variable, or passes `verify=False` explicitly, and is back where they were. **The CLI is unaffected.** `CLI.connect()` already sets `config.assume_untrusted = False` and only sets it `True` for `-k` / `--conf.insecure`, so it has always verified by default. This brings the library in line with the CLI rather than changing the CLI. Out of scope, and worth its own change: `ascenderkit/cli/__init__.py:16` calls `urllib3.disable_warnings(InsecureRequestWarning)` unconditionally at import, so even a verifying connection has the warning suppressed. And `ws.py` hardcodes `ssl.CERT_NONE` regardless of any of this, which ctrliq#27 covers. Note for whoever merges: ctrliq#25 also touches this constructor, so whichever lands second needs a rebase. Verified with `black --check`, `flake8` and the unit suite, 355 passing.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This was referenced Sep 12, 2026
cigamit
approved these changes
Sep 13, 2026
blaipr
added a commit
to blaipr/ascender-kit
that referenced
this pull request
Sep 13, 2026
Two places reach a submodule through its parent package without importing it: ```python import requests ... class Token_Auth(requests.auth.AuthBase): ``` ```python import yaml ... raise yaml.constructor.ConstructorError ``` Both work today, and only because `requests` and `yaml` happen to import those submodules themselves as part of their own initialisation. Nothing in the language guarantees that: `import requests` binds the package, not its children, and a release that stops importing `auth` eagerly turns this into an `AttributeError` at class definition time, which is to say at import of `ascenderkit`. Imported by name instead, which is what the code means and what a reader would expect: ```python from requests.auth import AuthBase from yaml.constructor import ConstructorError ``` This also clears the two `possibly-missing-submodule` warnings the type checker reports, which is how it surfaced. Note for whoever merges: ctrliq#25 and ctrliq#26 also edit `api/client.py`, so whichever lands after them needs a rebase. Verified with `black --check`, `flake8` and the unit suite, 355 passing.
cigamit
pushed a commit
that referenced
this pull request
Sep 13, 2026
Two places reach a submodule through its parent package without importing it: ```python import requests ... class Token_Auth(requests.auth.AuthBase): ``` ```python import yaml ... raise yaml.constructor.ConstructorError ``` Both work today, and only because `requests` and `yaml` happen to import those submodules themselves as part of their own initialisation. Nothing in the language guarantees that: `import requests` binds the package, not its children, and a release that stops importing `auth` eagerly turns this into an `AttributeError` at class definition time, which is to say at import of `ascenderkit`. Imported by name instead, which is what the code means and what a reader would expect: ```python from requests.auth import AuthBase from yaml.constructor import ConstructorError ``` This also clears the two `possibly-missing-submodule` warnings the type checker reports, which is how it surfaced. Note for whoever merges: #25 and #26 also edit `api/client.py`, so whichever lands after them needs a rebase. Verified with `black --check`, `flake8` and the unit suite, 355 passing.
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.
Using this package as a library meant unverified TLS, silently.
Connection.__init__tookverify=False, and the value that actually governs the normal path,config.assume_untrusted, defaulted toTrue. SoPage(...)built a connection with verification off, and the constructor then calleddisable_warnings()so nothing said as much. A library that talks to an Ascender over HTTPS was not checking who answered.Two defaults flip:
Connection(server, verify=True).config.assume_untrustednow defaults toFalse, and readsASCENDERKIT_ASSUME_UNTRUSTEDfor the opt-out, following the same pattern asASCENDERKIT_SESSIONSandASCENDERKIT_PREVENT_TEARDOWN. There was no environment variable for it before, only the config dictionary.This is a behaviour change for library consumers and is in the changelog as one. Anyone pointed at an Ascender with a self-signed certificate sets the variable, or passes
verify=Falseexplicitly, and is back where they were.The CLI is unaffected.
CLI.connect()already setsconfig.assume_untrusted = Falseand only sets itTruefor-k/--conf.insecure, so it has always verified by default. This brings the library in line with the CLI rather than changing the CLI.Out of scope, and worth its own change:
ascenderkit/cli/__init__.py:16callsurllib3.disable_warnings(InsecureRequestWarning)unconditionally at import, so even a verifying connection has the warning suppressed. Andws.pyhardcodesssl.CERT_NONEregardless of any of this, which #27 covers.Note for whoever merges: #25 also touches this constructor, so whichever lands second needs a rebase.
Verified with
black --check,flake8and the unit suite, 355 passing.