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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

codesecure_core-1.0.11-py3-none-any.whl (119.6 kB view details)

Uploaded Python 3

File details

Details for the file codesecure_core-1.0.11-py3-none-any.whl.

File metadata

File hashes

Hashes for codesecure_core-1.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 64f01f1c86e012065cf683bd532cef16c5fd02e94a4dffd6f062c169a766dd66
MD5 fe522fcbb78b1afcf525aa64b8dbc03b
BLAKE2b-256 3785f55a082eb8f0787b3599ba0370986a6bda7b14af552564b33728184741c1

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