Skip to content

Commit

Permalink
Refactor MISP config initialization to ease inheritance (#26)
Browse files Browse the repository at this point in the history
* Refactor misp config processing to ease inheritance
  • Loading branch information
nazywam authored Apr 30, 2024
1 parent b69070a commit 1acd39a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions karton/misp_pusher/misp_pusher.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ def __init__(self, *args, **kwargs) -> None:
if not self.config.get("misp", "key"):
raise RuntimeError("Misp config section is missing the key parameter")

self.misp_url = http_url(self.config.get("misp", "url"))
self.misp_key = self.config.get("misp", "key")
self.misp_ssl = not self.config.getboolean("misp", "insecure", False)
self.misp_timeout = self.config.getint("misp", "timeout", 10)
self.tag_events = self.config.getboolean("misp", "tag_events", True)
self.misp_published = self.config.getboolean("misp", "published", False)

self.cluster_mapping = {}
if self.config.get("misp", "galaxy_clusters_mapping"):
Expand All @@ -65,10 +70,10 @@ def process(self, task: Task) -> None:
return

misp = PyMISP(
url=http_url(self.config.get("misp", "url")),
key=self.config.get("misp", "key"),
ssl=not self.config.getboolean("misp", "insecure", False),
timeout=self.config.getint("misp", "timeout", 10),
url=self.misp_url,
key=self.misp_key,
ssl=self.misp_ssl,
timeout=self.misp_timeout,
)

# Upload structured data to MISP
Expand Down Expand Up @@ -115,7 +120,7 @@ def process(self, task: Task) -> None:
for o in iocs.to_misp():
event.add_object(o)

event.published = self.config.getboolean("misp", "published", False)
event.published = self.misp_published

misp.add_event(event)

Expand Down

0 comments on commit 1acd39a

Please sign in to comment.