-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
421 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import glob | ||
import json | ||
import logging | ||
import os | ||
import tempfile | ||
from datetime import timedelta | ||
from io import BytesIO | ||
from zipfile import ZipFile | ||
|
||
from core import taskmanager | ||
from core.schemas import indicator, task | ||
|
||
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.INFO) | ||
|
||
|
||
class YaraForge(task.FeedTask): | ||
_defaults = { | ||
"name": "YaraForge", | ||
"frequency": timedelta(days=1), | ||
"type": "feed", | ||
"description": "Collection of community Yara rules: https://yarahq.github.io/", | ||
} | ||
|
||
_SOURCE_ZIP = "https://github.com/YARAHQ/yara-forge/releases/latest/download/yara-forge-rules-core.zip" | ||
|
||
def run(self): | ||
response = self._make_request(self._SOURCE_ZIP, no_cache=True) | ||
if not response: | ||
logging.info(f"No response: skipping {self.name} update") | ||
return | ||
|
||
with tempfile.TemporaryDirectory() as tempdir: | ||
ZipFile(BytesIO(response.content)).extractall(path=tempdir) | ||
|
||
rules_path = os.path.join( | ||
tempdir, "packages", "core", "yara-rules-core.yar" | ||
) | ||
with open(rules_path, "r") as f: | ||
rules = f.read() | ||
|
||
indicator.Yara.import_bulk_rules(rules, tags=["yara-forge-core"]) | ||
|
||
|
||
taskmanager.TaskManager.register_task(YaraForge) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.