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 requests import get
from jericho_validator import Jericho
example_b64 = "https://raw.githubusercontent.com/hostinfodev/jericho-validator/main/example/example.png.b64"
b64_url = get(example_b64).text
def test_valid_b64(b64_url):
try:
# Check the data URL (image)
j = Jericho.jericho(b64_url)
except Jericho.Exceptions.ImageTooLarge:
print('Image is too large.')
except Jericho.Exceptions.EmptyFileName:
print('File name is empty.')
except Jericho.Exceptions.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.')
if __name__ == '__main__':
test_valid_b64(b64_url)
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
Built Distribution
Close
Hashes for jericho_validator-1.1.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7df249d71887b771c1ab377e457082216e1fd1f218bb640297fb86e20d79659a |
|
MD5 | d009a65f1769c127224cd2cd48cbdb0a |
|
BLAKE2b-256 | 6514f180d14d24d254e6aae0bdd2e8605bae8a01027118a24a4b2e1c90791606 |