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_2-1.0.0.tar.gz (4.3 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_2-1.0.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file uscg_leetcode_validator_2-1.0.0.tar.gz.

File metadata

File hashes

Hashes for uscg_leetcode_validator_2-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f3a5664fedc7390a3578565a6cd161b324fa4a949dd40347b4ef8441d5c1ae35
MD5 b348e6d0d1d70eb18553e2eb069599ca
BLAKE2b-256 5f906e68c2b37e7090ee7203ac85f02cdce077651be0511a5b18d3ef526830f0

See more details on using hashes here.

File details

Details for the file uscg_leetcode_validator_2-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for uscg_leetcode_validator_2-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8d284c7a5fcb8f3ff5c0a6a88e367ee9ae37e03703363fdb74fdf713dbf44eb
MD5 88b0313c34937a8d9cb1631aaf360925
BLAKE2b-256 3655b1ba128896506988e296ad43807e61652b6de4967b1a7f6374456ec67923

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