Skip to content

Add input linter when asking for password#54

Open
clavedeluna wants to merge 3 commits into
dlint-py:masterfrom
clavedeluna:add-password-linter
Open

Add input linter when asking for password#54
clavedeluna wants to merge 3 commits into
dlint-py:masterfrom
clavedeluna:add-password-linter

Conversation

@clavedeluna

Copy link
Copy Markdown
Contributor

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 as input("Please enter your name. Please do not enter your password")

First pass attempt, would love feedback.

@mschwager mschwager left a comment

Copy link
Copy Markdown
Contributor

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?

Comment thread dlint/linters/input_password_ask.py Outdated
Comment thread docs/README.md Outdated
Comment thread dlint/linters/input_password_ask.py Outdated

def _get_arg_or_kwarg(self, node):
if node.args:
return node.args[0].value

Copy link
Copy Markdown
Contributor

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 :)

@clavedeluna
clavedeluna force-pushed the add-password-linter branch from 418d575 to bf602c3 Compare June 16, 2026 11:51
@clavedeluna
clavedeluna requested a review from mschwager June 16, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add linter to detect input asking for password

2 participants