Skip to content

fix: make "Secret in Secrets Manager" more consistent #1102

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

Open
wants to merge 1 commit 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
4 changes: 4 additions & 0 deletions ggshield/core/text_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def format_line_count(line_count: Union[int, None], padding: int) -> str:
return " " * max(0, padding - len(str(line_count))) + str(line_count)


def format_bool(value: bool) -> str:
return "YES" if value else "NO"


_VALIDITY_TEXT_FOR_ID = {
"unknown": "Unknown",
# cannot_check is the old ID for secrets for which there are no checkers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from ggshield import __version__ as ggshield_version
from ggshield.core.match_span import MatchSpan
from ggshield.core.text_utils import format_bool

from ..extended_match import ExtendedMatch
from ..secret_scan_collection import Result, Secret, SecretScanCollection
Expand Down Expand Up @@ -83,7 +84,7 @@ def _create_sarif_result_dict(
markdown_message = f"Secret detected: [{secret.detector_display_name}]({secret.documentation_url})"
else:
markdown_message = f"Secret detected: {secret.detector_display_name}"
markdown_message += f"\nSecret in Secrets Manager: {secret.is_vaulted}"
markdown_message += f"\nSecret in Secrets Manager: {format_bool(secret.is_vaulted)}"
markdown_message += f"\nMatches:\n{matches_li}"

# Create dict
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from ggshield.core.text_utils import (
STYLE,
clip_long_line,
format_bool,
format_text,
pluralize,
translate_validity,
Expand Down Expand Up @@ -304,10 +305,10 @@ def secret_header(
message = f"""
{start_line} Secret detected: {secret_type}{validity_msg}
{indent}Occurrences: {number_occurrences}
{indent}Known by GitGuardian dashboard: {"YES" if known_secret else "NO"}
{indent}Known by GitGuardian dashboard: {format_bool(known_secret)}
{indent}Incident URL: {secret.incident_url if known_secret and secret.incident_url else "N/A"}
{indent}Secret SHA: {ignore_sha}
{indent}Secret in Secrets Manager: {secret.is_vaulted}
{indent}Secret in Secrets Manager: {format_bool(secret.is_vaulted)}
"""
if secret.documentation_url is not None:
message += f"{indent}Detector documentation: {secret.documentation_url}\n"
Expand Down
Loading
Loading