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.12-py3-none-any.whl (119.6 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for codesecure_core-1.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 3705a516d876928502960ccca3369792a76de284bf7def6d24addef4a19da69b
MD5 b34b1ee48932fdb977f155b61e18f5a2
BLAKE2b-256 4987ae1ae35ab2e48789447ea9a2b7518ab07e1b053fe646e49cea935eb5274d

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