Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove sneaky unicode characters that break a regex and console outputs on Windows #6987

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion checkov/common/output/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def print_console(

if not is_quiet:
for file in self.parsing_errors:
output_data += colored(f"Error parsing file {file}ֿ\n", "red")
output_data += colored(f"Error parsing file {file}\n", "red")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line causes problems with outputs, notice a symbol before \n


if created_baseline_path:
output_data += colored(
Expand Down
2 changes: 1 addition & 1 deletion checkov/common/runners/runner_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def print_reports(
)

# Remove colors from the cli output
ansi_escape = re.compile(r'(?:\x1B[@-_]|[\x80-\x9F])[09:;<=>?]*[ -/]*[@-~]')
ansi_escape = re.compile(r'(?:\x1B[@-_]|[\x80-\x9F])[0-9:;<=>?]*[ -/]*[@-~]')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line makes a wrong regex, notice a wrong dash

data_outputs['cli'] = ansi_escape.sub('', cli_output)
if "sarif" in config.output:
sarif = Sarif(reports=sarif_reports, tool=self.tool)
Expand Down
2 changes: 1 addition & 1 deletion checkov/kubernetes/checks/resource/k8s/HostPort.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def __init__(self) -> None:
"""
https://kubernetes.io/docs/concepts/configuration/overview/

Dont specify a hostPort for a Pod unless it is absolutely necessary.
Don't specify a hostPort for a Pod unless it is absolutely necessary.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was changed by the script I made to go over this repo to find bad unicode characters.
I left it in the PR just because unicode seems unnecessary here. There's no bug in this line.

When you bind a Pod to a hostPort, it limits the number of places the
Pod can be scheduled, because each <hostIP, hostPort, protocol> combination
must be unique.
Expand Down
2 changes: 1 addition & 1 deletion checkov/serverless/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def get_scannable_file_paths(root_folder: str | None = None, excluded_paths: lis
return files_list

for root, d_names, f_names in os.walk(root_folder):
# Don't walk in to "node_modules" directories under the root folder. If for some reason
# Don't walk in to "node_modules" directories under the root folder. If for some reason
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was changed by the script I made to go over this repo to find bad unicode characters.
I left it in the PR just because unicode seems unnecessary here. There's no bug in this line.

# scanning one of these is desired, it can be directly specified.
if "node_modules" in d_names:
d_names.remove("node_modules")
Expand Down
2 changes: 1 addition & 1 deletion checkov/terraform/checks/resource/kubernetes/HostPort.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def __init__(self):
"""
https://kubernetes.io/docs/concepts/configuration/overview/

Dont specify a hostPort for a Pod unless it is absolutely necessary.
Don't specify a hostPort for a Pod unless it is absolutely necessary.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was changed by the script I made to go over this repo to find bad unicode characters.
I left it in the PR just because unicode seems unnecessary here. There's no bug in this line.

When you bind a Pod to a hostPort, it limits the number of places the
Pod can be scheduled, because each <hostIP, hostPort, protocol> combination
must be unique.
Expand Down