Repository navigation
init never writes a credential into the schema as a default (BL-208, P0) - #97
Merged
Merged
Conversation
…ue (BL-208) Both schema writers decide through importer._classify_variable, so the fix is there: - value_embeds_credential: a URL whose userinfo has a password (any scheme, `user:pass@` or `:pass@`) or a connection string with a password=/pwd= field is secret, so it gets no default, whatever its name. A URL with only a user name keeps its default. - The name check also matches a keyword's plural as a whole token (CREDENTIALS, KEYS, TOKENS) and the keywords passphrase and passwd. - init names each variable whose value held a password. Tests cover every credential form through init, init --from (.env, Compose, a Python module with --as-local-values, --force) and the merge path; 17 of the 27 fail on the old importer. Fixes #94.
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 39174296 | Triggered | Generic Password | b19192a | envshield/tests/test_import_credentials.py | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
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.
Fixes #94
In one line:
initno longer copies a password into the committedenv.schema.toml(or the.env.examplebuilt from it) when a value holds a credential or a variable's name means one.Problem (BL-208, P0 under AGENTS.md §4)
initjudged each.envvalue secret or not by its name and a value check, then wrote every non-secret value as a schemadefaultValue.REDIS_URL=redis://:password@cache:6379became a default, password included...._PASSPHRASE,GOOGLE_API_CREDENTIALSandDATABASE_URL-style variables did too.Root cause and design
Both schema writers decide through
importer._classify_variable, the import path behindinitandinit --fromand the merge of other config files. So the fix covers the whole class in one place:value_embeds_credential:user:pass@or:pass@, percent-encoded or not; a malformed URL is judged by its text.password=/pwd=field.CREDENTIALS,KEYS,TOKENS).MONKEYSandAUTHORSstill don't.passphraseandpasswd.initnames each variable whose value held a password.Alternatives
*_URLsecret by name: rejected. It would drop safe defaults (API_BASE=https://…) and still miss credentials under other names.Security
Invariant: a secret value must never enter an output representation; here, a committed file. The tests exercise the class, not the reported case. More names now count as secret (plurals,
passphrase), which is the safe direction.setupuses the same name check to decide which prompts hide input, so it hides those too.Compatibility
Re-importing may now mark a few more variables secret and drop their default. An existing schema's hand-set entries are kept as before.
Tests
envshield/tests/test_import_credentials.py(27 tests). Every credential form: Redis:pass@, Postgres,mongodb+srvwith an encoded password, AMQP, ADO.NET, libpq, ODBC.init,init --from(.env, a Compose manifest, a Python module with--as-local-values,--force) and the merge path. Each asserts the password is in neitherenv.schema.toml,.env.examplenor the output.ruff checkandruff format --checkclean.Re-run on the trial repositories
Fresh
initon cal.com, Documenso, Formbricks, Plane and PostHog, with a credential-bearingpostgres://URL for every*_URL/*_URI/*_DSNkey:.env.example(17 variables would have leaked in cal.com alone);PASSPHRASE/CREDENTIALSnames are secret with no default;Not fixed here
BL-209 / #96 (P1, needs a decision): a project that ran
initbefore this fix may already have a password committed in its schema.scan, the pre-commit hook andcheckall pass it.Branch note
The branch merges
mainrather than being rebased: the force-push a rebase needs was blocked. Squash-merging gives one commit either way.Product / market impact
Table stakes: "secret values never leave the place they belong" (§1).
🤖 Generated with Claude Code
https://claude.ai/code/session_01376EvgPvifpHL8LP5BYoPc