Skip to content

Commit 538facf

Browse files
committed
fix: make "Secret in Secrets Manager" more consistent
In ggshield text output, the value for the "Known by GitGuardian dashboard" is "YES" or "NO", but the value for the new "Secret in Secrets Manager" is "true" or "false". This commit makes "Secret in Secrets Manager" use "YES" or "NO" too.
1 parent 9a6a393 commit 538facf

File tree

6 files changed

+97
-133
lines changed

6 files changed

+97
-133
lines changed

ggshield/core/text_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ def format_line_count(line_count: Union[int, None], padding: int) -> str:
5454
return " " * max(0, padding - len(str(line_count))) + str(line_count)
5555

5656

57+
def format_bool(value: bool) -> str:
58+
return "YES" if value else "NO"
59+
60+
5761
_VALIDITY_TEXT_FOR_ID = {
5862
"unknown": "Unknown",
5963
# cannot_check is the old ID for secrets for which there are no checkers

ggshield/verticals/secret/output/secret_sarif_output_handler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from ggshield import __version__ as ggshield_version
88
from ggshield.core.match_span import MatchSpan
9+
from ggshield.core.text_utils import format_bool
910

1011
from ..extended_match import ExtendedMatch
1112
from ..secret_scan_collection import Result, Secret, SecretScanCollection
@@ -83,7 +84,7 @@ def _create_sarif_result_dict(
8384
markdown_message = f"Secret detected: [{secret.detector_display_name}]({secret.documentation_url})"
8485
else:
8586
markdown_message = f"Secret detected: {secret.detector_display_name}"
86-
markdown_message += f"\nSecret in Secrets Manager: {secret.is_vaulted}"
87+
markdown_message += f"\nSecret in Secrets Manager: {format_bool(secret.is_vaulted)}"
8788
markdown_message += f"\nMatches:\n{matches_li}"
8889

8990
# Create dict

ggshield/verticals/secret/output/secret_text_output_handler.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from ggshield.core.text_utils import (
1010
STYLE,
1111
clip_long_line,
12+
format_bool,
1213
format_text,
1314
pluralize,
1415
translate_validity,
@@ -304,10 +305,10 @@ def secret_header(
304305
message = f"""
305306
{start_line} Secret detected: {secret_type}{validity_msg}
306307
{indent}Occurrences: {number_occurrences}
307-
{indent}Known by GitGuardian dashboard: {"YES" if known_secret else "NO"}
308+
{indent}Known by GitGuardian dashboard: {format_bool(known_secret)}
308309
{indent}Incident URL: {secret.incident_url if known_secret and secret.incident_url else "N/A"}
309310
{indent}Secret SHA: {ignore_sha}
310-
{indent}Secret in Secrets Manager: {secret.is_vaulted}
311+
{indent}Secret in Secrets Manager: {format_bool(secret.is_vaulted)}
311312
"""
312313
if secret.documentation_url is not None:
313314
message += f"{indent}Detector documentation: {secret.documentation_url}\n"

0 commit comments

Comments
 (0)