Skip exact hosts covered by a .domain in nginx maps; confine router with SELinux
ci/woodpecker/pr/lint Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful

This commit is contained in:
2026-10-23 22:37:51 +11:00
parent 4ee52cb615
commit edbe3faeb0
2 changed files with 14 additions and 3 deletions
+6 -3
View File
@@ -85,8 +85,12 @@ router_config() {
done
} >"$dir/dnsmasq.conf"
# nginx "hostnames" rejects an exact key that a .domain key already covers.
local map=""
for host in $hosts; do map+=" $host 1;"$'\n'; done
for host in $hosts; do
[[ $host != .* && " ${hosts//$'\n'/ } " == *" .$host "* ]] && continue
map+=" $host 1;"$'\n'
done
cat >"$dir/nginx.conf" <<EOF
load_module /usr/lib/nginx/modules/ngx_stream_module.so;
worker_processes 1;
@@ -172,8 +176,7 @@ main() {
podman run -d --rm --name "$router" \
--network "$session:ip=$rip" --network "$EGRESS_NET" \
--security-opt label=disable \
-v "$tmp:/etc/router:ro" \
-v "$tmp:/etc/router:ro,Z" \
"$ROUTER_IMAGE" >/dev/null
wait_port "$router" "$rip" 443
+8
View File
@@ -54,6 +54,14 @@ check tcp-servers "$(printf '%s\n' \
"$(grep 'set \$up' <<<"$nginx")"
check listens-on-router-only "" "$(grep -E 'listen ' <<<"$nginx" | grep -v 'listen 10\.89\.7\.2:')"
f=$(list '.example.org' 'example.org' 'example.org:22' 'a.example.org' 'example.org')
dir=$(mktemp -d)
router_config "$f" "$dir" 10.89.7.2 >/dev/null
check overlap-dnsmasq "$(printf '%s\n' 'address=/example.org/127.0.0.2' 'host-record=a.example.org,127.1.0.1' \
'host-record=example.org,127.1.0.2')" "$(grep -E '^(address=/e|host-record)' "$dir/dnsmasq.conf")"
check overlap-map "$(printf ' %s 1;\n' .example.org a.example.org .example.org a.example.org)" \
"$(grep '^ .* 1;$' "$dir/nginx.conf")"
for bad in 'exa mple.com' 'example.com:0' 'example.com:70000' 'example.com:ssh' '*.example.com' \
'-bad.com' 'http://example.com' 'a..b' '.example.com:22'; do
(allowlist_entries "$(list "$bad")") >/dev/null 2>&1