Skip to content

Commit

Permalink
Merge pull request #79 from ait-testbed/fix_var_int
Browse files Browse the repository at this point in the history
Automatically Convert int-variables to type str
  • Loading branch information
whotwagner authored Jun 14, 2024
2 parents eb9ad00 + 126e3e9 commit bc3e725
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/attackmate/schemas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def check_var_pattern(value: str, info: ValidationInfo) -> str:
BeforeValidator(transform_int_to_str),
AfterValidator(check_var_pattern)]

# Like StringNumber but without checks for valid $variable
StrInt = Annotated[Optional[str | int], BeforeValidator(transform_int_to_str)]

class BaseCommand(BaseModel):
def list_template_vars(self) -> List[str]:
Expand Down
3 changes: 2 additions & 1 deletion src/attackmate/schemas/playbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from .tempfile import TempfileCommand
from .debug import DebugCommand
from .regex import RegExCommand
from .base import StrInt


Commands = List[Union[
Expand Down Expand Up @@ -62,5 +63,5 @@


class Playbook(BaseModel):
vars: Optional[Dict[str, str]] = None
vars: Optional[Dict[str, StrInt]] = None
commands: Commands

0 comments on commit bc3e725

Please sign in to comment.