From 43b3ae1fe29346d2a6f469b74718bd3776deea36 Mon Sep 17 00:00:00 2001 From: Gareth Palmer Date: Sat, 17 Jun 2023 23:58:27 +1200 Subject: [PATCH] Fix pylint warnings. --- .pylintrc | 2 +- enccnf | 10 +++++----- sgnfile | 4 ++-- stripsgn | 2 +- tlvfile | 8 ++++---- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.pylintrc b/.pylintrc index 04813b3..104aed0 100644 --- a/.pylintrc +++ b/.pylintrc @@ -3,7 +3,7 @@ persistent=no extension-pkg-whitelist=lxml [MESSAGES CONTROL] -disable=missing-module-docstring,missing-class-docstring,missing-function-docstring,bad-whitespace,invalid-name,line-too-long,redefined-builtin,too-many-statements,too-many-branches,too-many-locals,too-many-arguments,broad-except,consider-using-sys-exit,len-as-condition,no-else-continue,duplicate-code +disable=missing-module-docstring,missing-class-docstring,missing-function-docstring,bad-whitespace,invalid-name,line-too-long,redefined-builtin,too-many-statements,too-many-branches,too-many-locals,too-many-arguments,broad-except,consider-using-sys-exit,len-as-condition,no-else-continue,duplicate-code,raise-missing-from [REPORTS] output-format=text diff --git a/enccnf b/enccnf index 5df15f5..3ff759b 100755 --- a/enccnf +++ b/enccnf @@ -133,7 +133,7 @@ def parse_enc_file(enc_file, tftp_certificate_file): elif tlv_tag == HEADER_HASH_ALGORITHM: hash_algorithm = tlv_data[tlv_index] - print(f'Digest Algorithm: ', end = '') + print('Digest Algorithm: ', end = '') if hash_algorithm == HASH_SHA1: print('SHA1') @@ -179,7 +179,7 @@ def parse_enc_file(enc_file, tftp_certificate_file): elif tlv_tag == HEADER_ENCRYPTION_HASH_ALGORITHM: encryption_hash_algorithm = tlv_data[tlv_index] - print(f'Encryption Digest Algorithm: ', end = '') + print('Encryption Digest Algorithm: ', end = '') if encryption_hash_algorithm == HASH_SHA1: print('SHA1') @@ -202,7 +202,7 @@ def parse_enc_file(enc_file, tftp_certificate_file): print('') if hash_algorithm is None: - raise ProgramError(f'Missing HEADER_HASH_ALGORITHM') + raise ProgramError('Missing HEADER_HASH_ALGORITHM') if hash_algorithm not in (HASH_SHA1, HASH_SHA512): raise ProgramError(f'Unsupported HEADER_HASH_ALGORITHM: {hash_algorithm}') @@ -270,7 +270,7 @@ def remove_enc_file(enc_file, private_key_file): if tlv_tag != HEADER_VERSION: raise ProgramError(f'Tag is not HEADER_VERSION: {tlv_tag}') - (major, minor) = struct.unpack_from('B B', tlv_data, tlv_index) + # Skip version tlv_index += tlv_length (tlv_tag, tlv_length) = struct.unpack_from('> B H', tlv_data, tlv_index) @@ -748,7 +748,7 @@ def main(): elif mode == 'remove': if private_key_file is None: - raise ProgramError(f'No private-key file specified') + raise ProgramError('No private-key file specified') remove_enc_file(enc_file, private_key_file) diff --git a/sgnfile b/sgnfile index f7fab1c..e4a2895 100755 --- a/sgnfile +++ b/sgnfile @@ -118,7 +118,7 @@ def parse_sgn_file(sgn_file, tftp_certificate_file): elif tlv_tag == HEADER_HASH_ALGORITHM: hash_algorithm = tlv_data[tlv_index] - print(f'Digest Algorithm: ', end = '') + print('Digest Algorithm: ', end = '') if hash_algorithm == HASH_SHA1: print('SHA1') @@ -211,7 +211,7 @@ def remove_sgn_file(sgn_file): if tlv_tag != HEADER_VERSION: raise ProgramError(f'Tag is not HEADER_VERSION: {tlv_tag}') - (major, minor) = struct.unpack_from('B B', tlv_data, tlv_index) + # Skip version tlv_index += tlv_length (tlv_tag, tlv_length) = struct.unpack_from('> B H', tlv_data, tlv_index) diff --git a/stripsgn b/stripsgn index bbd7ce6..ffe77ce 100755 --- a/stripsgn +++ b/stripsgn @@ -36,7 +36,7 @@ def strip_sgn_file(sgn_file): if tlv_tag != HEADER_VERSION: raise ProgramError(f'Tag is not HEADER_VERSION: {tlv_tag}') - (major, minor) = struct.unpack_from('B B', tlv_data, tlv_index) + # Skip version tlv_index += tlv_length (tlv_tag, tlv_length) = struct.unpack_from('> B H', tlv_data, tlv_index) diff --git a/tlvfile b/tlvfile index 053aa19..981d41d 100755 --- a/tlvfile +++ b/tlvfile @@ -148,7 +148,7 @@ def parse_tlv_file(tlv_file): elif tlv_tag == HEADER_HASH_ALGORITHM: hash_algorithm = tlv_data[tlv_index] - print(f'Digest Algorithm: ', end = '') + print('Digest Algorithm: ', end = '') if hash_algorithm == HASH_SHA1: print('SHA1') @@ -188,10 +188,10 @@ def parse_tlv_file(tlv_file): print('') if sast_serial_number is None: - raise ProgramError(f'Missing HEADER_SERIAL_NUMBER') + raise ProgramError('Missing HEADER_SERIAL_NUMBER') if hash_algorithm is None: - raise ProgramError(f'Missing HEADER_HASH_ALGORITHM') + raise ProgramError('Missing HEADER_HASH_ALGORITHM') if hash_algorithm not in (HASH_SHA1, HASH_SHA512): raise ProgramError(f'Unsupported HEADER_HASH_ALGORITHM: {hash_algorithm}') @@ -238,7 +238,7 @@ def parse_tlv_file(tlv_file): elif tlv_tag == RECORD_ROLE: (role,) = struct.unpack_from('> H', tlv_data, tlv_index) - print(f'Role: ', end = '') + print('Role: ', end = '') if role == ROLE_SAST: print('SAST')