Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(submodules): use env vars from getGitEnvironmentVariables #31934

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tim-thacker-nullify
Copy link

@tim-thacker-nullify tim-thacker-nullify commented Oct 13, 2024

Changes

This change uses the existing getGitEnvironmentVariables function during the cloning of git submodules.

This function has been used to include support for updating private git ssh submodules on github.com, but it was not added in the function triggered when the cloneSubmodules config file option is set to true.

see: #22061

Context

#30942

Private submodules on the github.com app cannot currently be cloned with the cloneSubmodules option when the .gitmodules file is configured with ssh.

This is because the GitHub App token does not have SSH permissions, it can only auth via HTTP.

My use case is private Go submodules on github.com, for the "postUpdateOptions": ["gomodTidy", "gomodUpdateImportPaths"], options to work, I need my private git submodules cloned.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@rarkins rarkins changed the title clone git submodules with env vars from getGitEnvironmentVariables feat(submodules): use env vars from getGitEnvironmentVariables Oct 14, 2024
const gitSubmoduleAuthEnvironmentVariables = getGitEnvironmentVariables();
const gitEnv = {
// pass all existing env variables
...process.env,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was git already passing all env variables before this? Because normally we'd want this controlled by exposeAllEnv.

Copy link
Author

@tim-thacker-nullify tim-thacker-nullify Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what you mean exactly, but right now git is not configured with the ENV var that forces github.com submodules to be cloned with https rather than ssh.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the discussion about the problem #30942

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question I'm asking is: does the simple-git library pass the entire env through to git already today?

Renovate contains controls for admins to decide if they want to pass all env (including secrets) through to child processes. I just want to make sure that we're not opening up any security holes here.

@@ -366,7 +372,7 @@ export async function cloneSubmodules(
try {
logger.debug(`Cloning git submodule at ${submodule}`);
await gitRetry(() =>
git.submoduleUpdate(['--init', '--recursive', submodule]),
git.env(gitEnv).submoduleUpdate(['--init', '--recursive', submodule]),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another angle of the question above: if there's no git.env.submoduleUpdate and just git.submoduleUpdate then is the whole env passed through by default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants