Skip to content
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

Fixes for audit #83

Merged
merged 5 commits into from
Oct 10, 2018
Merged

Fixes for audit #83

merged 5 commits into from
Oct 10, 2018

Conversation

jkozera
Copy link
Contributor

@jkozera jkozera commented Oct 8, 2018

This PR fixes two issues I've noticed in the audit mode:

  1. keyword plugin failing with SecretNotFoundOnSpecifiedLineError if the secret is different in terms of lowercase vs uppercase. (before this change the keyword plugin is case-insensitive at
    for identifier in self.secret_generator(string.lower()):
    but case-sensitive at
    for line in BLACKLIST:
    — and the latter is used by the audit mode at
    for raw_secret in _raw_secret_generator(plugin, secret_line):
    )
  2. _get_secret_with_context failing for small files if they don't have \n at the end of the file.

Jerzy Kozera added 3 commits October 8, 2018 17:52
@KevinHock
Copy link
Collaborator

This looks great to me! Thank you so much for making this, squeaky clean commits too. :)

@@ -55,7 +55,7 @@ def analyze_string(self, string, line_num, filename):
if WHITELIST_REGEX.search(string):
return output

for identifier in self.secret_generator(string.lower()):
for identifier in self.secret_generator(string):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably more performant to make the string lowered once here, and passed into secret_generator, than to make it .lower() every time.

@@ -68,5 +68,5 @@ def analyze_string(self, string, line_num, filename):

def secret_generator(self, string):
for line in BLACKLIST:
if line in string:
if line.lower() in string.lower():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just change PASS = in BLACKLIST to lowercase?

As per @domanchi comments for the PR Yelp#83, doing `lower()` once
is enough, and should also be faster.
@jkozera
Copy link
Contributor Author

jkozera commented Oct 8, 2018

@domanchi Good points :) I will update the PR shortly.

@KevinHock KevinHock merged commit 680f00a into Yelp:master Oct 10, 2018
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.

None yet

3 participants