Skip to content

Commit 6fc6beb

Browse files
jeffjensenclaude
andcommitted
docs(site): Document the consolidated findings report
usage.adoc gains a report section — the configuration-key table (`database-audits.report.*`), the default report location, and the fix-fidelity levels; archetype.adoc documents the `reportFormat` and `fixFormat` parameters in the property table and command examples; index.adoc mentions the report in the overview. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016phSDvM51hkfSYdjcGQrwz
1 parent f374df8 commit 6fc6beb

3 files changed

Lines changed: 108 additions & 3 deletions

File tree

integration/src/site/asciidoc/archetype.adoc

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ mvn archetype:generate -DinteractiveMode=false \
4848
-DdatabasePlatform=postgresql \
4949
-DdatabaseImage=none \
5050
-DdisabledTests=false \
51+
-DreportFormat=asciidoc \
52+
-DfixFormat=liquibase-xml \
53+
-DfixPlacement=both \
5154
-DdataSourceName=none \
5255
-DoutputDirectory=/path/to/output
5356
----
@@ -87,6 +90,9 @@ mvn archetype:generate -DinteractiveMode=false \
8790
-DdatabasePlatform=postgresql \
8891
-DdatabaseImage=none \
8992
-DdisabledTests=false \
93+
-DreportFormat=asciidoc \
94+
-DfixFormat=liquibase-xml \
95+
-DfixPlacement=both \
9096
-DdataSourceName=none \
9197
-DoutputDirectory=target/audit-scratch \
9298
-DprojectDirectory=.
@@ -148,6 +154,21 @@ Pass only the ones that differ.
148154
| both
149155
| When `true`, annotates every generated test with JUnit's `@Disabled`, so the suite is generated and compiles but does not run. (`SchemaEntityValidationAuditIT` is annotated on the class rather than the method, so its Spring context never loads.) Useful for scaffolding the audits into a project that does not pass them yet — remove the `@Disabled` annotations to enable audits one at a time.
150156

157+
| `reportFormat`
158+
| `asciidoc`
159+
| both
160+
| Format of the consolidated findings report the auto-registered listener writes when a run has findings: `asciidoc`, `markdown`, or `text`. Seeded into the generated `junit-platform.properties` as `database-audits.report.format`. See the link:usage.html#_consolidated_findings_report[Consolidated findings report] guide.
161+
162+
| `fixFormat`
163+
| `liquibase-xml`
164+
| both
165+
| Per-finding remediation the report emits: `liquibase-xml` (a `databaseChangeLog` fragment), `sql` (raw DDL), or `none` (findings only). Seeded as `database-audits.report.fix-format`.
166+
167+
| `fixPlacement`
168+
| `both`
169+
| both
170+
| Where the report places each audit's fixes: `both` (default — inline under each audit and in a consolidated section), `inline` (only under each audit), or `section` (only the consolidated block). Seeded as `database-audits.report.fix-placement`.
171+
151172
| `dataSourceName`
152173
| `none`
153174
| both
@@ -203,7 +224,7 @@ Pass only the ones that differ.
203224
│ └── WhereClauseIndexAuditIT.java
204225
└── resources/
205226
├── application.properties (schema-name, ddl-auto=none, Liquibase changelog path)
206-
├── junit-platform.properties (ClassOrderer$OrderAnnotation enabled)
227+
├── junit-platform.properties (ClassOrderer$OrderAnnotation + database-audits.report.* keys)
207228
└── db/changelog/
208229
└── db.changelog-master.xml (parent + child tables with indexes)
209230
----
@@ -232,7 +253,7 @@ src/test/
232253
│ ├── UnconditionalMutationAuditIT.java
233254
│ └── WhereClauseIndexAuditIT.java
234255
└── resources/
235-
└── junit-platform.properties (ClassOrderer$OrderAnnotation enabled)
256+
└── junit-platform.properties (ClassOrderer$OrderAnnotation + database-audits.report.* keys)
236257
----
237258

238259
`RepositoryWorkloadIT` is *not* generated in this mode — your existing tests already prime the SQL

integration/src/site/asciidoc/index.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
`database-audits-spring-boot-integration` wires the link:https://database-audits.github.io/core[database-audits-core]
44
audit library into a Spring Boot test context. One `@Import` enables ten database audits across three families:
5-
catalog (schema metadata), JPA (entity/schema agreement), and runtime (live SQL execution).
5+
catalog (schema metadata), JPA (entity/schema agreement), and runtime (live SQL execution). Every finding is also
6+
collected into a link:usage.html#_consolidated_findings_report[consolidated report] — Markdown, AsciiDoc, or text,
7+
with optional SQL or Liquibase fixes — written automatically at the end of the test run.
68

79
== Dependency
810

