Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions detect_secrets/plugins/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from abc import ABCMeta
from abc import abstractmethod

from detect_secrets.plugins.core.constants import WHITELIST_REGEX


class BasePlugin(object):
"""This is an abstract class to define Plugins API"""
Expand All @@ -23,6 +25,8 @@ def analyze(self, file, filename):
"""
potential_secrets = {}
for line_num, line in enumerate(file.readlines(), start=1):
if WHITELIST_REGEX.search(line):
continue
secrets = self.analyze_string(line, line_num, filename)
potential_secrets.update(secrets)

Expand Down
4 changes: 0 additions & 4 deletions detect_secrets/plugins/keyword.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

from .base import BasePlugin
from detect_secrets.core.potential_secret import PotentialSecret
from detect_secrets.plugins.core.constants import WHITELIST_REGEX


BLACKLIST = (
Expand All @@ -54,9 +53,6 @@ class KeywordDetector(BasePlugin):
def analyze_string(self, string, line_num, filename):
output = {}

if WHITELIST_REGEX.search(string):
return output

for identifier in self.secret_generator(string):
secret = PotentialSecret(
self.secret_type,
Expand Down
2 changes: 2 additions & 0 deletions test_data/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ keyB = 456789123
567891234

keyC =

password = 12345678901234 # pragma: whitelist secret