AI Security Platform (AISec)

January 31, 2026 ยท View on GitHub

An AI-powered security analysis platform that identifies logic flaws and vulnerabilities in code, specifically designed for AI-generated code.

๐Ÿš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/aisec/platform.git
cd platform

# Option 1: Docker Compose (Recommended)
cp .env.example .env
# Edit .env with your API keys
docker-compose up -d

# Option 2: Local Development
make dev
make services  # Start all microservices

Basic Usage

# Local CLI scanning
./bin/aisec scan examples/

# Docker-based scanning
curl -X POST "http://localhost:8004/analyze" \
  -H "Content-Type: application/json" \
  -d '{
    "file_paths": ["examples/cross_file_vulnerability.py"],
    "enable_llm": true,
    "enable_reachability": true
  }'

# GitHub Integration
# 1. Create GitHub App with webhook URL: https://your-domain.com/webhook
# 2. Set GITHUB_TOKEN and GITHUB_WEBHOOK_SECRET in .env
# 3. Open a PR to trigger automatic security analysis

๐Ÿ— Architecture

  • Go: CLI and orchestration services
  • Python: AI analysis engine with LangGraph
  • Tree-sitter: Multi-language AST parsing
  • Postgres + pgvector: Knowledge graph storage

Components

  1. CLI Tool (cmd/aisec/): Command-line interface for scanning and authentication
  2. Semgrep Service (services/semgrep_service.py): Deterministic security rules with AI-generated patterns
  3. Knowledge Graph (services/knowledge_graph.py): Postgres + pgvector for code relationships
  4. LLM Analysis (services/real_llm_analysis.py): Claude 3.5 Sonnet with self-critique
  5. Hybrid Analysis (services/hybrid_analysis.py): Signal fusion and intelligent triage
  6. GitHub Integration (services/github_integration.py): PR comments and check runs
  7. Parser Service (services/tree_sitter_service.py): AST extraction for context

๐Ÿ“‹ Features

โœ… Implemented (Week 1)

  • CLI Skeleton: aisec auth login, aisec scan .
  • Tree-sitter Parser: Basic Python parsing with function/import extraction
  • Context Extractor: Identifies functions, imports, and API routes
  • Mock Security Analysis: Detects common vulnerability patterns
  • Configuration System: YAML-based policy configuration

โœ… Implemented (Week 2)

  • Semgrep Integration: Custom AI-generated code rules with 5 specialized patterns
  • Knowledge Graph: Postgres + pgvector for code relationship tracking
  • Reachability Engine: Cross-file vulnerability analysis
  • Real LLM Integration: Claude 3.5 Sonnet with structured outputs
  • LangGraph Self-Critique: AI validation loop for improved accuracy
  • Hybrid Analysis: Signal deduplication and intelligent triage
  • GitHub Integration: PR comments, check runs, and suggested changes
  • Docker Compose: Full microservices deployment

โœ… Implemented (Week 3)

  • Advanced Risk Scoring: Business-aware risk formula with sensitivity analysis
  • Policy-as-Code Engine: YAML-based automated triage decisions
  • Real Tree-sitter: Production AST parsing with symbol resolution
  • Sensitive Data Detection: Automatic identification of restricted data patterns
  • Exploitability Simulation: LLM-generated exploit commands for critical findings
  • Slack/Teams Integration: Human-in-the-loop triage for uncertain findings
  • CLI Explain Command: Interactive teacher-mode explanations for developers
  • Code Snippet Optimization: Context-aware LLM prompt optimization

๏ฟฝ In Progress (Week 4)

  • Fix Generation: AI-powered vulnerability remediation with code patches
  • VS Code Extension: Real-time security linting and suggestions
  • Enterprise Features: SSO, team management, advanced reporting

๐Ÿ“… Planned (Future)

  • Multi-language Support: Java, Go, Rust, JavaScript frameworks
  • Advanced Analytics: Security metrics, trends, and compliance reporting
  • Custom Rule Builder: Visual interface for creating security rules

๐Ÿ” Vulnerability Detection

The platform focuses on AI-specific security issues:

AI-Generated Code Patterns

  • IDOR Vulnerabilities: Missing authorization in destructive operations
  • Injection Flaws: SQL/command injection in LLM-generated code
  • Insecure AI Agents: Dangerous tools without proper safeguards
  • Prompt Injection: Missing input validation in AI systems
  • Hallucinated APIs: Non-existent libraries and methods

Example Detection

# โŒ Vulnerable: No authorization check
@app.delete("/users/{user_id}")
def delete_user(user_id: int):
    query = f"DELETE FROM users WHERE id = {user_id}"
    db.execute(query)  # IDOR vulnerability
$ curl -X POST "http://localhost:8004/analyze" \
  -H "Content-Type: application/json" \
  -d '{
    "file_paths": ["examples/sensitive_payment_data.py"],
    "enable_llm": true,
    "enable_reachability": true
  }'

๐Ÿšจ Found 1 security issue:
1. [critical] Payment data exposure without authorization
   ๐Ÿ“ sensitive_payment_data.py:8
   ๐Ÿ’ก Accessing restricted payment data via public API without proper controls
   ๐Ÿ”ง BLOCK: This violates policy "Protect Restricted Data"
   ๐Ÿ“Š Risk Score: 92.5/100 | Policy: BLOCK | Sources: [semgrep, llm, risk_scoring, policy_engine]
   ๐Ÿ’ฌ Exploit: curl -X GET 'http://localhost:8000/admin/payments'

โš™๏ธ Configuration

Create an aisec.yaml file to customize scanning:

# AISec Configuration File - Week 3 Policy-as-Code
# This file defines policies for security scanning and automated decisions

# Policy-as-Code rules
policies:
  # Protect restricted data - BLOCK any access without proper controls
  - name: "Protect Restricted Data"
    description: "Block any access to restricted/sensitive data without proper controls"
    if: "data_sensitivity == restricted && reachability > 0.5"
    then: "BLOCK"
    priority: 10
    enabled: true

  # Payment data protection
  - name: "Payment Data Protection"
    description: "Block any issues with payment/financial data"
    if: "sensitive_patterns contains payment && risk_level in [medium, high, critical]"
    then: "BLOCK"
    priority: 15
    enabled: true

# Risk Scoring settings
risk_scoring:
  # Sensitivity multipliers
  sensitivity_multipliers:
    restricted: 2.0
    confidential: 1.5
    internal: 1.0
    public: 0.5

# Human-in-the-loop settings
human_in_the_loop:
  enabled: true
  triage_conditions:
    - "risk_level == high && confidence < 0.7"
    - "sensitive_patterns contains payment && confidence < 0.9"

๐Ÿงช Development

Running Tests

# Run Go tests
go test ./...

# Run Python tests
python -m pytest tests/

# Run all tests
make test

Development Services

# Start all services with Docker Compose
docker-compose up -d

# Start individual services locally
make run-semgrep    # Port 8002
make run-kg         # Port 8003  
make run-llm        # Port 8005
make run-hybrid     # Port 8004
make run-risk       # Port 8007
make run-policy     # Port 8008
make run-ast        # Port 8009
make run-slack      # Port 8010

# Test Week 3 features
make test-risk      # Test advanced risk scoring
make test-policy    # Test policy engine
make test-ast       # Test AST symbol resolution
make test-slack     # Test Slack triage

# Week 3 demo
make demo-week3

# CLI explain command
./bin/aisec explain idor-001 --teacher --verbose

Project Structure

SEC-OSS/
โ”œโ”€โ”€ cmd/aisec/                    # CLI application
โ”œโ”€โ”€ internal/                     # Internal packages
โ”‚   โ”œโ”€โ”€ auth/                    # Authentication logic
โ”‚   โ”œโ”€โ”€ cli/                     # CLI commands (including explain)
โ”‚   โ”œโ”€โ”€ scanner/                 # Core scanning engine
โ”‚   โ””โ”€โ”€ parser/                  # AST parsing
โ”œโ”€โ”€ pkg/                         # Public packages
โ”‚   โ”œโ”€โ”€ ast/                     # AST utilities
โ”‚   โ””โ”€โ”€ config/                  # Configuration
โ”œโ”€โ”€ services/                    # Python microservices
โ”‚   โ”œโ”€โ”€ semgrep_service.py       # Deterministic scanning
โ”‚   โ”œโ”€โ”€ knowledge_graph.py       # Code relationships
โ”‚   โ”œโ”€โ”€ real_llm_analysis.py     # Claude 3.5 Sonnet
โ”‚   โ”œโ”€โ”€ hybrid_analysis.py       # Signal fusion (updated)
โ”‚   โ”œโ”€โ”€ risk_scoring.py          # Business-aware risk scoring
โ”‚   โ”œโ”€โ”€ policy_engine.py         # Policy-as-Code engine
โ”‚   โ”œโ”€โ”€ real_ast_parser.py       # Production AST parsing
โ”‚   โ”œโ”€โ”€ slack_integration.py      # Human-in-the-loop triage
โ”‚   โ”œโ”€โ”€ github_integration.py    # PR automation
โ”‚   โ””โ”€โ”€ tree_sitter_service.py  # AST extraction
โ”œโ”€โ”€ examples/                    # Example vulnerable code
โ”‚   โ”œโ”€โ”€ cross_file_vulnerability.py
โ”‚   โ”œโ”€โ”€ database_utils.py
โ”‚   โ”œโ”€โ”€ vulnerable_code.py
โ”‚   โ””โ”€โ”€ sensitive_payment_data.py  # Week 3 demo
โ”œโ”€โ”€ scripts/                     # Database initialization
โ”œโ”€โ”€ docker-compose.yml           # Full stack deployment (updated)
โ”œโ”€โ”€ .env.example                 # Environment template
โ””โ”€โ”€ aisec.yaml                  # Configuration file (updated)

๐ŸŽฏ Success Metrics

MetricTarget (v1)Why it matters
MTTR< 1 hourMeasures if fixes are being used
False Positive Rate< 5%Developer adoption
"Vibe" Accuracy> 80%Explanation quality
Scan Latency< 30sDeveloper workflow

๐Ÿ›  Tech Stack

  • Language: Go (CLI/Orchestrator) + Python (AI/Analysis)
  • LLM: Claude 3.5 Sonnet (Analysis) + GPT-4o-mini (Classification)
  • Database: Supabase (Postgres + Vector + Auth)
  • Parsing: Tree-sitter (Multi-language AST)
  • Graph: Postgres (Apache Age) / Neo4j

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

๐Ÿ“„ License

MIT License - see LICENSE file for details.

๐Ÿ”— Next Steps

Week 4 Focus: Deploy AI-powered fix generation and VS Code extension for real-time security feedback.

Week 3 Achievement: โœ… "The Smart Guardrail" - Successfully implemented the Friday goal:

  1. โœ… Advanced risk scoring with business impact analysis
  2. โœ… Policy-as-Code engine with automated triage decisions
  3. โœ… Real AST parsing with symbol resolution
  4. โœ… Sensitive data detection and exploitability simulation
  5. โœ… Human-in-the-loop triage via Slack/Teams integration
  6. โœ… Interactive CLI explain command for developer education

Platform Status: ๐Ÿง  Intelligent Security Brain - The system now makes autonomous triage decisions, understands business impact, and provides intelligent guardrails that know when to block and when to stay silent.