Skip to content

Commit da17012

Browse files
author
Aaron Loo
committed
Merge branch 'pre-v1-list-all-plugins' into pre-v1-launch
2 parents 15a3ef5 + fc9a030 commit da17012

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

detect_secrets/core/usage/plugins.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ def add_plugin_options(parent: argparse.ArgumentParser) -> None:
1818
),
1919
)
2020

21+
parser.add_argument(
22+
'--list-all-plugins',
23+
action='store_true',
24+
help='Lists all plugins that will be used for the scan.',
25+
)
26+
2127
_add_custom_plugins(parser)
2228
_add_custom_limits(parser)
2329
_add_disable_flag(parser)
24-
# TODO: custom plugins?
2530

2631

2732
def _add_custom_plugins(parser: argparse._ArgumentGroup) -> None:

detect_secrets/main.py

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from .core.secrets_collection import SecretsCollection
1616
from .core.usage import ParserBuilder
1717
from .exceptions import InvalidBaselineError
18+
from .settings import get_settings
1819

1920

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

3940

4041
def handle_scan_action(args: argparse.Namespace) -> None:
42+
if args.list_all_plugins:
43+
# NOTE: If there was a baseline provided, it would already have been parsed and
44+
# settings populated by the time it reaches here.
45+
print('\n'.join(get_settings().plugins))
46+
return
47+
4148
if args.string:
4249
line = args.string
4350
if isinstance(args.string, bool):

tests/main_test.py

+7
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ def test_only_displays_result_if_actual_secret():
163163
assert not output['results']
164164

165165

166+
def test_list_all_plugins():
167+
with mock_printer(main_module) as printer:
168+
assert main_module.main(['scan', '--list-all-plugins']) == 0
169+
170+
assert printer.message
171+
172+
166173
@contextmanager
167174
def mock_stdin(response=None):
168175
if not response:

0 commit comments

Comments
 (0)