Skip to content

Fix #1385: derive nxcdb hosts CSV header from the protocol's HostsTable - #1387

Open
Diogo-Damasceno wants to merge 1 commit into
Pennyw0rth:mainfrom
Diogo-Damasceno:fix/nxcdb-host-csv-header
Open

Fix #1385: derive nxcdb hosts CSV header from the protocol's HostsTable#1387
Diogo-Damasceno wants to merge 1 commit into
Pennyw0rth:mainfrom
Diogo-Damasceno:fix/nxcdb-host-csv-header

Conversation

@Diogo-Damasceno

@Diogo-Damasceno Diogo-Damasceno commented Sep 4, 2026

Copy link
Copy Markdown

Description

Fixes #1385. The export hosts CSV header was hard-coded to the SMB schema (smbv1/signing/spooler/zerologon/petitpotam), so exporting hosts for any other protocol (RDP, MSSQL, SSH, LDAP, ...) produced a header that did not match the row content.

Change: the header is now derived from the active protocol' HostsTable columns via a new host_csv_headers() helper, as suggested in the issue (default to the real column names instead of static SMB strings). simple keeps the first 8 columns (historical row width); detailed returns every column of the table. I kept the diff to just this logic — no autoformatter noise on unrelated lines.

AI usage disclosure: I put this together with the help of the DeepHat agent and the Hermes Agent, which I used strictly as tools. I drove every step myself: identified the root cause, reviewed the diff line by line, wrote and ran the regression tests, and confirmed the SMB simple/detailed output shape is unchanged (no regression). The logic and the tests are mine; the agents were just a faster keyboard.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Setup guide for the review

  • Build a workspace with, e.g., RDP hosts: nxc rdp <host> then nxcdb, proto rdp, export hosts detailed rdp.csv.
    • Before: header was id;ip;hostname;domain;os;dc;smbv1;signing;spooler;zerologon;petitpotam (SMB-only, wrong for RDP).
    • After: header is id;ip;hostname;domain;os;nla -- matches the actual RDP row content.
  • SMB export is unchanged in shape (simple still = first 8 SMB columns; detailed = all 11).
  • Local test: pytest tests/test_nxcdb_host_export.py (3 tests: SMB simple/detailed unchanged, RDP has no SMB-only columns). Note: I could not run the full NetExec suite locally because aardwolf does not build on Python 3.14 (see Install fails with Python 3.14 #1241); the change is isolated to the CSV header derivation and is covered by the new unit tests.

Checklist

  • I have ran Ruff against my changes
  • I have added or updated the tests (tests/test_nxcdb_host_export.py)
  • I have linked relevant sources (issue nxcdb CSV header mismatch #1385; maintainer direction: use the real column names)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • This requires a documentation update (no user-facing behaviour change beyond the corrected header)

@NeffIsBack

Copy link
Copy Markdown
Member

Hi and thanks for the PR!

Please revert the formatting changes tho. Also please disclose AI usage in the PR description (see PR template).

…s HostsTable

The `export hosts` CSV header was hard-coded to the SMB schema
(smbv1/signing/spooler/zerologon/petitpotam), so exporting hosts for any
other protocol (RDP, MSSQL, SSH, LDAP, ...) produced a header that did not
match the row content.

Now the header is derived from the active protocol's HostsTable columns via a
new `host_csv_headers()` helper, as suggested in the issue: default to the
real column names instead of static SMB strings. `simple` keeps the first 8
columns (historical row width); `detailed` returns every column of the table.
No unrelated formatting changes.

Added tests/test_nxcdb_host_export.py covering SMB (no regression) and RDP
(no SMB-only columns leak into the header). Verified on Python 3.14.7.
@Diogo-Damasceno
Diogo-Damasceno force-pushed the fix/nxcdb-host-csv-header branch from 26c55d1 to ce33ac0 Compare September 4, 2026 11:14
@Diogo-Damasceno

Copy link
Copy Markdown
Author

Thanks @NeffIsBack — and sorry about the formatting noise, that was on me. I let the formatter loose on lines that had nothing to do with the fix.

I've reverted all of it now: the diff is just the host_csv_headers() helper and its use in do_export. No unrelated reformatting.

I also added the AI-usage disclosure to the description as you asked. For the record: I put this together with the help of the DeepHat agent and the Hermes Agent, which I used strictly as tools — I drove every step myself, reviewed the diff line by line, wrote and ran the regression tests, and confirmed the SMB simple/detailed shape is unchanged.

Logic and tests are unchanged; SMB exports still produce the same simple/detailed shape as before. Let me know if anything else needs a look.

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.

nxcdb CSV header mismatch

2 participants