diff options
| author | stuppie | 2026-03-12 11:53:18 -0600 |
|---|---|---|
| committer | stuppie | 2026-03-12 11:53:18 -0600 |
| commit | d9ab70d98624e22b87dfe40cc5e18c8ad5eb44c4 (patch) | |
| tree | 194ec20d29ec614fc2344ab242923cbbded06316 /tests/models/network/nmap.py | |
| parent | b0306293ef52816998a463fbfe4c5b97d00b9b65 (diff) | |
| download | generalresearch-d9ab70d98624e22b87dfe40cc5e18c8ad5eb44c4.tar.gz generalresearch-d9ab70d98624e22b87dfe40cc5e18c8ad5eb44c4.zip | |
some tests to execute the full Toolrun pipeline for each tool. fix small bugs
Diffstat (limited to 'tests/models/network/nmap.py')
| -rw-r--r-- | tests/models/network/nmap.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/models/network/nmap.py b/tests/models/network/nmap.py new file mode 100644 index 0000000..f034bf0 --- /dev/null +++ b/tests/models/network/nmap.py @@ -0,0 +1,29 @@ +import subprocess + +from generalresearch.models.network.definitions import IPProtocol +from generalresearch.models.network.nmap.execute import execute_nmap +import faker + +from generalresearch.models.network.nmap.result import PortState +from generalresearch.models.network.tool_run import ToolName, ToolClass + +fake = faker.Faker() + + +def resolve(host): + return subprocess.check_output(["dig", host, "+short"]).decode().strip() + + +def test_execute_nmap_scanme(toolrun_manager): + ip = resolve("scanme.nmap.org") + + run = execute_nmap(ip=ip, top_ports=20) + assert run.tool_name == ToolName.NMAP + assert run.tool_class == ToolClass.PORT_SCAN + assert run.ip == ip + result = run.parsed + + port22 = result._port_index[(IPProtocol.TCP, 22)] + assert port22.state == PortState.OPEN + + toolrun_manager.create_nmap_run(run) |
