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.3.tar.gz (1.8 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.3-py3-none-any.whl (2.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: uscg_leetcode_validator-1.0.3.tar.gz
  • Upload date:
  • Size: 1.8 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.3.tar.gz
Algorithm Hash digest
SHA256 d0baef750c6a4523655bffa3d02a38563894f1247b10585ff8f941d9f70a8766
MD5 fbfbbd74a9da4c1e472b214b0d8e535c
BLAKE2b-256 85ad0c66579a6009255d97895e5b6db4e6edcc06d16b90f85b7ec059d67d5e4c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for uscg_leetcode_validator-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 46f35e7109086cd969806dca8af8ad7d502e6190a1fa42a36c94e7b031bf7eb0
MD5 fb7b141a07a7e48bab910e7bc21a5680
BLAKE2b-256 43ca4d30e326d9f7a51d4e65f1091c77d62dd832a01e05ac86401bb63459bef5

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