Merge pull request #4309 from jrblixt/InformUnderscoreFormat-Issue_4054

Inform user when underscore-formatted options are used.
This commit is contained in:
Maximilian Hils 2020-11-26 18:39:45 +01:00 committed by GitHub
commit b01d574d8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -9,6 +9,7 @@ Unreleased: mitmproxy next
* Deprecation of pathod and pathoc tools and modules. Future releases might not contain them! (@Kriechi)
* Addon to suppress unwanted error messages sent by mitmproxy. (@anneborcherding)
* Updated imports and styles for web scanner helper addons. (@anneborcherding)
* Inform when underscore-formatted options are used in client arg. (@jrblixt)
* --- TODO: add new PRs above this line ---

View File

@ -1,4 +1,5 @@
import sys
import re
DEPRECATED = """
--confdir
@ -153,3 +154,12 @@ def check():
REPLACEMENTS.get(option, None) or option.lstrip("-").replace("-", "_")
)
)
# Check for underscores in the options. Options always follow '--'.
for argument in args:
underscoreParam = re.search('[-]{2}((.*?_)(.*?(\s|$)))+', argument)
if underscoreParam is not None:
print("{} uses underscores, please use hyphens {}".format(
argument,
argument.replace('_', '-'))
)

View File

@ -26,7 +26,8 @@ from mitmproxy.utils import arg_check
'"ldap[s]:url_server_ldap:dn_auth:password:dn_subtree" '
'for LDAP authentication.'),
(["--replacements"], "--replacements is deprecated.\n"
"Please use `--modify-body` or `--modify-headers` instead.")
"Please use `--modify-body` or `--modify-headers` instead."),
(["--underscore_option"], "--underscore_option uses underscores, please use hyphens --underscore-option")
])
def test_check_args(arg, output):
f = io.StringIO()