Skip to main content

Calculate context-aware confidence scores for security findings

Project description

Context Confidence Rating (CCR™)

License: MIT PyPI Python Version Downloads Status

A lightweight library for calculating context-aware confidence scores for security findings.

CCR helps you understand how much a security scanner actually understands your codebase's risk context—not just whether vulnerabilities exist, but whether they're actually exploitable given your application's architecture, dependencies, and security controls.

🎯 Built by Secuarden - Product Security Intelligence Platform


🚀 Quick Start

# Install
pip install context-confidence-rating

# Analyze a repository
ccr analyze /path/to/your/repo

# Get CCR for a specific finding
ccr analyze /path/to/repo --file "api/auth.py" --vuln "SQL Injection" --severity "HIGH"

💡 What is CCR?

Context Confidence Rating (CCR™) is a 0-100 score that indicates how well security analysis tools understand your codebase's actual risk context. Higher scores mean:

  • ✅ Better understanding of data flows
  • ✅ More accurate vulnerability prioritization
  • ✅ Fewer false positives to investigate
  • ✅ More reliable findings for compliance audits

The Problem It Solves

Traditional security scanners give you:

❌ "Found 500 vulnerabilities" (but 480 are noise)

CCR-enhanced analysis gives you:

✅ "Found 20 exploitable vulnerabilities (CCR 85/100 confidence)"

📊 Usage

Python API

from ccr import ContextAnalyzer

# Initialize analyzer
analyzer = ContextAnalyzer("/path/to/repo")

# Get baseline repository CCR
baseline = analyzer.calculate_repo_baseline_ccr()
print(f"Repository CCR: {baseline.score}/100")

# Calculate CCR for a specific finding
finding = {
    "file": "api/payments.py",
    "vulnerability": "SQL Injection",
    "severity": "HIGH"
}

result = analyzer.calculate_ccr(finding)
print(f"Finding CCR: {result.score}/100 ({result.confidence})")
print(f"Reasoning: {result.reasoning}")

Command Line

# Analyze repository baseline
ccr analyze /path/to/repo

# Verbose output with reasoning
ccr analyze /path/to/repo --verbose

# JSON output for CI/CD integration
ccr analyze /path/to/repo --json

# Analyze specific finding
ccr analyze /path/to/repo \
  --file "src/auth.py" \
  --vuln "Hardcoded Credentials" \
  --severity "CRITICAL"

CI/CD Integration

# .github/workflows/security.yml
name: Security Scan with CCR

on: [pull_request]

jobs:
  security:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Run SAST scanner
        run: semgrep --config=auto --json > findings.json
      
      - name: Calculate Context Confidence
        run: |
          pip install context-confidence-rating
          ccr analyze . --json > ccr-report.json
          
      - name: Check CCR threshold
        run: |
          CCR_SCORE=$(jq '.score' ccr-report.json)
          if [ "$CCR_SCORE" -lt 60 ]; then
            echo "::warning::Low context confidence ($CCR_SCORE/100) - findings may need manual review"
          fi

🔍 What CCR Analyzes

CCR examines your repository for context signals:

Signal Weight What It Means
Framework Detection 15% Understanding of web frameworks (Django, Flask, Express)
Dependency Tracking 15% Presence of requirements.txt, package.json, etc.
Data Flow Analysis 20% Ability to trace data through your code
Entry Point Mapping 15% Understanding of application entry points
Config Awareness 10% Detection of configuration files
Security Controls 15% Presence of security policies, CI/CD, CODEOWNERS
Test Coverage 10% Existence of test files and frameworks

CCR Score Ranges

  • 71-100 (High): Strong context understanding - findings highly reliable
  • 41-70 (Medium): Moderate context - some findings may need verification
  • 0-40 (Low): Limited context - manual review recommended

🎯 Use Cases

1. Vulnerability Triage

Re-rank scanner outputs based on actual exploitability in your codebase.

findings = run_security_scanner()  # Returns 500 findings
for finding in findings:
    ccr_result = analyzer.calculate_ccr(finding)
    if ccr_result.score >= 70 and finding.severity == "HIGH":
        prioritize_for_immediate_fix(finding)

2. Audit Preparation

Show auditors you have strong context understanding.

ccr_result = analyzer.calculate_repo_baseline_ccr()
print(f"Our security analysis has {ccr_result.score}/100 context confidence")
# Demonstrates mature security posture

3. Scanner Comparison

