Calculate context-aware confidence scores for security findings
Project description
Context Confidence Rating (CCR™)
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/secuarden/context-confidence-rating.git
cd context-confidence-rating
pip install -e .
Development Installation
git clone https://github.com/secuarden/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/secuarden/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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file context_confidence_rating-0.1.0.tar.gz.
File metadata
- Download URL: context_confidence_rating-0.1.0.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2bf637287272467000a4e7ce53ba3ca41a3796a150e36fd5797c97b8a22c266c
|
|
| MD5 |
3ce4bb7d3083b0d075cd5dc998df5334
|
|
| BLAKE2b-256 |
e429c06e5ccd591142e9595e9c2ae7aeacb387749b83dc12721f72705c8cca4f
|
File details
Details for the file context_confidence_rating-0.1.0-py3-none-any.whl.
File metadata
- Download URL: context_confidence_rating-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4b03c18e523ec4557deb68b95ff4290bf5fedf2a2e2bac98806327827e5d7fd
|
|
| MD5 |
d62e024f250fe1ace956ccfb1d857628
|
|
| BLAKE2b-256 |
99ce4bd2fd53375f6c71353f37935193cbfee00f5e8faf2fc581dd6a3a5b4ef8
|