Skip to main content

Compliance & security SDK for Leo smart contracts

Project description

๐Ÿ”’ Comp-LEO SDK

PyPI version License Python 3.10+

Compliance & Security for Leo Smart Contracts | 100% Local | Zero Network Calls

Comp-LEO brings shift-left compliance to the Aleo ecosystem. Check your Leo smart contracts for security vulnerabilities and compliance issues in seconds, not months. Find issues during development, not after deployment.


โœจ Features

๐Ÿ” Static Analysis - Parse Leo code with regex-based AST extraction
๐Ÿ›ก๏ธ 10+ Security Rules - Access control, input validation, overflow risks
๐Ÿ“Š Smart Scoring - Severity-weighted compliance scores (0-100)
๐ŸŽจ Beautiful CLI - Interactive menu with auto-scan and selection
๐Ÿ“ˆ Multiple Formats - Export reports as JSON, HTML, or Markdown
๐Ÿค– CI/CD Ready - GitHub Actions, GitLab CI, pre-commit hooks
๐Ÿ”’ 100% Private - Code never leaves your machine
โšก Blazing Fast - <100ms per file, 25x faster than AI tools
๐Ÿ†“ Free & Open Source - Apache 2.0 license


๐Ÿš€ Quick Start

Installation

pip install comp-leo

# With interactive menu mode
pip install comp-leo[interactive]

# With file watching
pip install comp-leo[watch]

# Full install
pip install comp-leo[all]

Usage

๐ŸŽจ Interactive Menu Mode (Recommended)

The interactive menu mode provides a beautiful, user-friendly interface with auto-scanning:

comp-leo --interactive

Features:

  • ๐Ÿ” Auto-scans for .leo files in current directory, parent, and programs/ folders
  • ๐Ÿ“‹ Shows up to 5 files directly in the main menu for quick access
  • โŒจ๏ธ Navigate with arrow keys, select with Enter
  • ๐Ÿ”„ Rescan on demand to find new files
  • ๐Ÿ“Š View detailed results and statistics
  • ๐Ÿ’พ Export reports in multiple formats

Example Session:

  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ•—   โ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—       โ–ˆโ–ˆโ•—     โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— 
 โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•”โ•โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—      โ–ˆโ–ˆโ•‘     โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•”โ•โ•โ•โ–ˆโ–ˆโ•—
 โ–ˆโ–ˆโ•‘     โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ–ˆโ–ˆโ–ˆโ–ˆโ•”โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘     โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘
 โ–ˆโ–ˆโ•‘     โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ•šโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ–ˆโ–ˆโ•‘     โ–ˆโ–ˆโ•”โ•โ•โ•  โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘
 โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘ โ•šโ•โ• โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘           โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•
  โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•     โ•šโ•โ•โ•šโ•โ•           โ•šโ•โ•โ•โ•โ•โ•โ•โ•šโ•โ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ• 

Compliance & Security for Leo Smart Contracts
v0.1.1 | Zero-Knowledge Compliance | 100% Local

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
๐Ÿ“‹ Interactive Menu Mode
Use arrow keys to navigate, Enter to select

๐Ÿ” Scanning for Leo files...
โœ“ Found 8 Leo file(s)

โ€บ What would you like to do?
  โ”€โ”€โ”€ Quick Check โ”€โ”€โ”€
โ–ธ โœ“ programs/sbom_registry/src/main.leo
  โœ“ programs/compliance_oracle/src/main.leo
  โœ“ programs/token/src/main.leo
  ... and 5 more files
  โ”€โ”€โ”€ More Options โ”€โ”€โ”€
  ๐Ÿ” Browse & Check File
  ๐Ÿ“ Check Directory
  ๐Ÿ”„ Rescan for Leo Files
  ๐Ÿ“‹ List Available Policies
  ๐Ÿ”ง Change Policy Pack
  โ“ Help
  โŒ Exit

Menu Navigation:

  • Use โ†‘/โ†“ arrow keys to move
  • Press Enter to select
  • Press Ctrl+C to cancel (returns to menu)
  • Select "โŒ Exit" to quit

Quick Check: Select any file from the "Quick Check" section to instantly analyze it. Results show violations, severity, and compliance score.

After Running a Check: The menu dynamically updates to show additional options:

  ๐Ÿ“Š View Last Results      # See all violations with details
  ๐Ÿ“ˆ Show Statistics        # View detailed metrics
  ๐Ÿ’พ Export Report          # Save as JSON/HTML/Markdown

