From bb1aefa6b8d985b9c51f788984350c79f8c27da0 Mon Sep 17 00:00:00 2001 From: Robert Stypa Date: Tue, 7 Nov 2023 16:19:27 +0100 Subject: [PATCH] refactor: add comments, fix review findings Signed-off-by: Robert Stypa --- suit_generator/suit/types/common.py | 9 ++++----- tests/fuzz/fuzz_suit_obj.py | 2 ++ tests/fuzz/fuzz_suit_tstr.py | 2 ++ tests/fuzz/fuzz_suit_yaml.py | 2 ++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/suit_generator/suit/types/common.py b/suit_generator/suit/types/common.py index 5948d61e..0d1ab6bf 100644 --- a/suit_generator/suit/types/common.py +++ b/suit_generator/suit/types/common.py @@ -8,18 +8,17 @@ Code inspired by/based on https://github.com/tomchy/suit-composer. """ from __future__ import annotations - -import json from dataclasses import dataclass from typing import cast - -from suit_generator.logger import log_call import functools -import cbor2 import binascii import logging import struct +import json + +import cbor2 +from suit_generator.logger import log_call from suit_generator.suit.types.keys import suit_integrated_payloads, suit_integrated_dependencies from suit_generator.exceptions import GeneratorError diff --git a/tests/fuzz/fuzz_suit_obj.py b/tests/fuzz/fuzz_suit_obj.py index a59d70c6..67e9f591 100644 --- a/tests/fuzz/fuzz_suit_obj.py +++ b/tests/fuzz/fuzz_suit_obj.py @@ -288,6 +288,8 @@ def fuzz_full_path(data): cbor2 = env2.to_cbor() assert cbor1.hex() == cbor2.hex() except ValueError: + # ValueError is expected for some payloads since it's used by all suit-generator levels to report + # not valid data. pass diff --git a/tests/fuzz/fuzz_suit_tstr.py b/tests/fuzz/fuzz_suit_tstr.py index acac37c2..7b8c5481 100644 --- a/tests/fuzz/fuzz_suit_tstr.py +++ b/tests/fuzz/fuzz_suit_tstr.py @@ -32,6 +32,8 @@ def fuzz_tstr(data): fuzz_bytes = fdp.ConsumeBytes(16) SuitTstr.from_cbor(fuzz_bytes) except ValueError: + # ValueError is expected for some payloads since it's used by all suit-generator levels to report + # not valid data. pass diff --git a/tests/fuzz/fuzz_suit_yaml.py b/tests/fuzz/fuzz_suit_yaml.py index 257952a9..ad50f0e1 100644 --- a/tests/fuzz/fuzz_suit_yaml.py +++ b/tests/fuzz/fuzz_suit_yaml.py @@ -99,6 +99,8 @@ def fuzz_yaml_component_id(data): env2 = SuitEnvelopeTagged.from_cbor(cbor1) env2.to_cbor() except ValueError: + # ValueError is expected for some payloads since it's used by all suit-generator levels to report + # not valid data. pass