Repository navigation
readonly tokens get ignored when setting up GIT_CONFIG_* environment variables #41757
Replies: 2 comments 1 reply
This comment has been hidden.
This comment has been hidden.
|
I've now added a reproducer repo for completeness. For
At the moment I cannot scope down my |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
How are you running Renovate?
Self-hosted Renovate CLI
Which platform you running Renovate on?
GitHub.com
Which version of Renovate are you using?
43.58.0 (also tried on 41.173.1, same issue)
Please tell us more about your question or problem
Several managers /
postUpgradeTasksusegetGitEnvironmentVariablesto setGIT_CONFIG_*environment variables with credentials for git integration. As far as I can tell, these are set unconditionally without a way to opt out, which is quite worrying. What's more worrying is that when running on the GitHub platformgetGitEnvironmentVariablesselects the platform GitHub token (the one that has write access to repositories), even when a read-only token is available (seerenovate/lib/util/git/auth.ts
Line 178 in bc82cff
readonlyoption, and therefore any rules with areadonlyoption in the for loop infindget skipped). This means that multiple managers andpostUpgradeTasksget a token with write access even when a readonly token is available, which seems the opposite of what the docs imply should happen:An additional complication is that the read and write tokens can be scoped to different sets of repos. Renovate should only ever need write access to repositories in
RENOVATE_REPOSITORIES, so it makes sense to scopeRENOVATE_TOKENto only those repositories. GitHub doesn't allow scoping a token with write access to some repositories and read access to others, so a second read-only token is necessary if the repository being worked on depends on other private GitHub resources.Affected functionality
This is the full list of places where the token is passed:
renovate/lib/workers/repository/update/branch/execute-post-upgrade-commands.ts
Line 140 in bc82cff
renovate/lib/util/git/index.ts
Line 375 in bc82cff
renovate/lib/modules/manager/git-submodules/update.ts
Line 15 in bc82cff
renovate/lib/modules/manager/gomod/artifacts.ts
Line 216 in bc82cff
renovate/lib/modules/datasource/git-refs/base.ts
Line 30 in bc82cff
renovate/lib/modules/manager/conan/artifacts.ts
Line 25 in bc82cff
renovate/lib/modules/manager/cargo/artifacts.ts
Line 37 in bc82cff
renovate/lib/modules/manager/cargo/artifacts.ts
Line 68 in bc82cff
renovate/lib/modules/manager/poetry/artifacts.ts
Line 223 in bc82cff
renovate/lib/modules/manager/copier/artifacts.ts
Line 76 in bc82cff
renovate/lib/modules/manager/vendir/artifacts.ts
Line 37 in bc82cff
renovate/lib/modules/manager/pep621/processors/pdm.ts
Line 112 in bc82cff
renovate/lib/modules/manager/pep621/processors/uv.ts
Line 199 in bc82cff
Tools/commands in these paths:
postUpgradeTasks: user-defined commandsgit-submodulesandgitutil:git submodule update,git checkoutgit-refsdatasource:git ls-remotegomod:go get,go mod tidy, optionalgo mod vendor/go work sync/go generatecargo:cargo update --config net.git-fetch-with-cli=true ...conan:conan lock create ...poetry:poetry update --lock --no-interaction ...copier:copier update ...vendir:vendir syncpep621:pdm update ...,uv lock ...A lot of these use cases are quite benign, but it's hard to anticipate what can be abused now or in the future. I would argue all of them should be receiving readonly tokens where possible, or none at all without explicit opt in.
Suggestions
To improve the situation we could:
GIT_CONFIG*environment variable setting. There is already a mechanism to set environment variables through thecustomEnvVariablesoption.As far as I'm aware, none of these are possible at the moment. Would be very interested to know if that's not true. I think my issues would be mostly solved if the following test was passing in
lib/util/git/auth.spec.ts:Reproduction
I confirmed the issue with a
config.jswhere the read-only token is passed as an environment variable:Then I used
postUpgradeTasksto extract the token and perform a write action (like writing a comment on a PR the write token has access to).You can find a reproduction repo with instructions: https://github.com/samgiz/renovate-41757-reproducer.
Logs (if relevant)
No response
All reactions