Skip to content

Commit a36f353

Browse files
committed
Merge branch '80-versions-in-markdown-result-of-tls-client-simulation-are-splitted'
Closes: #80
2 parents b4678a8 + 2ea8b38 commit a36f353

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

cryptoparser/common/base.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ def __call__(self, obj, level):
6161

6262
class Serializable(object): # pylint: disable=too-few-public-methods
6363
_MARKDOWN_RESULT_STRING_CLASSES = (
64-
CryptoDataParamsBase,
6564
ipaddress.IPv4Network,
6665
ipaddress.IPv6Network,
6766
urllib3.util.url.Url,
@@ -143,7 +142,7 @@ def _json_traverse(obj, result_func):
143142
])
144143
elif hasattr(obj, '__dict__'):
145144
result = Serializable._json_traverse(obj.__dict__, result_func)
146-
elif isinstance(obj, (list, tuple)):
145+
elif isinstance(obj, (list, tuple, frozenset, set)):
147146
result = [Serializable._json_traverse(item, result_func) for item in obj]
148147
else:
149148
result = result_func(obj)
@@ -227,7 +226,7 @@ def _markdown_is_directly_printable(obj):
227226
return not isinstance(obj, enum.Enum) and isinstance(obj, six.string_types + six.integer_types + (float, ))
228227

229228
@classmethod
230-
def _markdown_result(cls, obj, level=0): # pylint: disable=too-many-branches
229+
def _markdown_result(cls, obj, level=0): # pylint: disable=too-many-branches,too-many-return-statements
231230
if obj is None:
232231
result = cls.post_text_encoder('n/a', level)
233232
elif isinstance(obj, bool):
@@ -245,17 +244,19 @@ def _markdown_result(cls, obj, level=0): # pylint: disable=too-many-branches
245244
return cls.post_text_encoder(obj.value, level)
246245

247246
return cls.post_text_encoder(obj.name, level)
248-
elif attr.has(type(obj)):
249-
result = cls._markdown_result_complex(obj, level)
250247
elif isinstance(obj, cls._MARKDOWN_RESULT_STRING_CLASSES):
251248
return False, str(obj)
252249
elif isinstance(obj, datetime.timedelta):
253250
return False, str(obj.seconds)
251+
elif isinstance(obj, CryptoDataParamsBase) and hasattr(obj, '__str__'):
252+
return False, str(obj)
253+
elif attr.has(type(obj)):
254+
result = cls._markdown_result_complex(obj, level)
254255
elif hasattr(obj, '_asdict'):
255256
result = cls._markdown_result(obj._asdict(), level)
256257
elif hasattr(obj, '__dict__') or isinstance(obj, dict):
257258
result = cls._markdown_result_complex(obj, level)
258-
elif isinstance(obj, (list, tuple, set, ArrayBase)):
259+
elif isinstance(obj, (list, tuple, frozenset, set, ArrayBase)):
259260
result = cls._markdown_result_list(obj, level)
260261
elif isinstance(obj, (bytes, bytearray)):
261262
result = cls.post_text_encoder(bytes_to_hex_string(obj, separator=':', lowercase=False), level)

submodules/cryptodatahub

Submodule cryptodatahub updated from 78947c4 to 3539eb3

test/tls/test_extension.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,7 @@ def test_markdown(self):
440440

441441
self.assertEqual(scts[0].as_markdown(), '\n'.join([
442442
'* Version: V1',
443-
'* Log:',
444-
' * ID: AAECAwQFBgcICQoLDA0ODwABAgMEBQYHCAkKCwwNDg8=',
443+
'* Log: AAECAwQFBgcICQoLDA0ODwABAgMEBQYHCAkKCwwNDg8=',
445444
'* Timestamp: 1970-01-01 00:00:00.001000+00:00',
446445
'* Extensions: -',
447446
'* Signature Algorithm: none with no encryption',
@@ -450,12 +449,7 @@ def test_markdown(self):
450449

451450
self.assertEqual(scts[1].as_markdown(), '\n'.join([
452451
'* Version: V1',
453-
'* Log:',
454-
' * ID: lgbALGkAM6odFF9ZxuJkjQVJ8N+WqrjbkVpw2OzzkKU=',
455-
' * Description: Akamai CT Log',
456-
' * Log State:',
457-
' * State Type: REJECTED',
458-
' * Timestamp: 2015-11-27 15:37:00+00:00',
452+
'* Log: Akamai CT Log (lgbALGkAM6odFF9ZxuJkjQVJ8N+WqrjbkVpw2OzzkKU=)',
459453
'* Timestamp: 1970-01-01 00:00:00.001000+00:00',
460454
'* Extensions: -',
461455
'* Signature Algorithm: none with no encryption',

0 commit comments

Comments
 (0)