Merge branch 'cloudflare:master' into master

This commit is contained in:
Areg Vrtanesyan 2025-09-25 09:28:01 +01:00 committed by GitHub
commit fef42f8518
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 114 additions and 3 deletions

17
.ci/github.gitlab-ci.yml Normal file
View File

@ -0,0 +1,17 @@
include:
- local: .ci/commons.gitlab-ci.yml
######################################
### Sync master branch with Github ###
######################################
push-github:
stage: sync
rules:
- !reference [.default-rules, run-on-master]
script:
- ./.ci/scripts/github-push.sh
secrets:
CLOUDFLARED_DEPLOY_SSH_KEY:
vault: gitlab/cloudflare/tun/cloudflared/_branch/master/cloudflared_github_ssh/data@kv
file: false
cache: {}

31
.ci/scripts/github-push.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
set -e -o pipefail
BRANCH="master"
TMP_PATH="$PWD/tmp"
PRIVATE_KEY_PATH="$TMP_PATH/github-deploy-key"
PUBLIC_KEY_GITHUB_PATH="$TMP_PATH/github.pub"
mkdir -p $TMP_PATH
# Setup Private Key
echo "$CLOUDFLARED_DEPLOY_SSH_KEY" > $PRIVATE_KEY_PATH
chmod 400 $PRIVATE_KEY_PATH
# Download GitHub Public Key for KnownHostsFile
ssh-keyscan -t ed25519 github.com > $PUBLIC_KEY_GITHUB_PATH
# Setup git ssh command with the right configurations
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=$PUBLIC_KEY_GITHUB_PATH -o IdentitiesOnly=yes -i $PRIVATE_KEY_PATH"
# Add GitHub as a new remote
git remote add github git@github.com:cloudflare/cloudflared.git || true
# GitLab doesn't pull branch references, instead it creates a new one on each pipeline.
# Therefore, we need to manually fetch the reference to then push it to GitHub.
git fetch origin $BRANCH:$BRANCH
git push -u github $BRANCH
if TAG="$(git describe --tags --exact-match 2>/dev/null)"; then
git push -u github "$TAG"
fi

52
.ci/scripts/vuln-check.sh Executable file
View File

@ -0,0 +1,52 @@
#!/bin/bash
set -e
# Define the file to store the list of vulnerabilities to ignore.
IGNORE_FILE=".vulnignore"
# Check if the ignored vulnerabilities file exists. If not, create an empty one.
if [ ! -f "$IGNORE_FILE" ]; then
touch "$IGNORE_FILE"
echo "Created an empty file to store ignored vulnerabilities: $IGNORE_FILE"
echo "# Add vulnerability IDs (e.g., GO-2022-0450) to ignore, one per line." >> "$IGNORE_FILE"
echo "# You can also add comments on the same line after the ID." >> "$IGNORE_FILE"
echo "" >> "$IGNORE_FILE"
fi
# Run govulncheck and capture its output.
VULN_OUTPUT=$(go run -mod=readonly golang.org/x/vuln/cmd/govulncheck@latest ./... || true)
# Print the govuln output
echo "====================================="
echo "Full Output of govulncheck:"
echo "====================================="
echo "$VULN_OUTPUT"
echo "====================================="
echo "End of govulncheck Output"
echo "====================================="
# Process the ignore file to remove comments and empty lines.
# The 'cut' command gets the vulnerability ID and removes anything after the '#'.
# The 'grep' command filters out empty lines and lines starting with '#'.
CLEAN_IGNORES=$(grep -v '^\s*#' "$IGNORE_FILE" | cut -d'#' -f1 | sed 's/ //g' | sort -u || true)
# Filter out the ignored vulnerabilities.
UNIGNORED_VULNS=$(echo "$VULN_OUTPUT" | grep 'Vulnerability')
# If the list of ignored vulnerabilities is not empty, filter them out.
if [ -n "$CLEAN_IGNORES" ]; then
UNIGNORED_VULNS=$(echo "$UNIGNORED_VULNS" | grep -vFf <(echo "$CLEAN_IGNORES") || true)
fi
# If there are any vulnerabilities that were not in our ignore list, print them and exit with an error.
if [ -n "$UNIGNORED_VULNS" ]; then
echo "🚨 Found new, unignored vulnerabilities:"
echo "-------------------------------------"
echo "$UNIGNORED_VULNS"
echo "-------------------------------------"
echo "Exiting with an error. ❌"
exit 1
else
echo "🎉 No new vulnerabilities found. All clear! ✨"
exit 0
fi

