Skip to content

Commit

Permalink
Merge pull request #27 from DenizenB/main
Browse files Browse the repository at this point in the history
Move progress bar to stderr
  • Loading branch information
thomaspatzke committed Jun 19, 2023
2 parents 5bca5b1 + 57506b9 commit 1ca0fea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions sigma/cli/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import click
from collections import Counter
from prettytable import PrettyTable
from sys import stderr

from sigma.exceptions import SigmaConditionError, SigmaError
from sigma.cli.rules import load_rules
Expand Down Expand Up @@ -78,7 +79,7 @@ def check(input, validation_config, file_pattern, fail_on_error, fail_on_issues)
rule_error_count = sum(rule_errors.values())
#rule_error_count = rule_errors.total()

with click.progressbar(check_rules, label="Checking Sigma rules") as rules:
with click.progressbar(check_rules, label="Checking Sigma rules", file=stderr) as rules:
issues = rule_validator.validate_rules(rules)

issue_count = len(issues)
Expand Down Expand Up @@ -141,4 +142,4 @@ def check(input, validation_config, file_pattern, fail_on_error, fail_on_issues)
if fail_on_error and rule_error_count > 0 or fail_on_issues and issue_count > 0:
click.get_current_context().exit(1)
except SigmaError as e:
click.echo("Check error: " + str(e), err=True)
click.echo("Check error: " + str(e), err=True)
5 changes: 3 additions & 2 deletions sigma/cli/rules.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pathlib import Path
from sys import stderr
import click
from sigma.collection import SigmaCollection

Expand All @@ -10,9 +11,9 @@ def load_rules(input, file_pattern):
input,
recursion_pattern="**/" + file_pattern,
)
with click.progressbar(list(rule_paths), label="Parsing Sigma rules") as progress_rule_paths:
with click.progressbar(list(rule_paths), label="Parsing Sigma rules", file=stderr) as progress_rule_paths:
rule_collection = SigmaCollection.load_ruleset(
progress_rule_paths,
collect_errors=True,
)
return rule_collection
return rule_collection

0 comments on commit 1ca0fea

Please sign in to comment.