Skip to content

Commit 49786cf

Browse files
TMHSDigitalclaude
andcommitted
Drop spent resume state after a degraded resumed run (#396)
A resumed run that finished degraded or unreliable wrote no new state.json, and neither upload branch matched, so the baseline artifact kept the old state and every later run resumed the same remainder. Replace the artifact in that case with the old results only (plus a marker file so the upload is never empty), and add a CI case: stop a lab 5 scan, resume it to a degraded finish, and check that the next use starts a new scan. Fixes #396 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 090df0a commit 49786cf

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

‎.github/workflows/go.yml‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,52 @@ jobs:
350350
test "${{ steps.after.outputs.added }}" = 0
351351
test "${{ steps.after.outputs.removed }}" = 0
352352
353+
# A resumed scan that finishes degraded leaves no state of its own; the
354+
# artifact must drop the spent state so the next use starts over rather
355+
# than resuming the same remainder forever (#396). Lab 5's timeouts make
356+
# every pass degraded.
357+
- name: Stop a failing scan at its time budget
358+
id: stopped-degraded
359+
uses: ./
360+
with:
361+
version: source
362+
domain: example.com
363+
wordlist: examples/labs/words.txt
364+
args: -simulate-zone examples/labs/lab5-failures.zone -seed 7 -rate 5 -t 1
365+
max-duration: 2s
366+
baseline-artifact: subenum-ci-resume-degraded-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.os }}
367+
368+
- name: Continue it to a degraded finish
369+
id: resumed-degraded
370+
uses: ./
371+
with:
372+
version: source
373+
domain: example.com
374+
wordlist: examples/labs/words.txt
375+
args: -simulate-zone examples/labs/lab5-failures.zone -seed 7 -rate 5 -t 1
376+
max-duration: 5m
377+
baseline-artifact: subenum-ci-resume-degraded-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.os }}
378+
379+
- name: Start over after the degraded finish
380+
id: after-degraded
381+
uses: ./
382+
with:
383+
version: source
384+
domain: example.com
385+
wordlist: examples/labs/words.txt
386+
args: -simulate-zone examples/labs/lab5-failures.zone -seed 7 -rate 5 -t 1
387+
max-duration: 2s
388+
baseline-artifact: subenum-ci-resume-degraded-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.os }}
389+
390+
- name: Check the spent state was not resumed again
391+
shell: bash
392+
run: |
393+
set -euo pipefail
394+
test "${{ steps.stopped-degraded.outputs.resumed }}" = false
395+
test "${{ steps.resumed-degraded.outputs.resumed }}" = true
396+
test "${{ steps.resumed-degraded.outputs.verdict }}" = degraded
397+
test "${{ steps.after-degraded.outputs.resumed }}" = false
398+
353399
# The action's default install path, as users get it: download the latest
354400
# release, check it against checksums.txt and its attestation, unpack it
355401
# (#325). The action job above builds from source and never reaches that

‎action.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,14 @@ runs:
306306
printf '%s\n' "$key" > "$carry/state.key"
307307
echo "carry-state=true" >> "$GITHUB_OUTPUT"
308308
echo "::notice::The scan stopped before it finished; the next run with baseline-artifact $BASELINE continues it."
309+
elif [ -n "$BASELINE" ] && [ "$resumed" = true ]; then
310+
# The resumed scan finished below complete and spent its state.
311+
# Replace the artifact without that state, or every later run
312+
# resumes the same remainder again (#396). The marker file keeps
313+
# the upload from being empty when there are no results to carry.
314+
if [ -s "$base/results.jsonl" ]; then cp "$base/results.jsonl" "$carry/"; fi
315+
printf 'The resumed scan finished %s; the next run starts a new scan.\n' "$verdict" > "$carry/state-spent.txt"
316+
echo "carry-state=true" >> "$GITHUB_OUTPUT"
309317
fi
310318
# 0 = ok, 4 = changes found; 3 = some -dL targets failed and 1 = the
311319
# scan failed, and the verdict says how bad, so fail-on decides. A 1

0 commit comments

Comments
 (0)