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

Add Occurences to Potential Secrets #527

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

jpdakran
Copy link
Member

@jpdakran jpdakran commented Apr 1, 2022

A potential secret is uniquely identified by three main properties: filename, secret_hash, type. Since line_number is not included this means we will only track a single potential secret in a file although it may appear on multiple lines. This is a fundamental design decision.

The idea behind this pull request is to give users some insight to how many occurences a potential secret is showing up in their files. This does not violate the fundamental design above but rather serves as an improvement hopefully giving better insight to developers on the overall scope of their potential secrets.

One of the key changes is changing the SecretsCollection data structure from a Set to a List. The reasoning behind this decision is when we are scanning through the file - we do not only want to deny duplicate secrets to the data structure but alter the existing potential secrets occurrences. List gives us a lot of flexibility with changing properties in the data structure while Set is a little restricted. The new List will operate almost identically to the previous Set in terms of not allowing duplicate secrets but with the addition of tracking occurrences.

The occurrences property will operate very similar to the line_number property. They are similar in the way that we will not alert on the change of this property but rather only notify the user that the baseline file changed with updated information on their secrets.

@@ -180,7 +187,11 @@ def trim(
# Only update line numbers if we're tracking them.
existing_secret.line_number = secret.line_number
Copy link
Member

Choose a reason for hiding this comment

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

Looking at your implementation, it looks like it could be fairly trivial to track the line number of each of the occurrences found and report them as it was mentioned in #493.

@KBiru
Copy link

KBiru commented Sep 7, 2022

Hi, @lorenzodb1 Is this feature already added, or it is still in pending review state? I mean is this feature coming in the next release? It seems to me that it would be a good one to add.

@reddybhaskarvengala
Copy link

Hi,

Any update on this feature? it seems open for very long time.

Thanks,
Bhaskar.

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.

4 participants