Skip to main content

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)

Metadata

Release files for jericho-validator 1.1.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jericho-validator 1.1.12
File Size Uploaded
jericho_validator-1.1.12.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jericho-validator 1.1.12
File Interpreter ABI Platform
jericho_validator-1.1.12-py3-none-any.whl Python 3 none any Details

Total release size: 10.1 kB

Release files / jericho_validator-1.1.12.tar.gz

Download URL jericho_validator-1.1.12.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7d0a9d94939da33900a516a88b00964fb7c906eebd2858639d99f9009878b084
BLAKE2b-256 checksum
How to use checksums
27e158cf5116f5c4f6faae7abb2a4474cba7bd6bb8cd261f26031418c2926c19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.6

Release files / jericho_validator-1.1.12-py3-none-any.whl

Download URL jericho_validator-1.1.12-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7df249d71887b771c1ab377e457082216e1fd1f218bb640297fb86e20d79659a
BLAKE2b-256 checksum
How to use checksums
6514f180d14d24d254e6aae0bdd2e8605bae8a01027118a24a4b2e1c90791606
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.1 CPython/3.9.6

Release history Release notifications | RSS feed

This release

1.1.12 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page