Skip to content

Commit

Permalink
Fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
lvoloshyn-sekoia committed Jul 3, 2024
1 parent 67890f9 commit 8534461
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 6 additions & 5 deletions sekoia_automation/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,13 @@ def update_sekoia_library(
SDKUpdater(modules_path=modules_path).update_sdk_version()


if __name__ == "__main__":
app()


@app.command(name="run-action")
def run_action(
data_path: Path = typer.Option(".", help="Path to the context data"),
modules_path: Path = typer.Option(".", help="Path to the playbook modules"),
module_name: str = typer.Option(..., help="Name of the module to test"),
class_name: str = typer.Option(..., help="Class name of the action to test"),
Expand All @@ -197,10 +202,6 @@ def run_action(
arg.split("=", maxsplit=1)[0]: arg.split("=", maxsplit=1)[1] for arg in args
}
module_runner = ModuleItemRunner(
module_name=module_name, class_name=class_name, root_path=modules_path
module_name=module_name, class_name=class_name, root_path=modules_path, data_path=data_path

Check failure on line 205 in sekoia_automation/cli.py

View workflow job for this annotation

GitHub Actions / Lint

Ruff (E501)

sekoia_automation/cli.py:205:89: E501 Line too long (99 > 88)
)
print(module_runner.run(args=kwargs))


if __name__ == "__main__":
app()
7 changes: 4 additions & 3 deletions sekoia_automation/scripts/action_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@


class ModuleItemRunner:

Check failure on line 14 in sekoia_automation/scripts/action_runner.py

View workflow job for this annotation

GitHub Actions / Lint

Ruff (I001)

sekoia_automation/scripts/action_runner.py:1:1: I001 Import block is un-sorted or un-formatted
def __init__(self, class_name: str, module_name: str, root_path: Path):
def __init__(self, class_name: str, module_name: str, root_path: Path, data_path: Path = Path(".")):

Check failure on line 15 in sekoia_automation/scripts/action_runner.py

View workflow job for this annotation

GitHub Actions / Lint

Ruff (E501)

sekoia_automation/scripts/action_runner.py:15:89: E501 Line too long (104 > 88)
self.__class_name = class_name
self.__root_path = root_path # `automation-library` folder by default
self.__module_path = (root_path / module_name).resolve()
self.__data_path = data_path

def load_class_from_path(self, path: Path | str, class_name: str) -> typing.Type:
# Add the directory containing the module to sys.path
Expand Down Expand Up @@ -181,8 +182,8 @@ def run(self, args: dict) -> dict | None:
)

module_item = module_item_cls(
module=module, data_path=Path(".")
) # @todo set custom path?
module=module, data_path=self.__data_path
)

module_item_type = self.get_module_item_type(module_item_cls)
if module_item_type == "Action":
Expand Down

0 comments on commit 8534461

Please sign in to comment.