Skip to content

enterprise tests.yml add gitee secret token - #17368

Merged
JinHai-CN merged 2 commits into
infiniflow:mainfrom
myf-bee:main-testyml-add-token
Jul 24, 2026
Merged

JinHai-CN merged 2 commits into
infiniflow:mainfrom
myf-bee:main-testyml-add-token

Conversation

@myf-bee

@myf-bee myf-bee commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

enterprise tests.yml add gitee secret token

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jul 24, 2026
@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The GitHub Actions test workflow now uses secrets.GITEE_TOKEN for Gitee Git URL rewriting and Docker BuildKit secrets across preflight, Infinity, and Elasticsearch nightly test paths.

Changes

Gitee CI authentication

Layer / File(s) Summary
Preflight token configuration
.github/workflows/tests.yml
The preflight Python test setup replaces the hard-coded Gitee OAuth token with secrets.GITEE_TOKEN.
Nightly build token wiring
.github/workflows/tests.yml
Infinity and Elasticsearch nightly builds pass the token through temporary Docker build secret files and use it for subsequent Git URL rewriting.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: ci

Suggested reviewers: hz-186

Poem

I’m a rabbit guarding the build,
With token secrets safely sealed.
Gitee hops through Docker’s door,
No hard-coded keys remain anymore.
CI runs clean from shore to shore.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description only repeats the change and omits the requested background context and purpose. Expand the Summary with what problem this solves, why the Gitee token is needed, and any relevant reviewer context.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is specific and matches the main workflow change to use a Gitee secret token.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 601742e and d0cd332.

📒 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/"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔒 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 || true

Repository: 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:


🌐 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:


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.

Comment on lines +224 to +228
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}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔒 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} .

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔒 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.

@JinHai-CN
JinHai-CN merged commit ae4727e into infiniflow:main Jul 24, 2026
3 checks passed
@myf-bee
myf-bee deleted the main-testyml-add-token branch August 5, 2026 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants