Skip to main content

Used to validate restricted python code inputs against test cases.

Project description

USCG Leetcode Validator

A secure Python code validator for coding challenge platforms like LeetCode-style or CTF environments.

This package runs and validates submitted Python functions under strict constraints using Python's AST (Abstract Syntax Tree). It ensures that only allowed operations (like basic loops, arithmetic, and safe built-ins) are used. This is ideal for running untrusted user code in coding competitions, while preventing unsafe or unwanted behavior.


🚀 Features

  • ✅ Accepts only a single top-level function in the submitted code
  • ✅ Rejects all imports, lambdas, classes, and custom function definitions
  • ✅ Optionally allows safe built-ins like len() and range()
  • ✅ Enforces AST-level constraints before execution
  • ✅ Runs submitted function against a list of test cases
  • ✅ Outputs time taken and pass/fail result for each test case

📦 Installation

To install from PyPI:

pip install uscg_leetcode_validator

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

uscg_leetcode_validator-1.0.4.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uscg_leetcode_validator-1.0.4-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file uscg_leetcode_validator-1.0.4.tar.gz.

File metadata

  • Download URL: uscg_leetcode_validator-1.0.4.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for uscg_leetcode_validator-1.0.4.tar.gz
Algorithm Hash digest
SHA256 c2e50ee06e625c3ff1a1bd229e75f856ea0e6066ce2cf33ce08d1973ff764ae3
MD5 09d1949e03c95c02c44c0b0966aed0f7
BLAKE2b-256 5232a96a971e2b5d0c96aaa3bb251c0969585a56b327e40328e9e1a9aaf5c611

See more details on using hashes here.

File details

Details for the file uscg_leetcode_validator-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for uscg_leetcode_validator-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ae32121db23d2d88fe71dd440e63bb21f4a599f8e7a4b5f845d6e473f462471d
MD5 48db836b3e2d619de3faac8eadad0a39
BLAKE2b-256 35d7fc8742c12dc76d2c2125b300c0019ef06bcb6ad44f5cd8281b9b0a995d7a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page