[Testing] Add unit tests for core protocol libraries (HTTP, SSH, FTP, SMTP, Telnet, POP3)
Summary
The protocol handler libraries under nettacker/core/lib/ are almost entirely untested.
Out of 13 protocol files, only 3 have test coverage (SMB, SSL, Socket).
The remaining 10 — including HTTP, SSH, FTP, FTPS, SMTP, SMTPS, POP3, POP3S, Telnet, and Base —
have zero unit tests.
Affected Files
nettacker/core/lib/base.py— base connection class (parent of all protocols)nettacker/core/lib/http.py— used by all scan/vuln modulesnettacker/core/lib/ssh.pynettacker/core/lib/ftp.py/ftps.pynettacker/core/lib/smtp.py/smtps.pynettacker/core/lib/pop3.py/pop3s.pynettacker/core/lib/telnet.py
What Needs to Be Done
- [ ] Write unit tests for
base.pycovering connection lifecycle, timeout handling, and error states - [ ] Write unit tests for
http.pycovering request building, response parsing, and condition matching (mockrequests) - [ ] Write unit tests for
ssh.pycovering auth attempts and error handling (mockparamiko) - [ ] Write unit tests for
ftp.py,ftps.pycovering login flows and error handling (mockftplib) - [ ] Write unit tests for
smtp.py,smtps.pycovering connection and auth flows - [ ] Write unit tests for
pop3.py,pop3s.py - [ ] Write unit tests for
telnet.py - [ ] Place tests in
tests/core/lib/test_<protocol>.pymatching the existing pattern
Acceptance Criteria
- All network calls must be mocked (no real connections)
- Each protocol file achieves ≥ 80% line coverage
- Tests run successfully with
pytest tests/core/lib/
Context
This is part of the GSoC 2026 goal to raise overall test coverage to 85%.
The existing tests/core/lib/test_socket.py and test_smb.py can serve as reference implementations.
@securestep9, Please Guide me !
I'm starting with the base.py tests since BaseEngine is the parent class for all protocol engines and its methods are the foundation of the scanning pipeline.
My PR adds 25 unit tests covering:
BaseLibrary: default state, brute_force noopfilter_large_content(): space-boundary truncation, custom filter rates, edge casesprocess_conditions(): successful/failed conditions, temp event storage, port extraction from URLs and ports field, log field cleanup, sensitive header removalBaseEngine.run(): library method dispatch, ports-to-port renaming, retry logic (partial failure + all-retries-fail)get_dependent_results_from_database(): event retrieval, polling until available, multi-event parsingfind_and_replace_dependent_values(): passthrough for non-dependent datareplace_dependent_values(): delegation verification
Achieved 87% line coverage for base.py with all network calls mocked.
Following up from my base.py tests in PR #1401, I'm picking up the remaining brute-force protocol libraries: SSH, FTP, FTPS, SMTP, SMTPS, POP3, POP3S, and Telnet.
All eight share the same structure (BaseLibrary subclass with a brute_force method that connects, authenticates, and returns credentials). I'll cover:
- Successful authentication returning the expected credential dict
- Connection/auth failures propagating the correct exceptions
- TLS-specific behavior (starttls for SMTPS, FTP_TLS for FTPS, POP3_SSL for POP3S)
- SSH's conditional auth strategy selection (Password vs NoneAuth based on whether a password is supplied)
- Telnet's interactive read/write login sequence
All network calls mocked.
Hi! I'm a GSoC 2026 applicant and would like to work on this.
I've already written unit tests for smtp.py locally on
WSL2 (Ubuntu 24.04, Python 3.12.3) and they pass with
100% coverage. I plan to cover smtp.py, smtps.py, ftp.py,
ftps.py, pop3.py, pop3s.py, and telnet.py in a single PR.
Could a maintainer confirm this issue is available?