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

Add support for SARIF output for secret scanning #920

Merged
merged 6 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 2 additions & 0 deletions ggshield/cmd/secret/scan/secret_scan_common_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
create_config_callback,
create_ctx_callback,
exit_zero_option,
format_option,
get_config_from_context,
json_option,
)
Expand Down Expand Up @@ -122,6 +123,7 @@ def add_secret_scan_common_options() -> Callable[[AnyFunction], AnyFunction]:
def decorator(cmd: AnyFunction) -> AnyFunction:
add_common_options()(cmd)
json_option(cmd)
format_option(cmd)
_output_option(cmd)
_show_secrets_option(cmd)
exit_zero_option(cmd)
Expand Down
17 changes: 17 additions & 0 deletions ggshield/cmd/utils/common_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,23 @@ def _set_json_output_format(
)


def _set_output_format(
fnareoh marked this conversation as resolved.
Show resolved Hide resolved
ctx: click.Context, param: click.Parameter, value: Optional[str]
) -> Optional[str]:
if value:
ctx_obj = ContextObj.get(ctx)
ctx_obj.output_format = OutputFormat(value)
return value


format_option = click.option(
"--format",
type=click.Choice([x.value for x in OutputFormat]),
help="Output format.",
callback=_set_output_format,
)
fnareoh marked this conversation as resolved.
Show resolved Hide resolved


directory_argument = click.argument(
"directory",
type=click.Path(exists=True, readable=True, path_type=Path, file_okay=False),
Expand Down