Browse Mode: When you select "๐Ÿ” Browse & Check File":

  1. Enter a path (defaults to current directory)
  2. If it's a directory, see all .leo files
  3. Select a file to check
  4. See up to 30 files, with option to show all

๐Ÿ’ป Command Line Mode

For scripting and CI/CD, use direct commands:

# Check a single file
comp-leo check programs/my_contract/src/main.leo

# Check entire directory
comp-leo check programs/

# Check with custom threshold
comp-leo check programs/ --threshold 90

# Fail on any high severity issues
comp-leo check programs/ --fail-on-high

# Generate HTML report
comp-leo report programs/ --format html -o report.html

# Generate Markdown report
comp-leo report programs/ --format markdown -o COMPLIANCE.md

# List available policies
comp-leo list-policies

# Generate CI/CD configs
comp-leo init-ci

# Watch mode (auto-check on file changes)
comp-leo watch programs/

๐Ÿ“‹ Commands

Command Description
comp-leo Show banner and help
comp-leo --interactive Launch interactive menu mode
comp-leo check <path> Check Leo file or directory
comp-leo report <path> Generate compliance report
comp-leo list-policies List available policy packs
comp-leo init-ci Generate CI/CD configurations
comp-leo watch <path> Watch files for changes (requires [watch])
comp-leo --version Show version
comp-leo --help Show full help

๐ŸŽฏ Use Cases

Pre-Commit Hook

# .git/hooks/pre-commit
#!/bin/bash
comp-leo check programs/ --threshold 75 --fail-on-critical || exit 1

GitHub Actions

# .github/workflows/compliance.yml
name: Compliance Check
on: [pull_request]

jobs:
  compliance:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v4
        with:
          python-version: '3.10'
      - run: pip install comp-leo
      - run: comp-leo check programs/ --fail-on-critical

Python API

from comp_leo.analyzer.checker import ComplianceChecker

checker = ComplianceChecker(policy_pack="aleo-baseline")
result = checker.check_file("programs/my_contract/src/main.leo")

print(f"Score: {result.score}/100")
print(f"Violations: {len(result.violations)}")

for v in result.violations:
    print(f"{v.severity}: {v.message} at line {v.line_number}")

๐Ÿ“š Policy Packs

Pack Status Controls Focus Area
aleo-baseline โœ… Available 10+ Leo security best practices
nist-800-53 ๐Ÿšง v0.2.0 1,200+ Federal security baseline
iso-27001 ๐Ÿšง v0.2.0 114 Information security
pci-dss ๐Ÿšง v0.3.0 300+ Payment card security
gdpr ๐Ÿšง v0.3.0 99 Data protection & privacy

Current Rules (aleo-baseline)

  • โœ… Missing access control checks
  • โœ… Unvalidated inputs in transitions
  • โœ… Unprotected state mutations
  • โœ… Integer overflow risks
  • โœ… Missing event logging
  • โœ… Hardcoded credentials
  • โœ… Weak randomness
  • โœ… Reentrancy patterns
  • โœ… Gas optimization issues
  • โœ… Documentation gaps

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      Comp-LEO SDK                           โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  CLI Tool              API Service           CI Integration  โ”‚
โ”‚  comp-leo check        /v1/check             GitHub Actions  โ”‚
โ”‚  comp-leo fix          /v1/report            GitLab CI       โ”‚
โ”‚  comp-leo report       Authentication         PR Comments    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚               Static Analysis Engine                         โ”‚
โ”‚  Leo Parser โ†’ AST โ†’ Pattern Matcher โ†’ Scorer                โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚               Policy Engine                                  โ”‚
โ”‚  Rules | Severity | Evidence | Control Mapping              โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚               Remediation Engine (Future)                    โ”‚
โ”‚  Fix Generator โ†’ AI Agent โ†’ PR Creator                       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Example Output

โš ๏ธ  Compliance Check: 3 issues found

HIGH: Missing input validation [AC-3.1, NIST 800-53]
  โ†’ programs/payment/src/main.leo:45
  ๐Ÿ’ก Add assertion: assert(amount > 0u64);

MEDIUM: Insufficient logging [AU-2, NIST 800-53]
  โ†’ programs/payment/src/main.leo:78
  ๐Ÿ’ก Log transaction hash before state mutation

LOW: Public field exposure [privacy-001]
  โ†’ programs/payment/src/main.leo:12
  ๐Ÿ’ก Consider using private modifier for sensitive data

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
โœ… 47 checks passed  โš ๏ธ 3 warnings  โŒ 0 critical
Score: 85/100 (Threshold: 75)

