Repository navigation
Note when an exported key goes to a stored endpoint - #47
Merged
Merged
Conversation
The key and the endpoint are resolved independently, so a key exported in TOC_API_KEY is sent to whatever non-default endpoint `tmxcaliber init` stored, unless TOC_API_URL is also set. That precedence is unchanged. Commands now print a note on stderr, once per run and before the first request, naming the endpoint and the credentials file it came from and pointing at TOC_API_URL. Stdout stays the command's output. Settings records where the endpoint came from and owns the condition, so the library still prints nothing. API commands and ThreatModel references given as a document source both build their client through remote_cli.connect, the one place the note is written. Bump to 0.5.4.
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.
What
Commands now print a note on stderr when a key exported in
TOC_API_KEYis about to be sent to a non-default endpoint thattmxcaliber initstored in the credentials file, andTOC_API_URLis unset:Why
The key and the endpoint are resolved independently, on purpose (see the comment in
load_settings). So a key exported for one API, whileinitonce stored a different endpoint, is sent to that stored endpoint with nothing on screen to say so. Resolution is unchanged; this only makes it visible.How
Settings.endpoint_sourcerecords where the endpoint came from, andSettings.sends_environment_key_to_stored_endpointowns the condition. The library still prints nothing.remote_cli.connect()is the one place a client is built from resolved settings, and the one place the note is written. Every API command goes through it (run_api_command), and so does every ThreatModel reference given as a document source (resolve_command_source).connectis only called for a reference.initis unchanged and keeps its ownTOC_API_KEYnote.Version
0.5.4, since 0.5.3 shipped with #46.
Checks run locally
uv run coverage run ./test/run_tests.py: 578 passeduv run ruff format --check .,uv run ruff check .,uv run mypy: cleanuv buildandtwine check: passed