Skip to content

Commit

Permalink
Merge branch 'pre-v1-list-all-plugins' into pre-v1-launch
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Loo committed Dec 2, 2020
2 parents 15a3ef5 + fc9a030 commit da17012
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
7 changes: 6 additions & 1 deletion detect_secrets/core/usage/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ def add_plugin_options(parent: argparse.ArgumentParser) -> None:
),
)

parser.add_argument(
'--list-all-plugins',
action='store_true',
help='Lists all plugins that will be used for the scan.',
)

_add_custom_plugins(parser)
_add_custom_limits(parser)
_add_disable_flag(parser)
# TODO: custom plugins?


def _add_custom_plugins(parser: argparse._ArgumentGroup) -> None:
Expand Down
7 changes: 7 additions & 0 deletions detect_secrets/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from .core.secrets_collection import SecretsCollection
from .core.usage import ParserBuilder
from .exceptions import InvalidBaselineError
from .settings import get_settings


def main(argv: Optional[List[str]] = None) -> int:
Expand All @@ -38,6 +39,12 @@ def parse_args(argv: Optional[List[str]] = None) -> argparse.Namespace:


def handle_scan_action(args: argparse.Namespace) -> None:
if args.list_all_plugins:
# NOTE: If there was a baseline provided, it would already have been parsed and
# settings populated by the time it reaches here.
print('\n'.join(get_settings().plugins))
return

if args.string:
line = args.string
if isinstance(args.string, bool):
Expand Down
7 changes: 7 additions & 0 deletions tests/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ def test_only_displays_result_if_actual_secret():
assert not output['results']


def test_list_all_plugins():
with mock_printer(main_module) as printer:
assert main_module.main(['scan', '--list-all-plugins']) == 0

assert printer.message


@contextmanager
def mock_stdin(response=None):
if not response:
Expand Down

0 comments on commit da17012

Please sign in to comment.