Skip to content

Commit

Permalink
crypto material plugin: added test for summary and tags
Browse files Browse the repository at this point in the history
  • Loading branch information
jstucke committed Aug 21, 2024
1 parent 7875b85 commit 48caaab
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from __future__ import annotations

from pathlib import Path
from typing import TYPE_CHECKING

import pytest

from ..code.crypto_material import AnalysisPlugin

if TYPE_CHECKING:
from analysis.plugin import AnalysisPluginV0

TEST_DATA_DIR = Path(__file__).parent / 'data'


Expand Down Expand Up @@ -67,3 +71,14 @@ def test_false_positive_ssl_cert(self, analysis_plugin):

def test_false_positive_pkcs_cert(self, analysis_plugin):
_rule_match(analysis_plugin, 'pkcs_fp.file', 0)

def test_summary_and_tags(self, analysis_plugin: AnalysisPluginV0):
test_file = TEST_DATA_DIR / 'id_rsa'
assert test_file.is_file(), 'test file is missing'
with test_file.open('rb') as fp:
result = analysis_plugin.analyze(fp, None, None)
summary = analysis_plugin.summarize(result)
tags = analysis_plugin.get_tags(result, summary)
assert summary == ['SshRsaPrivateKeyBlock']
assert len(tags) == 1
assert tags[0].name == 'private_key_inside'

0 comments on commit 48caaab

Please sign in to comment.