Skip to content

Commit

Permalink
Verify target before dumping.
Browse files Browse the repository at this point in the history
  • Loading branch information
xkww3n committed Dec 6, 2023
1 parent fbfd5bb commit ca5e7c3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Utils/ruleset.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ def load(src: Path) -> RuleSet:


def dump(src: RuleSet, target: str, dst: Path, filename: str) -> None:
if target not in const.TARGETS:
raise TypeError("Invalid target.")
match target:
case "yaml":
filename = filename + ".yaml"
Expand Down Expand Up @@ -206,8 +208,6 @@ def dump(src: RuleSet, target: str, dst: Path, filename: str) -> None:
ruleset["rules"][0]["ip_cidr"] = []
ruleset["rules"][0]["ip_cidr"].append(rule.Payload)
dist.write(dumps(ruleset, indent=2))
else:
raise TypeError("Target type unsupported.")


def batch_dump(src: RuleSet, targets: list, dst_path: Path, filename: str) -> None:
Expand Down

0 comments on commit ca5e7c3

Please sign in to comment.