Skip to content

test(plugins): add parser unit tests for scapy_recon plugin (#1431)#1710

Open
Khanvilkarshravani27 wants to merge 2 commits into
utksh1:mainfrom
Khanvilkarshravani27:add-scapy-recon-parser-tests
Open

test(plugins): add parser unit tests for scapy_recon plugin (#1431)#1710
Khanvilkarshravani27 wants to merge 2 commits into
utksh1:mainfrom
Khanvilkarshravani27:add-scapy-recon-parser-tests

Conversation

@Khanvilkarshravani27

Copy link
Copy Markdown
Collaborator

Description

Adds a dedicated parser unit test suite for the scapy_recon plugin to protect parser behaviour from regressions.

The new test file (testing/backend/test_scapy_recon_parser.py) includes 38 tests that cover:

  • Metadata contract: Validates metadata.json structure, required fields, engine binary, and output parser type.
  • Normal ARP output: Verifies correct IP + MAC extraction, finding keys, category, severity, description, and remediation.
  • ICMP output: Verifies hosts with no MAC address default to "Unknown".
  • Edge cases: Ensures the parser handles single hosts, empty inputs, whitespace-only, malformed strings, mixed valid/noise lines, and large subnet outputs (50 hosts) without crashing.

Related Issues

Closes #1431

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Testing (Adds missing parser test coverage for an existing plugin)

How Has This Been Tested?

Ran the test suite locally using pytest to ensure all new and existing tests pass:

python -m pytest testing/backend/test_scapy_recon_parser.py -v --noconftest

Checklist

  • My code follows the code style of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Some of the scapy_recon parser tests are useful, but this PR is too bloated and mixes in unrelated parser_sandbox changes.\n\n1. Remove the unrelated backend/sandbox changes.\n2. Trim the test suite to the meaningful parser regression cases instead of large volumes of repetitive shape assertions.\n3. Keep the PR focused on the parser behavior only.\n\nPlease resubmit a smaller, more targeted test PR.

@utksh1 utksh1 added type:testing Testing work category bonus label area:plugins Scanner plugin metadata, schemas, or plugin runtime work level:intermediate 35 pts difficulty label for moderate contributor PRs labels Jul 7, 2026
@Khanvilkarshravani27 Khanvilkarshravani27 force-pushed the add-scapy-recon-parser-tests branch from 6e64234 to ff9e761 Compare July 8, 2026 09:00
@Khanvilkarshravani27

Copy link
Copy Markdown
Collaborator Author

Hi @utksh1,

Thanks for the feedback — all points are now addressed:

  • Removed unrelated parser_sandbox.py changes
  • Trimmed redundant shape/volume assertions and duplicate empty‑key check
  • Squashed to a single commit (test‑file only, parser behaviour focus)

Let me know if you'd like any further changes.

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The unrelated sandbox code is gone, but this is still much larger than needed for parser regression coverage: it includes a broad metadata contract suite and many redundant shape assertions. Please reduce it to focused parser cases (normal output, empty output, malformed input, noise, and missing MAC), then rebase on current main and rerun CI.

Cover the scapy_recon plugin parser.py with targeted behavioural tests:

- Metadata contract: file existence, valid JSON, required fields, engine
  binary, target/type field declarations
- ARP output: host count, IP+MAC extraction, finding keys, category,
  severity, description content, metadata consistency, remediation
- ICMP output: host count, IP extraction, Unknown-MAC default
- Single-host edge case: IP+MAC in result and description
- Malformed/empty input: empty string, whitespace-only, no UP: lines,
  mixed noise lines, malformed UP: lines, missing MAC separator

No changes to backend source; test file only.
@Khanvilkarshravani27 Khanvilkarshravani27 force-pushed the add-scapy-recon-parser-tests branch from 6f62855 to 12fab65 Compare July 14, 2026 15:07
@Khanvilkarshravani27

Copy link
Copy Markdown
Collaborator Author

Hi @utksh1,

All points addressed:

  • Removed the metadata contract suite and redundant shape assertions
  • Trimmed to 11 focused tests: normal ARP output, missing MAC, empty input, noise lines, and malformed input (parametrized)
  • Rebased on current main and force-pushed as a single clean commit

All 11 tests pass locally:

python -m pytest testing/backend/test_scapy_recon_parser.py -v --noconftest
# 11 passed in 0.52s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:plugins Scanner plugin metadata, schemas, or plugin runtime work level:intermediate 35 pts difficulty label for moderate contributor PRs type:testing Testing work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PLUGINS] Add parser unit tests for scapy_recon plugin

2 participants