Skip to content

Commit

Permalink
fix(capa2sarif): remove dependencies from pyproject toml to guarded i…
Browse files Browse the repository at this point in the history
…mport statements
  • Loading branch information
ReversingWithMe committed Jun 7, 2024
1 parent eb07aea commit f663749
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ dev = [
"stix2==3.0.1",
"requests==2.31.0",
"mypy-protobuf==3.6.0",
"sarif_om==1.0.4",
"jschema_to_python==1.2.3",
# type stubs for mypy
"types-backports==0.1.3",
"types-colorama==0.4.15.11",
Expand Down
16 changes: 13 additions & 3 deletions scripts/capa2sarif.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,26 @@
import argparse
from pathlib import Path

from sarif_om import Tool, SarifLog, Run, ToolComponent
from jschema_to_python.to_json import to_json

from capa.version import __version__

from typing import Optional, List


logger = logging.getLogger('capa2sarif')

# Dependencies
try:
from sarif_om import Tool, SarifLog, Run, ToolComponent
except ImportError as e:
logger.error("Required import `sarif_om` is not installed. This is solved by installing `python3 -m pip install sarif_om>=1.0.4`. %s", e)
exit(-4)

try:
from jschema_to_python.to_json import to_json
except ImportError as e:
logger.error("Required import `jschema_to_python` is not installed. This is solved by installing `python3 -m pip install jschema_to_python>=1.2.3`, %s", e)
exit(-4)


def _parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(
Expand Down

0 comments on commit f663749

Please sign in to comment.