Skip to main content

Enterprise-grade security analysis core engine

Project description

CodeSecure Core (codesecure-core)

The codesecure-core package is the programmatic orchestration brain of the CodeSecure platform. It provides the centralized, stateless logic for executing security scanners, managing asynchronous jobs, and enriching findings with AI models.

🎯 Module Purpose

This package encapsulates the strict business logic of the platform, adhering to a "Thin Client" architecture. It does not export command-line (CLI) applications or MCP Transport interfaces directly. Instead, it provides a stable Python API (Singletons) designed to be consumed by other packages in the CodeSecure monorepo, such as codesecure-cli and codesecure-mcp.

📦 Local Installation

Because core has no dependency on the UI/CLI layer, it can be installed natively for programmatic API usage.

cd packages/core
python -m venv .venv

# Install the core logic with basic SAST scanners
pip install -e .

# [Optional] Install AI providers (Google Gemini or Kiro CLI dependencies)
pip install -e .[google,aws]

🔌 Exported APIs & Features

The Core package exposes Manager classes via the Singleton pattern:

  1. ScannerEngine: Orchestrates local/container execution for Bandit, Semgrep, Checkov, detect-secrets, npm-audit, pip-audit, etc.
    from codesecure.scanners.engine import get_scanner_engine
    
  2. JobManager: Async execution tracking, lock management, TTL limits, and progress percentages.
    from codesecure.jobs.manager import get_job_manager
    
  3. AIProviderManager: Abstracts batch prompting against Gemini and Kiro. Calculates False Positive tracking dynamically.
    from codesecure.ai_providers.manager import get_ai_manager
    

🛠️ Integration Example

Here is how a downstream module (like the MCP server) imports and utilizes the core library programmatically:

import asyncio
from pathlib import Path
from codesecure.common.models import ScanMode, CloudProvider
from codesecure.scanners.engine import get_scanner_engine

async def programmatically_scan(target_dir: str):
    scan_path = Path(target_dir).resolve()
    engine = get_scanner_engine()
    
    # Check available scanners
    available = engine.get_available_scanners(ScanMode.LOCAL)
    print(f"Scanners ready: {available}")
    
    # Run a unified scan seamlessly combining multiple tools
    result = await engine.run_scan(
        path=scan_path,
        mode=ScanMode.LOCAL,
        cloud_provider=CloudProvider.NONE
    )
    
    print(f"Total findings discovered: {len(result.findings)}")

asyncio.run(programmatically_scan("./my_project"))

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

codesecure_core-1.0.0b10.tar.gz (85.0 kB view details)

Uploaded Source

Built Distribution

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

codesecure_core-1.0.0b10-py3-none-any.whl (113.1 kB view details)

Uploaded Python 3

File details

Details for the file codesecure_core-1.0.0b10.tar.gz.

File metadata

  • Download URL: codesecure_core-1.0.0b10.tar.gz
  • Upload date:
  • Size: 85.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for codesecure_core-1.0.0b10.tar.gz
Algorithm Hash digest
SHA256 b0543f6882ee199989052209dbcc4237aae00df497fc7879ef215ad1c9ac5a23
MD5 0cd4780f018a7c777339a3e77a22d511
BLAKE2b-256 e44afb76a75237dec41667835c4332fddd1f05f6f6459d81f2b8763a03b70980

See more details on using hashes here.

File details

Details for the file codesecure_core-1.0.0b10-py3-none-any.whl.

File metadata

File hashes

Hashes for codesecure_core-1.0.0b10-py3-none-any.whl
Algorithm Hash digest
SHA256 2428053b97db400f65cb9de95ceff7ca83a41f85da74c6340e5b89a5c2f9849f
MD5 d91c41bee63e9a75678797cca6efd60b
BLAKE2b-256 572ac75e7c1d4938a52f5f313cea5ee40705608c5fd9c32156e5aee16aa68ebc

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