Skip to content

Commit f016c90

Browse files
committed
Action: expose the changes file and takeover/internal counts (#311)
The Action reported how many names changed but not where the changes were, and said nothing about takeover candidates or non-public addresses, so a workflow could not act on them without re-reading the report. It now has three more outputs: changes (the path of changes.jsonl, set only when there were previous results to compare with), takeovers and internal. The job summary gains both counts and lists the first 50 takeover candidates. The CI action job asserts the new outputs on the lab zone, and the monitoring guide shows opening an issue from them. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com> Fixes #311
1 parent f465df8 commit f016c90

5 files changed

Lines changed: 57 additions & 5 deletions

File tree

‎.github/workflows/go.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ jobs:
184184
set -euo pipefail
185185
test "${{ steps.scan.outputs.verdict }}" = complete
186186
test "${{ steps.scan.outputs.found }}" -ge 5
187+
test "${{ steps.scan.outputs.takeovers }}" -ge 1
188+
test "${{ steps.scan.outputs.internal }}" = 0
189+
test -z "${{ steps.scan.outputs.changes }}"
187190
grep -q 'dangling-cname' takeovers.sarif
188191
cp "${{ steps.scan.outputs.results }}" previous.jsonl
189192
echo "gone.lab.example" >> previous.jsonl
@@ -202,6 +205,8 @@ jobs:
202205
run: |
203206
test "${{ steps.diff.outputs.added }}" = 0
204207
test "${{ steps.diff.outputs.removed }}" = 1
208+
grep -q '"change":"removed"' "${{ steps.diff.outputs.changes }}"
209+
grep -q 'gone.lab.example' "${{ steps.diff.outputs.changes }}"
205210
206211
# Builds the Dockerfile for both published platforms without pushing, so a
207212
# broken image is caught on the PR rather than during a release.

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3131
- `-max-duration 20m` gives a run a time budget. When it runs out no new names are tested, lookups already under way finish, and the run ends normally: results, the `-stats` report (`stopped_by: "duration"`, untested names in `skipped_by_cap`) and a `degraded` verdict. Under `-dL` one budget covers every target. The GitHub Action gains a `max-duration` input, so a scheduled scan can stop before the job's `timeout-minutes` kills it without a report, and `pkg/subenum` gains `Config.MaxDuration` and `Stats.Expired`. With `-max-queries`, the report now says `stopped_by: "queries"` (#190).
3232
- The progress line and the TUI status bar show an estimated time left (`| ETA 4m12s`), from the rate over the last 30 seconds, once a scan has run for 5 seconds; it disappears at 100% (#191).
3333
- `-diff-records` makes `-diff` compare the records of names found again, so a CNAME re-pointed at an unclaimed service or a moved address is reported as `changed` (`~ name` in text; `"change": "changed"` with `previous_records` in JSON and JSONL), counted in the report's `diff.changed`, and exits 4. When either side has a CNAME only the alias targets are compared, so CDN address rotation is not a change. The previous file must be JSON, JSONL or CSV. The GitHub Action gains a `changed` output (#189).
34+
- The GitHub Action gains three outputs: `changes`, the path of the JSONL file listing the added, removed and changed names (empty when there were no previous results to diff against), so a later step can open an issue or post them; `takeovers`, the number of takeover candidates found; and `internal`, the number of names answering with an address that is not public. The job summary table has a column for each count and lists the takeover candidates under it. `docs/monitoring.md` shows a step that opens an issue from `changes` (#311).
3435

3536
### Changed
3637
- A run that `-max-duration` stopped with names untested, or that the reliability guard aborted, saves its resume state to the `-state` file like an interrupted one and prints `continue with: subenum -resume <file>`, so a time-boxed job continues where the last one stopped instead of testing the same first names again. The exit code is unchanged (0 for a spent budget). A resumed run that stops the same way saves its state again, and one that finishes no longer counts the names an earlier part skipped, so it can end `complete` (#294).

‎action.yml‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ outputs:
7474
changed:
7575
description: Names whose records changed since the previous results (add -diff-records to args).
7676
value: ${{ steps.scan.outputs.changed }}
77+
changes:
78+
description: >-
79+
Path of the changes (JSONL): one line per added, removed or changed name
80+
with a "change" field, then the run summary. Empty when there were no
81+
previous results to diff against.
82+
value: ${{ steps.scan.outputs.changes }}
83+
takeovers:
84+
description: Takeover candidates among the names found (needs CNAME or NS in -type).
85+
value: ${{ steps.scan.outputs.takeovers }}
86+
internal:
87+
description: Names found that answer with an address that is not public.
88+
value: ${{ steps.scan.outputs.internal }}
7789
results:
7890
description: Path of the full results (JSONL).
7991
value: ${{ steps.scan.outputs.results }}
@@ -185,19 +197,29 @@ runs:
185197
added=$(jq '.diff.added // 0' "$out/run.json")
186198
removed=$(jq '.diff.removed // 0' "$out/run.json")
187199
changed=$(jq '.diff.changed // 0' "$out/run.json")
200+
takeovers=$(jq '[.targets[].takeover_candidates // 0] | add // 0' "$out/run.json")
201+
internal=$(jq '[.targets[].internal_addresses // 0] | add // 0' "$out/run.json")
188202
{
189203
echo "verdict=$verdict"; echo "found=$found"; echo "added=$added"; echo "removed=$removed"; echo "changed=$changed"
204+
echo "takeovers=$takeovers"; echo "internal=$internal"
190205
echo "results=$out/results.jsonl"; echo "stats=$out/run.json"
206+
# Without -diff the scan prints every result, not changes.
207+
if [ -n "$prev" ]; then echo "changes=$out/changes.jsonl"; fi
191208
} >> "$GITHUB_OUTPUT"
192209
193210
{
194211
echo "### subenum: $verdict"
195212
echo
196213
echo "$reason"
197214
echo
198-
echo "| Target | Verdict | Found | Queries |"
199-
echo "|---|---|---|---|"
200-
jq -r '.targets[] | "| \(.domain) | \(.verdict) | \(.found // 0) | \(.queries_sent // 0) |"' "$out/run.json"
215+
echo "| Target | Verdict | Found | Queries | Takeover candidates | Internal addresses |"
216+
echo "|---|---|---|---|---|---|"
217+
jq -r '.targets[] | "| \(.domain) | \(.verdict) | \(.found // 0) | \(.queries_sent // 0) | \(.takeover_candidates // 0) | \(.internal_addresses // 0) |"' "$out/run.json"
218+
if [ "$takeovers" != 0 ]; then
219+
echo
220+
echo "**Takeover candidates:** $takeovers"
221+
jq -r 'select(.takeover_candidate) | "- `\(.subdomain)`: \(.takeover_candidate)"' "$out/results.jsonl" | head -50
222+
fi
201223
if [ -n "$prev" ]; then
202224
echo
203225
echo "**Changes since the previous results:** $added added, $removed removed, $changed changed."

‎docs/_data/unreleased.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ values:
2828
action:
2929
- max-duration
3030
- changed
31+
- changes
32+
- takeovers
33+
- internal
3134
# pkg/subenum identifiers
3235
library:
3336
- AutoRate

‎docs/monitoring.md‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,29 @@ jobs:
121121
| `version` | `latest` | Release to install, or `source` to build the action's checkout |
122122
| `token` | `github.token` | Token for downloading the release and the baseline artifact |
123123

124-
Outputs: `verdict`, `found`, `added`, `removed`, `changed`{% include unreleased.html action="changed" %} (with `-diff-records`), and the paths `results` (JSONL)
125-
and `stats` (the run-quality report). The step below builds the same thing by
124+
Outputs: `verdict`, `found`, `added`, `removed`, `changed`{% include unreleased.html action="changed" %} (with `-diff-records`),
125+
`takeovers`{% include unreleased.html action="takeovers" %} (takeover candidates among the names found; needs `CNAME` or `NS` in `-type`),
126+
`internal`{% include unreleased.html action="internal" %} (names answering with an address that is not public), and the paths `results` (JSONL),
127+
`stats` (the run-quality report) and `changes`{% include unreleased.html action="changes" %} (JSONL, one line per added, removed or
128+
changed name with a `change` field; empty when there were no previous results to
129+
diff against). The job summary lists the takeover candidates under the table.
130+
131+
To open an issue with the new names, add a step after the action (the job
132+
then also needs `issues: write`):
133+
134+
{% raw %}
135+
```yaml
136+
- if: steps.subenum.outputs.added != '0'
137+
env:
138+
GH_TOKEN: ${{ github.token }}
139+
CHANGES: ${{ steps.subenum.outputs.changes }}
140+
run: |
141+
jq -r 'select(.change == "added") | "- \(.subdomain)"' "$CHANGES" > body.md
142+
gh issue create --repo "$GITHUB_REPOSITORY" --title "New subdomains ($(date -u +%F))" --body-file body.md
143+
```
144+
{% endraw %}
145+
146+
The step below builds the same thing by
126147
hand, if you prefer to see every command.
127148

128149
## Example: a scheduled GitHub Actions workflow

0 commit comments

Comments
 (0)