示例#1
0
文件: test_base64.py 项目: za/cpython
 def test_b32hexdecode(self):
     test_cases = [
         # to_decode, expected, casefold
         (b'', b'', False),
         (b'00======', b'\x00', False),
         (b'C4======', b'a', False),
         (b'C5H0====', b'ab', False),
         (b'C5H66===', b'abc', False),
         (b'C5H66P0=', b'abcd', False),
         (b'C5H66P35', b'abcde', False),
         (b'', b'', True),
         (b'00======', b'\x00', True),
         (b'C4======', b'a', True),
         (b'C5H0====', b'ab', True),
         (b'C5H66===', b'abc', True),
         (b'C5H66P0=', b'abcd', True),
         (b'C5H66P35', b'abcde', True),
         (b'c4======', b'a', True),
         (b'c5h0====', b'ab', True),
         (b'c5h66===', b'abc', True),
         (b'c5h66p0=', b'abcd', True),
         (b'c5h66p35', b'abcde', True),
     ]
     for to_decode, expected, casefold in test_cases:
         with self.subTest(to_decode=to_decode, casefold=casefold):
             self.assertEqual(base64.b32hexdecode(to_decode, casefold),
                              expected)
             self.assertEqual(
                 base64.b32hexdecode(to_decode.decode('ascii'), casefold),
                 expected)
示例#2
0
文件: test_base64.py 项目: za/cpython
 def test_b32hexdecode_error(self):
     tests = [b'abc', b'ABCDEF==', b'==ABCDEF', b'c4======']
     prefixes = [b'M', b'ME', b'MFRA', b'MFRGG', b'MFRGGZA', b'MFRGGZDF']
     for i in range(0, 17):
         if i:
             tests.append(b'=' * i)
         for prefix in prefixes:
             if len(prefix) + i != 8:
                 tests.append(prefix + b'=' * i)
     for data in tests:
         with self.subTest(to_decode=data):
             with self.assertRaises(binascii.Error):
                 base64.b32hexdecode(data)
             with self.assertRaises(binascii.Error):
                 base64.b32hexdecode(data.decode('ascii'))
示例#3
0
shelve.open(
    filepath
)  # $ decodeInput=filepath decodeOutput=shelve.open(..) decodeFormat=pickle decodeMayExecuteInput getAPathArgument=filepath
shelve.open(
    filename=filepath
)  # $ decodeInput=filepath decodeOutput=shelve.open(..) decodeFormat=pickle decodeMayExecuteInput getAPathArgument=filepath

# TODO: These tests should be merged with python/ql/test/experimental/dataflow/tainttracking/defaultAdditionalTaintStep/test_string.py
base64.b64decode(
    payload
)  # $ decodeInput=payload decodeOutput=base64.b64decode(..) decodeFormat=Base64
base64.standard_b64decode(
    payload
)  # $ decodeInput=payload decodeOutput=base64.standard_b64decode(..) decodeFormat=Base64
base64.urlsafe_b64decode(
    payload
)  # $ decodeInput=payload decodeOutput=base64.urlsafe_b64decode(..) decodeFormat=Base64
base64.b32decode(
    payload
)  # $ decodeInput=payload decodeOutput=base64.b32decode(..) decodeFormat=Base32
base64.b32hexdecode(
    payload
)  # $ decodeInput=payload decodeOutput=base64.b32hexdecode(..) decodeFormat=Base32
base64.b16decode(
    payload
)  # $ decodeInput=payload decodeOutput=base64.b16decode(..) decodeFormat=Base16
# deprecated since Python 3.1, but still works
base64.decodestring(
    payload
)  # $ decodeInput=payload decodeOutput=base64.decodestring(..) decodeFormat=Base64