Repository navigation
fix(scripts): keep a self-hosted GitLab token on its own host - #20
Merged
Merged
Conversation
runner-ctl.sh loads $MINIRUNNER_HOME/mini-runner.env with `.`, so a GITLAB_HOST set there without `export` (as mini-runner.env.example does) stayed in the control script's shell. start runs check-repo.sh as a child process, which then fell back to gitlab.com. With a self-hosted GitLab the project check asked the wrong server, and on the curl path it sent the self-hosted GITLAB_TOKEN to gitlab.com whenever that token was in the environment. runner-ctl.sh now exports GITLAB_HOST right after loading the env file when it is set, so the check asks the server named there. gh-runners-ctl.sh is unchanged: it only checks GitHub repositories. check-repo.sh no longer sends GITLAB_TOKEN to a default host. On the curl path (no glab), the token is sent only to a host named in GITLAB_HOST, gitlab.com included; with the token and no GITLAB_HOST, a GitLab target is reported UNVERIFIED (exit 3) and no request is made. The glab path is unchanged, since glab keeps its own login per --hostname. The script header, the env example and docs/public-repos.md state the rule. Tests: the host from the env file reaches a fake curl and a fake glab started by runner-ctl.sh, the token without GITLAB_HOST is never sent, and with GITLAB_HOST set the token goes only to that host.
# Conflicts: # docs/public-repos.md # scripts/mini-runner.env.example
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.
runner-ctl.sh loads $MINIRUNNER_HOME/mini-runner.env with
., so a GITLAB_HOST set there withoutexport(as mini-runner.env.example does) stayed in the control script's shell. start runscheck-repo.sh as a child process, which then fell back to gitlab.com. With a self-hosted GitLab the
project check asked the wrong server, and on the curl path it sent the self-hosted GITLAB_TOKEN to
gitlab.com whenever that token was in the environment.
runner-ctl.sh now exports GITLAB_HOST right after loading the env file when it is set, so the check
asks the server named there. gh-runners-ctl.sh is unchanged: it only checks GitHub repositories.
check-repo.sh no longer sends GITLAB_TOKEN to a default host. On the curl path (no glab), the token is
sent only to a host named in GITLAB_HOST, gitlab.com included; with the token and no GITLAB_HOST, a
GitLab target is reported UNVERIFIED (exit 3) and no request is made. The glab path is unchanged, since
glab keeps its own login per --hostname. The script header, the env example and docs/public-repos.md
state the rule, and the check-repo wrapper in the README and the env example no longer says the control
scripts do not pass GITLAB_HOST on.
Tests: the host from the env file reaches a fake curl and a fake glab started by runner-ctl.sh, the
token without GITLAB_HOST is never sent, and with GITLAB_HOST set the token goes only to that host.