integration/src/site/asciidoc/usage.adoc

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,3 +375,85 @@ schemas are handled naturally.
375375
*before Hibernate builds it* — so your own (production) datasource configuration is untouched. Also connect that
376376
datasource with `preferQueryMode=simple` (see <<postgresql-jdbc-requirement>>); otherwise run only the catalog and
377377
JPA audits against that datasource.
378+
379+
== Consolidated findings report
380+
381+
Every audit failure is also collected into a single report file, written automatically at the end of the test run
382+
by a JUnit `TestExecutionListener` shipped in the integration jar and auto-registered via `META-INF/services` — no
383+
setup and no console scraping. The listener is *inert when the run is clean*: it writes nothing unless there are
384+
findings, so unrelated test runs are unaffected.
385+
386+
The report groups findings by audit family and audit, reproducing each finding's message, and can additionally emit
387+
a remediation for each finding — raw SQL DDL or a Liquibase changeset.
388+
389+
[NOTE]
390+
====
391+
The report is populated from *per-audit* assertion failures — the per-audit ITs the archetype generates, or any
392+
test that calls an individual `*AuditAssertion` bean. The `DatabaseAuditAssertions` facade
393+
(`assertAllClean` / `assertCatalogClean` / …) aggregates its failures into one combined `AssertionError`, which the
394+
report does not itemize; prefer the per-audit assertions when you want the consolidated report.
395+
====
396+
397+
=== Configuration
398+
399+
Set these JUnit Platform configuration parameters in `src/test/resources/junit-platform.properties` (each is also
400+
honored as a same-named system property):
401+
402+
|===
403+
| Key | Default | Description
404+
405+
| `database-audits.report.enabled`
406+
| `true`
407+
| Master switch. `false` disables the report entirely.
408+
409+
| `database-audits.report.format`
410+
| `asciidoc`
411+
| Report format: `asciidoc`, `markdown`, or `text`.
412+
413+
| `database-audits.report.fix-format`
414+
| `liquibase-xml`
415+
| Per-finding remediation: `liquibase-xml` (a `databaseChangeLog` fragment), `sql` (raw DDL), or `none` (findings only).
416+
417+
| `database-audits.report.fix-placement`
418+
| `both`
419+
| Where fixes appear: `both` (default — inline under each audit and in a consolidated section), `inline` (only under each audit), or `section` (only the consolidated block).
420+
421+
| `database-audits.report.output-file`
422+
| `target/database-audit-report.<ext>`
423+
| Where the report is written; the default extension follows the format (`md` / `adoc` / `txt`).
424+
|===
425+
426+
[source,properties]
427+
----
428+
# src/test/resources/junit-platform.properties
429+
database-audits.report.format=asciidoc
430+
database-audits.report.fix-format=liquibase-xml
431+
database-audits.report.fix-placement=both
432+
----
433+
434+
=== Fix fidelity
435+
436+
Generated fixes are labeled by how faithfully they remediate the finding, because not every finding carries enough
437+
information for an exact fix:
438+
439+
* *precise* — executable, dialect-correct DDL that fully fixes the finding (e.g. `CREATE INDEX` for an unindexed
440+
foreign key, `DROP INDEX` for a redundant index, `ALTER COLUMN … TYPE` for a foreign-key type mismatch).
441+
* *template* — DDL with a `TODO` you must complete (e.g. a missing primary key's key columns cannot be inferred from
442+
the catalog).
443+
* *best-effort* — an index suggestion whose relation is parsed from the `EXPLAIN` plan; verify the columns.
444+
* *advisory* — no DDL; a full-table `UPDATE`/`DELETE` needs a `WHERE` clause in code, not a schema change.
445+
446+
In `liquibase-xml` mode only *precise* fixes become runnable `<changeSet>` elements — built from Liquibase's
447+
database-agnostic change types (`<createIndex>`, `<dropIndex>`, `<modifyDataType>`, `<addColumn>`,
448+
`<addNotNullConstraint>`), so Liquibase renders the dialect-correct SQL for your database rather than this module
449+
hand-writing it. The rest are emitted as XML comments, so the embedded `databaseChangeLog` stays well-formed and
450+
applies cleanly. Change-set ids are derived from the finding, so regenerating over the same findings is stable.
451+
452+
With the default `both` placement, each audit's fix is shown inline beneath its findings *and* gathered in the
453+
consolidated section; for `liquibase-xml` the inline blocks are `<changeSet>` fragments to read alongside the audit,
454+
while the consolidated section is the single, applicable `<databaseChangeLog>`. Set `fix-placement` to `inline` to
455+
drop the consolidated section, or `section` for the consolidated block only.
456+
457+
The archetype seeds `database-audits.report.format`, `database-audits.report.fix-format`, and
458+
`database-audits.report.fix-placement` into the generated `junit-platform.properties` from its `-DreportFormat`,
459+
`-DfixFormat`, and `-DfixPlacement` parameters — see link:archetype.html[Archetype].

0 commit comments

Comments
 (0)