๐Ÿ†• What's New in v0.1.1

โœจ Interactive Menu Mode - Beautiful TUI with auto-scanning
๐Ÿ“ Smart File Discovery - Auto-finds Leo files in current/parent directories
๐ŸŽฏ Quick Check - One-click checking from scanned files
๐Ÿ”„ Rescan on Demand - Refresh file list without restarting
๐Ÿ“Š Dynamic Menus - Context-aware options based on state
๐ŸŽจ Enhanced CLI - Improved error messages and help
๐Ÿ“ฆ Optional Dependencies - Install only what you need ([interactive], [watch], [all])

๐Ÿ”’ Why 100% Local?

Your code never leaves your machine. No AI APIs. No network calls. True privacy for ZK blockchain development.

  • No Data Leakage - Code stays on your machine
  • Works Offline - Zero network dependency
  • Deterministic - Same code = same results always
  • Fast - <100ms vs 2-5s with cloud AI
  • Free Forever - No per-check costs
  • Auditable - Open source, verify everything

See WHY_LOCAL.md for full philosophy.

Pricing

Tier Checks/Month Price Features
Freemium 100 Free Core policies, CLI access
Pro 1,000 $99/mo All policies, API access, CI integration
Enterprise Unlimited $999/mo Custom rules, SLA, white-label

Project Structure

comp-leo-sdk/
โ”œโ”€ cli/                    # Command-line tool
โ”œโ”€ api/                    # FastAPI service
โ”œโ”€ analyzer/              # Static analysis engine
โ”‚  โ”œโ”€ parser.py           # Leo AST parser
โ”‚  โ”œโ”€ checker.py          # Pattern matcher
โ”‚  โ””โ”€ scorer.py           # Severity & scoring
โ”œโ”€ policies/              # Compliance rule definitions
โ”‚  โ”œโ”€ nist_800_53.json
โ”‚  โ”œโ”€ iso_27001.json
โ”‚  โ”œโ”€ pci_dss.json
โ”‚  โ””โ”€ aleo_baseline.json
โ”œโ”€ integrations/          # CI/CD plugins
โ”‚  โ”œโ”€ github/
โ”‚  โ””โ”€ gitlab/
โ””โ”€ tests/                 # Test suite

Development Roadmap

Phase 1: Foundation (Weeks 1-4)

  • Leo parser & AST builder
  • Core static analysis patterns
  • NIST 800-53 baseline (80% of ISO overlap)
  • CLI tool with local checks
  • Unit test suite (>80% coverage)

Phase 2: API & Monetization (Weeks 5-8)

  • FastAPI service with authentication
  • Rate limiting & usage tracking
  • API key management portal
  • Stripe integration for paid tiers

Phase 3: CI/CD & Ecosystem (Weeks 9-12)

  • GitHub Actions integration
  • PR comment bot
  • Policy pack expansion (PCI, GDPR)
  • VS Code extension

Phase 4: AI Auto-Fix (Weeks 13-16)

  • Fix suggestion engine
  • LLM integration (GPT-4/Claude)
  • Automated PR generation
  • Confidence scoring for fixes

Contributing

See CONTRIBUTING.md for development setup and guidelines.

License

Apache 2.0 for core SDK (open-source) Proprietary for API service & enterprise features


Built for the Aleo ecosystem | Website |

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

comp_leo-0.1.1.tar.gz (80.1 kB view details)

Uploaded Source

Built Distribution

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

comp_leo-0.1.1-py3-none-any.whl (45.0 kB view details)

Uploaded Python 3

File details

Details for the file comp_leo-0.1.1.tar.gz.

File metadata

  • Download URL: comp_leo-0.1.1.tar.gz
  • Upload date:
  • Size: 80.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for comp_leo-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c0b69ef373105b30f9d2afaeda8e03947b9e5547685a7c10929681c3a4827228
MD5 136eb30bca0815b681ce860b4936d569
BLAKE2b-256 2d0e02fb515a4d1d5066d61e7aac036f21f5a6ca727e85b557be5f005fb26fa6

See more details on using hashes here.

File details

Details for the file comp_leo-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: comp_leo-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 45.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for comp_leo-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4ad636f51482fc3d131afa17a38f74bb2b8ae9b112b6469f6c4025c81fb6205f
MD5 0eb61b2e52c5679061569c95b257c1f4
BLAKE2b-256 856b7d3b347957a9f672ea29dbdf3971c83ccfac6f9228ec042da05c9ab8d99b

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