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

Use python instead of sed/wc during audit #120

Merged
merged 2 commits into from
Feb 1, 2019

Conversation

killuazhu
Copy link
Contributor

Update audit code to read files using python instead of sed/wc to align the end of line character handling.

If the audit is performed on a file with non-posix end of line characters then it would incorrectly extract the line range from the file and miscalculate the index of the line the secret is on. This would result in an error during the audit "Secret not found on line....".

The root cause of this issue was due to audit using "sed" and "wc" to extract line ranges from the file and count total lines. When these tools encountered the non-posix end of line characters they would calculate different lines then via python which uses a universal or cross-platform end of line characters.

To ensure that it would calculate the same lines as the scan the audit code has been updated to use python to read the original file and extract the specified lines.

CC @jribm

@killuazhu
Copy link
Contributor Author

@KevinHock Travis build has passed now. Ready for a look.

@KevinHock KevinHock self-requested a review January 31, 2019 20:34
Copy link
Collaborator

@KevinHock KevinHock left a comment

Choose a reason for hiding this comment

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

Looks great to me 🚢 , thanks so much for making this @killuazhu! :D

I'll make a new release with this change tomorrow, if that's okay 👍

@killuazhu
Copy link
Contributor Author

@KevinHock thanks for accepting the PR. I'm glad it could be accepted so quick! 👍

Jeffrey T. Robke and others added 2 commits January 31, 2019 20:54
* Update audit code to read files using python instead of sed/wc to align end of line character handling.

    If audit is performed on a file with non-posix end of line characters then it would incorrectly extract
    the line range from the file and miscalculate the index of the line the secret is on.  This would result
    in an error during the audit "Secret not found on line....".

    The root cause of this issue was due to audit using "sed" and "wc" to extract line ranges from the file and
    count total lines.  When these tools encountered non-posix end of line characters they would calcaulate
    different lines then via python which uses universal or cross platform end of line characters.

    To ensure that it would calculate the same lines as the scan the audit code has been updated to use
    python to read the original file and extract the specified lines.
@KevinHock KevinHock merged commit 6330c44 into Yelp:master Feb 1, 2019
@killuazhu killuazhu deleted the contribute-no-sed-wc branch April 11, 2019 19:44
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

2 participants