Repository navigation
enterprise tests.yml add gitee secret token - #17368
Conversation
📝 WalkthroughWalkthroughThe GitHub Actions test workflow now uses ChangesGitee CI authentication
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/tests.yml:
- Line 227: Restrict the Docker build commands in the relevant workflow jobs to
trusted revisions or non-pull-request events before passing the gitee_token
secret. Update the steps invoking Docker with --secret id=gitee_token (including
the alternate occurrence) so pull-request-controlled Dockerfiles cannot access
the token, while preserving token-bearing builds for trusted workflow contexts.
- Line 135: Update the Git configuration commands in the workflow, including all
occurrences of the GITEE_TOKEN setup, to avoid writing the credential to global
~/.gitconfig. Gate token use to trusted events and use an ephemeral, narrowly
scoped Git configuration for required dependency operations, then remove or
unset it before running pull-request-controlled uv setup and tests; preserve
unauthenticated behavior for untrusted events.
- Line 135: Update the Gitee authentication setup at all listed git config
occurrences to avoid directly interpolating secrets in run commands: expose
GITEE_TOKEN through the step or job environment, then reference the environment
variable in the command so special characters cannot alter shell parsing or URL
construction.
- Around line 224-228: Update the workflow block after GITEE_TOKEN_FILE is
created to register an EXIT trap that always removes the temporary token file,
including when docker pull or build fails. Ensure the token file remains
permission-restricted immediately after creation, before writing the secret or
invoking Docker.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 636426d2-9532-404b-b519-910268eba3fd
📒 Files selected for processing (1)
.github/workflows/tests.yml
| - name: Prepare Python test environment | ||
| run: | | ||
| git config --global url."https://oauth2:796df937ae36d0014a35aa8ab2b02609@gitee.com/".insteadOf "https://gitee.com/" | ||
| git config --global url."https://oauth2:${{ secrets.GITEE_TOKEN }}@gitee.com/".insteadOf "https://gitee.com/" |
There was a problem hiding this comment.
🔒 Security & Privacy | 🔴 Critical | 🏗️ Heavy lift
Do not persist GITEE_TOKEN in global Git configuration.
These commands write the token into ~/.gitconfig, then execute pull-request-controlled uv setup and tests. The credential can be read by repository code and may remain on a reused self-hosted runner. Use trusted-event gating and an ephemeral, scoped Git configuration that is removed before executing untrusted code. GitHub explicitly warns that privileged workflows must not check out untrusted pull-request code while retaining access to secrets. (docs.github.com)
Also applies to: 232-232, 679-679
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/tests.yml at line 135, Update the Git configuration
commands in the workflow, including all occurrences of the GITEE_TOKEN setup, to
avoid writing the credential to global ~/.gitconfig. Gate token use to trusted
events and use an ephemeral, narrowly scoped Git configuration for required
dependency operations, then remove or unset it before running
pull-request-controlled uv setup and tests; preserve unauthenticated behavior
for untrusted events.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== workflow locations =="
rg -n 'GITEE_TOKEN|insteadOf' .github/workflows/tests.yml || true
echo
echo "== context around lines =="
sed -n '120,150p;215,240p;660,686p' .github/workflows/tests.yml | cat -n
echo
echo "== all env secrets in workflow =="
rg -n 'secrets\.[A-Z_]+|GITEE_TOKEN' .github/workflows/tests.yml || trueRepository: infiniflow/ragflow
Length of output: 6493
🌐 Web query:
oauth2 URL userinfo percent-encode @ : # special characters git https://oauth2:[email protected]
💡 Result:
When including authentication tokens (such as OAuth2 access tokens) in the userinfo part of a URL (the section before the @ symbol), you must percent-encode any reserved characters that appear within the token to ensure the URL is parsed correctly [1][2][3][4]. The userinfo component is defined as: userinfo = *( unreserved / pct-encoded / sub-delims / ":") [1][5]. Because the "@" character acts as the delimiter between the userinfo and the host, it cannot appear literally within the userinfo part [1][3][4]. If your token contains an "@", it must be encoded as %40 [2][3][4]. Similarly, the "#" character is a reserved fragment delimiter and must be encoded as %23 if it appears in the userinfo to avoid it being incorrectly interpreted as the start of a URL fragment [2]. For the specific Git usage pattern https://oauth2:[email protected], the following rules apply: 1. Characters needing encoding: Any character that is not unreserved (alphanumeric, -,., _, ~) or explicitly allowed as a sub-delimiter or colon must be percent-encoded [1][5][6]. If your token contains @,:, or #, these must be encoded [2]. 2. The colon (:): The colon is a valid character in the userinfo component [1][5]. However, it is also the separator between the username (oauth2) and the password (your token). If your token contains a literal colon, it may cause parsing ambiguity depending on the client; encoding it as %3A is generally safer when the token is used as a password in this format [2]. 3. Client-side handling: Git and various URL-parsing libraries handle userinfo differently [4][7][8]. Some systems may require that you manually encode the token before constructing the URL string, while others may perform this encoding automatically [3][7]. If you encounter authentication failures, verify whether the tool is decoding the userinfo before passing it to the authentication header (where it should be sent as-is) or if it is failing to parse the URL correctly due to unencoded special characters [3]. In summary, to avoid issues, always URL-encode the token string before embedding it in the URL [2]. For example, if your token is my@token#123, the URL should be formatted as https://oauth2:my%40token%[email protected] [2].
Citations:
- 1: https://datatracker.ietf.org/doc/html/rfc3986.html
- 2: https://http.dev/percent-encoding
- 3: httpc: Fix percent-encoding of userinfo in URLs erlang/otp#8575
- 4: Should
URIsupport usernames with the@character ruby/uri#42 - 5: https://www.rfc-editor.org/rfc/rfc3986.html
- 6: https://stackoverflow.com/questions/5913623/rfc3986-which-pchars-need-to-be-percent-encoded
- 7: https://github.com/go-gitea/gitea/blob/v1.26.2/modules/git/url/url.go
- 8: netrc x-oauth-basic no longer works since 1.2.0-rc1 go-gitea/gitea#2480
🌐 Web query:
GitHub Actions secrets must be base64 encoded if value contains non-printable characters
💡 Result:
GitHub Actions does not strictly require secrets to be Base64 encoded if they contain non-printable characters [1][2]. However, using Base64 encoding is a recommended best practice for storing binary data or complex strings that might otherwise be misinterpreted or corrupted by shell environments, logging mechanisms, or workflow parsers [1][3]. When you store data as a secret in GitHub, the platform treats the value as a single entity and attempts to redact it from your logs [4]. Problems with "non-printable characters" or special symbols often arise not because the storage itself fails, but because of how these characters are interpreted when the secret is injected into a shell or an environment variable [5]. Key considerations include: 1. Handling Binary and Complex Data: Official documentation explicitly recommends using Base64 encoding to store binary blobs (such as certificates or keys) as secrets [1][2]. This ensures that the data maintains its integrity throughout the workflow [1][3]. 2. Avoiding Shell Interpretation: Special characters (such as $, , or newlines) can be interpreted by the shell in a run step, leading to errors or corrupted values [5]. Encoding the secret as Base64 and decoding it within the workflow (e.g., using base64 --decode) is a reliable way to bypass shell-specific parsing issues [1][5][2]. 3. Secret Masking and Redaction: GitHub's automatic redaction mechanism is designed to mask secrets in logs [4]. However, if you transform a secret (such as Base64 encoding it), the resulting transformed value is no longer identical to the original secret [6][7]. If this new value is printed in the logs, it may not be automatically masked [6][7]. You must manually register any transformed or encoded versions of secrets if you want them to be redacted [6][7]. 4. Security Warning: Base64 encoding is an encoding scheme, not a form of encryption [1][3]. Anyone with access to the encoded value can trivially decode it [3]. Ensure that your underlying secret management and repository access controls remain robust [3].
Citations:
- 1: https://docs.github.com/actions/security-guides/using-secrets-in-github-actions
- 2: https://github.com/github/docs/blob/main/content/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets.md
- 3: https://nhimg.org/faq/what-do-teams-get-wrong-about-base64-encoded-secrets/
- 4: https://docs.github.com/en/actions/concepts/security/secrets
- 5: https://stackoverflow.com/questions/77605186/special-characters-in-github-actions-workflow-secret-are-not-being-preserved
- 6: https://github.com/github/docs/blob/main/content/actions/reference/security/secure-use.md
- 7: https://docs.github.com/en/actions/reference/security/secure-use
Avoid interpolating the Gitee secret directly into shell commands.
Using ${{ secrets.GITEE_TOKEN }} inside single run: expressions lets special characters in the token change command parsing and produces malformed git config URLs when chars like @, :, or # are present. Store the secret in workflow env/workflow secrets or safely encode it, then reference the value where it is needed.
Also applies to: 225, 232, 672, 679.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/tests.yml at line 135, Update the Gitee authentication
setup at all listed git config occurrences to avoid directly interpolating
secrets in run commands: expose GITEE_TOKEN through the step or job environment,
then reference the environment variable in the command so special characters
cannot alter shell parsing or URL construction.
| GITEE_TOKEN_FILE="$(mktemp)" | ||
| printf '%s' '${{ secrets.GITEE_TOKEN }}' > "${GITEE_TOKEN_FILE}" | ||
| sudo docker pull ubuntu:24.04 | ||
| sudo DOCKER_BUILDKIT=1 docker build --build-arg NEED_MIRROR=1 --build-arg HTTPS_PROXY=${HTTPS_PROXY} --build-arg HTTP_PROXY=${HTTP_PROXY} -f Dockerfile -t ${RAGFLOW_IMAGE} . | ||
| sudo DOCKER_BUILDKIT=1 docker build --build-arg NEED_MIRROR=1 --build-arg HTTPS_PROXY=${HTTPS_PROXY} --build-arg HTTP_PROXY=${HTTP_PROXY} --secret id=gitee_token,src=${GITEE_TOKEN_FILE} -f Dockerfile -t ${RAGFLOW_IMAGE} . | ||
| rm -f "${GITEE_TOKEN_FILE}" |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Always remove the temporary token file on failure.
rm -f is reached only after a successful pull and build. With set -e, any earlier failure leaves the token on the self-hosted runner. Register an EXIT trap immediately after mktemp and keep the file permission-restricted.
Also applies to: 671-675
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/tests.yml around lines 224 - 228, Update the workflow
block after GITEE_TOKEN_FILE is created to register an EXIT trap that always
removes the temporary token file, including when docker pull or build fails.
Ensure the token file remains permission-restricted immediately after creation,
before writing the secret or invoking Docker.
| printf '%s' '${{ secrets.GITEE_TOKEN }}' > "${GITEE_TOKEN_FILE}" | ||
| sudo docker pull ubuntu:24.04 | ||
| sudo DOCKER_BUILDKIT=1 docker build --build-arg NEED_MIRROR=1 --build-arg HTTPS_PROXY=${HTTPS_PROXY} --build-arg HTTP_PROXY=${HTTP_PROXY} -f Dockerfile -t ${RAGFLOW_IMAGE} . | ||
| sudo DOCKER_BUILDKIT=1 docker build --build-arg NEED_MIRROR=1 --build-arg HTTPS_PROXY=${HTTPS_PROXY} --build-arg HTTP_PROXY=${HTTP_PROXY} --secret id=gitee_token,src=${GITEE_TOKEN_FILE} -f Dockerfile -t ${RAGFLOW_IMAGE} . |
There was a problem hiding this comment.
🔒 Security & Privacy | 🔴 Critical | 🏗️ Heavy lift
Do not pass the token to a pull-request-controlled Dockerfile.
The surrounding jobs check out pull-request merge refs, so a pull request can modify Dockerfile. Any modified RUN --mount=type=secret,id=gitee_token instruction can read and exfiltrate the token during the build; BuildKit only prevents the secret from being baked into the image. (docs.docker.com) Restrict secret-bearing builds to trusted revisions/events.
Also applies to: 674-674
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/tests.yml at line 227, Restrict the Docker build commands
in the relevant workflow jobs to trusted revisions or non-pull-request events
before passing the gitee_token secret. Update the steps invoking Docker with
--secret id=gitee_token (including the alternate occurrence) so
pull-request-controlled Dockerfiles cannot access the token, while preserving
token-bearing builds for trusted workflow contexts.
Summary
enterprise tests.yml add gitee secret token