Skip to content

Commit 9f9124b

Browse files
committed
Remove BBOTTarget pickle support
The HTTP engine subprocess that consumed pickled targets is gone — blasthttp runs in-process. Drop BaseTarget.__getstate__/__setstate__, ScanBlacklist.__setstate__, and the test_target_pickle round-trip test.
1 parent f448bf4 commit 9f9124b

2 files changed

Lines changed: 0 additions & 46 deletions

File tree

bbot/scanner/target.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,6 @@ def __len__(self):
178178
def __bool__(self):
179179
return bool(len(self._rt)) or bool(self.event_seeds)
180180

181-
def __getstate__(self):
182-
"""Serialize for pickling — RadixTarget (PyO3) can't be pickled directly."""
183-
return {
184-
"inputs": [str(e.input) for e in self.event_seeds],
185-
"strict_scope": self.strict_scope,
186-
"acl_mode": getattr(self._rt, "_acl_mode", False),
187-
}
188-
189-
def __setstate__(self, state):
190-
"""Reconstruct from pickled state."""
191-
self.__init__(*state["inputs"], strict_scope=state["strict_scope"], acl_mode=state.get("acl_mode", False))
192-
193181
def __eq__(self, other):
194182
return self.hash == getattr(other, "hash", None)
195183

@@ -266,10 +254,6 @@ def __init__(self, *args, **kwargs):
266254
self.blacklist_regexes = set()
267255
super().__init__(*args, **kwargs)
268256

269-
def __setstate__(self, state):
270-
self.blacklist_regexes = set()
271-
super().__setstate__(state)
272-
273257
def get(self, host, **kwargs):
274258
"""
275259
Blacklists only accept IPs or strings. This is cleaner since we need to search for regex patterns.

bbot/test/test_step_1/test_target.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -703,36 +703,6 @@ def counting_EventSeed(input):
703703
)
704704

705705

706-
def test_target_pickle():
707-
"""BBOTTarget must survive pickle round-trips (used by HTTP engine subprocess)."""
708-
import pickle
709-
710-
from bbot.scanner.target import BBOTTarget
711-
712-
target = BBOTTarget(
713-
target=["evilcorp.com", "1.2.3.0/24"],
714-
blacklist=["bad.evilcorp.com"],
715-
strict_scope=False,
716-
)
717-
718-
data = pickle.dumps(target)
719-
restored = pickle.loads(data)
720-
721-
# scope checks work after unpickling
722-
assert restored.in_target("evilcorp.com")
723-
assert restored.in_target("www.evilcorp.com")
724-
assert restored.in_target("1.2.3.4")
725-
assert not restored.in_target("9.9.9.9")
726-
727-
# blacklist works after unpickling
728-
assert restored.blacklisted("bad.evilcorp.com")
729-
assert not restored.in_scope("bad.evilcorp.com")
730-
assert restored.in_scope("good.evilcorp.com")
731-
732-
# hashes match
733-
assert target.hash == restored.hash
734-
735-
736706
def test_target_comments():
737707
"""Target strings support # comments — both full-line and inline."""
738708
from bbot.scanner.target import BBOTTarget

0 commit comments

Comments
 (0)