-
Notifications
You must be signed in to change notification settings - Fork 15
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 input linter when asking for password #54
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Can you also add a line under an Added
section in Unreleased
in the CHANGELOG?
off_by_default = False | ||
|
||
_code = 'DUO139' | ||
_error_tmpl = 'DUO139 avoid using "input" to ask for password' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I try to include the remediation in the message if it's short enough. How does this sound?
DUO139 avoid using "input" to ask for password, prefer "getpass.getpass"
@@ -42,6 +42,7 @@ Dlint uses a simple, folder-based hierarchy written in [Markdown](https://en.wik | |||
- [`DUO136` `BadXmlsecModuleAttributeUseLinter` insecure "xmlsec" attribute use](https://github.com/dlint-py/dlint/blob/master/docs/linters/DUO136.md) | |||
- [`DUO137` `BadItsDangerousKwargUseLinter` insecure "itsdangerous" use allowing empty signing](https://github.com/dlint-py/dlint/blob/master/docs/linters/DUO137.md) | |||
- [`DUO138` `BadReCatastrophicUseLinter` catastrophic "re" usage - denial-of-service possible](https://github.com/dlint-py/dlint/blob/master/docs/linters/DUO138.md) | |||
- todo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this needs a bump 👍
|
||
def _get_arg_or_kwarg(self, node): | ||
if node.args: | ||
return node.args[0].value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also check that node.args
and node.keywords
are not empty before checking [0]
. This would produce a runtime error in the code because input
takes 1 argument, but you never know what code you'll find in the wild. In other words, static analysis will often see code that hasn't been executed, or has all kinds of weird bugs, so it's best to be defensive :)
Closes #16
The goal is to detect when a user uses the built-in
input
function with an arg or kwarg of string containing "password". Unit tests demonstrate when this may be a false positive, such asinput("Please enter your name. Please do not enter your password")
First pass attempt, would love feedback.