Skip to content

The exported report's audit_log section was always silently empty - #100

Merged
Nerds489 merged 1 commit into
mainfrom
fix/export-audit-log-query
Sep 25, 2026
Merged

Nerds489 merged 1 commit into
mainfrom
fix/export-audit-log-query

Conversation

@Nerds489

Copy link
Copy Markdown
Owner

A confirmed silent-failure bug, off the #33 roadmap (found in a survey during
this session's work, flagged, now fixed).

The bug

ExportManager._gather_session_data queried:

SELECT * FROM audit_log WHERE session_id = ? ORDER BY timestamp

audit_log has neither column. It is the orchestrator's process-wide event
log, keyed by created_at, with no session (schema.sql says so explicitly).
The query raised straight into a debug-logged try/except, so the audit_log
section of every exported report was dropped without a word. The exporters
read data.get("audit_log", []), so the hole defaulted to empty and nothing
downstream noticed.

The #44 work spotted the mismatch in a comment and added the hash-chained trail
as the real record, but left the broken query returning nothing.

Fix

SELECT * FROM audit_log ORDER BY created_at -- process-wide like the chain
beside it, real column, so a row reaches the report.

Why it survived, and the guards that close it

export/manager.py's SELECTs were never run against the schema in a test (the
existing export tests use db=None, so the try/except swallows any mismatch).

  • export/manager.py joins test_db_schema.py's CONSUMERS. Read-only, so no
    INSERTs to add to the write-set check, but its FROM-tables are now verified
    against the schema.
  • A new test runs _gather_session_data against a real DatabaseEngine with a
    real audit_log row and asserts the section is populated; the old query
    returned []. A second test pins that it is process-wide (one row shows for
    two different session ids).

1031 passed; bats 39/39; ruff introduces nothing new (net -1 long line).
12.1.5 -> 12.1.6.

ExportManager._gather_session_data queried
`SELECT * FROM audit_log WHERE session_id = ? ORDER BY timestamp`, but audit_log
has neither column: it is the orchestrator's PROCESS-WIDE event log, keyed by
created_at, with no session (schema.sql says so). Every call raised into a
debug-logged try/except, so the audit_log section of every exported report was
dropped without a trace. The exporters even read `data.get("audit_log", [])`,
defaulting the hole to empty, so nothing downstream noticed either.

The prior #44 work spotted the mismatch in a comment and added the hash-chained
trail as the real record, but left the broken query in place still returning
nothing. Fixed: `SELECT * FROM audit_log ORDER BY created_at`, process-wide like
the chain, so a real row reaches the report.

Why it survived: export/manager.py's SELECTs were never run against the schema in
a test (the existing export tests use db=None, so the try/except swallows). Two
guards close that:
- export/manager.py joins test_db_schema.py's CONSUMERS. It is read-only, so it
  adds no INSERTs to the write-set check, but its FROM-tables are now verified to
  exist in the schema.
- a new test runs _gather_session_data against a real DatabaseEngine with a real
  audit_log row and asserts the section is populated; the old query returned [].

1031 passed; bats 39/39; ruff introduces nothing new (net -1 long line).
12.1.5 -> 12.1.6.
@Nerds489
Nerds489 merged commit ce953dd into main Sep 25, 2026
2 checks passed
@Nerds489
Nerds489 deleted the fix/export-audit-log-query branch September 25, 2026 14:48
Nerds489 added a commit that referenced this pull request Sep 25, 2026
Same documenting-fiction defect the top-level README carried before its rewrite,
in the supporting docs:

  docs/TOOL_REFERENCE.md   headed v10.0.0, described `netreaper session`,
                           `netreaper crack`, `netreaper install`, `netreaper
                           help` and --quick/--monitor flags, none real.
  docs/README.md           indexed NETREAPER-GIT-HOWTO.md and
                           NETREAPER-FORGOTTEN-FEATURES.md, never in the folder.
  ENVIRONMENT_VARIABLES.md,
  SUPPORT.md               "see also" links to QUICKREF/HOWTO/TROUBLESHOOTING,
                           also absent.

Command examples now match the real CLI (scan --type, wifi monitor/crack, web
auto, ble plan, can dump), the indexes and see-also links resolve, and the
top-level README is named as the authoritative command reference so these do not
drift into a second source of truth again.

test_docs_reference_real_commands.py guards it: a `netreaper <word>` in any
docs/*.md must be a registered command, and a sibling-doc link must resolve. It
found the dead links above, and its first run also caught my own caveat text
naming the fake commands in `netreaper <cmd>` form -- reworded so the counter-
examples do not read as real.

1033 passed; bats 39/39; ruff clean. 12.1.6 -> 12.1.7.

Stacked on #100 (fix/export-audit-log-query); merge that first.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant