Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
417fe18fe8 | ||
|
|
9d86f1d6f0 | ||
|
|
79495d2a30 | ||
|
|
3503227234 | ||
|
|
49c1ac8239 | ||
|
|
b3dc6e33d1 | ||
|
|
2610857d48 | ||
|
|
ec64cc6508 | ||
|
|
bedba358ae | ||
|
|
38d5901112 | ||
|
|
1037c2114b | ||
|
|
64b8a919e8 | ||
|
|
007b2f490e | ||
|
|
21146660de | ||
|
|
70cf2b51c5 | ||
|
|
fc06ff4886 | ||
|
|
93fe213c18 | ||
|
|
348d39192b | ||
|
|
71ba8a73fc | ||
|
|
e196e61941 | ||
|
|
6e923d3f32 | ||
|
|
f8fd388ade | ||
|
|
0cc1b3cb37 | ||
|
|
a8ce9a5d1a | ||
|
|
7e614803aa | ||
|
|
09fb0c0b43 | ||
|
|
c6d525fec8 | ||
|
|
cf45734fc0 | ||
|
|
387c551c41 | ||
|
|
56daf61290 | ||
|
|
59be656047 |
No files matched your search
+130
-9
@@ -6,7 +6,8 @@ on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
schedule:
|
||||
- cron: "0 6 * * 1"
|
||||
# Saturday 05:00 UTC: 06:00 in Paris in winter, 07:00 in summer (Gitea runs cron in UTC).
|
||||
- cron: "0 5 * * 6"
|
||||
|
||||
jobs:
|
||||
build-and-scan:
|
||||
@@ -18,6 +19,30 @@ jobs:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Get shared actions
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
repository: labeex/cicdeex
|
||||
ref: 1.0.0
|
||||
token: ${{ secrets.CICDEEX_TOKEN }}
|
||||
path: .cicdeex
|
||||
persist-credentials: false
|
||||
|
||||
- name: Scan for secrets
|
||||
run: |
|
||||
# docker cp, not a build COPY: a repo's own .dockerignore (e.g. one that
|
||||
# excludes .git for prod builds) would otherwise silently give an empty,
|
||||
# falsely-clean scan.
|
||||
CID=$(docker create zricethezav/gitleaks:v8.30.1 detect --source=/repo --no-banner -v)
|
||||
docker cp . "$CID:/repo"
|
||||
docker start -a "$CID"
|
||||
STATUS=$?
|
||||
docker rm "$CID" > /dev/null
|
||||
exit $STATUS
|
||||
|
||||
- name: Lint Dockerfile with hadolint
|
||||
run: docker run --rm -i hadolint/hadolint:v2.15.1-alpine hadolint --failure-threshold error - < Dockerfile
|
||||
|
||||
- name: Build Docker image
|
||||
run: docker build -t socat-proxy:ci .
|
||||
|
||||
@@ -33,28 +58,85 @@ jobs:
|
||||
run: docker build --target lint -t socat-proxy:lint .
|
||||
|
||||
- name: Scan with Trivy (critical - blocking)
|
||||
id: trivy_critical
|
||||
continue-on-error: true
|
||||
run: |
|
||||
docker run --rm \
|
||||
-e DOCKER_HOST=tcp://dockerhost:2375 \
|
||||
--add-host=dockerhost:host-gateway \
|
||||
aquasec/trivy:0.74.0 image --exit-code 1 --severity CRITICAL socat-proxy:ci
|
||||
aquasec/trivy:0.76.2 image --exit-code 1 --severity CRITICAL socat-proxy:ci
|
||||
|
||||
- name: Handle CRITICAL findings
|
||||
if: steps.trivy_critical.outcome == 'failure'
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" != "schedule" ]; then
|
||||
echo "::error::CRITICAL vulnerabilities found, failing the build."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Scheduled scan found CRITICAL vulnerabilities — attempting an automatic apk upgrade + rescan."
|
||||
|
||||
sed -i '/^FROM .* AS base$/a RUN apk upgrade --no-cache' Dockerfile
|
||||
docker build -t socat-proxy:remediated .
|
||||
|
||||
if docker run --rm \
|
||||
-e DOCKER_HOST=tcp://dockerhost:2375 \
|
||||
--add-host=dockerhost:host-gateway \
|
||||
aquasec/trivy:0.76.2 image --exit-code 1 --severity CRITICAL socat-proxy:remediated; then
|
||||
echo "apk upgrade clears the CRITICAL finding(s) — opening a PR for review."
|
||||
|
||||
BRANCH="auto/cve-fix-$(date +%Y%m%d)-$(echo "${{ github.sha }}" | cut -c1-7)"
|
||||
git config user.name "socat-proxy-ci"
|
||||
git config user.email "[email protected]"
|
||||
git checkout -b "$BRANCH"
|
||||
git add Dockerfile
|
||||
git commit -m "Auto-remediate CRITICAL CVE via apk upgrade"
|
||||
git config --unset-all http.https://git.djeex.fr/.extraheader || true
|
||||
git push "https://Djeex:${{ secrets.CI_PUSH_TOKEN }}@git.djeex.fr/Djeex/socat-proxy.git" "HEAD:$BRANCH"
|
||||
|
||||
PR_JSON=$(curl -s -X POST \
|
||||
-H "Authorization: token ${{ secrets.CI_PUSH_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$(jq -n --arg head "$BRANCH" '{title: "🔒 Auto: remediate CRITICAL CVE via apk upgrade", head: $head, base: "main", body: "Opened automatically by the scheduled CVE scan. An `apk upgrade --no-cache` cleared the CRITICAL Trivy finding(s) in a rebuild — review the diff and merge to publish the fix."}')" \
|
||||
"https://git.djeex.fr/api/v1/repos/Djeex/socat-proxy/pulls")
|
||||
echo "PR API response: $(echo "$PR_JSON" | jq -r '.html_url // .message // "unknown"')"
|
||||
else
|
||||
echo "::error::apk upgrade does not clear the CRITICAL finding(s) — no automatic fix available, needs manual review."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Scan with Trivy (high - informative)
|
||||
run: |
|
||||
docker run --rm \
|
||||
-e DOCKER_HOST=tcp://dockerhost:2375 \
|
||||
--add-host=dockerhost:host-gateway \
|
||||
aquasec/trivy:0.74.0 image --exit-code 0 --severity HIGH socat-proxy:ci
|
||||
aquasec/trivy:0.76.2 image --exit-code 0 --severity HIGH socat-proxy:ci
|
||||
|
||||
# Pilot: the shared publish action in dry-run, before the real publish,
|
||||
# to compare its output with what the step below really does.
|
||||
- name: Publish dry-run (cicdeex pilot)
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||
continue-on-error: true
|
||||
uses: ./.cicdeex/publish
|
||||
with:
|
||||
image: socat-proxy:ci
|
||||
paths: '^(Dockerfile|entrypoint\.sh|VERSION)$'
|
||||
push-token: ${{ secrets.CI_PUSH_TOKEN }}
|
||||
registry-token: ${{ secrets.REGISTRY_TOKEN }}
|
||||
github-mirror: "true"
|
||||
github-token: ${{ secrets.GH_TOKEN }}
|
||||
dry-run: "true"
|
||||
|
||||
- name: Publish tagged image
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||
run: |
|
||||
BEFORE="${{ github.event.before }}"
|
||||
if [ -n "$BEFORE" ] && [ "$BEFORE" != "0000000000000000000000000000000000000000" ] && git cat-file -e "$BEFORE" 2>/dev/null; then
|
||||
CHANGED=$(git diff --name-only "$BEFORE" "${{ github.sha }}")
|
||||
BASE_REF="$BEFORE"
|
||||
else
|
||||
CHANGED=$(git diff --name-only HEAD~1 HEAD)
|
||||
BASE_REF="HEAD~1"
|
||||
fi
|
||||
CHANGED=$(git diff --name-only "$BASE_REF" "${{ github.sha }}")
|
||||
echo "Changed files:"
|
||||
echo "$CHANGED"
|
||||
|
||||
@@ -102,6 +184,16 @@ jobs:
|
||||
docker push "$IMAGE:$MINOR_TAG"
|
||||
docker push "$IMAGE:$VERSION"
|
||||
|
||||
GHCR_IMAGE=ghcr.io/djeex/socat-proxy
|
||||
echo "${{ secrets.GH_TOKEN }}" | docker login ghcr.io -u Djeex --password-stdin
|
||||
|
||||
docker tag socat-proxy:ci "$GHCR_IMAGE:latest"
|
||||
docker tag socat-proxy:ci "$GHCR_IMAGE:$MINOR_TAG"
|
||||
docker tag socat-proxy:ci "$GHCR_IMAGE:$VERSION"
|
||||
docker push "$GHCR_IMAGE:latest"
|
||||
docker push "$GHCR_IMAGE:$MINOR_TAG"
|
||||
docker push "$GHCR_IMAGE:$VERSION"
|
||||
|
||||
TRIGGER_MSG=$(git log -1 --format=%s "${{ github.sha }}")
|
||||
PR_NUM=$(echo "$TRIGGER_MSG" | grep -oE '#[0-9]+' | head -1 | tr -d '#' || true)
|
||||
|
||||
@@ -127,9 +219,9 @@ jobs:
|
||||
fi
|
||||
fi
|
||||
|
||||
CHANGED_LIST=$(echo "$CHANGED" | sed 's/^/- /')
|
||||
|
||||
REPO_URL="https://git.djeex.fr/Djeex/socat-proxy"
|
||||
COMMIT_LIST=$(git log --no-merges --format="- %s ([%h](${REPO_URL}/commit/%H))" "$BASE_REF".."${{ github.sha }}")
|
||||
|
||||
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
|
||||
SOURCE_LINE="[${SHORT_SHA}](${REPO_URL}/commit/${{ github.sha }})"
|
||||
if [ -n "$PR_NUM" ]; then
|
||||
@@ -145,8 +237,8 @@ jobs:
|
||||
**Source:** ${SOURCE_LINE}
|
||||
**Image:** \`${IMAGE}:${VERSION}\`
|
||||
|
||||
**Changed files:**
|
||||
${CHANGED_LIST}
|
||||
**Commits:**
|
||||
${COMMIT_LIST}
|
||||
EOF
|
||||
)
|
||||
|
||||
@@ -161,3 +253,32 @@ jobs:
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$JSON_PAYLOAD" \
|
||||
"https://git.djeex.fr/api/v1/repos/Djeex/socat-proxy/releases"
|
||||
|
||||
MIRROR_NOTICE="_This github repo is a mirror of https://git.djeex.fr/Djeex/socat-proxy. You'll find full package, PR, history and release note there._"
|
||||
GH_BODY=$(printf '%s\n\n%s' "$MIRROR_NOTICE" "$BODY")
|
||||
|
||||
GH_JSON_PAYLOAD=$(jq -n \
|
||||
--arg tag "$VERSION" \
|
||||
--arg name "$VERSION" \
|
||||
--arg body "$GH_BODY" \
|
||||
--arg sha "${{ github.sha }}" \
|
||||
'{tag_name: $tag, name: $name, target_commitish: $sha, body: $body}')
|
||||
|
||||
GH_STATUS=0
|
||||
for i in 1 2 3 4 5; do
|
||||
GH_STATUS=$(curl -s -o /tmp/gh_release.json -w "%{http_code}" -X POST \
|
||||
-H "Authorization: Bearer ${{ secrets.GH_TOKEN }}" \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$GH_JSON_PAYLOAD" \
|
||||
"https://api.github.com/repos/Djeex/socat-proxy/releases")
|
||||
if [ "$GH_STATUS" = "201" ]; then
|
||||
break
|
||||
fi
|
||||
echo "GitHub Release attempt $i failed (HTTP $GH_STATUS) — mirror may not have synced this commit yet, retrying in 15s..."
|
||||
sleep 15
|
||||
done
|
||||
echo "GitHub Release API response: $GH_STATUS"
|
||||
if [ "$GH_STATUS" != "201" ]; then
|
||||
cat /tmp/gh_release.json 2>/dev/null || true
|
||||
fi
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
FROM alpine:3.24.1 AS base
|
||||
FROM alpine:3.24.4@sha256:f59abe656b692d901e184be3445e084786602108599d2a51d229c0f5a48c71bf AS base
|
||||
|
||||
RUN apk add --no-cache socat netcat-openbsd su-exec \
|
||||
&& rm -rf /var/cache/apk/* /tmp/*
|
||||
|
||||
+1
-1
@@ -145,7 +145,7 @@ fi
|
||||
|
||||
log "[~] Testing connection to target..."
|
||||
# Test if we can reach the target before starting socat
|
||||
if ! nc -z "$TARGET_HOST" "$TARGET_PORT" 2>/dev/null; then
|
||||
if ! nc -z -w 2 "$TARGET_HOST" "$TARGET_PORT" 2>/dev/null; then
|
||||
log "[!] Cannot connect to $TARGET_HOST:$TARGET_PORT - socat will retry automatically"
|
||||
else
|
||||
log "[✓] Connection to $TARGET_HOST:$TARGET_PORT is working"
|
||||
|
||||
+1
-22
@@ -1,25 +1,4 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": ["config:recommended"],
|
||||
"timezone": "Europe/Paris",
|
||||
"labels": ["bot"],
|
||||
"packageRules": [
|
||||
{
|
||||
"matchManagers": ["dockerfile"],
|
||||
"matchUpdateTypes": ["patch"],
|
||||
"automerge": true
|
||||
},
|
||||
{
|
||||
"matchUpdateTypes": ["major"],
|
||||
"addLabels": ["major"]
|
||||
},
|
||||
{
|
||||
"matchUpdateTypes": ["minor"],
|
||||
"addLabels": ["minor"]
|
||||
}
|
||||
],
|
||||
"vulnerabilityAlerts": {
|
||||
"enabled": true,
|
||||
"addLabels": ["bug"]
|
||||
}
|
||||
"extends": ["local>labeex/renovateex"]
|
||||
}
|
||||
@@ -58,7 +58,11 @@ socat_pid() {
|
||||
wait_for_log() {
|
||||
pattern="$1"
|
||||
tries=0
|
||||
while [ "$tries" -lt 20 ]; do
|
||||
# 40 * 0.25s = 10s — merge-triggered runs can land on a cold runner
|
||||
# (evicted Docker cache, first container start), pushing the very first
|
||||
# backgrounded entrypoint.sh past a tighter budget even though nothing's
|
||||
# actually wrong; a rerun on a warm runner always passes.
|
||||
while [ "$tries" -lt 40 ]; do
|
||||
grep -qE "$pattern" "$LOG" 2>/dev/null && return 0
|
||||
tries=$((tries + 1))
|
||||
sleep 0.25
|
||||
|
||||
Reference in new issue
Block a user