find_known_secrets/searcher.py
def search_known_secrets(self):  # type: () -> None
        """
        Search a path for known secrets, outputing text and file when found
        :return:
        """
        count = 0
        here = os.path.abspath(self.source)
        # python 3 only!
        # for file in glob.glob(here + "/" + "**/*.*", recursive=True):

        # py 2
        matches = []
        for root, dirnames, filenames in os.walk(here + "/"):
            for filename in filenames:
                matches.append(os.path.join(root, filename))

        for file in matches:
            if os.path.isdir(file):
                continue
            with open(file) as f:
                try:
                    contents = f.read()
                except UnicodeDecodeError:
                    continue
                except Exception as e:
                    print(e)
                    print(file)
                    raise
            for secret in self.secrets:
                if secret in contents:
                    for line in contents.split("\n"):
                        if secret in line:
                            self.found.setdefault(file, []).append(
                                (
                                    secret,
                                    line.replace(
                                        secret,
                                        Fore.RED
                                        + Back.YELLOW
                                        + secret
                                        + Style.RESET_ALL,
                                    ),
                                )
                            )
                            count += 1
def search_known_secrets(self):  # type: () -> None
        """
        Search a path for known secrets, outputing text and file when found
        :return:
        """
        count = 0
        here = os.path.abspath(self.source)
        # python 3 only!
        # for file in glob.glob(here + "/" + "**/*.*", recursive=True):

        # py 2
        matches = []
        for root, dirnames, filenames in os.walk(here + "/"):
            for filename in filenames:
                matches.append(os.path.join(root, filename))

        for file in matches:
            if os.path.isdir(file):
                continue
            with open(file) as f:
                try:
                    contents = f.read()
                except UnicodeDecodeError:
                    continue
                except Exception as e:
                    print(e)
                    print(file)
                    raise
            for secret in self.secrets:
                if secret in contents:
                    for line in contents.split("\n"):
                        if secret in line:
                            self.found.setdefault(file, []).append(
                                (
                                    secret,
                                    line.replace(
                                        secret,
                                        Fore.RED
                                        + Back.YELLOW
                                        + secret
                                        + Style.RESET_ALL,
                                    ),
                                )
                            )
                            count += 1
Search a path for known secrets, outputing text and file when found
        :return: