From cb6c30f9f7764f31c402bd01c5ff236ee478b9e6 Mon Sep 17 00:00:00 2001 From: TheTechromancer Date: Wed, 8 Nov 2023 12:32:17 -0500 Subject: [PATCH] fix event tests --- bbot/core/event/base.py | 15 +++++++-------- bbot/test/conftest.py | 2 +- bbot/test/test_step_1/test_events.py | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/bbot/core/event/base.py b/bbot/core/event/base.py index bdfbe7dab4..91dab6f1ef 100644 --- a/bbot/core/event/base.py +++ b/bbot/core/event/base.py @@ -800,7 +800,6 @@ class ASN(DictEvent): class CODE_REPOSITORY(DictHostEvent): class _data_validator(BaseModel): url: str - # _validate_url = field_validator("url")(validators.validate_url) _validate_url = field_validator("url")(validators.validate_url) def _pretty_string(self): @@ -1055,7 +1054,7 @@ class _data_validator(BaseModel): host: str severity: str description: str - url: Optional[str] + url: Optional[str] = None _validate_host = field_validator("host")(validators.validate_host) _validate_severity = field_validator("severity")(validators.validate_severity) @@ -1069,7 +1068,7 @@ class FINDING(DictHostEvent): class _data_validator(BaseModel): host: str description: str - url: Optional[str] + url: Optional[str] = None _validate_host = field_validator("host")(validators.validate_host) def _pretty_string(self): @@ -1080,7 +1079,7 @@ class TECHNOLOGY(DictHostEvent): class _data_validator(BaseModel): host: str technology: str - url: Optional[str] + url: Optional[str] = None _validate_host = field_validator("host")(validators.validate_host) def _data_id(self): @@ -1096,7 +1095,7 @@ class VHOST(DictHostEvent): class _data_validator(BaseModel): host: str vhost: str - url: Optional[str] + url: Optional[str] = None _validate_host = field_validator("host")(validators.validate_host) def _pretty_string(self): @@ -1107,8 +1106,8 @@ class PROTOCOL(DictHostEvent): class _data_validator(BaseModel): host: str protocol: str - port: Optional[int] - banner: Optional[str] + port: Optional[int] = None + banner: Optional[str] = None _validate_host = field_validator("host")(validators.validate_host) _validate_port = field_validator("port")(validators.validate_port) @@ -1160,7 +1159,7 @@ class _data_validator(BaseModel): url: str host: str WAF: str - info: Optional[str] + info: Optional[str] = None _validate_url = field_validator("url")(validators.validate_url) _validate_host = field_validator("host")(validators.validate_host) diff --git a/bbot/test/conftest.py b/bbot/test/conftest.py index 67e7515ff7..84b2077fe8 100644 --- a/bbot/test/conftest.py +++ b/bbot/test/conftest.py @@ -18,7 +18,7 @@ def pytest_sessionfinish(session, exitstatus): logger.removeHandler(handler) # Wipe out BBOT home dir - shutil.rmtree("/tmp/.bbot_test", ignore_errors=True) + # shutil.rmtree("/tmp/.bbot_test", ignore_errors=True) yield diff --git a/bbot/test/test_step_1/test_events.py b/bbot/test/test_step_1/test_events.py index 842b91f9cb..8868e71a30 100644 --- a/bbot/test/test_step_1/test_events.py +++ b/bbot/test/test_step_1/test_events.py @@ -234,7 +234,7 @@ async def test_events(events, scan, helpers, bbot_config): ) assert json.loads(test_vuln2.data_human)["severity"] == "INFO" assert test_vuln2.host.is_private - with pytest.raises(ValidationError, match=".*severity.*\n.*field required.*"): + with pytest.raises(ValidationError, match=".*validation error.*\nseverity\n.*Field required.*"): test_vuln = scan.make_event({"host": "evilcorp.com", "description": "asdf"}, "VULNERABILITY", dummy=True) with pytest.raises(ValidationError, match=".*host.*\n.*Invalid host.*"): test_vuln = scan.make_event(