Skip to content

feat(display): improve NAT rule directionality presentation in markdown reports - #182

Merged
unclesp1d3r merged 1 commit into
mainfrom
60-improve-nat-rule-directionality-presentation-in-markdown-reports
Jan 21, 2026
Merged

feat(display): improve NAT rule directionality presentation in markdown reports#182
unclesp1d3r merged 1 commit into
mainfrom
60-improve-nat-rule-directionality-presentation-in-markdown-reports

Conversation

@unclesp1d3r

Copy link
Copy Markdown
Member

Summary

  • Add BuildOutboundNATTable and BuildInboundNATTable methods to MarkdownBuilder for clear visual separation of NAT rule types
  • Update BuildSecuritySection to use new NAT table builders with direction indicators (⬆️ Outbound / ⬇️ Inbound)
  • Add inbound rules count to NAT summary and security warning for port forwarding exposure
  • Update all templates (opnsense_report.md.tmpl, opnsense_report_comprehensive.md.tmpl, reports/standard.md.tmpl) to properly iterate over inbound NAT rules

Test plan

  • Verified with just ci-check - all tests pass
  • Added unit tests for BuildOutboundNATTable (with rules, empty rules, special characters)
  • Added unit tests for BuildInboundNATTable (with rules, empty rules, special characters)
  • Added unit tests for BuildSecuritySection with both NAT types and security warnings

Closes #60

🤖 Generated with Claude Code

…wn reports

Add clear visual separation between outbound and inbound NAT rules with
direction indicators and proper table structures:

- Add BuildOutboundNATTable and BuildInboundNATTable methods to MarkdownBuilder
- Update BuildSecuritySection to use new NAT table builders
- Add direction indicators (⬆️ Outbound / ⬇️ Inbound) in table rows
- Add inbound rules count to NAT summary
- Add security warning for inbound NAT rules (port forwarding exposure)
- Update templates to iterate over inbound NAT rules with proper tables
- Add clear H4 subsection headers: "Outbound NAT (Source Translation)"
  and "Inbound NAT (Port Forwarding)"

Closes #60

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 21, 2026 04:55
@unclesp1d3r unclesp1d3r linked an issue Jan 21, 2026 that may be closed by this pull request
25 tasks
@coderabbitai

coderabbitai Bot commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

Failed to post review comments

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Reorganized NAT sections with dedicated Outbound (Source Translation) and Inbound (Port Forwarding) tables.
    • Added direction indicators to distinguish NAT rule types in reports.
    • Enhanced inbound NAT display with external port, target IP, and priority columns.
    • Added security warnings for inbound NAT configurations.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

This PR enhances NAT rule presentation in markdown reports by implementing dedicated outbound and inbound NAT table builders with direction indicators, security warnings, and template integration for clear traffic flow visualization.

Changes

Cohort / File(s) Summary
NAT Table Builders
internal/converter/markdown.go
Added BuildOutboundNATTable() and BuildInboundNATTable() helper functions that generate formatted markdown tables with field escaping, protocol/status defaults, and interface link formatting. Integrated both helpers into Security section rendering; updated NAT Summary display to include inbound rule counts and dynamic mode resolution from available sources.
NAT Table Tests
internal/converter/markdown_builder_test.go
Added 6 new test functions covering outbound and inbound NAT table generation (with rules, empty rules, special characters) plus 4 integration tests for NAT sections within Security output (both NAT types present, inbound warnings, NAT reflection). Introduced comprehensive test data builders (createComprehensiveTestData) for representative configuration structures.
Report Templates
internal/templates/opnsense_report.md.tmpl, internal/templates/opnsense_report_comprehensive.md.tmpl, internal/templates/reports/standard.md.tmpl
Renamed "Outbound NAT Rules" to "Outbound NAT (Source Translation)" with added Direction column (⬆️ Outbound). Added new "Inbound NAT (Port Forwarding)" section with Direction column (⬇️ Inbound), External Port, Target IP, Target Port, and Priority columns. Introduced security warning block for inbound NAT exposure; removed Created By columns; updated empty-state messaging.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #110: Extends converter/markdown builder test infrastructure and data builders used in this PR's new test coverage
  • PR #72: Modifies NAT-related markdown rendering in identical files (markdown.go, templates) with overlapping table presentation logic
  • PR #77: Adds/expands NATSummary and NAT configuration reporting structures that complement this PR's table builders and template rendering

Suggested labels

type:feature, go, testing, priority:normal

Poem

🔀 Outbound flows in arrows bright,
Inbound welcomes foreign light,
Tables clear the muddy waters—
⬆️ and ⬇️ guide the data's daughters!
Security warnings light the way,
NAT rules now have their say! 🎯

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title follows conventional commit format with 'feat' type and clear scope describing NAT directionality improvements in markdown reports.
Description check ✅ Passed Description covers implementation details, testing (unit tests and ci-check verification), and provides a clear summary of changes across multiple files and templates.
Linked Issues check ✅ Passed All coding requirements from issue #60 are met: BuildOutboundNATTable and BuildInboundNATTable methods implemented, direction indicators added, security warnings included, templates updated to iterate inbound/outbound rules.
Out of Scope Changes check ✅ Passed All changes are focused on issue #60 objectives: NAT table builders, security section updates, template modifications, and comprehensive unit test coverage for NAT rendering.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 60-improve-nat-rule-directionality-presentation-in-markdown-reports

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request improves the presentation of NAT rules in markdown reports by introducing clear visual directionality indicators and separating inbound/outbound NAT rules into dedicated sections.

Changes:

  • Added BuildOutboundNATTable and BuildInboundNATTable methods to MarkdownBuilder for programmatic generation of NAT rule tables with direction indicators (⬆️ Outbound / ⬇️ Inbound)
  • Updated BuildSecuritySection to use the new table builders and include inbound rules count in the NAT summary
  • Added security warnings for port forwarding configurations that increase attack surface
  • Updated all templates to properly iterate over inbound NAT rules and display them with consistent formatting

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/converter/markdown.go Added BuildOutboundNATTable and BuildInboundNATTable methods with proper escaping, status formatting, and direction indicators; updated BuildSecuritySection to use new builders and include inbound rules count
internal/converter/markdown_builder_test.go Added comprehensive unit tests for new NAT table builders covering rules with data, empty rules, special characters, and security warnings
internal/templates/reports/standard.md.tmpl Updated NAT sections with direction indicators, proper iteration over inbound rules, and security warnings
internal/templates/opnsense_report_comprehensive.md.tmpl Updated NAT sections with direction indicators, proper iteration over inbound rules, and security warnings
internal/templates/opnsense_report.md.tmpl Updated NAT sections with direction indicators, proper iteration over inbound rules, inbound count in summary, and security warnings

@codecov

codecov Bot commented Jan 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.64286% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/converter/markdown.go 94.64% 3 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai Bot added go Pull requests that update go code priority:normal Normal priority issue testing Test infrastructure and test-related issues type:feature New feature implementation labels Jan 21, 2026
@unclesp1d3r
unclesp1d3r merged commit 1cf068f into main Jan 21, 2026
22 of 23 checks passed
@unclesp1d3r
unclesp1d3r deleted the 60-improve-nat-rule-directionality-presentation-in-markdown-reports branch January 21, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update go code priority:normal Normal priority issue testing Test infrastructure and test-related issues type:feature New feature implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve NAT rule directionality presentation in markdown reports

2 participants