-
-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathvalidate-repos.sh
More file actions
executable file
·121 lines (104 loc) · 3.39 KB
/
Copy pathvalidate-repos.sh
File metadata and controls
executable file
·121 lines (104 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/bash
echo "::group:: ===$(basename "$0")==="
set -eou pipefail
REPOS_DIR="/etc/yum.repos.d"
VALIDATION_FAILED=0
ENABLED_REPOS=()
echo "Validating all repository files are disabled..."
# Check if repos directory exists
if [[ ! -d "$REPOS_DIR" ]]; then
echo "Warning: $REPOS_DIR does not exist"
exit 0
fi
# Function to check if a repo file has any enabled repos
check_repo_file() {
local repo_file="$1"
local basename_file
basename_file=$(basename "$repo_file")
# Skip if file doesn't exist or isn't readable
[[ ! -f "$repo_file" ]] && return 0
[[ ! -r "$repo_file" ]] && return 0
# Check for enabled=1 in the file
if grep -q "^enabled=1" "$repo_file" 2>/dev/null; then
echo "ENABLED: $basename_file"
ENABLED_REPOS+=("$basename_file")
VALIDATION_FAILED=1
# Show which sections are enabled
echo " Enabled sections:"
local section_name=""
while IFS= read -r line; do
if [[ "$line" =~ ^\[.*\]$ ]]; then
section_name="$line"
elif [[ "$line" =~ ^enabled=1 ]]; then
echo " - $section_name"
fi
done < "$repo_file"
else
echo "Disabled: $basename_file"
fi
}
echo ""
echo "Checking COPR repositories (standard naming)..."
echo "NOTE: With secure isolated installation, NO COPRs should be globally enabled!"
for repo in "$REPOS_DIR"/_copr:copr.fedorainfracloud.org:*.repo; do
[[ -f "$repo" ]] && check_repo_file "$repo"
done
echo ""
echo "Checking COPR repositories (non-standard naming)..."
echo "SECURITY: Enabled COPRs can inject malicious versions of Fedora packages!"
for repo in "$REPOS_DIR"/_copr_*.repo; do
[[ -f "$repo" ]] && check_repo_file "$repo"
done
echo ""
echo "Checking other third-party repositories..."
# List of known third-party repos that should be disabled
OTHER_REPOS=(
"fedora-multimedia.repo"
"tailscale.repo"
"vscode.repo"
"docker-ce.repo"
"fedora-cisco-openh264.repo"
"fedora-coreos-pool.repo"
"terra.repo"
)
for repo_name in "${OTHER_REPOS[@]}"; do
repo_path="$REPOS_DIR/$repo_name"
if [[ -f "$repo_path" ]]; then
check_repo_file "$repo_path"
fi
done
echo ""
echo "Checking RPM Fusion repositories..."
for repo in "$REPOS_DIR"/rpmfusion-*.repo; do
[[ -f "$repo" ]] && check_repo_file "$repo"
done
echo ""
echo "Checking Fedora updates-testing (should be disabled unless beta)..."
if [[ -f "$REPOS_DIR/fedora-updates-testing.repo" ]]; then
if grep -q "^enabled=1" "$REPOS_DIR/fedora-updates-testing.repo" 2>/dev/null; then
# Allow updates-testing to be enabled for beta builds
if [[ "${UBLUE_IMAGE_TAG:-stable}" == "beta" ]]; then
echo "updates-testing is enabled (allowed for beta builds)"
else
echo "ENABLED: fedora-updates-testing.repo (should only be enabled for beta)"
ENABLED_REPOS+=("fedora-updates-testing.repo")
VALIDATION_FAILED=1
fi
else
echo "Disabled: fedora-updates-testing.repo"
fi
fi
# Final summary
echo ""
echo "======================================"
if [[ $VALIDATION_FAILED -eq 1 ]]; then
echo "VALIDATION FAILED"
echo "======================================"
echo ""
echo "The following repositories are still ENABLED:"
for repo in "${ENABLED_REPOS[@]}"; do
echo " • $repo"
done
exit 1
fi
echo "::endgroup::"