View File

@ -7,7 +7,7 @@ default:
VAULT_ID_TOKEN: VAULT_ID_TOKEN:
aud: https://vault.cfdata.org aud: https://vault.cfdata.org
stages: [pre-build, build, validate, test, package, release] stages: [sync, pre-build, build, validate, test, package, release]
include: include:
##################################################### #####################################################
@ -15,6 +15,11 @@ include:
##################################################### #####################################################
- local: .ci/commons.gitlab-ci.yml - local: .ci/commons.gitlab-ci.yml
#####################################################
########### Sync Repository with Github #############
#####################################################
- local: .ci/github.gitlab-ci.yml
##################################################### #####################################################
############# Build or Fetch CI Image ############### ############# Build or Fetch CI Image ###############
##################################################### #####################################################

3
.vulnignore Normal file
View File

@ -0,0 +1,3 @@
# Add vulnerability IDs (e.g., GO-2022-0450) to ignore, one per line.
# You can also add comments on the same line after the ID.
GO-2025-3942 # Ignore core-dns vulnerability since we will be removing the proxy-dns feature in the near future

View File

@ -142,7 +142,7 @@ clean:
.PHONY: vulncheck .PHONY: vulncheck
vulncheck: vulncheck:
@go run -mod=readonly golang.org/x/vuln/cmd/govulncheck@latest ./... @./.ci/scripts/vuln-check.sh
.PHONY: cloudflared .PHONY: cloudflared
cloudflared: cloudflared:

View File

@ -1,3 +1,7 @@
2025.9.1
- 2025-09-22 TUN-9855: Create script to ignore vulnerabilities from govuln check
- 2025-09-19 TUN-9852: Remove fmt.Println from cloudflared access command
2025.9.0 2025.9.0
- 2025-09-15 TUN-9820: Add support for FedRAMP in originRequest Access config - 2025-09-15 TUN-9820: Add support for FedRAMP in originRequest Access config
- 2025-09-11 TUN-9800: Migrate cloudflared-ci pipelines to Gitlab CI - 2025-09-11 TUN-9800: Migrate cloudflared-ci pipelines to Gitlab CI

View File

@ -255,7 +255,6 @@ func getToken(appURL *url.URL, appInfo *AppInfo, useHostOnly bool, autoClose boo
// getTokensFromEdge will attempt to use the transfer service to retrieve an app and org token, save them to disk, // getTokensFromEdge will attempt to use the transfer service to retrieve an app and org token, save them to disk,
// and return the app token. // and return the app token.
func getTokensFromEdge(appURL *url.URL, appAUD, appTokenPath, orgTokenPath string, useHostOnly bool, autoClose bool, isFedramp bool, log *zerolog.Logger) (string, error) { func getTokensFromEdge(appURL *url.URL, appAUD, appTokenPath, orgTokenPath string, useHostOnly bool, autoClose bool, isFedramp bool, log *zerolog.Logger) (string, error) {
fmt.Println("Get tokens from edge ", autoClose)
// If no org token exists or if it couldn't be exchanged for an app token, then run the transfer service flow. // If no org token exists or if it couldn't be exchanged for an app token, then run the transfer service flow.
// this weird parameter is the resource name (token) and the key/value // this weird parameter is the resource name (token) and the key/value