Support fetching tokens from an external command - #469
Conversation
Note on integration test count updates (
|
|
@ammachado, thanks for looking into the test issues. Yes, it really seems that some of the expected issues are not included in the search results anymore. Interestingly, for pull requests your changes seem not needed anymore. Something weird is happening on the GitHub side. Here's a slightly modified version of your adjustments: |
psss
left a comment
There was a problem hiding this comment.
Thanks much for implementing this! Looks good, just two minor comments. Also the following statement from the pull request description is not valid, right?
- Breaking change: setting more than one of
token,token_file,token_commandin a section is now a hardConfigError. Previously the lower-precedence keys were silently ignored.
…re widely - Remove CLAUDE.md from this branch per review request; the repo guidance content is fine but belongs in its own PR. - Document token_command (alongside token/token_file) in the github and gitlab plugin docstrings, matching the jira/confluence notes.
…re widely - Remove CLAUDE.md from this branch per review request; the repo guidance content is fine but belongs in its own PR. - Document token_command (alongside token/token_file) in the github and gitlab plugin docstrings, matching the jira/confluence notes.
…re widely - Remove CLAUDE.md from this branch per review request; the repo guidance content is fine but belongs in its own PR. - Document token_command (alongside token/token_file) in the github and gitlab plugin docstrings, matching the jira/confluence notes.
lukaszachy
left a comment
There was a problem hiding this comment.
LGTM, finally a safer way to store tokens
- List `token_command` in the gitlab and jira config examples, next to the `token` and `token_file` entries that were already there - Clarify that the token command inherits did's environment (so `BW_SESSION` and friends work) and only loses shell expansion - Include the command line in the `FileNotFoundError` and `CalledProcessError` messages, matching the timeout message - Document why caching the token for the process lifetime does not widen exposure of the secret - Reword a test comment that read as a typo Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Add `token_command` as a third token source alongside `token` and `token_file`, so secrets can be pulled from password managers such as BitWarden (`bw get password ...`) or 1Password (`op read op://...`). The command is parsed with shlex (no shell) and its stdout is used as the token; failures raise `ConfigError`. Results are memoized per process so multiple sections sharing a command only invoke the tool once. Setting more than one of `token`, `token_file`, `token_command` is now a hard `ConfigError` (previously the lower-precedence keys were silently ignored). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Fix terminal color reset sequence (\033[1;m -> \033[0m) so background color does not bleed into subsequent output - Extract the human-readable 'message' field from GitHub API JSON error responses instead of printing the raw JSON blob - Drop the Future object reference from ReportError log lines so only the error text is shown Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Mirror the dependency list from the mypy hook so pylint can resolve all project imports, substituting requests/python-dateutil for their type-stub equivalents. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Adriano Machado <60320+ammachado@users.noreply.github.com>
Update expected ANSI escape sequences from \033[1;m to \033[0m following the fix in cbef398. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> rh-pre-commit.version: 2.4.0 rh-pre-commit.check-secrets: ENABLED
…re widely - Remove CLAUDE.md from this branch per review request; the repo guidance content is fine but belongs in its own PR. - Document token_command (alongside token/token_file) in the github and gitlab plugin docstrings, matching the jira/confluence notes.
- List `token_command` in the gitlab and jira config examples, next to the `token` and `token_file` entries that were already there - Clarify that the token command inherits did's environment (so `BW_SESSION` and friends work) and only loses shell expansion - Include the command line in the `FileNotFoundError` and `CalledProcessError` messages, matching the timeout message - Document why caching the token for the process lifetime does not widen exposure of the secret - Reword a test comment that read as a typo Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
@kwk, all fourteen threads from your review are answered, and the branch is rebased on current Changed in 179036d:
Answered without a code change, reasoning in each thread:
I offered in several threads to split the colour-reset and pre-commit changes into separate PRs if you would still prefer this one narrower. Happy to do that, just say which. One note on CI: the four Fedora |
|
Okay, let me make one thing clear, I like the feature. But I also like Big Buts (the song is cool as well but written differently). Can we please get a policy for AI contributions? I simply do not buy that my last review was answered by a human. And I refuse to work this way. I'm getting really angry about such comments. Not because they are incorrect or inaccurate but because I feel like someone is operating a machine instead of thinking for him or herself. This is disrespectful. @psss please look at the responses and tell me this was written by a person. |
|
@kwk I use Claude Code to assist me, but I review all the work it does. This PR is not on autopilot. I'll move the color reset and log improvements to a different PR. |
The color reset in did/utils.py (with the three test assertions that follow from it), the stat failure log message in did/stats.py, and the pylint additional_dependencies in .pre-commit-config.yaml are not part of this feature. They go to separate pull requests instead, per review feedback on psss#469. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
01833ef to
538af51
Compare
Summary
token_commandas a third token source alongsidetoken/token_file, so plugins can pull secrets from password managers such as BitWarden (bw get password did-jira) or 1Password (op read op://Personal/Jira/token). The command is parsed withshlex(no shell) and its stripped stdout is used as the token; failures raiseConfigError. Results are memoized per process viafunctools.lru_cacheso multiple config sections sharing a command only invoke the external tool once.token,token_file,token_commandis set in a section:token>token_file>token_command, matching the existingtokenvs.token_fileprecedence — lower-precedence keys are silently ignored, same as before.jira,confluence,github, andgitlabplugin docstrings to documenttoken_commandand the precedence rule. Other plugins automatically gain the feature through the shareddid.base.get_tokenhelper.Test plan
pytest tests/unit/test_base.py::TestGetToken— 13/13 passing (5 new tests for the command source, precedence, failure modes, and memoization)pytest tests/unit -n autoclean except for pre-existing failures unrelated to token handling (nitrate/psycopg2build needspg_configlocally; oneredminelive-data test).[all]installedtoken_command = printf %s ...and confirm the report runs🤖 Generated with Claude Code