Repository navigation
Conversation
The --output flag took its default from the 'namespace' config key, so a namespace list in the user config raised a TypeError and an 'output' key was never honoured. Also add the missing f-string prefix so the error for a prohibited kubectl flag names the flag. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
PluginManager.instantiate() called parse_args(*keys, default), which made the default plug-in path part of the config key path. Calling instantiate() without a prior parse_args() therefore failed with "cannot import 'None'". Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
time.mktime() treats the frozen UTC time tuple as local time, so the test failed on any machine whose time zone is ahead of UTC. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
On Windows 'az' is 'az.cmd', which subprocess cannot start by its bare name. Use the path returned by shutil.which(), as the az command does. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
load_dotted_object() swallowed every ModuleNotFoundError, so running without the 'aws' extra reported that awsrun.plugins.creds did not contain 'aws.Default' rather than that boto3 was missing. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
The config type check listed 'ntml', so 'auth: ntlm' was rejected and the misspelling passed validation only to fail with a KeyError. Also validate --loader-auth and --loader-parser values on the command line. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
Add --issuer and the 'issuer' config key. The default is unchanged. Also correct the documented type of the 'region' option. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
The variant was derived from the raw program name, so running the module directly failed with 'unknown variant: cli.py'. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
…nfig Commands run concurrently in worker threads, but KUBECONFIG was set in the process-wide os.environ before each subprocess started, so one account's kubectl could run against another account's cluster. Pass the variable in a per-call copy of the environment instead. The kubeconfig is now generated with yaml.safe_dump: long-term credentials no longer get AWS_SESSION_TOKEN set to the string 'None', values are always quoted correctly, and slashes in the account name are escaped in the file name. Output file names no longer lose everything after a dot in the account name. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
Path.with_suffix() replaced everything after the last dot, so accounts such as 'team.prod' and 'team.dev' wrote to the same file. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
The parsed arguments, including --saml-password and friends, were logged verbatim when running with --log-level INFO or DEBUG. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
The password from the config file or the PASSWORD environment variable was used as the argparse default of --saml-password, --oauth2-password and --ad-password, so 'awsrun --help' printed it as '(default: ...)'. The fallback is now resolved when the plug-in is instantiated; precedence is unchanged (flag, config, environment, prompt). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
Every loader cached its accounts in one file, <tmp>/awsrun.dat: - On a multi-user system any other user could create that file (and an .expiry file next to it, honoured even with caching disabled) to choose the accounts awsrun selects, or read the cached account list. - The file was shared by every URL, parser and by awsrun and azurerun, so within max_age one source's accounts were returned for another. - The temporary file used while saving had a fixed, predictable name. The default cache file is now named after the source and kept in the user's cache directory ($XDG_CACHE_HOME or ~/.cache, under awsrun/, mode 0700), and is written through a private temporary file. An explicit cache_path is still honoured. HTTP requests made by the loaders now have a timeout so an unresponsive server cannot hang the CLI. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
An identity provider that stopped responding would hang the CLI forever. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
The bundled dx_status, dx_maint and last commands call sys.exit() when their optional dependencies are missing. SystemExit is not an Exception, so with a default install the list of commands was never displayed and an unknown command reported another command's install hint. Running such a command by name still prints its hint. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
…rl-C The confirmation prompt failed with 'EOF when reading a line' when there was nobody to answer, and Ctrl-C printed a stack trace. An interrupted run also kept processing every account still waiting for a worker before it could exit; those are now cancelled. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
…oint IAM user keys have no session token, which was not detected, so the access key and secret key were sent to the sign-in service before it rejected them. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
pyproject.toml referred to LICENSE while the file is LICENSE.md, and depended on the bs4 placeholder rather than beautifulsoup4 itself. Also list the Python versions that CI already tests. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
The directory arrives as a string from the command line or the config file, but was joined to the file name with the '/' operator, so saving the output failed with "unsupported operand type(s) for /: 'str' and 'str'". It is converted to a path, and created if it does not exist, as the aws command does. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
The integration tests expected the cache to be <tmp>/awsrun.dat. They now look for the file of the loader and URL under test, in a cache directory that belongs to the test. The file URLs are built with Path.as_uri() so these tests also pass on Windows. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Avro Guha <avro.guha@gmail.com>
This branch has not been deployed
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
A set of security and reliability fixes found by reading the code and then confirmed against a real AWS account and a real EKS cluster. Every fix comes with tests that fail on
masterand pass here. The commits are small and independent, one topic each, so they can be reviewed (or cherry-picked) one at a time. I am happy to split this into several pull requests if that is easier to review.No new dependencies. No change to the public library API. The behaviour changes that a user could notice are listed in their own section below.
Security
masterfix(kubectl): give each kubectl its own KUBECONFIG and a valid kubeconfigKUBECONFIGwas set in the process-wideos.environfrom worker threads, so with several accounts one account'skubectlcould run against another account's cluster. A test with 8 threads reproduces it.fix(acctload): cache accounts per source in a private directory<tmp>/awsrun.dat. On a multi-user host another user could create that file (and an.expiryfile beside it, which was honoured even withmax_age: 0) and so choose the accounts awsrun acts on, or read the cached list. The file was also shared by every URL, parser and byawsrun/azurerun, so one source's accounts could be returned for another. The temporary file used while saving had a fixed name.$XDG_CACHE_HOME/awsrunor~/.cache/awsrun(mode 0700), written through a private temporary file. An explicitcache_pathis still honoured.fix(creds): do not show the configured password in --helpPASSWORDwas the argparse default of--saml-password,--oauth2-passwordand--ad-password, soawsrun --helpprinted it as(default: ...).fix(plugmgr): mask passwords, secrets and tokens in the INFO log--log-level INFO.fix(console): never send long-term credentials to the federation endpointfix(acctload)/fix(session): add a timeout ...Bugs
masterfix(kubectl): give each kubectl ...AWS_SESSION_TOKEN: None, andkubectlanswered "You must be logged in to the server". Confirmed on a real EKS cluster with IAM user keys. The kubeconfig is now built withyaml.safe_dump, which also quotes values correctly.fix(kubectl): make --awsrun-output-dir work/:unsupported operand type(s) for /: 'str' and 'str'. Found while testing on EKS.fix(kubectl): read --output default from its own config key--outputtook its default from thenamespaceconfig key, so a namespace list in the config raised aTypeErrorand anoutputkey was ignored. The error for a prohibited flag also printed a literal--{arg}.fix(cmdmgr): list commands even when an optional one exits on importdx_status,dx_maintandlastcallsys.exit()when their extras are missing.SystemExitis not anException, so with a defaultawsrun[aws]install the command list was never displayed and an unknown command reported another command's install hint. Running such a command by name still prints its hint.fix(accts): accept the documented 'ntlm' auth type in URLLoaderntml, soauth: ntlmwas rejected and the misspelling passed validation only to fail with aKeyError.--loader-authand--loader-parservalues are now validated too.fix(aws,az): keep dotted account names in --awsrun-output-dir file namesPath.with_suffix()replaced everything after the last dot, so accounts such asteam.prodandteam.devwrote to the same file.fix(plugmgr): pass default by keyword when instantiate parses implicitlyinstantiate()without a priorparse_args()failed with "cannot import 'None'". Affects library users.fix(plugmgr): report a missing dependency instead of 'does not contain'awsextra the error was "module 'awsrun.plugins.creds' does not contain 'aws.Default'" rather than a missingboto3.fix(acctload): run the resolved Azure CLI path in the AzureCLI loaderazisaz.cmd, whichsubprocesscannot start by its bare name. Theazcommand already used the resolved path.fix(cli): allow running as 'python -m awsrun.cli'Command line behaviour
fix(cli): explain --force when stdin is closed and exit cleanly on Ctrl-C--force.AWSRUN_TRACEstill shows the trace).feat(console): make the sign-in URL issuer configurableadds--issuerand theissuerconfig key. The default is unchanged.Documentation, build and tests
docs: correct examples and references that do not match the code(import path ofCredsViaProfile,LoadBalancerArn, a copied config example,__all__, the formatter named in CONTRIBUTING).build: correct the license file name and declare beautifulsoup4(pyproject.tomlpointed atLICENSEwhile the file isLICENSE.md;bs4is a placeholder forbeautifulsoup4; classifiers for the Python versions CI already tests).test(cache): make the mtime in test_caching independent of the time zone: this existing test failed on any machine whose time zone is ahead of UTC.test(acctload): follow the cache to its per-source location: updates the integration tests for the new cache location, and builds file URLs withPath.as_uri()so they also pass on Windows.Behaviour changes to be aware of
<tmp>/awsrun.datto a per-source file under~/.cache/awsrun. An existing cache is simply not reused once.cache_pathis unaffected.~/.kube/awsrun-*has the same content but is produced by a YAML serializer, and omitsAWS_SESSION_TOKENwhen there is no token.--helpshows(default: None)for the password flags.Testing
masterfirst to confirm that it fails there.pip install .[aws,azure,dev] ruff,ruff check --extend-select I .,ruff format --check .,pytest) was run on Linux for Python 3.9, 3.10, 3.11, 3.12 and 3.13: all 504 tests pass on each. The unit tests were also repeated 25 times on Windows and 10 times on Linux to check for flaky tests.masterand this branch. Output and exit codes match, apart from theconsolefix above.kubectllist clusters, get namespaces and pods, several namespaces, JSON/YAML/text annotation, output directory, a refused write and prohibited flags.Not covered: SAML and OAuth2 sign-in against a real identity provider, cross-account roles, several accounts in parallel (the
KUBECONFIGrace is covered by a threaded unit test only), and the interactivelast -iscreen.Not included
Two things I noticed and left alone because they change behaviour people may rely on. I can open issues for them if useful:
--include,--excludeand--forceare consumed anywhere on the line, so they cannot be passed through to a wrapped tool (aws s3 sync --exclude ...).🤖 Generated with Claude Code