Commit f026fbac authored by Simo Sorce's avatar Simo Sorce

Remove pylint star-args exceptions

Newer pylint version completely removed the star-args warning, including
recognizing the exception in the source code.
Remove it from all source code to avoid annoyinf pylint errors about
unrecognized exceptions, and add a general exception in the pylint makefile
invocation, as apparently it is ok there. This will avoid warnings if older
versions of pylint are used.
Signed-off-by: default avatarSimo Sorce <simo@redhat.com>
parent 0060099b
......@@ -8,6 +8,7 @@ lint:
# Ignore cherrypy class members as they are dynamically added
pylint -d c,r,i,W0613 -r n -f colorized \
--notes= \
--disable=star-args \
./jwcrypto
pep8:
......
......@@ -207,7 +207,7 @@ class JWK(object):
key = os.urandom(size // 8)
params['kty'] = 'oct'
params['k'] = key
self.import_key(**params) # pylint: disable=star-args
self.import_key(**params)
def _encode_int(self, i):
I = hex(i).rstrip("L").lstrip("0x")
......@@ -233,7 +233,7 @@ class JWK(object):
params['dp'] = self._encode_int(pn.dmp1)
params['dq'] = self._encode_int(pn.dmq1)
params['qi'] = self._encode_int(pn.iqmp)
self.import_key(**params) # pylint: disable=star-args
self.import_key(**params)
def _get_curve_by_name(self, name):
if name == 'P-256':
......@@ -257,7 +257,7 @@ class JWK(object):
params['x'] = self._encode_int(pn.public_numbers.x)
params['y'] = self._encode_int(pn.public_numbers.y)
params['d'] = self._encode_int(pn.private_value)
self.import_key(**params) # pylint: disable=star-args
self.import_key(**params)
def import_key(self, **kwargs):
names = list(kwargs.keys())
......
......@@ -295,8 +295,8 @@ class Cookbook08JWSTests(unittest.TestCase):
plaintext = base64url_decode(Payload_plaintext_b64_4)
protected = \
base64url_decode(JWS_Protected_Header_4_1_2).decode('utf-8')
pub_key = jwk.JWK(**RSA_Public_Key_3_3) # pylint: disable=star-args
pri_key = jwk.JWK(**RSA_Private_Key_3_4) # pylint: disable=star-args
pub_key = jwk.JWK(**RSA_Public_Key_3_3)
pri_key = jwk.JWK(**RSA_Private_Key_3_4)
S = jws.JWS(payload=plaintext)
S.add_signature(pri_key, None, protected)
self.assertEqual(JWS_compact_4_1_3, S.serialize(compact=True))
......@@ -307,8 +307,8 @@ class Cookbook08JWSTests(unittest.TestCase):
plaintext = base64url_decode(Payload_plaintext_b64_4)
protected = \
base64url_decode(JWS_Protected_Header_4_2_2).decode('utf-8')
pub_key = jwk.JWK(**RSA_Public_Key_3_3) # pylint: disable=star-args
pri_key = jwk.JWK(**RSA_Private_Key_3_4) # pylint: disable=star-args
pub_key = jwk.JWK(**RSA_Public_Key_3_3)
pri_key = jwk.JWK(**RSA_Private_Key_3_4)
S = jws.JWS(payload=plaintext)
S.add_signature(pri_key, None, protected)
# Can't compare signature with reference because RSASSA-PSS uses
......@@ -324,8 +324,8 @@ class Cookbook08JWSTests(unittest.TestCase):
plaintext = base64url_decode(Payload_plaintext_b64_4)
protected = \
base64url_decode(JWS_Protected_Header_4_3_2).decode('utf-8')
pub_key = jwk.JWK(**EC_Public_Key_3_1) # pylint: disable=star-args
pri_key = jwk.JWK(**EC_Private_Key_3_2) # pylint: disable=star-args
pub_key = jwk.JWK(**EC_Public_Key_3_1)
pri_key = jwk.JWK(**EC_Private_Key_3_2)
S = jws.JWS(payload=plaintext)
S.add_signature(pri_key, None, protected)
# Can't compare signature with reference because ECDSA uses
......@@ -341,7 +341,7 @@ class Cookbook08JWSTests(unittest.TestCase):
plaintext = base64url_decode(Payload_plaintext_b64_4)
protected = \
base64url_decode(JWS_Protected_Header_4_4_2).decode('utf-8')
key = jwk.JWK(**Symmetric_Key_MAC_3_5) # pylint: disable=star-args
key = jwk.JWK(**Symmetric_Key_MAC_3_5)
S = jws.JWS(payload=plaintext)
S.add_signature(key, None, protected)
sig = S.serialize(compact=True)
......@@ -357,7 +357,7 @@ class Cookbook08JWSTests(unittest.TestCase):
protected = \
base64url_decode(JWS_Protected_Header_4_6_2).decode('utf-8')
header = json_encode(JWS_Unprotected_Header_4_6_2)
key = jwk.JWK(**Symmetric_Key_MAC_3_5) # pylint: disable=star-args
key = jwk.JWK(**Symmetric_Key_MAC_3_5)
S = jws.JWS(payload=plaintext)
S.add_signature(key, None, protected, header)
sig = S.serialize()
......@@ -370,7 +370,7 @@ class Cookbook08JWSTests(unittest.TestCase):
def test_4_7_signing(self):
plaintext = base64url_decode(Payload_plaintext_b64_4)
header = json_encode(JWS_Unprotected_Header_4_7_2)
key = jwk.JWK(**Symmetric_Key_MAC_3_5) # pylint: disable=star-args
key = jwk.JWK(**Symmetric_Key_MAC_3_5)
S = jws.JWS(payload=plaintext)
S.add_signature(key, None, None, header)
sig = S.serialize()
......@@ -387,22 +387,22 @@ class Cookbook08JWSTests(unittest.TestCase):
protected = \
base64url_decode(JWS_Protected_Header_4_8_2).decode('utf-8')
header = json_encode(JWS_Unprotected_Header_4_8_2)
pri_key = jwk.JWK(**RSA_Private_Key_3_4) # pylint: disable=star-args
pri_key = jwk.JWK(**RSA_Private_Key_3_4)
S.add_signature(pri_key, None, protected, header)
# 4_8_3
header = json_encode(JWS_Unprotected_Header_4_8_3)
pri_key = jwk.JWK(**EC_Private_Key_3_2) # pylint: disable=star-args
pri_key = jwk.JWK(**EC_Private_Key_3_2)
S.add_signature(pri_key, None, None, header)
# 4_8_4
protected = \
base64url_decode(JWS_Protected_Header_4_8_4).decode('utf-8')
sym_key = jwk.JWK(**Symmetric_Key_MAC_3_5) # pylint: disable=star-args
sym_key = jwk.JWK(**Symmetric_Key_MAC_3_5)
S.add_signature(sym_key, None, protected)
sig = S.serialize()
# Can't compare signature with reference because ECDSA uses
# random nonces every time a signature is generated.
rsa_key = jwk.JWK(**RSA_Public_Key_3_3) # pylint: disable=star-args
ec_key = jwk.JWK(**EC_Public_Key_3_1) # pylint: disable=star-args
rsa_key = jwk.JWK(**RSA_Public_Key_3_3)
ec_key = jwk.JWK(**EC_Public_Key_3_1)
S.deserialize(sig, rsa_key)
S.deserialize(sig, ec_key)
S.deserialize(sig, sym_key)
......@@ -954,7 +954,7 @@ class Cookbook08JWETests(unittest.TestCase):
def test_5_1_encryption(self):
plaintext = Payload_plaintext_5
protected = base64url_decode(JWE_Protected_Header_5_1_4)
rsa_key = jwk.JWK(**RSA_key_5_1_1) # pylint: disable=star-args
rsa_key = jwk.JWK(**RSA_key_5_1_1)
E = jwe.JWE(plaintext, protected)
E.add_recipient(rsa_key)
e = E.serialize()
......@@ -970,7 +970,7 @@ class Cookbook08JWETests(unittest.TestCase):
def test_5_2_encryption(self):
plaintext = Payload_plaintext_5
protected = base64url_decode(JWE_Protected_Header_5_2_4)
rsa_key = jwk.JWK(**RSA_key_5_2_1) # pylint: disable=star-args
rsa_key = jwk.JWK(**RSA_key_5_2_1)
E = jwe.JWE(plaintext, protected)
E.add_recipient(rsa_key)
e = E.serialize()
......@@ -995,7 +995,7 @@ class Cookbook08JWETests(unittest.TestCase):
def test_5_6_encryption(self):
plaintext = Payload_plaintext_5
protected = base64url_decode(JWE_Protected_Header_5_6_3)
aes_key = jwk.JWK(**AES_key_5_6_1) # pylint: disable=star-args
aes_key = jwk.JWK(**AES_key_5_6_1)
E = jwe.JWE(plaintext, protected)
E.add_recipient(aes_key)
_ = E.serialize(compact=True)
......@@ -1013,7 +1013,7 @@ class Cookbook08JWETests(unittest.TestCase):
def test_5_8_encryption(self):
plaintext = Payload_plaintext_5
protected = base64url_decode(JWE_Protected_Header_5_8_4)
aes_key = jwk.JWK(**AES_key_5_8_1) # pylint: disable=star-args
aes_key = jwk.JWK(**AES_key_5_8_1)
E = jwe.JWE(plaintext, protected)
E.add_recipient(aes_key)
e = E.serialize()
......@@ -1029,7 +1029,7 @@ class Cookbook08JWETests(unittest.TestCase):
def test_5_9_encryption(self):
plaintext = Payload_plaintext_5
protected = base64url_decode(JWE_Protected_Header_5_9_4)
aes_key = jwk.JWK(**AES_key_5_8_1) # pylint: disable=star-args
aes_key = jwk.JWK(**AES_key_5_8_1)
E = jwe.JWE(plaintext, protected)
E.add_recipient(aes_key)
e = E.serialize()
......@@ -1046,7 +1046,7 @@ class Cookbook08JWETests(unittest.TestCase):
plaintext = Payload_plaintext_5
protected = base64url_decode(JWE_Protected_Header_5_10_4)
aad = base64url_decode(AAD_5_10_1)
aes_key = jwk.JWK(**AES_key_5_8_1) # pylint: disable=star-args
aes_key = jwk.JWK(**AES_key_5_8_1)
E = jwe.JWE(plaintext, protected, aad=aad)
E.add_recipient(aes_key)
e = E.serialize()
......@@ -1061,7 +1061,7 @@ class Cookbook08JWETests(unittest.TestCase):
plaintext = Payload_plaintext_5
protected = base64url_decode(JWE_Protected_Header_5_11_4)
unprotected = json_encode(JWE_Unprotected_Header_5_11_5)
aes_key = jwk.JWK(**AES_key_5_8_1) # pylint: disable=star-args
aes_key = jwk.JWK(**AES_key_5_8_1)
E = jwe.JWE(plaintext, protected, unprotected)
E.add_recipient(aes_key)
e = E.serialize()
......@@ -1075,7 +1075,7 @@ class Cookbook08JWETests(unittest.TestCase):
def test_5_12_encryption(self):
plaintext = Payload_plaintext_5
unprotected = json_encode(JWE_Unprotected_Header_5_12_5)
aes_key = jwk.JWK(**AES_key_5_8_1) # pylint: disable=star-args
aes_key = jwk.JWK(**AES_key_5_8_1)
E = jwe.JWE(plaintext, None, unprotected)
E.add_recipient(aes_key)
e = E.serialize()
......
......@@ -165,24 +165,24 @@ class TestJWK(unittest.TestCase):
def test_create_pubKeys(self):
keylist = PublicKeys['keys']
for key in keylist:
_ = jwk.JWK(**key) # pylint: disable=star-args
_ = jwk.JWK(**key)
def test_create_priKeys(self):
keylist = PrivateKeys['keys']
for key in keylist:
_ = jwk.JWK(**key) # pylint: disable=star-args
_ = jwk.JWK(**key)
def test_create_symKeys(self):
keylist = SymmetricKeys['keys']
for key in keylist:
jwkey = jwk.JWK(**key) # pylint: disable=star-args
jwkey = jwk.JWK(**key)
_ = jwkey.get_op_key('sign')
_ = jwkey.get_op_key('verify')
e = jwkey.export()
self.assertEqual(json_decode(e), key)
_ = jwk.JWK(**Useofx5c) # pylint: disable=star-args
_ = jwk.JWK(**RSAPrivateKey) # pylint: disable=star-args
_ = jwk.JWK(**Useofx5c)
_ = jwk.JWK(**RSAPrivateKey)
def test_generate_keys(self):
jwk.JWK(generate='oct', size=256)
......@@ -360,10 +360,10 @@ A6_serialized = \
'}'
A6_example = {
'payload': bytes(bytearray(A2_payload)),
'key1': jwk.JWK(**A2_key), # pylint: disable=star-args
'key1': jwk.JWK(**A2_key),
'protected1': bytes(bytearray(A2_protected)).decode('utf-8'),
'header1': json_encode({"kid": "2010-12-29"}),
'key2': jwk.JWK(**A3_key), # pylint: disable=star-args
'key2': jwk.JWK(**A3_key),
'protected2': bytes(bytearray(A3_protected)).decode('utf-8'),
'header2': json_encode({"kid": "e9bc097a-ce51-4036-9562-d2ade882db0d"}),
'serialized': A6_serialized}
......@@ -499,7 +499,7 @@ E_A1_vector = \
"SdiwkIr3ajwQzaBtQD_A." \
"XFBoMYUZodetZdvTiFvSkQ"
E_A1_ex = {'key': jwk.JWK(**E_A1_key), # pylint: disable=star-args
E_A1_ex = {'key': jwk.JWK(**E_A1_key),
'protected': base64url_decode(E_A1_protected),
'plaintext': bytes(bytearray(E_A1_plaintext)),
'vector': E_A1_vector}
......@@ -548,7 +548,7 @@ E_A2_vector = \
"KDlTtXchhZTGufMYmOYGS4HffxPSUrfmqCHXaI9wOGY." \
"9hH0vgRfYgPnAHOd8stkvw"
E_A2_ex = {'key': jwk.JWK(**E_A2_key), # pylint: disable=star-args
E_A2_ex = {'key': jwk.JWK(**E_A2_key),
'protected': base64url_decode(E_A2_protected),
'plaintext': E_A2_plaintext,
'vector': E_A2_vector}
......@@ -563,7 +563,7 @@ E_A3_vector = \
"KDlTtXchhZTGufMYmOYGS4HffxPSUrfmqCHXaI9wOGY." \
"U0m_YmjN04DJvceFICbCVQ"
E_A3_ex = {'key': jwk.JWK(**E_A3_key), # pylint: disable=star-args
E_A3_ex = {'key': jwk.JWK(**E_A3_key),
'protected': base64url_decode(E_A3_protected).decode('utf-8'),
'plaintext': E_A3_plaintext,
'vector': E_A3_vector}
......@@ -589,9 +589,9 @@ E_A4_vector = \
'"ciphertext":"KDlTtXchhZTGufMYmOYGS4HffxPSUrfmqCHXaI9wOGY",' \
'"tag":"Mz-VPPyU4RlcuYv1IwIvzw"}'
E_A4_ex = {'key1': jwk.JWK(**E_A2_key), # pylint: disable=star-args
E_A4_ex = {'key1': jwk.JWK(**E_A2_key),
'header1': '{"alg":"RSA1_5","kid":"2011-04-29"}',
'key2': jwk.JWK(**E_A3_key), # pylint: disable=star-args
'key2': jwk.JWK(**E_A3_key),
'header2': '{"alg":"A128KW","kid":"7"}',
'protected': base64url_decode(E_A4_protected),
'unprotected': json_encode(E_A4_unprotected),
......@@ -700,7 +700,7 @@ A2_token = \
class TestJWT(unittest.TestCase):
def test_A1(self):
key = jwk.JWK(**E_A2_key) # pylint: disable=star-args
key = jwk.JWK(**E_A2_key)
# first encode/decode ourselves
T = jwt.JWT(A1_header, A1_claims)
T.make_encrypted_token(key)
......@@ -710,7 +710,7 @@ class TestJWT(unittest.TestCase):
T = jwt.JWT(jwt=A1_token, key=key)
def test_A2(self):
sigkey = jwk.JWK(**A2_example['key']) # pylint: disable=star-args
sigkey = jwk.JWK(**A2_example['key'])
Touter = jwt.JWT(jwt=A2_token, key=E_A2_ex['key'])
Tinner = jwt.JWT(jwt=Touter.claims, key=sigkey)
self.assertEqual(A1_claims, json_decode(Tinner.claims))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment