Validate arbitrary base64-encoded image uploads as incoming data urls while preserving image integrity but removing EXIF and unwanted artifacts and mitigating RCE-exploit potential.
Project description
jericho-validator
Validate arbitrary image uploads from incoming data urls while preserving file integrity but removing EXIF and unwanted artifacts and RCE exploit potential.
Installation
PyPi: pip install jericho_validator
Manually: python setup.py install
Example Usage
from jericho_validator import jerichoValidator, jerichoExceptions
with open('example.png.b64') as f:
data = f.read()
try:
# Check the data URL (image)
j = jerichoValidator(data)
except jerichoExceptions.ImageTooLarge:
print('Image is too large.')
except jerichoExceptions.EmptyFileName:
print('File name is empty.')
except jerichoExceptions.UnsupportedImageType:
print('Image type not supported.')
except Exception as e:
print(e)
if j.isValid:
print('Image is valid.')
print('Image size in bytes: ' + str(j.sizeBytes))
print('Image dimensions: ' + str(j.dimensions))
print('Image filename: ' + j.filename)
print('Image extension: ' + j.extension)
print('Image format prefix: ' + j.formatPrefix)
else:
print('Image is invalid.')
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jericho_validator-1.0.tar.gz
(4.9 kB
view hashes)
Built Distribution
Close
Hashes for jericho_validator-1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66ec8a82567f7bb53c0a86d6df66968edc1e0d2698968d8a771264ccc8ecad16 |
|
MD5 | 32d0888673bc96366926879d51df988a |
|
BLAKE2b-256 | 54e2ef6f660830653c21272306f3c51ca5fff6d5e1745f283ad17524dc4d3d8a |