Evaluate which security tools work best for your codebase.

# Tool A gives 500 findings with CCR 45 (low confidence)
# Tool B gives 50 findings with CCR 82 (high confidence)
# → Tool B is more effective for your context

4. CI/CD Quality Gate

Fail builds when context drops below threshold.

ccr analyze . --json | jq '.score' | awk '$1 < 60 {exit 1}'

🛠️ Installation

From PyPI (when published)

pip install context-confidence-rating

From Source

git clone https://github.com/secuardenai/context-confidence-rating.git
cd context-confidence-rating
pip install -e .

Development Installation

git clone https://github.com/secuardenai/context-confidence-rating.git
cd context-confidence-rating
pip install -e ".[dev]"
pytest

📖 Example Output

============================================================
  Context Confidence Rating (CCR™) Analysis
============================================================

📊 CCR Score: 78/100
🎯 Confidence Level: HIGH
   ✓ Strong context understanding - findings highly reliable

📋 Context Signals Detected:
   ✓ Framework Detection (+15 points)
      Frameworks: Flask, SQLAlchemy
   ✓ Dependency Tracking (+15 points)
      Files: requirements.txt, Pipfile.lock
   ✓ Data Flow Analysis (+20 points)
   ✓ Entry Point Mapping (+15 points)
   ✓ Security Controls (+13 points)
      Controls: security_policy, ci_cd_pipeline, code_ownership

💡 Reasoning:
   ✓ Framework Detection
   ✓ Dependency Tracking
   ✓ Data Flow Analysis
   ✓ Entry Point Mapping
   ✓ Config Awareness
   ✓ Security Controls
   ↑ High-severity finding prioritization (+5)

📁 Repository Overview:
   Languages: Python, JavaScript
   Files: 247
   Frameworks: Flask, SQLAlchemy

💡 Recommendations:
   • Excellent context signals detected!
   • Consider integrating CCR into your CI/CD pipeline

============================================================

🔗 Integration with Security Tools

CCR is designed to enhance—not replace—existing security scanners:

  • Semgrep: Enhance SAST findings with context scores
  • Bandit: Add confidence to Python security analysis
  • Snyk: Contextualize dependency vulnerability impact
  • GitHub Security: Prioritize CodeQL/Dependabot alerts
  • Custom Tools: Integrate via JSON output

🤝 Contributing

We welcome contributions! This is an open-source project maintained by Secuarden.

# Setup development environment
git clone https://github.com/secuardenai/context-confidence-rating.git
cd context-confidence-rating
pip install -e ".[dev]"

# Run tests
pytest

# Format code
black ccr/
flake8 ccr/

📝 License

MIT License - see LICENSE file for details.

🙏 Credits

Created by the Secuarden team.

CCR™ (Context Confidence Rating) is a trademark of Appsec360.


🚀 Want More?

CCR is the open-source foundation of Secuarden - our Product Security Intelligence Platform that:

  • 🔍 Transforms generic SAST findings into audit-ready compliance evidence
  • 🎯 Prioritizes vulnerabilities using CCR + exploitability analysis
  • 📊 Maps findings to SOC 2, ISO 27001, PCI-DSS requirements
  • 🤖 Generates AI-powered remediation with context-aware code suggestions
  • ✅ Provides PR-level security enforcement with intelligent blocking

Try Secuarden Free →


Questions? Open an issue or email hello@secuarden.com

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

context_confidence_rating-0.1.2.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

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

context_confidence_rating-0.1.2-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file context_confidence_rating-0.1.2.tar.gz.

File metadata

File hashes

Hashes for context_confidence_rating-0.1.2.tar.gz
Algorithm Hash digest
SHA256 24f4ba58ffbaccfe0d89f9a33a21949c89e3360af29cc67df56d59a87c72cd77
MD5 0a0d303f0a9926cbbafa6410ee913ef2
BLAKE2b-256 711e5af3e867ef27ef44874b1b637e1bb73a9a5c9e7406c7b18031fb7e941a9a

See more details on using hashes here.

File details

Details for the file context_confidence_rating-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for context_confidence_rating-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f58f643d3844c884eaa3ccfba911a2f6522ffbf6c5c7c3baf4215955496d1960
MD5 39fa2f322e92ee71fb964832212bb10e
BLAKE2b-256 943223dc81b33b6683b241beb47e68b4e5127442d8bf9dc28cb4ce7ddcdf20a8

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