aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--abusectl/cli.py15
-rw-r--r--tests/test_cli.py22
2 files changed, 37 insertions, 0 deletions
diff --git a/abusectl/cli.py b/abusectl/cli.py
index c467f9a..2b4e1d7 100644
--- a/abusectl/cli.py
+++ b/abusectl/cli.py
@@ -433,6 +433,21 @@ def _cmd_report(args) -> int:
)
return EXIT_NOT_CONFIGURED
+ # Warned, not refused: a case with abuse-desk destinations and no
+ # vendors is a perfectly good report, and this tool is specified to be
+ # useful with no API key configured anywhere. Not silent either. A user
+ # who believes MISP is configured and finds no misp row has a typo'd
+ # section name, and MISP is the gate for everything irreversible: a case
+ # built with no gate, discovered at submit time, is discovered a step
+ # too late.
+ if not settings.destinations:
+ print(
+ "abusectl report: no reporting destinations configured, so this "
+ "case will reach abuse desks only. Add [misp], [abusedb] or "
+ f"[urlhaus] to {config_path}, or run `abusectl init`.",
+ file=sys.stderr,
+ )
+
try:
manifest = case.load(args.case)
except FileNotFoundError:
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 89da6b0..3638edd 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -458,6 +458,28 @@ class ReportCommand(unittest.TestCase):
self.assertEqual(written["destinations"], [])
self.assertEqual(written["unreportable"], [])
+ def test_no_configured_destination_warns_and_still_exits_zero(self):
+ self._write_config('[reporter]\nemail = "r@example.org"\n')
+ case_path = self._make_case()
+ code, _, err = self._run(
+ "--config", str(self.config), "report", str(case_path)
+ )
+ self.assertEqual(code, 0)
+ self.assertIn("no reporting destinations", err)
+ self.assertIn(str(self.config), err)
+
+ def test_a_configured_destination_produces_no_warning(self):
+ self._write_config(
+ '[reporter]\nemail = "r@example.org"\n'
+ '\n[abusedb]\napi_key = "k"\n'
+ )
+ case_path = self._make_case()
+ code, _, err = self._run(
+ "--config", str(self.config), "report", str(case_path)
+ )
+ self.assertEqual(code, 0)
+ self.assertNotIn("no reporting destinations", err)
+
if __name__ == "__main__":
unittest.main()