Skip to content

Commit

Permalink
fix event tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechromancer committed Nov 8, 2023
1 parent a1e02ce commit cb6c30f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
15 changes: 7 additions & 8 deletions bbot/core/event/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion bbot/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion bbot/test/test_step_1/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit cb6c30f

Please sign in to comment.