This is an automated email from the ASF dual-hosted git repository.

hello-stephen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 6261b18dc35 [chore](ci) Pin the TeamCity endpoint before requesting an 
OIDC token (#71037)
6261b18dc35 is described below

commit 6261b18dc35c0967bb7d4aaf7816d53104ea6779
Author: shuke <[email protected]>
AuthorDate: Wed Nov 25 21:59:45 2026 +0800

    [chore](ci) Pin the TeamCity endpoint before requesting an OIDC token 
(#71037)
    
    ### Background
    
    GitHub Actions requests a short-lived OIDC token to submit approved
    TeamCity builds to Function Compute (FC). The repository variable
    `TEAMCITY_FC_TRIGGER_URL` supplies the destination.
    
    ### What problem does this PR solve?
    
    Issue Number: None
    Related PR: #70984
    PR Type: Build/CI/Chore
    
    Problem Summary:
    
    The submission helper accepted any HTTPS host with the path `/trigger`.
    A typo in the host could send the token to a different service. Check
    the full URL against the approved Hong Kong FC endpoint before
    requesting the token.
    
    ### Details
    
    - **Affected** — The Bash submission helper used by the
    comment-triggered TeamCity workflow and its Python tests.
    - **Behavior change:** An empty or mismatched URL stops submission
    before either HTTP request. The configured production URL continues to
    work.
    - **Developer and release impact:** Migrating the endpoint requires
    updating the pinned URL and its test in a reviewed change alongside the
    repository variable.
    - **CI permissions and secrets:** The existing job requests the same
    OIDC audience. The change restricts where the token can be sent.
    - **License and third-party** — None.
    - **Rollback** — Revert the change to restore the previous URL
    validation.
    
    ### Testing
    
    - On macOS, the new test failed against the original helper when an
    alternate HTTPS host reached the mocked HTTP client. All 21 helper and
    workflow tests passed with the fix. The tests cover an empty value, a
    different host, a trailing slash, a query string, plain HTTP, and
    successful submission to the approved URL using a mock.
    - `bash -n` and `git diff --check` passed.
    
    ### Release note
    
    None.
    
    ### Check List (For Author)
    
    - Behavior changed: Yes (TeamCity submission accepts only the approved
    FC endpoint)
    - Does this need documentation: No
    - Pre-submission status: Ready. Verified locally with mocked HTTP. A
    live build was outside the scope of this change.
    
    ### AI Disclosure
    
    - Tool: OpenAI Codex
    - Generated: Shell change, tests and PR description.
    - Human review: Pending.
---
 regression-test/pipeline/common/teamcity-utils.sh     |  6 +++++-
 .../pipeline/common/tests/test_teamcity_utils.py      | 19 +++++++++++++++++--
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/regression-test/pipeline/common/teamcity-utils.sh 
b/regression-test/pipeline/common/teamcity-utils.sh
index 519b054b994..1f8fa3e11bd 100644
--- a/regression-test/pipeline/common/teamcity-utils.sh
+++ b/regression-test/pipeline/common/teamcity-utils.sh
@@ -42,7 +42,11 @@ teamcity_fc_submit() (
     set +x
     local lane=$1 pr=$2 head=$3 branch=$4 repeat=$5 token body receipt
     local endpoint=${TEAMCITY_FC_TRIGGER_URL:?Set the repository variable 
TEAMCITY_FC_TRIGGER_URL}
-    [[ "$endpoint" =~ ^https://[A-Za-z0-9.-]+/trigger$ ]] || { echo 'Invalid 
FC HTTPS trigger URL' >&2; return 1; }
+    local 
expected_endpoint='https://doris-c-trigger-mtjzjrppvu.cn-hongkong.fcapp.run/trigger'
+    if [ "$endpoint" != "$expected_endpoint" ]; then
+        echo "TEAMCITY_FC_TRIGGER_URL must be $expected_endpoint" >&2
+        return 1
+    fi
     token=$(printf 'Authorization: Bearer %s\n' 
"${ACTIONS_ID_TOKEN_REQUEST_TOKEN:?}" |
         curl -q --proto '=https' --fail --silent --show-error --max-time 20 
--header @- \
             --get --data-urlencode 
'audience=urn:apache:doris:ci:teamcity-trigger' 
"${ACTIONS_ID_TOKEN_REQUEST_URL:?}" |
diff --git a/regression-test/pipeline/common/tests/test_teamcity_utils.py 
b/regression-test/pipeline/common/tests/test_teamcity_utils.py
index 43f51ff4105..b28c6d88af7 100644
--- a/regression-test/pipeline/common/tests/test_teamcity_utils.py
+++ b/regression-test/pipeline/common/tests/test_teamcity_utils.py
@@ -28,6 +28,7 @@ import unittest
 
 HELPER = Path(__file__).parents[1] / 'teamcity-utils.sh'
 HEAD = 'a' * 40
+FC_TRIGGER_URL = 
'https://doris-c-trigger-mtjzjrppvu.cn-hongkong.fcapp.run/trigger'
 
 
 class TeamCityUtilsTests(unittest.TestCase):
@@ -224,6 +225,20 @@ curl(){ python3 "$FIXTURE_ROOT/status_mock.py" "$@"; }
         self.assertNotEqual(result.returncode, 0)
         self.assertIn('Missing FC lane plan', result.stderr)
 
+    def test_fc_submission_rejects_unexpected_url_before_requesting_oidc(self):
+        mock = 'curl() { echo "unexpected curl call" >&2; return 1; }\n'
+        for endpoint in ('', 'https://fc.example/trigger', FC_TRIGGER_URL + 
'/',
+                         FC_TRIGGER_URL + '?source=ci', 
FC_TRIGGER_URL.replace('https:', 'http:')):
+            with self.subTest(endpoint=endpoint):
+                result = self.run_shell(mock + 'teamcity_fc_submit p0 123 ' + 
HEAD + ' master 1',
+                                        mock=False, check=False, env={
+                                            'TEAMCITY_FC_TRIGGER_URL': 
endpoint,
+                                            'ACTIONS_ID_TOKEN_REQUEST_URL': 
'https://oidc.example/token',
+                                            'ACTIONS_ID_TOKEN_REQUEST_TOKEN': 
'job-token',
+                                        })
+                self.assertNotEqual(result.returncode, 0)
+                self.assertNotIn('unexpected curl call', result.stderr)
+
     def test_fc_submission_validates_receipts_and_never_reposts(self):
         mock = '''curl(){
     local header
@@ -232,7 +247,7 @@ curl(){ python3 "$FIXTURE_ROOT/status_mock.py" "$@"; }
         [[ "$header" == 'Authorization: Bearer job-token' ]] || return 1
         echo '{"value":"fixture-oidc"}'
     else
-        [[ "${!#}" == 'https://fc.example/trigger' &&
+        [[ "${!#}" == "$TEAMCITY_FC_TRIGGER_URL" &&
            "$header" == 'Authorization: Bearer fixture-oidc' ]] || return 1
         while [[ $# -gt 0 && "$1" != --data-binary ]]; do shift; done
         echo "$2" >> "$FIXTURE_ROOT/fc-posts"
@@ -250,7 +265,7 @@ curl(){ python3 "$FIXTURE_ROOT/status_mock.py" "$@"; }
                                                   ({}, 0, 28, False)]:
             posts = self.root / 'fc-posts'
             posts.unlink(missing_ok=True)
-            env = {'TEAMCITY_FC_TRIGGER_URL': 'https://fc.example/trigger',
+            env = {'TEAMCITY_FC_TRIGGER_URL': FC_TRIGGER_URL,
                    'ACTIONS_ID_TOKEN_REQUEST_URL': 
'https://oidc.example/token',
                    'ACTIONS_ID_TOKEN_REQUEST_TOKEN': 'job-token',
                    'FC_REPLY': json.dumps(reply), 'FC_STATUS': str(status), 
'FC_EXIT': str(exit_code)}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to