Improve evidence classification and compact CLI reporting
This commit is contained in:
1 parent
9dc7289652
commit
dda4f8563f
28 files changed
+945
-87
No files matched your search
+7
-4
@@ -7,6 +7,7 @@ from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from rpcscope.cli import main
|
||||
from rpcscope.checks import CheckResult
|
||||
|
||||
|
||||
TOOLS = {"nxc": "nxc", "enum4linux-ng": None, "rpcdump": None, "msfconsole": None}
|
||||
@@ -25,7 +26,8 @@ class CliTests(unittest.TestCase):
|
||||
self.assertEqual(code, 0)
|
||||
self.assertFalse(destination.exists())
|
||||
self.assertEqual(any(command[0] == "enum4linux-ng" for command in commands), deep)
|
||||
self.assertEqual(sum("-M" in command for command in commands), 11 if isolated else 7)
|
||||
self.assertEqual(sum("-M" in command for command in commands), 10 if isolated else 6)
|
||||
self.assertTrue(any(command[0] == "<native:smb-compression>" for command in commands))
|
||||
self.assertTrue(any(command[0] == "<native:longlogon>" for command in commands))
|
||||
|
||||
def test_tcp_share_dry_run_shows_gating_without_guessing_live_capabilities(self):
|
||||
@@ -68,7 +70,7 @@ class CliTests(unittest.TestCase):
|
||||
with patch("rpcscope.runner.doctor", return_value=TOOLS), patch("rpcscope.runner._run", side_effect=execute), \
|
||||
contextlib.redirect_stdout(captured), contextlib.redirect_stderr(diagnostics):
|
||||
code = main(["scan", "192.0.2.0/30", "--checks", "ms17-010", "--authorised",
|
||||
"--discovery", "smb", "--no-enum4linux", "--no-rpcdump", "--progress", "plain", "-o", str(destination)])
|
||||
"--discovery", "smb", "--no-enum4linux", "--no-rpcdump", "--progress", "plain", "--format", "full", "-o", str(destination)])
|
||||
self.assertEqual(code, 0)
|
||||
self.assertIn("[3/3] SUMMARY scan complete", diagnostics.getvalue())
|
||||
self.assertIn("VULN: [MS17-010]", captured.getvalue())
|
||||
@@ -97,15 +99,16 @@ class CliTests(unittest.TestCase):
|
||||
def execute(command, timeout, log, password, **kwargs):
|
||||
return (0, "") if "-M" in command else (0, "SMB 192.0.2.1 445 HOST [*] Windows 11 (name:HOST)")
|
||||
with patch("rpcscope.runner.doctor", return_value=TOOLS), patch("rpcscope.runner._run", side_effect=execute), \
|
||||
patch("rpcscope.runner.probe_smb_compression", return_value=CheckResult("inconclusive", "no response")), \
|
||||
contextlib.redirect_stdout(output), contextlib.redirect_stderr(diagnostics):
|
||||
code = main(["scan", "192.0.2.1", "--checks", "smbghost", "--discovery", "smb", "--authorised",
|
||||
"--no-enum4linux", "--no-rpcdump", "-o", str(Path(temporary) / "out")])
|
||||
self.assertEqual(code, 0)
|
||||
self.assertIn("UNKNOWN:", output.getvalue())
|
||||
self.assertIn("CHECKS: 1/1", output.getvalue())
|
||||
self.assertIn("1 hosts | 0 confirmed", output.getvalue())
|
||||
self.assertNotIn("PARTIAL", output.getvalue())
|
||||
self.assertNotIn("NOT VULNERABLE", output.getvalue())
|
||||
self.assertIn("SUMMARY scan complete", diagnostics.getvalue())
|
||||
self.assertIn("COMPLETE |", diagnostics.getvalue())
|
||||
|
||||
def test_dry_run_has_no_files_and_keeps_json_on_stdout(self):
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
|
||||
Reference in new issue
Block a user