Skip to content

Commit

Permalink
Update CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicoretti committed Oct 25, 2023
1 parent c70fff9 commit 6ba2dac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
18 changes: 8 additions & 10 deletions exasol/toolbox/tools/security.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""This module contains security related CLI tools and code"""
import json
from enum import Enum
import re
import subprocess
import sys
from dataclasses import (
asdict,
dataclass,
)
from enum import Enum
from functools import partial
from inspect import cleandoc
from typing import (
Expand Down Expand Up @@ -36,7 +36,7 @@ class Issue:


def _issues(input) -> Generator[Issue, None, None]:
lines = (l for l in input if l.strip() != '')
lines = (l for l in input if l.strip() != "")
for line in lines:
obj = json.loads(line)
yield Issue(**obj)
Expand Down Expand Up @@ -169,13 +169,13 @@ def create_security_issue(issue: Issue) -> Tuple[str, str]:


class Format(str, Enum):
Maven = 'maven'
Maven = "maven"


# pylint: disable=redefined-builtin
@CVE_CLI.command(name="convert")
def convert(
format: Format = typer.Argument(..., help="input format to be converted."),
format: Format = typer.Argument(..., help="input format to be converted."),
) -> None:
def _maven():
issues = from_maven(sys.stdin.read())
Expand All @@ -189,14 +189,14 @@ def _maven():


class Filter(str, Enum):
Github = 'github'
PassThrough = 'pass-through'
Github = "github"
PassThrough = "pass-through"


# pylint: disable=redefined-builtin
@CVE_CLI.command(name="filter")
def filter(
type: Filter = typer.Argument(help="filter type to apply"),
type: Filter = typer.Argument(help="filter type to apply"),
) -> None:
"""
Filter specific CVE's from the input
Expand All @@ -217,16 +217,14 @@ def _github():
]
for issue in _issues_as_json_str(filtered_issues):
stdout(issue)

raise typer.Exit(code=0)

def _pass_through():
for line in sys.stdin:
stdout(line)

raise typer.Exit(code=0)

actions = {Filter.Github: _github, Filter.PassThrough: _pass_through()}
actions = {Filter.Github: _github, Filter.PassThrough: _pass_through}
action = actions[type]
action()

Expand Down
4 changes: 2 additions & 2 deletions exasol/toolbox/tools/tbx.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
)

CLI = typer.Typer()
CLI.add_typer(workflow.CLI, name="workflow", help='Manage github workflows')
CLI.add_typer(security.CLI, name="security", help='Security related helpers')
CLI.add_typer(workflow.CLI, name="workflow", help="Manage github workflows")
CLI.add_typer(security.CLI, name="security", help="Security related helpers")


if __name__ == "__main__":
Expand Down

0 comments on commit 6ba2dac

Please sign in to comment.