Repository navigation
Fix gitee add env token - #17266
Fix gitee add env token#17266myf-bee wants to merge 3 commits into
Conversation
📝 WalkthroughWalkthroughThe CI workflow now runs PR checks through ChangesCI event and mirror authentication
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant GitHubActions
participant DockerBuild
participant Gitee
GitHubActions->>DockerBuild: pass GITEE_TOKEN as a BuildKit secret
DockerBuild->>Gitee: fetch mirrored build resources with NEED_MIRROR=1
GitHubActions->>Gitee: rewrite test-environment git URLs with GITEE_TOKEN
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Checkov (3.3.8).github/workflows/sep-tests.ymlTraceback (most recent call last): 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: 3
🤖 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/sep-tests.yml:
- Around line 351-359: Ensure temporary Gitee token files are cleaned up on
failed builds by installing an EXIT trap immediately after each GITEE_TOKEN_FILE
mktemp assignment: update .github/workflows/sep-tests.yml lines 351-359 and
930-938 with the same cleanup trap, while retaining the existing explicit rm
cleanup.
- Around line 17-20: Replace the pull_request_target trigger in the workflow
with pull_request so fork PR code runs without repository secrets, preserving
the synchronize and labeled activity types. Remove or revise any dependent
secret usage, including GITEE_TOKEN, so the workflow remains safe when checking
out and executing PR-controlled code.
- Line 245: Replace the global Git configuration used at all three sites in
.github/workflows/sep-tests.yml (lines 245, 364, and 943) with one temporary
job-scoped GIT_CONFIG_GLOBAL file, and remove that file after the corresponding
uv command completes. Ensure each site uses the temporary config for its Git
access and does not persist the token in the runner’s user-level configuration.
🪄 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: bee4ae7c-ed99-4d83-9a6b-e6c451eccf6a
📒 Files selected for processing (1)
.github/workflows/sep-tests.yml
| # We use pull_request_target so that GITEE_TOKEN (and other repo secrets) are available when building | ||
| # ragflow:nightly from a fork PR, while still running the full test suite on PRs labeled with `ci`. | ||
| pull_request_target: | ||
| types: [synchronize, labeled] |
There was a problem hiding this comment.
🔒 Security & Privacy | 🔴 Critical | ⚡ Quick win
Do not execute fork PR code under pull_request_target.
This event grants repository secrets, but the workflow checks out the PR merge ref (Lines 58 and 287) and executes PR-controlled Dockerfiles, hooks, package setup, and tests on a self-hosted runner. Once a PR has the ci label, an attacker can push a later commit and exfiltrate GITEE_TOKEN from the Git config or BuildKit secret mount. Run untrusted PR CI under pull_request without secrets; reserve pull_request_target for trusted base-repository metadata or an explicitly trusted, immutable ref.
🤖 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/sep-tests.yml around lines 17 - 20, Replace the
pull_request_target trigger in the workflow with pull_request so fork PR code
runs without repository secrets, preserving the synchronize and labeled activity
types. Remove or revise any dependent secret usage, including GITEE_TOKEN, so
the workflow remains safe when checking out and executing PR-controlled code.
| if: steps.detect_changes.outputs.has_python_changes == 'true' | ||
| 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 | 🟠 Major | ⚡ Quick win
Avoid persisting the token in the runner’s global Git config. git config --global writes the credential to the runner user’s ~/.gitconfig without cleanup, allowing later jobs on this self-hosted runner to read it.
.github/workflows/sep-tests.yml#L245-L245: use a temporaryGIT_CONFIG_GLOBALand remove it afteruvcompletes..github/workflows/sep-tests.yml#L364-L364: use the same temporary, job-scoped Git config..github/workflows/sep-tests.yml#L943-L943: use the same temporary, job-scoped Git config.
📍 Affects 1 file
.github/workflows/sep-tests.yml#L245-L245(this comment).github/workflows/sep-tests.yml#L364-L364.github/workflows/sep-tests.yml#L943-L943
🤖 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/sep-tests.yml at line 245, Replace the global Git
configuration used at all three sites in .github/workflows/sep-tests.yml (lines
245, 364, and 943) with one temporary job-scoped GIT_CONFIG_GLOBAL file, and
remove that file after the corresponding uv command completes. Ensure each site
uses the temporary config for its Git access and does not persist the token in
the runner’s user-level configuration.
| GITEE_TOKEN_FILE="$(mktemp)" | ||
| printf '%s' '${{ secrets.GITEE_TOKEN }}' > "${GITEE_TOKEN_FILE}" | ||
| ( | ||
| flock -w 10800 9 || { echo "Timed out waiting for the shared Docker build slot" >&2; exit 1; } | ||
| echo "Acquired Docker build slot for ${DOC_ENGINE}/${API_PROXY_SCHEME}" | ||
| ##sudo docker pull ubuntu:24.04 | ||
| sudo DOCKER_BUILDKIT=1 docker build --build-arg NEED_MIRROR=0 --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} . | ||
| ) 9>"${BUILD_LOCK_FILE}" | ||
| rm -f "${GITEE_TOKEN_FILE}" |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Clean up token files on failed builds. With set -e, a failed docker build exits before the following rm, leaving a readable credential file on the persistent runner. Install an EXIT trap immediately after mktemp.
.github/workflows/sep-tests.yml#L351-L359: addtrap 'rm -f "$GITEE_TOKEN_FILE"' EXIT..github/workflows/sep-tests.yml#L930-L938: add the same failure-safe cleanup trap.
📍 Affects 1 file
.github/workflows/sep-tests.yml#L351-L359(this comment).github/workflows/sep-tests.yml#L930-L938
🤖 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/sep-tests.yml around lines 351 - 359, Ensure temporary
Gitee token files are cleaned up on failed builds by installing an EXIT trap
immediately after each GITEE_TOKEN_FILE mktemp assignment: update
.github/workflows/sep-tests.yml lines 351-359 and 930-938 with the same cleanup
trap, while retaining the existing explicit rm cleanup.
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
internal/admin/router.go (1)
14-15: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove CI marker comments from source files. These comments do not document runtime behavior and should not remain in production or test source. Preserve only the meaningful Vite explanation on Line 9 and remove its trailing marker text.
internal/admin/router.go#L14-L15: restore the header and remove both CI marker lines.internal/cli/admin_parser.go#L15-L15: delete the marker comment.internal/cli/benchmark.go#L15-L15: delete the marker comment.internal/cli/cli_test.go#L15-L15: delete the marker comment.internal/common/constants_test.go#L15-L15: delete the marker comment.mcp/client/streamable_http_client.py#L14-L14: remove the marker suffix.memory/utils/infinity_conn.py#L15-L15: delete the marker comment.ragflow_deps/download_deps.py#L31-L31: restore the original header wording.test/testcases/test_http_api/test_chat_assistant_management/test_chat_sdk_routes_unit.py#L14-L14: remove the marker suffix.test/unit_test/api/apps/restful_apis/test_agentbots_access_control.py#L14-L14: remove the marker suffix.web/tailwind.config.js#L1-L1: delete the marker comment.web/vite.config.ts#L9-L9: remove onlytest web ci 2.As per coding guidelines, remove stale documentation and unnecessary compatibility or marker-only surfaces.
🤖 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 `@internal/admin/router.go` around lines 14 - 15, Remove the CI marker comments while preserving meaningful headers and explanations: in internal/admin/router.go lines 14-15 restore the header and remove both marker lines; delete the marker comments at internal/cli/admin_parser.go:15, internal/cli/benchmark.go:15, internal/cli/cli_test.go:15, internal/common/constants_test.go:15, memory/utils/infinity_conn.py:15, web/tailwind.config.js:1; remove marker suffixes at mcp/client/streamable_http_client.py:14, test/testcases/test_http_api/test_chat_assistant_management/test_chat_sdk_routes_unit.py:14, and test/unit_test/api/apps/restful_apis/test_agentbots_access_control.py:14; restore the original header wording at ragflow_deps/download_deps.py:31; and at web/vite.config.ts:9 remove only the specified CI marker text while retaining the Vite explanation.Source: Coding guidelines
🤖 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:
- Around line 222-230: Update the workflow’s Docker build shell block to
register cleanup for the temporary file immediately after creating it, so the
token file is removed on success, failure, or cancellation. Apply the same
change to both affected build blocks, preserving the existing token creation and
build commands while replacing the success-only rm flow with exit-safe cleanup.
- Around line 222-230: Restrict secret-bearing Docker builds to trusted refs and
contexts: in .github/workflows/tests.yml lines 222-230 and 671-679, remove
GITEE_TOKEN from PR-controlled builds and ensure those builds cannot pass it to
Dockerfile instructions; in Dockerfile lines 53-65, consume the token only when
the build context is trusted and never from an untrusted pull request.
In `@internal/admin/router.go`:
- Line 14: Restore the exact Apache license header boilerplate at
internal/admin/router.go:14-14, mcp/client/streamable_http_client.py:14-14,
test/testcases/test_http_api/test_chat_assistant_management/test_chat_sdk_routes_unit.py:14-14,
and test/unit_test/api/apps/restful_apis/test_agentbots_access_control.py:14-14
by removing all appended test or CI text; make no other changes.
---
Nitpick comments:
In `@internal/admin/router.go`:
- Around line 14-15: Remove the CI marker comments while preserving meaningful
headers and explanations: in internal/admin/router.go lines 14-15 restore the
header and remove both marker lines; delete the marker comments at
internal/cli/admin_parser.go:15, internal/cli/benchmark.go:15,
internal/cli/cli_test.go:15, internal/common/constants_test.go:15,
memory/utils/infinity_conn.py:15, web/tailwind.config.js:1; remove marker
suffixes at mcp/client/streamable_http_client.py:14,
test/testcases/test_http_api/test_chat_assistant_management/test_chat_sdk_routes_unit.py:14,
and test/unit_test/api/apps/restful_apis/test_agentbots_access_control.py:14;
restore the original header wording at ragflow_deps/download_deps.py:31; and at
web/vite.config.ts:9 remove only the specified CI marker text while retaining
the Vite explanation.
🪄 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: e9d4d7c0-266a-45c5-9e51-9bf88cd9be86
📒 Files selected for processing (15)
.github/workflows/sep-tests.yml.github/workflows/tests.ymlDockerfileinternal/admin/router.gointernal/cli/admin_parser.gointernal/cli/benchmark.gointernal/cli/cli_test.gointernal/common/constants_test.gomcp/client/streamable_http_client.pymemory/utils/infinity_conn.pyragflow_deps/download_deps.pytest/testcases/test_http_api/test_chat_assistant_management/test_chat_sdk_routes_unit.pytest/unit_test/api/apps/restful_apis/test_agentbots_access_control.pyweb/tailwind.config.jsweb/vite.config.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- .github/workflows/sep-tests.yml
| env: | ||
| GITEE_TOKEN: ${{ secrets.GITEE_TOKEN }} | ||
| run: | | ||
| set -euo pipefail | ||
| 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} . | ||
| _gitee_secret=$(mktemp) | ||
| printf '%s' "${GITEE_TOKEN}" > "${_gitee_secret}" | ||
| sudo DOCKER_BUILDKIT=1 docker build --secret id=gitee_token,src="${_gitee_secret}" --build-arg NEED_MIRROR=1 --build-arg HTTPS_PROXY=${HTTPS_PROXY} --build-arg HTTP_PROXY=${HTTP_PROXY} -f Dockerfile -t ${RAGFLOW_IMAGE} . | ||
| rm -f "${_gitee_secret}" |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Clean up the temporary token file on every exit path.
rm -f runs only after a successful build. A failed or cancelled build can leave the plaintext token on the persistent self-hosted runner.
Proposed cleanup
_gitee_secret=$(mktemp)
+ trap 'rm -f -- "${_gitee_secret}"' EXIT
printf '%s' "${GITEE_TOKEN}" > "${_gitee_secret}"
sudo DOCKER_BUILDKIT=1 docker build ...
- rm -f "${_gitee_secret}"Also applies to: 671-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 around lines 222 - 230, Update the workflow’s
Docker build shell block to register cleanup for the temporary file immediately
after creating it, so the token file is removed on success, failure, or
cancellation. Apply the same change to both affected build blocks, preserving
the existing token creation and build commands while replacing the success-only
rm flow with exit-safe cleanup.
🔒 Security & Privacy | 🔴 Critical | 🏗️ Heavy lift
The Gitee token crosses an untrusted PR build boundary.
pull_request_target checks out the PR merge ref and then supplies GITEE_TOKEN to Dockerfile instructions controlled by that PR. Keep secret-bearing builds on trusted refs/contexts only.
.github/workflows/tests.yml#L222-L230: removeGITEE_TOKENfrom builds that can execute PR-controlled Dockerfiles..github/workflows/tests.yml#L671-L679: apply the same trusted-context restriction to the Elasticsearch build.Dockerfile#L53-L65: consume the token only from a Dockerfile/context that is not supplied by an untrusted pull request.
📍 Affects 2 files
.github/workflows/tests.yml#L222-L230(this comment).github/workflows/tests.yml#L671-L679Dockerfile#L53-L65
🤖 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 222 - 230, Restrict secret-bearing
Docker builds to trusted refs and contexts: in .github/workflows/tests.yml lines
222-230 and 671-679, remove GITEE_TOKEN from PR-controlled builds and ensure
those builds cannot pass it to Dockerfile instructions; in Dockerfile lines
53-65, consume the token only when the build context is trusted and never from
an untrusted pull request.
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // | ||
| // limitations under the License. ci test 7 8 |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
Restore the exact Apache license headers. Do not append test or CI text to the “limitations under the License” line; keep legal boilerplate unchanged to avoid compliance ambiguity.
internal/admin/router.go#L14-L14: restore the original Apache header line.mcp/client/streamable_http_client.py#L14-L14: removetest ci.test/testcases/test_http_api/test_chat_assistant_management/test_chat_sdk_routes_unit.py#L14-L14: removeteset ci all.test/unit_test/api/apps/restful_apis/test_agentbots_access_control.py#L14-L14: removetest ci unit_test.
As per coding guidelines, remove stale documentation and preserve comments aligned with the current runtime path.
📍 Affects 4 files
internal/admin/router.go#L14-L14(this comment)mcp/client/streamable_http_client.py#L14-L14test/testcases/test_http_api/test_chat_assistant_management/test_chat_sdk_routes_unit.py#L14-L14test/unit_test/api/apps/restful_apis/test_agentbots_access_control.py#L14-L14
🤖 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 `@internal/admin/router.go` at line 14, Restore the exact Apache license header
boilerplate at internal/admin/router.go:14-14,
mcp/client/streamable_http_client.py:14-14,
test/testcases/test_http_api/test_chat_assistant_management/test_chat_sdk_routes_unit.py:14-14,
and test/unit_test/api/apps/restful_apis/test_agentbots_access_control.py:14-14
by removing all appended test or CI text; make no other changes.
Source: Coding guidelines
8f1c68f to
fc0a6c9
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/workflows/sep-tests.yml (1)
284-291: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick winDisable checkout credential persistence.
actions/checkout@v6persists credentials by default, so setpersist-credentials: falsein both checkout steps unless later git operations insidePR_NUMBERworkflows require the token.🤖 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/sep-tests.yml around lines 284 - 291, Disable credential persistence in both checkout steps by adding the checkout action’s persist-credentials setting as false. Apply this consistently to both checkout configurations, while preserving the existing behavior only if later git operations in PR_NUMBER workflows explicitly require the token.Source: Linters/SAST tools
🤖 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/sep-tests.yml:
- Line 61: Remove the unsupported allow-unsafe-pr-checkout input from all
actions/checkout@v6 configurations in the workflow, including the occurrences
near lines 61, 291, and 871. Keep the remaining checkout settings unchanged.
---
Outside diff comments:
In @.github/workflows/sep-tests.yml:
- Around line 284-291: Disable credential persistence in both checkout steps by
adding the checkout action’s persist-credentials setting as false. Apply this
consistently to both checkout configurations, while preserving the existing
behavior only if later git operations in PR_NUMBER workflows explicitly require
the token.
🪄 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: f4258468-8e8c-4373-b53a-06a7cf0f7c96
📒 Files selected for processing (1)
.github/workflows/sep-tests.yml
| ref: ${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.sha }} | ||
| fetch-depth: 0 | ||
| fetch-tags: true | ||
| allow-unsafe-pr-checkout: true |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
actionlint .github/workflows/sep-tests.ymlRepository: infiniflow/ragflow
Length of output: 4540
Remove the unsupported checkout input.
actions/checkout@v6 does not define allow-unsafe-pr-checkout; it is not in the available inputs, so this setting is ignored. Remove it from lines 61, 291, and 871, or pin to an action version that actually supports it.
🧰 Tools
🪛 actionlint (1.7.12)
[error] 61-61: input "allow-unsafe-pr-checkout" is not defined in action "actions/checkout@v6". available inputs are "clean", "fetch-depth", "fetch-tags", "filter", "github-server-url", "lfs", "path", "persist-credentials", "ref", "repository", "set-safe-directory", "show-progress", "sparse-checkout", "sparse-checkout-cone-mode", "ssh-key", "ssh-known-hosts", "ssh-strict", "ssh-user", "submodules", "token"
(action)
🪛 zizmor (1.26.1)
[warning] 55-61: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
🤖 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/sep-tests.yml at line 61, Remove the unsupported
allow-unsafe-pr-checkout input from all actions/checkout@v6 configurations in
the workflow, including the occurrences near lines 61, 291, and 871. Keep the
remaining checkout settings unchanged.
Source: Linters/SAST tools
Summary
Fix gitee add env token