Skip to content

Python: Exclude dotted module paths from hardcoded credentials#16

Open
mrigankpawagi wants to merge 1 commit into
mainfrom
improve-py-hardcoded-creds-module-paths
Open

Python: Exclude dotted module paths from hardcoded credentials#16
mrigankpawagi wants to merge 1 commit into
mainfrom
improve-py-hardcoded-creds-module-paths

Conversation

@mrigankpawagi

Copy link
Copy Markdown
Owner

Fix

Excludes strings matching the pattern of Python dotted module/class paths (e.g., django.contrib.auth.hashers.PBKDF2PasswordHasher) from being considered as potential hardcoded credentials.

Problem

The py/hardcoded-credentials query flags Django settings like PASSWORD_HASHERS which contain dotted Python class paths as values. These are not credentials - they are module references. MRVA confirmed FPs on Django projects with settings like PASSWORD_HASHERS = ["django.contrib.auth.hashers.PBKDF2PasswordHasher"].

Validation

The regex [a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*){2,} matches dotted paths with 3+ components, which are almost never actual credentials.

Strings matching the pattern of Python dotted module/class paths
(e.g., 'django.contrib.auth.hashers.PBKDF2PasswordHasher') are not
credentials. They are class references used in configuration settings
like PASSWORD_HASHERS, AUTHENTICATION_BACKENDS, and MIDDLEWARE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants