feat(cli): warn when --env values look like credentials - #2655
Open
letv1nnn wants to merge 3 commits into
Open
Conversation
Signed-off-by: Artem Lytvyn <alytvyn@redhat.com>
Signed-off-by: Artem Lytvyn <alytvyn@redhat.com>
letv1nnn
requested review from
a team,
derekwaynecarr,
maxamillion and
mrunalp
as code owners
August 7, 2026 16:08
letv1nnn
marked this pull request as draft
August 7, 2026 16:09
letv1nnn
force-pushed
the
warn-credential-env-vars
branch
from
August 7, 2026 16:24
ca90468 to
3d4db33
Compare
Signed-off-by: Artem Lytvyn <alytvyn@redhat.com>
letv1nnn
force-pushed
the
warn-credential-env-vars
branch
from
August 7, 2026 16:32
3d4db33 to
51926bc
Compare
letv1nnn
marked this pull request as ready for review
August 7, 2026 16:35
mrunalp
reviewed
Aug 7, 2026
| } | ||
|
|
||
| fn credential_env_matches(env: &HashMap<String, String>) -> Vec<(String, Vec<ProfileSuggestion>)> { | ||
| const SUFFIXES: [&str; 7_usize] = [ |
Collaborator
There was a problem hiding this comment.
instead of suffixes could check for presence anywhere within the key.
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
openshell sandbox createnow emits a non-blocking warning when an--envkey looks like a credential, steering users toward providers so secrets aren't exposed to the sandboxed agent. The warning suggests a specificprovider createcommand when the key matches a built-in provider profile, and otherwise links to the providers docs.Related Issue
#2548
Changes
credential_env_matchesincrates/openshell-cli/src/commands/common.rs: flags--envkeys by name only — known provider env vars frombuiltin_profiles(), plus*_TOKEN,*_SECRET,*_PASSWORD,*_CREDENTIAL,*_ACCESS_KEY,*_SECRET_KEY,*_API_KEYsuffixes (case-insensitive). Never inspects or prints values.warn_credential_env_vars: prints a non-blocking stderr warning per flagged key. When built-in profiles claim the key it lists a specificopenshell provider createcommand per match (a key can map to several, e.g.GITHUB_TOKEN→ copilot and github); otherwise it links to the providers docs.--no-credential-warningsflag tosandbox createand wire the warning in before theCreateSandboxRPC (create only, notexec).warn_credential_env_varsthroughrunto match the existingparse_env_pairscall pattern.common.rscovering profile match, suffix-only match, case-insensitivity, non-credential skip,no-value-leak, and deterministic ordering.
docs/sandboxes/manage-sandboxes.mdx.Example output
Testing
mise run pre-commitpassesChecklist