Repository navigation
The CSV report says what conversion left out, like the other surfaces (#308) - #382
Conversation
…#308) Measured on main: a PF Sense upload whose DHCP WAN rule could not be converted showed the skip on the dashboard (X-Netwise-Conversion-Gap-Count) and in the HTML report, while the CSV of the same scan had no trace of it. Every row read as a complete account of a firewall with a rule left out, in the export most likely to be forwarded. render_csv() now writes an excluded_during_conversion column on every row, from the same coverage.summarise() the HTML uses: the skip notes, UNKNOWN when the record cannot be read, or empty when nothing was excluded. It is kept out of CSV_COLUMNS because other renderers build their header from that tuple and their rows by hand. tests/test_coverage_on_every_surface.py is #308's item 2: one upload through the real converter, three surfaces, three states (excluded, nothing excluded, unreadable). Its docstring says the surfaces are enumerated, not discovered, as asked on the issue.
patelankeet2
left a comment
There was a problem hiding this comment.
Verified independently rather than trusted from the PR's own tables.
- Diffed against the real merge-base: exactly the 4 files, 179/-4, matching the stat claimed.
- Checked
coverage.summarise()'s actual return dict directly inanalysis/coverage.py--conversion_gapsandconversion_gaps_unreadableare real keys, not assumed from the PR body. Confirmedrender_html()calls the same function the same way (_coverage_html(), line 343), so the "same three states, from the same function, cannot disagree" claim is true by inspection, not just by argument. - Ran
tests/test_coverage_on_every_surface.pyandtests/test_report_export.pyon the branch: 41 passed. - Independently mutation-tested one of the table's own claimed mutants rather than taking it on trust: reverted
web/main.py's CSV call to the oldrender_csv(results, source=subject)with noconversion_gaps. Two tests failed for the right reason (test_a_skipped_rule_is_named_on_every_surface,test_an_unreadable_record_is_unknown_on_every_surface), both asserting the CSV column stayed empty/unaware instead of naming the skip. Reverted after. - Full suite on the branch: 1817 passed, 13 skipped, 0 failed.
ruff check --select E4,E7,E9,Fon the four changed files: clean.
One non-blocking note, not a request for changes: the multiple-gaps case ("; ".join(...)) isn't exercised by a test with more than one skip -- the fixture only produces one. Low risk given each note is an internal structured message rather than arbitrary text, but worth a parametrized case if this file gets touched again.
Approving.
|
@patelankeet2, thanks. On the multiple-gaps note, I measured it rather than pushing a test, because a push would void your approval on A PF Sense file with two different skip causes (a DHCP WAN carrying a rule, and a rule naming an So the join holds today, and splitting on |
#308's item 2, the test that can fail, plus the live instance it found on
main.The bug, measured on
main(fa568f7) with real BatfishA PF Sense upload whose DHCP WAN rule cannot be converted (the client's real shape):
The CSV is the export most likely to be forwarded, and it read as a complete account of a firewall with a rule left out. This is #308's rule broken in the direction the issue calls dangerous: the silent surface is the one that looks complete.
The fix
render_csv()writes anexcluded_during_conversioncolumn on every row, taking its value from the samecoverage.summarise()the HTML uses:UNKNOWN -- the record of what conversion excluded could not be read ...It sits on every row for the reason
report_subjectalready does (#347): a single labelled row does not survive sorting, filtering or pasting a few rows into an email.The same upload on this branch:
Kept out of
CSV_COLUMNSon purpose. #298's comparison CSV writes its header fromCSV_COLUMNSand builds its rows by hand. Adding the column there would leave that header one column wider than its rows the moment both land, and no merge conflict would show it. @patelankeet2, nothing for you to change; I wanted you to know why the constant is separate.The test, #308 item 2
tests/test_coverage_on_every_surface.py: one upload through the real endpoint and the real PF Sense converter, three surfaces, three states.No Batfish: only
pipeline._analyseis stubbed, with canned clean findings. That is the case where a silent surface does most harm, because nothing else on it hints at a gap.As @SamikaPerera asked on #308, its docstring says the surfaces are enumerated, not discovered. A fourth surface added later will not be caught unless someone adds it to the test. The saved-scans comparison (#223) already records skips and is the obvious candidate to check next.
Mutation testing
7 mutants, each killed, with Batfish running and stopped:
The first four are the point: before this, nothing could object to the CSV going silent.
One existing test changed:
test_no_dashboard_only_text_leaks_into_either_formatpinned the CSV header to exactlyCSV_COLUMNS. It now pinsCSV_COLUMNS + CSV_REPORT_COLUMNS, so a dashboard-only key leaking into the export still fails it.Where #308 stands with this merged
Reviewers: @SamikaPerera (
/web/, and he offered to co-write this test), @patelankeet2 (#302's header half, and #298's CSV).