Skip to content

Commit 3618274

Browse files
TMHSDigitalclaude
andcommitted
Document every output field, with JSON Schema files (#433)
docs/output.md lists each JSON/JSONL result field, each CSV column and each -stats report field with its type, when it is present and its values. docs/schemas/result.v1.json and stats.v1.json (JSON Schema 2020-12) say the same for tools, and TestSchemasMatchStructs fails when a json tag on Result or Summary, nested objects included, is added, renamed or removed without the schema files. Fixes #433 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 3d8c23d commit 3618274

10 files changed

Lines changed: 473 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111
- `-hosts <file>` looks up a list of full host names, such as another tool's output or an old results file, instead of a wordlist, through the same wildcard filtering, resolver pool, pacing, verdict, `-diff` and output formats (`-` reads stdin). Targets still come from the `<domain>` argument or `-dL`: each looks up only the names under it, the most specific target when targets nest, and names under no target are out of scope, never queried, and counted in one note. It cannot be combined with `-w`, `-recursive` or `-tui` (#351).
12+
- An [output field reference](https://tmhsdigital.github.io/subenum/output.html) lists every JSON, JSONL and CSV result field and every `-stats` report field, with its type, when it is present and its values, and the site serves JSON Schema files for both (`schemas/result.v1.json`, `schemas/stats.v1.json`). A test fails when a field is added, renamed or removed in the code without the schema files (#433).
1213

1314
### Changed
1415
- The `-permute` pass is built in one set instead of three copies, and a target's pass builds at most 1,000,000 candidates (the seeds taken in sorted order, with a note when it stops there). For 50,000 seed names, as a large Certificate Transparency footprint gives, building the pass took about 11 s and 1.8 GB of allocations and now takes under 1 s and 150 MB. The `-dry-run` notes give the pass's bound: up to 93 candidates per name (#400).

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,8 @@ When a result has a CNAME record, subenum resolves the CNAME target with the tru
600600

601601
<br>
602602

603+
Every JSON, JSONL and CSV field and every `-stats` report field, with when it is present and its values, is listed in the [output field reference](https://tmhsdigital.github.io/subenum/output.html), with JSON Schema files for results and the report.
604+
603605
A recursive resolver asked about a subzone whose every name server is gone usually answers SERVFAIL instead of the delegation, so such a name is reported as inconclusive (see `-inconclusive`) rather than marked; scanning against the parent zone's authoritative server finds it.
604606

605607
A target or name server that exists but has no A or AAAA record (NODATA, such as a name with only MX or TXT records) is not dangling: when the address lookup comes back empty, subenum sends one more A query and marks the name only on an NXDOMAIN answer. A probe that fails (timeout, SERVFAIL) marks nothing.

‎docs/DOCUMENTATION_STRUCTURE.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Where each piece of subenum's documentation lives and who it is for. The files u
99
| [`README.md`](../README.md) | What subenum is, install, quick start, every flag, output formats, the TUI, completions and the man page |
1010
| [`docs/start.md`](start.md) | First scan, the run-quality verdict, what to read next |
1111
| [`docs/cli.md`](cli.md) | CLI reference: flags (generated from the code into [`_includes/flags.md`](_includes/flags.md)), exit codes, config file and `SUBENUM_*` defaults |
12+
| [`docs/output.md`](output.md) | Every JSON, JSONL and CSV result field and `-stats` report field, with the JSON Schema files in [`schemas/`](schemas/) that `TestSchemasMatchStructs` keeps in step with the code |
1213
| [`docs/pipelines.md`](pipelines.md) | Chaining with dnsx, httpx and nuclei; JSON logs; takeover candidates first |
1314
| [`docs/monitoring.md`](monitoring.md) | Scheduled scans with `-diff`, the GitHub Action ([`action.yml`](../action.yml)) and SARIF alerts |
1415
| [`docs/docker.md`](docker.md) | The container image: volumes, output files, permissions |

‎docs/ROADMAP.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ surprises:
4242
- **Stable flags.** No flag is renamed or removed without a deprecation release
4343
first (as `-retries` was for `-attempts`).
4444
- **Stable output schemas.** The JSON, JSONL and CSV fields are documented and
45-
only ever gain fields, never lose or rename them.
45+
only ever gain fields, never lose or rename them. The
46+
[field reference](output.html) and its JSON Schema files are in place, and
47+
a test keeps them in step with the code.
4648
- **Documented exit codes**, already in place (0, 1, 2, 3, 4, 130, 143).
4749
- **A run-quality report**, already in place (`-stats`, schema 1), so a result
4850
set says how far it can be trusted.

‎docs/_data/nav.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
url: /start.html
99
- title: CLI reference
1010
url: /cli.html
11+
- title: Output fields
12+
url: /output.html
1113

1214
- section: Guides
1315
footer: true

‎docs/cli.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ Settings you repeat on every run can live in the environment or a config file. T
5959

6060
## Output streams
6161

62-
Resolved names go to stdout and nothing else does, so `subenum example.com | httpx` works as expected. Progress, warnings and the per-outcome breakdown go to stderr. `-o` writes the same results to a file in the chosen `-format`; results files are replaced atomically. Repeat `-o` to write several files; a file without a prefix uses `-format`, and a prefix names its own format: `-o text:names.txt -o jsonl:results.jsonl`{% include unreleased.html value="o=format:path" %} writes bare names and JSONL in one run, whatever `-format` stdout uses.
62+
Resolved names go to stdout and nothing else does, so `subenum example.com | httpx` works as expected. Progress, warnings and the per-outcome breakdown go to stderr. `-o` writes the same results to a file in the chosen `-format`; results files are replaced atomically. Repeat `-o` to write several files; a file without a prefix uses `-format`, and a prefix names its own format: `-o text:names.txt -o jsonl:results.jsonl`{% include unreleased.html value="o=format:path" %} writes bare names and JSONL in one run, whatever `-format` stdout uses. [Output fields](output.html) lists every JSON, JSONL and CSV field and the `-stats` report's, with JSON Schema files.

‎docs/output.md‎

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
layout: default
3+
title: Output fields
4+
description: Every field of subenum's JSON, JSONL and CSV results and of the -stats run-quality report, with JSON Schema files.
5+
---
6+
7+
# Output fields
8+
9+
This page lists every field subenum writes, so a script can read results without reading Go source. Fields are only ever added, never renamed or removed, so a reader must accept fields it does not know. The same rules are in two JSON Schema (2020-12) files:
10+
11+
- [`schemas/result.v1.json`](schemas/result.v1.json): one result, as in JSON and JSONL output.
12+
- [`schemas/stats.v1.json`](schemas/stats.v1.json): the `-stats` report, also the last line of JSONL output.
13+
14+
A test fails when a field is added to the code but not to these files, so they stay current.
15+
16+
## Results: JSON and JSONL
17+
18+
`-format json` writes one array of results; `-format jsonl` writes one result per line, then the run-quality report as the last line (its `type` is `summary`). A field marked "when set" is left out otherwise.
19+
20+
| Field | Type | Present | Meaning |
21+
|---|---|---|---|
22+
| `subdomain` | string | always | The full name, lower case, without a trailing dot. |
23+
| `records` | array of `{type, value}` | always | The name's records of the `-type` record types. Empty for a name `-diff` reports as removed. |
24+
| `simulated` | boolean | when set | `true` on every result of a `-simulate` run. |
25+
| `takeover_candidate` | string | when set | A DNS-only [takeover hint](https://github.com/TMHSDigital/subenum#subdomain-takeover-hints): `dangling`, `provider:<name>` or `dangling:<name>`. Needs `CNAME` or `NS` in `-type`. |
26+
| `internal_address` | string | when set | The most notable non-public scope among the name's addresses: `loopback`, `unspecified`, `link-local`, `private` or `cgnat`. |
27+
| `partial` | boolean | when set | `true` when a requested record type's lookup failed on every attempt while another type answered: `records` may lack that type. |
28+
| `change` | string | with `-diff` | `added`, `removed`, or with `-diff-records` `changed`. `subenum diff` writes `missing` instead of `removed`, because it looks nothing up. |
29+
| `previous_records` | array of `{type, value}` | when `change` is `changed` | The baseline's records of the name. |
30+
| `permutation` | boolean | when set | `true` for a name the `-permute` pass found. |
31+
| `sources` | array of strings | scan results | What proposed the name, in this order: `wordlist`, `ct`, `wayback`, `axfr`; or `permute` alone for a `-permute` hit. Not on removed names or in `subenum diff` output. |
32+
| `target` | string | scan results | The scanned domain that found the name, which tells `-dL` results with nested targets apart. Not on removed names or in `subenum diff` output. |
33+
34+
A record's `type` is `A`, `AAAA`, `CNAME`, `NS`, `MX` or `TXT`. Its `value` is an address, a host name (`CNAME`, `NS`), `<preference> <host>` (`MX`), or the text (`TXT`), with a backslash and non-printable bytes written as `\DDD`.
35+
36+
## Results: CSV
37+
38+
CSV has one row per record, so a name with three records has three rows, and a name without records (a removed one) has one row with empty `type` and `value`. The header names the columns; optional ones are added in this order:
39+
40+
| Column | Present | Meaning |
41+
|---|---|---|
42+
| `subdomain` | always | As in JSON. |
43+
| `type` | always | The record type. |
44+
| `value` | always | The record value. A value starting with `=`, `+`, `-`, `@`, a tab or a carriage return gets a leading `'`, so a spreadsheet does not read it as a formula. |
45+
| `simulated` | `-simulate` | `true`. |
46+
| `takeover_candidate` | `CNAME` or `NS` in `-type` | As in JSON; empty when there is no hint. |
47+
| `change` | `-diff` | As in JSON. |
48+
| `sources` | scan results | As in JSON, joined with `;`. |
49+
| `target` | `-dL` | As in JSON. |
50+
51+
## Text
52+
53+
Text output is one name per line. `-show-records` appends the records as ` TYPE=value`, and `-diff` prefixes each name with `+`, `-` or `~`. Text has no other fields; use JSONL or CSV to keep them.
54+
55+
## Run-quality report
56+
57+
`-stats <file>` writes the report as indented JSON, and `-format jsonl` writes it as the last line. `schema` is `1`; it rises only if a field is renamed, removed or changes meaning. A field marked "when set" is left out when it is `0`, empty or `false`.
58+
59+
### Top level
60+
61+
| Field | Type | Present | Meaning |
62+
|---|---|---|---|
63+
| `type` | string | always | Always `summary`. |
64+
| `schema` | integer | always | `1`. |
65+
| `tool` | string | always | `subenum`. |
66+
| `version` | string | always | The version that wrote the report. |
67+
| `started` | string | always | When the run started, RFC 3339. |
68+
| `duration_ms` | integer | always | Run time in milliseconds. |
69+
| `simulated` | boolean | always | `true` for a `-simulate` run. |
70+
| `seed` | integer | `-simulate` | The simulation seed. |
71+
| `resolver` | string | not with `-simulate` | The `-dns-server` (scheme and host only), the lab's local server under `-simulate-zone`, or with `-r` the trusted resolver hits were re-validated against. |
72+
| `zone` | string | `-simulate-zone` | The lab scenario. |
73+
| `transport` | string | not with `-simulate` | `udp` (with TCP fallback), `tls` or `https`. |
74+
| `rate_limit` | integer | always | `-rate`; `0` is unlimited. |
75+
| `queries_sent` | integer | always | Queries sent on the wire, every target, type, retry and probe included. |
76+
| `achieved_qps` | number | always | `queries_sent` over the run time. |
77+
| `verdict` | string | always | `complete`, `degraded` or `unreliable`: the worst target's. |
78+
| `reason` | string | always | Why, in plain words. |
79+
| `targets` | array | always | One entry per target, below. |
80+
| `resolvers` | array | `-r` | Per pool resolver: `address`, `lookups`, `found`, `nxdomain`, `failed`, `benched`, `throttled`, `canaries`, `contradicted`, `flagged`. |
81+
| `diff` | object | `-diff` | `previous` (the file), `added`, `removed`, and when set `changed`, `still_resolving`, `unverified`. `removed` stays `0` unless the run was complete. |
82+
83+
### Each target
84+
85+
| Field | Type | Present | Meaning |
86+
|---|---|---|---|
87+
| `domain` | string | always | The target. |
88+
| `status` | string | always | `ok`, `failed`, `interrupted`, `skipped` (left out after an earlier target's reliability abort) or `not_run`. |
89+
| `error` | string | when set | Why a failed target failed. |
90+
| `processed`, `total` | integer | always | Candidates the main pass looked up, of how many. |
91+
| `found` | integer | always | Names the main pass found. |
92+
| `outcomes` | object | always | How each lookup ended: `resolved`, `nxdomain`, `timeout`, `refused`, `other`, `wildcard_filtered`, `excluded`. |
93+
| `queries_sent` | integer | always | This target's queries, its `-permute` pass included. |
94+
| `skipped_by_cap` | integer | always | Candidates a budget left untested. |
95+
| `stopped_by` | string | when set | `queries` (`-max-queries`) or `duration` (`-max-duration`). |
96+
| `takeover_candidates`, `internal_addresses` | integer | when set | Results with a takeover hint, or with a non-public address. |
97+
| `retried`, `recovered` | integer | when set | `-retry-inconclusive`: names looked up again, and those that then answered. |
98+
| `rate_backoffs`, `final_rate` | integer | when set | `-auto-rate`: times it halved the rate, and the rate it ended at. |
99+
| `permutation` | object | `-permute` ran | `seeds`, `candidates`, `found`, and when set `processed`, `queries_sent`, `verdict`. |
100+
| `sources` | array | `-ct`, `-sources` | Per source: `name` (`ct`, `wayback`), `names` added, `found`, and when set `error`, `truncated`. |
101+
| `ct_names`, `ct_error` | integer, string | when set | Repeat the `ct` entry of `sources`. |
102+
| `axfr_allowed`, `axfr_names`, `axfr_error`, `axfr_found` | array, integer, string, integer | when set | `-axfr`: servers that allowed a transfer, names it added, why none could be tried, results it proposed. |
103+
| `zone_denial` | string | when set | `-axfr`'s DNSSEC probe: `nsec` (anyone can list the zone), `nsec3` or `none`. |
104+
| `pool_hits`, `confirmed`, `unconfirmed` | integer | when set | `-r`: pool hits, and how many the trusted resolver confirmed or denied. |
105+
| `wildcard` | boolean | always | `true` when the target answers names that do not exist. |
106+
| `wildcard_fingerprint` | array of `{type, value}` | when set | The wildcard's answers. |
107+
| `verdict`, `reason` | string | always | The worse of the two passes'; `reason` starts with `permutation pass:` when that pass decided it. |

‎docs/schemas/result.v1.json‎

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://tmhsdigital.github.io/subenum/schemas/result.v1.json",
4+
"title": "subenum result",
5+
"description": "One result in subenum's JSON (an array of these) and JSONL (one per line) output. Version 1: fields are only ever added, so readers must accept fields they do not know. See https://tmhsdigital.github.io/subenum/output.html.",
6+
"type": "object",
7+
"required": ["subdomain", "records"],
8+
"additionalProperties": true,
9+
"properties": {
10+
"subdomain": {
11+
"type": "string",
12+
"description": "The full name found, lower case, without a trailing dot."
13+
},
14+
"records": {
15+
"type": "array",
16+
"description": "The name's records of the looked-up -type record types. Empty for a name -diff reports as removed.",
17+
"items": { "$ref": "#/$defs/record" }
18+
},
19+
"simulated": {
20+
"type": "boolean",
21+
"description": "true on every result of a -simulate run. Absent otherwise."
22+
},
23+
"takeover_candidate": {
24+
"type": "string",
25+
"description": "A DNS-only subdomain takeover hint: dangling, provider:<name> or dangling:<name>. Absent when there is none.",
26+
"pattern": "^(dangling|provider:.+|dangling:.+)$"
27+
},
28+
"internal_address": {
29+
"type": "string",
30+
"description": "The most notable non-public scope among the name's addresses. Absent when every address is public.",
31+
"enum": ["loopback", "unspecified", "link-local", "private", "cgnat"]
32+
},
33+
"partial": {
34+
"type": "boolean",
35+
"description": "true when the lookup of a requested record type failed on every attempt while another type answered: records may lack that type. Absent otherwise."
36+
},
37+
"change": {
38+
"type": "string",
39+
"description": "With -diff: added, removed, or (with -diff-records) changed. subenum diff writes missing instead of removed. Absent outside a diff.",
40+
"enum": ["added", "removed", "changed", "missing"]
41+
},
42+
"previous_records": {
43+
"type": "array",
44+
"description": "The baseline's records of a changed name. Present only when change is changed.",
45+
"items": { "$ref": "#/$defs/record" }
46+
},
47+
"permutation": {
48+
"type": "boolean",
49+
"description": "true for a name the -permute pass found. Absent otherwise."
50+
},
51+
"sources": {
52+
"type": "array",
53+
"description": "What proposed the name, in this order: wordlist, ct, wayback, axfr; or permute alone for a -permute hit. Absent on removed names and in subenum diff output.",
54+
"items": { "type": "string", "enum": ["wordlist", "ct", "wayback", "axfr", "permute"] }
55+
},
56+
"target": {
57+
"type": "string",
58+
"description": "The scanned domain that found the name; tells -dL results with nested targets apart. Absent on removed names and in subenum diff output."
59+
}
60+
},
61+
"$defs": {
62+
"record": {
63+
"type": "object",
64+
"required": ["type", "value"],
65+
"additionalProperties": true,
66+
"properties": {
67+
"type": {
68+
"type": "string",
69+
"description": "The record type.",
70+
"enum": ["A", "AAAA", "CNAME", "NS", "MX", "TXT"]
71+
},
72+
"value": {
73+
"type": "string",
74+
"description": "An address; a host name for CNAME and NS; <preference> <host> for MX; the text for TXT, with a backslash and non-printable bytes written as \\DDD."
75+
}
76+
}
77+
}
78+
}
79+
}

0 commit comments

Comments
 (0)