Skip to content

Commit

Permalink
Catch errors in find_capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
gdesmar committed Apr 4, 2024
1 parent 9edc347 commit 7d3b881
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.organizeImports": "explicit"
},
"editor.formatOnSave": true,
"editor.rulers": [
Expand Down
4 changes: 3 additions & 1 deletion CAPA/CAPA.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ def start(self):
self.argv = [
"--quiet",
"--signatures",
# Ruleset downloaded from https://github.com/fireeye/capa/tree/v7.0.1/sigs
os.path.join(os.path.dirname(__file__), "sigs"),
"--rules",
# Ruleset downloaded from https://github.com/mandiant/capa-rules/archive/refs/tags/v7.0.1.zip
os.path.join(os.path.dirname(__file__), "capa-rules-7.0.1"),
"--format",
"auto",
Expand All @@ -80,6 +82,7 @@ def get_capa_results(self, request: ServiceRequest, input_file):
else:
os_ = capa.loader.get_os(sample_path)
extractor = capa.main.get_extractor_from_cli(args, input_format, backend)
capabilities, counts = capa.capabilities.common.find_capabilities(rules, extractor, disable_progress=True)
except capa.main.ShouldExitError as e:
return {"path": input_file, "status": "error", "error": str(e), "status_code": e.status_code}
except Exception as e:
Expand All @@ -88,7 +91,6 @@ def get_capa_results(self, request: ServiceRequest, input_file):
"status": "error",
"error": f"unexpected error: {e}",
}
capabilities, counts = capa.capabilities.common.find_capabilities(rules, extractor, disable_progress=True)

meta = capa.loader.collect_metadata(argv, args.input_file, "auto", os_, [], extractor, counts)
meta.analysis.layout = capa.loader.compute_layout(rules, extractor, capabilities)
Expand Down

0 comments on commit 7d3b881

Please sign in to comment.