Skip to content

Commit

Permalink
Added flag to only output unremediated paths
Browse files Browse the repository at this point in the history
  • Loading branch information
akenion committed Jan 16, 2024
1 parent 5c50bbf commit a5da665
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 8 additions & 0 deletions wordfence/cli/remediate/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
"default_type": "base64"
},
**REMEDIATION_REPORT_CONFIG_OPTIONS,
"output-unremediated": {
"short_name": "u",
"description": "Only include unremediated paths in the output.",
"context": "CLI",
"argument_type": "FLAG",
"default": False,
"category": "Output Control"
},
"require-path": {
"description": "When enabled, invoking the remediate command without "
"specifying at least one path will trigger an error. "
Expand Down
10 changes: 8 additions & 2 deletions wordfence/cli/remediate/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def __init__(
columns: List[ReportColumn],
email_addresses: List[str],
mailer: Optional[Mailer],
write_headers: bool = False
write_headers: bool = False,
only_unremediated: bool = False
):
super().__init__(
format,
Expand All @@ -127,9 +128,12 @@ def __init__(
mailer,
write_headers
)
self.only_unremediated = only_unremediated
self.counts = RemediationCounts()

def add_result(self, result: RemediationResult):
if self.only_unremediated and result.remediated:
return
self.write_record(
RemediationReportRecord(
result
Expand Down Expand Up @@ -182,6 +186,7 @@ def __init__(self, context: CliContext):
read_stdin=context.config.read_stdin,
input_delimiter=context.config.path_separator
)
self.only_unremediated = context.config.output_unremediated

def _instantiate_report(
self,
Expand All @@ -196,7 +201,8 @@ def _instantiate_report(
columns,
email_addresses,
mailer,
write_headers
write_headers,
self.only_unremediated
)


Expand Down

0 comments on commit a5da665

Please sign in to comment.