def setup(self):
     self.logic = secrets_collection_factory(
         secrets=[
             {
                 'type_': 'A',
                 'lineno': 3,
                 'filename': 'fileA',
             },
             {
                 'type_': 'B',
                 'lineno': 2,
                 'filename': 'fileA',
             },
             {
                 'type_': 'C',
                 'lineno': 1,
                 'filename': 'fileB',
             },
         ],
         plugins=(
             HexHighEntropyString(3),
             PrivateKeyDetector(),
         ),
         exclude_files_regex='foo',
         word_list_file='will_be_mocked.txt',
         word_list_hash='5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8',
     )
 def setup(self):
     self.logic = secrets_collection_factory(
         secrets=[
             {
                 'type_': 'A',
                 'lineno': 3,
                 'filename': 'fileA',
             },
             {
                 'type_': 'B',
                 'lineno': 2,
                 'filename': 'fileA',
             },
             {
                 'type_': 'C',
                 'lineno': 1,
                 'filename': 'fileB',
             },
         ],
         plugins=(
             HexHighEntropyString(3),
             PrivateKeyDetector(),
         ),
         exclude_files_regex='foo',
     )
Example #3
0
    def test_analyze(self, file_content):
        logic = PrivateKeyDetector()

        f = create_file_object_from_string(file_content)
        output = logic.analyze(f, 'mock_filename')
        assert len(output) == 1
        for potential_secret in output:
            assert 'mock_filename' == potential_secret.filename
    def test_analyze(self):
        logic = PrivateKeyDetector()

        file_content = ('-----BEGIN RSA PRIVATE KEY-----'
                        'super secret private key here'
                        '-----END RSA PRIVATE KEY-----')

        f = create_file_object_from_string(file_content)
        assert 'mock_filename' in logic.analyze(f, 'mock_filename')
    def test_analyze(self):
        logic = PrivateKeyDetector()

        file_content = ('-----BEGIN RSA PRIVATE KEY-----'
                        'super secret private key here'
                        '-----END RSA PRIVATE KEY-----')

        f = create_file_object_from_string(file_content)
        output = logic.analyze(f, 'mock_filename')
        assert len(output) == 1
        for potential_secret in output:
            assert 'mock_filename' == potential_secret.filename
Example #6
0
 def test_does_not_affect_private_keys():
     assert not filters.gibberish.should_exclude_secret(
         'BEGIN PRIVATE KEY',
         plugin=PrivateKeyDetector(),
     )