MCPcopy
hub / github.com/freedomofpress/dangerzone / check_suspicious_options

Function check_suspicious_options

dangerzone/args.py:71–89  ·  view source on GitHub ↗
(args: list[str])

Source from the content-addressed store, hash-verified

69
70
71def check_suspicious_options(args: list[str]) -> None:
72 options = {arg for arg in args if arg.startswith("-")}
73 try:
74 files = set(os.listdir())
75 except OSError:
76 # If we can list files in the current working directory, this means that
77 # we're probably in an unlinked directory. Dangerzone should still work in
78 # this case, so we should return here.
79 return
80
81 intersection = options & files
82 if intersection:
83 filenames_str = ", ".join(intersection)
84 msg = (
85 f"Security: Detected CLI options that are also present as files in the"
86 f" current working directory: {filenames_str}"
87 )
88 click.echo(msg)
89 sys.exit(1)
90
91
92def override_parser_and_check_suspicious_options(click_main: click.Command) -> None:

Callers 1

custom_parse_fnFunction · 0.85

Calls 1

exitMethod · 0.80

Tested by

no test coverage detected