Compliance and Health Scoring

Built-in compliance rules evaluate resources for security, cost, reliability, and governance issues with an overall health score.

Overview

Knowledge Tree includes a compliance engine that evaluates every discovered resource against built-in rules. The compliance API returns an overall score (0-100), a letter grade (A-F), and detailed findings with remediation steps.

curl http://localhost:8080/api/v1/compliance

Compliance Score

The score starts at 100 and is reduced by findings:

SeverityDeductionCriteria
Critical-15Data exposure, public databases, unencrypted secrets
High-10Missing encryption, open management ports, single-AZ databases
Medium-5Missing logging, no backup, idle resources, missing tags
Low-2Naming violations, non-critical config drift

Built-in Rules

Security

Rule IDNameSeverityChecks
SEC-001Unencrypted EBS VolumeHighEBS volumes should be encrypted at rest
SEC-002Publicly Accessible RDSCriticalRDS instances should not be publicly accessible
SEC-003S3 Bucket Public AccessCriticalS3 buckets should block public access
SEC-004Security Group Open IngressHighSecurity groups should not allow 0.0.0.0/0 on SSH/RDP/DB ports

Cost Optimization

Rule IDNameSeverityChecks
COST-001Idle EC2 InstanceMediumRunning instances with low CPU utilization
COST-002Unattached EBS VolumeMediumVolumes not attached to any instance

Reliability

Rule IDNameSeverityChecks
REL-001Single-AZ RDSHighProduction databases should use Multi-AZ
REL-002No Backup RetentionHighDatabases should have backup retention configured

Governance

Rule IDNameSeverityChecks
GOV-001Missing Required TagsMediumResources should have environment and owner tags

Response Format

{
  "score": 72,
  "grade": "C",
  "resource_count": 150,
  "findings_count": 12,
  "by_category": [
    {"category": "security", "score": 60, "finding_count": 5},
    {"category": "cost", "score": 85, "finding_count": 3},
    {"category": "reliability", "score": 70, "finding_count": 2},
    {"category": "governance", "score": 65, "finding_count": 2}
  ],
  "by_severity": [
    {"severity": "critical", "count": 1},
    {"severity": "high", "count": 4},
    {"severity": "medium", "count": 7}
  ],
  "coverage_percent": 98.5
}