cloudflare/cloudflared

Public

mirrored from https://github.com/cloudflare/cloudflaredAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
2026.2.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.ci/scripts/vuln-check.sh

53lines · modecode

1#!/bin/bash
2set -e -u
3
4# Define the file to store the list of vulnerabilities to ignore.
5IGNORE_FILE=".vulnignore"
6
7go version
8# Check if the ignored vulnerabilities file exists. If not, create an empty one.
9if [ ! -f "$IGNORE_FILE" ]; then
10 touch "$IGNORE_FILE"
11 echo "Created an empty file to store ignored vulnerabilities: $IGNORE_FILE"
12 echo "# Add vulnerability IDs (e.g., GO-2022-0450) to ignore, one per line." >>"$IGNORE_FILE"
13 echo "# You can also add comments on the same line after the ID." >>"$IGNORE_FILE"
14 echo "" >>"$IGNORE_FILE"
15fi
16
17# Run govulncheck and capture its output.
18VULN_OUTPUT=$(go run -mod=readonly golang.org/x/vuln/cmd/govulncheck@latest ./... || true)
19
20# Print the govuln output
21echo "====================================="
22echo "Full Output of govulncheck:"
23echo "====================================="
24echo "$VULN_OUTPUT"
25echo "====================================="
26echo "End of govulncheck Output"
27echo "====================================="
28
29# Process the ignore file to remove comments and empty lines.
30# The 'cut' command gets the vulnerability ID and removes anything after the '#'.
31# The 'grep' command filters out empty lines and lines starting with '#'.
32CLEAN_IGNORES=$(grep -v '^\s*#' "$IGNORE_FILE" | cut -d'#' -f1 | sed 's/ //g' | sort -u || true)
33
34# Filter out the ignored vulnerabilities.
35UNIGNORED_VULNS=$(echo "$VULN_OUTPUT" | grep 'Vulnerability' || true)
36
37# If the list of ignored vulnerabilities is not empty, filter them out.
38if [ -n "$CLEAN_IGNORES" ]; then
39 UNIGNORED_VULNS=$(echo "$UNIGNORED_VULNS" | grep -vFf <(echo "$CLEAN_IGNORES") || true)
40fi
41
42# If there are any vulnerabilities that were not in our ignore list, print them and exit with an error.
43if [ -n "$UNIGNORED_VULNS" ]; then
44 echo "🚨 Found new, unignored vulnerabilities:"
45 echo "-------------------------------------"
46 echo "$UNIGNORED_VULNS"
47 echo "-------------------------------------"
48 echo "Exiting with an error. ❌"
49 exit 1
50else
51 echo "🎉 No new vulnerabilities found. All clear! ✨"
52 exit 0
53fi