[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7E47QSWAE1PWAZV1KCSSR5D":3,"skill-same:01M7E47QSWAE1PWAZV1KCSSR5D":84},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":46,"commitSha":47,"skillDirectory":48,"forksCount":49,"repositoryHtmlUrl":50,"repositoryHomepageUrl":6,"ownerHtmlUrl":51,"ownerBlogUrl":6,"ownerDescription":52,"updatedAt":53,"install":54,"resources":67},"01M7E47QSWAE1PWAZV1KCSSR5D","implementing-api-security-posture-management",null,"Implements API Security Posture Management (API-SPM) to continuously discover, classify, and risk-score APIs -- including internal, external, partner, and shadow endpoints -- while aggregating findings from DAST, SAST, SCA, and runtime monitoring into a unified risk view. Use when building continuous API inventory and risk-scoring, detecting configuration drift or policy violations, or unifying API risk visibility across an organization.","sanjeevafk\u002Fagent-skills","sanjeevafk","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F230678117?v=4","01M7C540EFY46ETG1NNWKS5X3Q","Sanjeev","01M7C540F366J5C1D587BMKH9Q",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fimplementing-api-security-posture-management\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fimplementing-api-security-posture-management\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: implementing-api-security-posture-management\ndescription: Implements API Security Posture Management (API-SPM) to continuously\n  discover, classify, and risk-score APIs -- including internal, external, partner,\n  and shadow endpoints -- while aggregating findings from DAST, SAST, SCA, and runtime\n  monitoring into a unified risk view. Use when building continuous API inventory\n  and risk-scoring, detecting configuration drift or policy violations, or unifying\n  API risk visibility across an organization.\ndomain: cybersecurity\nsubdomain: api-security\ntags:\n- api-security\n- aspm\n- api-posture-management\n- api-discovery\n- risk-scoring\n- api-governance\n- continuous-monitoring\n- api-inventory\nversion: '1.0'\nauthor: mahipal\nlicense: Apache-2.0\nnist_csf:\n- PR.PS-01\n- ID.RA-01\n- PR.DS-10\n- DE.CM-01\nmitre_attack:\n- T1190\n- T1059.007\n- T1552.001\n---\n\n# Implementing API Security Posture Management\n\n## Overview\n\nAPI Security Posture Management (API-SPM) provides continuous visibility into an organization's API attack surface by automatically discovering, classifying, and risk-scoring all APIs including internal, external, partner, and shadow endpoints. Unlike point-in-time testing tools, API-SPM operates continuously to detect configuration drift, policy violations, missing security controls, sensitive data exposure, and compliance gaps. It aggregates findings from DAST, SAST, SCA, and runtime monitoring tools to provide a unified view of API risk posture across the organization.\n\n\n## When to Use\n\n- When deploying or configuring implementing api security posture management capabilities in your environment\n- When establishing security controls aligned to compliance requirements\n- When building or improving security architecture for this domain\n- When conducting security assessments that require this implementation\n\n## Prerequisites\n\n- API gateway with traffic logging (Kong, AWS API Gateway, Apigee, Envoy)\n- OpenAPI specifications for documented APIs\n- SIEM or log aggregation platform (Splunk, Elastic)\n- CI\u002FCD pipeline access for shift-left integration\n- Cloud provider APIs for infrastructure discovery\n- Python 3.8+ for custom posture assessment tooling\n\n## Core Components\n\n### 1. API Discovery and Inventory\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"API Security Posture Management Engine\n\nContinuously discovers, classifies, and risk-scores APIs\nto maintain a comprehensive security posture inventory.\n\"\"\"\n\nimport json\nimport re\nimport hashlib\nfrom datetime import datetime, timedelta\nfrom typing import Dict, List, Optional, Set\nfrom dataclasses import dataclass, field\nfrom enum import Enum\n\nclass APIClassification(Enum):\n    EXTERNAL = \"external\"\n    INTERNAL = \"internal\"\n    PARTNER = \"partner\"\n    SHADOW = \"shadow\"\n    DEPRECATED = \"deprecated\"\n\nclass RiskLevel(Enum):\n    CRITICAL = 4\n    HIGH = 3\n    MEDIUM = 2\n    LOW = 1\n    INFO = 0\n\n@dataclass\nclass SecurityControl:\n    name: str\n    present: bool\n    required: bool\n    severity: RiskLevel\n    details: str = \"\"\n\n@dataclass\nclass APIEndpoint:\n    api_id: str\n    method: str\n    path: str\n    service_name: str\n    classification: APIClassification\n    owner: Optional[str] = None\n    version: Optional[str] = None\n    first_discovered: str = \"\"\n    last_seen: str = \"\"\n    documented: bool = False\n    security_controls: List[SecurityControl] = field(default_factory=list)\n    risk_score: float = 0.0\n    sensitive_data_types: Set[str] = field(default_factory=set)\n    compliance_tags: Set[str] = field(default_factory=set)\n    traffic_volume_daily: int = 0\n\nclass APIPostureManager:\n    SENSITIVE_PATTERNS = {\n        \"ssn\": re.compile(r'\\b\\d{3}-\\d{2}-\\d{4}\\b'),\n        \"credit_card\": re.compile(r'\\b\\d{4}[- ]?\\d{4}[- ]?\\d{4}[- ]?\\d{4}\\b'),\n        \"email\": re.compile(r'\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}\\b'),\n        \"api_key\": re.compile(r'\\b[A-Za-z0-9]{32,}\\b'),\n        \"jwt\": re.compile(r'eyJ[A-Za-z0-9_-]+\\.eyJ[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+'),\n        \"phone\": re.compile(r'\\b\\+?1?\\d{10,15}\\b'),\n    }\n\n    def __init__(self):\n        self.inventory: Dict[str, APIEndpoint] = {}\n        self.policy_rules: List[dict] = []\n\n    def generate_api_id(self, method: str, path: str, service: str) -> str:\n        raw = f\"{service}:{method}:{path}\"\n        return hashlib.sha256(raw.encode()).hexdigest()[:16]\n\n    def register_api(self, method: str, path: str, service_name: str,\n                     classification: APIClassification,\n                     documented: bool = False, owner: str = None) -> APIEndpoint:\n        api_id = self.generate_api_id(method, path, service_name)\n        now = datetime.now().isoformat()\n\n        if api_id in self.inventory:\n            endpoint = self.inventory[api_id]\n            endpoint.last_seen = now\n            return endpoint\n\n        endpoint = APIEndpoint(\n            api_id=api_id,\n            method=method,\n            path=path,\n            service_name=service_name,\n            classification=classification,\n            owner=owner,\n            first_discovered=now,\n            last_seen=now,\n            documented=documented\n        )\n        self.inventory[api_id] = endpoint\n        return endpoint\n\n    def assess_security_controls(self, endpoint: APIEndpoint,\n                                  traffic_sample: dict) -> List[SecurityControl]:\n        \"\"\"Evaluate security controls present on an API endpoint.\"\"\"\n        controls = []\n\n        # Authentication check\n        has_auth = any(h in traffic_sample.get('request_headers', {})\n                      for h in ['Authorization', 'X-API-Key', 'Cookie'])\n        controls.append(SecurityControl(\n            name=\"authentication\",\n            present=has_auth,\n            required=True,\n            severity=RiskLevel.CRITICAL,\n            details=\"No authentication mechanism detected\" if not has_auth else \"Authentication present\"\n        ))\n\n        # TLS\u002FHTTPS check\n        is_https = traffic_sample.get('scheme', '').lower() == 'https'\n        controls.append(SecurityControl(\n            name=\"transport_encryption\",\n            present=is_https,\n            required=True,\n            severity=RiskLevel.CRITICAL,\n            details=\"API accessible over HTTP without TLS\" if not is_https else \"HTTPS enforced\"\n        ))\n\n        # Rate limiting check\n        has_rate_limit = any(h.startswith('X-RateLimit') or h == 'Retry-After'\n                           for h in traffic_sample.get('response_headers', {}).keys())\n        controls.append(SecurityControl(\n            name=\"rate_limiting\",\n            present=has_rate_limit,\n            required=True,\n            severity=RiskLevel.HIGH,\n            details=\"No rate limiting headers detected\" if not has_rate_limit else \"Rate limiting active\"\n        ))\n\n        # CORS policy check\n        cors_origin = traffic_sample.get('response_headers', {}).get('Access-Control-Allow-Origin', '')\n        has_strict_cors = cors_origin and cors_origin != '*'\n        controls.append(SecurityControl(\n            name=\"cors_policy\",\n            present=has_strict_cors,\n            required=endpoint.classification == APIClassification.EXTERNAL,\n            severity=RiskLevel.HIGH if cors_origin == '*' else RiskLevel.MEDIUM,\n            details=f\"CORS origin: {cors_origin}\" if cors_origin else \"No CORS headers\"\n        ))\n\n        # Security headers\n        sec_headers = traffic_sample.get('response_headers', {})\n        required_headers = {\n            'X-Content-Type-Options': 'nosniff',\n            'Strict-Transport-Security': None,\n            'X-Frame-Options': None,\n            'Cache-Control': 'no-store',\n        }\n        missing = [h for h in required_headers if h not in sec_headers]\n        controls.append(SecurityControl(\n            name=\"security_headers\",\n            present=len(missing) == 0,\n            required=True,\n            severity=RiskLevel.MEDIUM,\n            details=f\"Missing headers: {', '.join(missing)}\" if missing else \"All security headers present\"\n        ))\n\n        # Input validation (check for schema validation errors in logs)\n        has_validation = traffic_sample.get('has_schema_validation', False)\n        controls.append(SecurityControl(\n            name=\"input_validation\",\n            present=has_validation,\n            required=True,\n            severity=RiskLevel.HIGH,\n            details=\"No schema validation detected\" if not has_validation else \"Input validation active\"\n        ))\n\n        endpoint.security_controls = controls\n        return controls\n\n    def calculate_risk_score(self, endpoint: APIEndpoint) -> float:\n        \"\"\"Calculate a composite risk score (0-100) for an API endpoint.\"\"\"\n        score = 0.0\n        max_score = 0.0\n\n        # Security controls scoring\n        for control in endpoint.security_controls:\n            weight = control.severity.value * 5\n            max_score += weight\n            if not control.present and control.required:\n                score += weight\n\n        # Classification risk multiplier\n        classification_weights = {\n            APIClassification.EXTERNAL: 1.5,\n            APIClassification.PARTNER: 1.3,\n            APIClassification.SHADOW: 2.0,\n            APIClassification.DEPRECATED: 1.8,\n            APIClassification.INTERNAL: 1.0,\n        }\n        multiplier = classification_weights.get(endpoint.classification, 1.0)\n\n        # Documentation penalty\n        if not endpoint.documented:\n            score += 10\n\n        # Sensitive data penalty\n        score += len(endpoint.sensitive_data_types) * 5\n\n        # Normalize to 0-100\n        if max_score > 0:\n            normalized = min(100, (score \u002F max_score) * 100 * multiplier)\n        else:\n            normalized = 0\n\n        endpoint.risk_score = round(normalized, 1)\n        return endpoint.risk_score\n\n    def generate_posture_report(self) -> dict:\n        \"\"\"Generate organization-wide API security posture report.\"\"\"\n        total = len(self.inventory)\n        if total == 0:\n            return {\"error\": \"No APIs in inventory\"}\n\n        risk_distribution = {level.name: 0 for level in RiskLevel}\n        classification_counts = {c.value: 0 for c in APIClassification}\n        undocumented = 0\n        missing_auth = 0\n        missing_tls = 0\n\n        for endpoint in self.inventory.values():\n            self.calculate_risk_score(endpoint)\n\n            if endpoint.risk_score >= 75:\n                risk_distribution[\"CRITICAL\"] += 1\n            elif endpoint.risk_score >= 50:\n                risk_distribution[\"HIGH\"] += 1\n            elif endpoint.risk_score >= 25:\n                risk_distribution[\"MEDIUM\"] += 1\n            else:\n                risk_distribution[\"LOW\"] += 1\n\n            classification_counts[endpoint.classification.value] += 1\n\n            if not endpoint.documented:\n                undocumented += 1\n\n            for control in endpoint.security_controls:\n                if control.name == \"authentication\" and not control.present:\n                    missing_auth += 1\n                if control.name == \"transport_encryption\" and not control.present:\n                    missing_tls += 1\n\n        avg_risk = sum(e.risk_score for e in self.inventory.values()) \u002F total\n\n        return {\n            \"report_date\": datetime.now().isoformat(),\n            \"total_apis\": total,\n            \"average_risk_score\": round(avg_risk, 1),\n            \"risk_distribution\": risk_distribution,\n            \"classification\": classification_counts,\n            \"undocumented_apis\": undocumented,\n            \"missing_authentication\": missing_auth,\n            \"missing_tls\": missing_tls,\n            \"top_risks\": sorted(\n                [{\"api_id\": e.api_id, \"method\": e.method, \"path\": e.path,\n                  \"service\": e.service_name, \"risk_score\": e.risk_score,\n                  \"classification\": e.classification.value}\n                 for e in self.inventory.values()],\n                key=lambda x: x[\"risk_score\"],\n                reverse=True\n            )[:20]\n        }\n```\n\n### 2. Policy Enforcement\n\nDefine and enforce security policies across all APIs:\n\n```yaml\n# api-security-policies.yaml\npolicies:\n  - name: require-authentication\n    description: All external APIs must require authentication\n    scope:\n      classification: [external, partner]\n    rule:\n      control: authentication\n      required: true\n    severity: critical\n    remediation: \"Add OAuth2, API key, or JWT authentication\"\n\n  - name: enforce-tls\n    description: All APIs must use HTTPS\n    scope:\n      classification: [external, internal, partner]\n    rule:\n      control: transport_encryption\n      required: true\n    severity: critical\n    remediation: \"Configure TLS certificates and redirect HTTP to HTTPS\"\n\n  - name: require-rate-limiting\n    description: External APIs must implement rate limiting\n    scope:\n      classification: [external]\n    rule:\n      control: rate_limiting\n      required: true\n    severity: high\n    remediation: \"Configure rate limiting at API gateway level\"\n\n  - name: no-wildcard-cors\n    description: APIs must not use wildcard CORS origins\n    scope:\n      classification: [external]\n    rule:\n      control: cors_policy\n      condition: \"origin != '*'\"\n    severity: high\n    remediation: \"Specify explicit allowed origins in CORS configuration\"\n\n  - name: documentation-required\n    description: All APIs must have OpenAPI documentation\n    scope:\n      classification: [external, partner]\n    rule:\n      documented: true\n    severity: medium\n    remediation: \"Create and publish OpenAPI specification\"\n\n  - name: deprecation-sunset\n    description: Deprecated APIs must have sunset headers\n    scope:\n      classification: [deprecated]\n    rule:\n      header_present: \"Sunset\"\n    severity: medium\n    remediation: \"Add Sunset header with planned removal date\"\n```\n\n## Continuous Monitoring Dashboard Metrics\n\n| Metric | Description | Target |\n|--------|------------|--------|\n| API Discovery Coverage | % of APIs with documentation | > 95% |\n| Average Risk Score | Mean risk score across all APIs | \u003C 25 |\n| Critical Findings | Number of critical-risk APIs | 0 |\n| Shadow API Count | Undocumented\u002Funmanaged APIs | 0 |\n| Authentication Coverage | % of APIs with auth controls | 100% |\n| TLS Coverage | % of APIs using HTTPS | 100% |\n| Policy Compliance | % of APIs meeting all policies | > 90% |\n| Mean Time to Remediate | Average days to fix findings | \u003C 7 days |\n\n## References\n\n- OX Security ASPM Guide 2025: https:\u002F\u002Fwww.ox.security\u002Fblog\u002Fapplication-security-posture-management-aspm\u002F\n- IBM ASPM Overview: https:\u002F\u002Fwww.ibm.com\u002Fthink\u002Ftopics\u002Faspm\n- StackHawk Best ASPM Tools: https:\u002F\u002Fwww.stackhawk.com\u002Fblog\u002Fbest-aspm-tools\u002F\n- AppSentinels API Security Posture Management: https:\u002F\u002Fappsentinels.ai\u002Fblog\u002Fapi-security-posture-management-from-reactive-protection-to-continuous-governance\u002F\n- Palo Alto Networks ASPM: https:\u002F\u002Fwww.paloaltonetworks.com\u002Fcyberpedia\u002Faspm-application-security-posture-management\n","# Implementing API Security Posture Management\n\n## Overview\n\nAPI Security Posture Management (API-SPM) provides continuous visibility into an organization's API attack surface by automatically discovering, classifying, and risk-scoring all APIs including internal, external, partner, and shadow endpoints. Unlike point-in-time testing tools, API-SPM operates continuously to detect configuration drift, policy violations, missing security controls, sensitive data exposure, and compliance gaps. It aggregates findings from DAST, SAST, SCA, and runtime monitoring tools to provide a unified view of API risk posture across the organization.\n\n\n## When to Use\n\n- When deploying or configuring implementing api security posture management capabilities in your environment\n- When establishing security controls aligned to compliance requirements\n- When building or improving security architecture for this domain\n- When conducting security assessments that require this implementation\n\n## Prerequisites\n\n- API gateway with traffic logging (Kong, AWS API Gateway, Apigee, Envoy)\n- OpenAPI specifications for documented APIs\n- SIEM or log aggregation platform (Splunk, Elastic)\n- CI\u002FCD pipeline access for shift-left integration\n- Cloud provider APIs for infrastructure discovery\n- Python 3.8+ for custom posture assessment tooling\n\n## Core Components\n\n### 1. API Discovery and Inventory\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"API Security Posture Management Engine\n\nContinuously discovers, classifies, and risk-scores APIs\nto maintain a comprehensive security posture inventory.\n\"\"\"\n\nimport json\nimport re\nimport hashlib\nfrom datetime import datetime, timedelta\nfrom typing import Dict, List, Optional, Set\nfrom dataclasses import dataclass, field\nfrom enum import Enum\n\nclass APIClassification(Enum):\n    EXTERNAL = \"external\"\n    INTERNAL = \"internal\"\n    PARTNER = \"partner\"\n    SHADOW = \"shadow\"\n    DEPRECATED = \"deprecated\"\n\nclass RiskLevel(Enum):\n    CRITICAL = 4\n    HIGH = 3\n    MEDIUM = 2\n    LOW = 1\n    INFO = 0\n\n@dataclass\nclass SecurityControl:\n    name: str\n    present: bool\n    required: bool\n    severity: RiskLevel\n    details: str = \"\"\n\n@dataclass\nclass APIEndpoint:\n    api_id: str\n    method: str\n    path: str\n    service_name: str\n    classification: APIClassification\n    owner: Optional[str] = None\n    version: Optional[str] = None\n    first_discovered: str = \"\"\n    last_seen: str = \"\"\n    documented: bool = False\n    security_controls: List[SecurityControl] = field(default_factory=list)\n    risk_score: float = 0.0\n    sensitive_data_types: Set[str] = field(default_factory=set)\n    compliance_tags: Set[str] = field(default_factory=set)\n    traffic_volume_daily: int = 0\n\nclass APIPostureManager:\n    SENSITIVE_PATTERNS = {\n        \"ssn\": re.compile(r'\\b\\d{3}-\\d{2}-\\d{4}\\b'),\n        \"credit_card\": re.compile(r'\\b\\d{4}[- ]?\\d{4}[- ]?\\d{4}[- ]?\\d{4}\\b'),\n        \"email\": re.compile(r'\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}\\b'),\n        \"api_key\": re.compile(r'\\b[A-Za-z0-9]{32,}\\b'),\n        \"jwt\": re.compile(r'eyJ[A-Za-z0-9_-]+\\.eyJ[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+'),\n        \"phone\": re.compile(r'\\b\\+?1?\\d{10,15}\\b'),\n    }\n\n    def __init__(self):\n        self.inventory: Dict[str, APIEndpoint] = {}\n        self.policy_rules: List[dict] = []\n\n    def generate_api_id(self, method: str, path: str, service: str) -> str:\n        raw = f\"{service}:{method}:{path}\"\n        return hashlib.sha256(raw.encode()).hexdigest()[:16]\n\n    def register_api(self, method: str, path: str, service_name: str,\n                     classification: APIClassification,\n                     documented: bool = False, owner: str = None) -> APIEndpoint:\n        api_id = self.generate_api_id(method, path, service_name)\n        now = datetime.now().isoformat()\n\n        if api_id in self.inventory:\n            endpoint = self.inventory[api_id]\n            endpoint.last_seen = now\n            return endpoint\n\n        endpoint = APIEndpoint(\n            api_id=api_id,\n            method=method,\n            path=path,\n            service_name=service_name,\n            classification=classification,\n            owner=owner,\n            first_discovered=now,\n            last_seen=now,\n            documented=documented\n        )\n        self.inventory[api_id] = endpoint\n        return endpoint\n\n    def assess_security_controls(self, endpoint: APIEndpoint,\n                                  traffic_sample: dict) -> List[SecurityControl]:\n        \"\"\"Evaluate security controls present on an API endpoint.\"\"\"\n        controls = []\n\n        # Authentication check\n        has_auth = any(h in traffic_sample.get('request_headers', {})\n                      for h in ['Authorization', 'X-API-Key', 'Cookie'])\n        controls.append(SecurityControl(\n            name=\"authentication\",\n            present=has_auth,\n            required=True,\n            severity=RiskLevel.CRITICAL,\n            details=\"No authentication mechanism detected\" if not has_auth else \"Authentication present\"\n        ))\n\n        # TLS\u002FHTTPS check\n        is_https = traffic_sample.get('scheme', '').lower() == 'https'\n        controls.append(SecurityControl(\n            name=\"transport_encryption\",\n            present=is_https,\n            required=True,\n            severity=RiskLevel.CRITICAL,\n            details=\"API accessible over HTTP without TLS\" if not is_https else \"HTTPS enforced\"\n        ))\n\n        # Rate limiting check\n        has_rate_limit = any(h.startswith('X-RateLimit') or h == 'Retry-After'\n                           for h in traffic_sample.get('response_headers', {}).keys())\n        controls.append(SecurityControl(\n            name=\"rate_limiting\",\n            present=has_rate_limit,\n            required=True,\n            severity=RiskLevel.HIGH,\n            details=\"No rate limiting headers detected\" if not has_rate_limit else \"Rate limiting active\"\n        ))\n\n        # CORS policy check\n        cors_origin = traffic_sample.get('response_headers', {}).get('Access-Control-Allow-Origin', '')\n        has_strict_cors = cors_origin and cors_origin != '*'\n        controls.append(SecurityControl(\n            name=\"cors_policy\",\n            present=has_strict_cors,\n            required=endpoint.classification == APIClassification.EXTERNAL,\n            severity=RiskLevel.HIGH if cors_origin == '*' else RiskLevel.MEDIUM,\n            details=f\"CORS origin: {cors_origin}\" if cors_origin else \"No CORS headers\"\n        ))\n\n        # Security headers\n        sec_headers = traffic_sample.get('response_headers', {})\n        required_headers = {\n            'X-Content-Type-Options': 'nosniff',\n            'Strict-Transport-Security': None,\n            'X-Frame-Options': None,\n            'Cache-Control': 'no-store',\n        }\n        missing = [h for h in required_headers if h not in sec_headers]\n        controls.append(SecurityControl(\n            name=\"security_headers\",\n            present=len(missing) == 0,\n            required=True,\n            severity=RiskLevel.MEDIUM,\n            details=f\"Missing headers: {', '.join(missing)}\" if missing else \"All security headers present\"\n        ))\n\n        # Input validation (check for schema validation errors in logs)\n        has_validation = traffic_sample.get('has_schema_validation', False)\n        controls.append(SecurityControl(\n            name=\"input_validation\",\n            present=has_validation,\n            required=True,\n            severity=RiskLevel.HIGH,\n            details=\"No schema validation detected\" if not has_validation else \"Input validation active\"\n        ))\n\n        endpoint.security_controls = controls\n        return controls\n\n    def calculate_risk_score(self, endpoint: APIEndpoint) -> float:\n        \"\"\"Calculate a composite risk score (0-100) for an API endpoint.\"\"\"\n        score = 0.0\n        max_score = 0.0\n\n        # Security controls scoring\n        for control in endpoint.security_controls:\n            weight = control.severity.value * 5\n            max_score += weight\n            if not control.present and control.required:\n                score += weight\n\n        # Classification risk multiplier\n        classification_weights = {\n            APIClassification.EXTERNAL: 1.5,\n            APIClassification.PARTNER: 1.3,\n            APIClassification.SHADOW: 2.0,\n            APIClassification.DEPRECATED: 1.8,\n            APIClassification.INTERNAL: 1.0,\n        }\n        multiplier = classification_weights.get(endpoint.classification, 1.0)\n\n        # Documentation penalty\n        if not endpoint.documented:\n            score += 10\n\n        # Sensitive data penalty\n        score += len(endpoint.sensitive_data_types) * 5\n\n        # Normalize to 0-100\n        if max_score > 0:\n            normalized = min(100, (score \u002F max_score) * 100 * multiplier)\n        else:\n            normalized = 0\n\n        endpoint.risk_score = round(normalized, 1)\n        return endpoint.risk_score\n\n    def generate_posture_report(self) -> dict:\n        \"\"\"Generate organization-wide API security posture report.\"\"\"\n        total = len(self.inventory)\n        if total == 0:\n            return {\"error\": \"No APIs in inventory\"}\n\n        risk_distribution = {level.name: 0 for level in RiskLevel}\n        classification_counts = {c.value: 0 for c in APIClassification}\n        undocumented = 0\n        missing_auth = 0\n        missing_tls = 0\n\n        for endpoint in self.inventory.values():\n            self.calculate_risk_score(endpoint)\n\n            if endpoint.risk_score >= 75:\n                risk_distribution[\"CRITICAL\"] += 1\n            elif endpoint.risk_score >= 50:\n                risk_distribution[\"HIGH\"] += 1\n            elif endpoint.risk_score >= 25:\n                risk_distribution[\"MEDIUM\"] += 1\n            else:\n                risk_distribution[\"LOW\"] += 1\n\n            classification_counts[endpoint.classification.value] += 1\n\n            if not endpoint.documented:\n                undocumented += 1\n\n            for control in endpoint.security_controls:\n                if control.name == \"authentication\" and not control.present:\n                    missing_auth += 1\n                if control.name == \"transport_encryption\" and not control.present:\n                    missing_tls += 1\n\n        avg_risk = sum(e.risk_score for e in self.inventory.values()) \u002F total\n\n        return {\n            \"report_date\": datetime.now().isoformat(),\n            \"total_apis\": total,\n            \"average_risk_score\": round(avg_risk, 1),\n            \"risk_distribution\": risk_distribution,\n            \"classification\": classification_counts,\n            \"undocumented_apis\": undocumented,\n            \"missing_authentication\": missing_auth,\n            \"missing_tls\": missing_tls,\n            \"top_risks\": sorted(\n                [{\"api_id\": e.api_id, \"method\": e.method, \"path\": e.path,\n                  \"service\": e.service_name, \"risk_score\": e.risk_score,\n                  \"classification\": e.classification.value}\n                 for e in self.inventory.values()],\n                key=lambda x: x[\"risk_score\"],\n                reverse=True\n            )[:20]\n        }\n```\n\n### 2. Policy Enforcement\n\nDefine and enforce security policies across all APIs:\n\n```yaml\n# api-security-policies.yaml\npolicies:\n  - name: require-authentication\n    description: All external APIs must require authentication\n    scope:\n      classification: [external, partner]\n    rule:\n      control: authentication\n      required: true\n    severity: critical\n    remediation: \"Add OAuth2, API key, or JWT authentication\"\n\n  - name: enforce-tls\n    description: All APIs must use HTTPS\n    scope:\n      classification: [external, internal, partner]\n    rule:\n      control: transport_encryption\n      required: true\n    severity: critical\n    remediation: \"Configure TLS certificates and redirect HTTP to HTTPS\"\n\n  - name: require-rate-limiting\n    description: External APIs must implement rate limiting\n    scope:\n      classification: [external]\n    rule:\n      control: rate_limiting\n      required: true\n    severity: high\n    remediation: \"Configure rate limiting at API gateway level\"\n\n  - name: no-wildcard-cors\n    description: APIs must not use wildcard CORS origins\n    scope:\n      classification: [external]\n    rule:\n      control: cors_policy\n      condition: \"origin != '*'\"\n    severity: high\n    remediation: \"Specify explicit allowed origins in CORS configuration\"\n\n  - name: documentation-required\n    description: All APIs must have OpenAPI documentation\n    scope:\n      classification: [external, partner]\n    rule:\n      documented: true\n    severity: medium\n    remediation: \"Create and publish OpenAPI specification\"\n\n  - name: deprecation-sunset\n    description: Deprecated APIs must have sunset headers\n    scope:\n      classification: [deprecated]\n    rule:\n      header_present: \"Sunset\"\n    severity: medium\n    remediation: \"Add Sunset header with planned removal date\"\n```\n\n## Continuous Monitoring Dashboard Metrics\n\n| Metric | Description | Target |\n|--------|------------|--------|\n| API Discovery Coverage | % of APIs with documentation | > 95% |\n| Average Risk Score | Mean risk score across all APIs | \u003C 25 |\n| Critical Findings | Number of critical-risk APIs | 0 |\n| Shadow API Count | Undocumented\u002Funmanaged APIs | 0 |\n| Authentication Coverage | % of APIs with auth controls | 100% |\n| TLS Coverage | % of APIs using HTTPS | 100% |\n| Policy Compliance | % of APIs meeting all policies | > 90% |\n| Mean Time to Remediate | Average days to fix findings | \u003C 7 days |\n\n## References\n\n- OX Security ASPM Guide 2025: https:\u002F\u002Fwww.ox.security\u002Fblog\u002Fapplication-security-posture-management-aspm\u002F\n- IBM ASPM Overview: https:\u002F\u002Fwww.ibm.com\u002Fthink\u002Ftopics\u002Faspm\n- StackHawk Best ASPM Tools: https:\u002F\u002Fwww.stackhawk.com\u002Fblog\u002Fbest-aspm-tools\u002F\n- AppSentinels API Security Posture Management: https:\u002F\u002Fappsentinels.ai\u002Fblog\u002Fapi-security-posture-management-from-reactive-protection-to-continuous-governance\u002F\n- Palo Alto Networks ASPM: https:\u002F\u002Fwww.paloaltonetworks.com\u002Fcyberpedia\u002Faspm-application-security-posture-management\n",{"name":5,"tags":25,"author":34,"domain":35,"license":15,"version":36,"nist_csf":37,"subdomain":26,"description":7,"mitre_attack":42},[26,27,28,29,30,31,32,33],"api-security","aspm","api-posture-management","api-discovery","risk-scoring","api-governance","continuous-monitoring","api-inventory","mahipal","cybersecurity","1.0",[38,39,40,41],"PR.PS-01","ID.RA-01","PR.DS-10","DE.CM-01",[43,44,45],"T1190","T1059.007","T1552.001","main","4e084e84eb42fc53e144c89c0f7f48b39c8a4b0f","collections\u002Fcybersecurity-skills\u002Fskills\u002Fimplementing-api-security-posture-management",1,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills","https:\u002F\u002Fgithub.com\u002Fsanjeevafk","First make it work. Then make it right. Then make it fast.","2026-11-14 13:36:16",{"source":8,"skillName":5,"commands":55,"prompt":65,"zipAvailable":66},[56,59,62],{"tool":57,"command":58},"npx","npx skills add sanjeevafk\u002Fagent-skills --skill implementing-api-security-posture-management",{"tool":60,"command":61},"bunx","bunx skills add sanjeevafk\u002Fagent-skills --skill implementing-api-security-posture-management",{"tool":63,"command":64},"pnpm","pnpm dlx skills add sanjeevafk\u002Fagent-skills --skill implementing-api-security-posture-management","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fimplementing-api-security-posture-management\u002FSKILL.md",true,[68,72,78],{"path":69,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":71,"sourceHtmlUrl":16},"LICENSE","许可证",11255,{"path":73,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":76,"sourceHtmlUrl":77},"references\u002Fapi-reference.md","REFERENCE","参考文档",1466,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fimplementing-api-security-posture-management\u002Freferences\u002Fapi-reference.md",{"path":79,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":82,"sourceHtmlUrl":83},"scripts\u002Fagent.py","SCRIPT","脚本",6253,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fimplementing-api-security-posture-management\u002Fscripts\u002Fagent.py",[85,93,101,109,117,124],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":89,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":20},"01M7EFHX67M3KKXT1BXVPA5ADT","zarr-python","Chunked N-D arrays for cloud storage (Zarr-Python 3). Compressed arrays, parallel I\u002FO, S3\u002FGCS via fsspec, NumPy\u002FDask\u002FXarray compatible, for large-scale scientific computing pipelines.","MIT","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzarr-python\u002FSKILL.md",[],[],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":89,"licenseFileUrl":97,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":20},"01M7EFFQGM51TZBGRENXY50ZYM","whiteboard-diagrams","Create accurate, simple, hand-drawn whiteboard diagrams from a user's process, system, architecture, learning workflow, comparison, or causal explanation. Use when the user asks for a scribbly whiteboard visual, educational workflow graphic, hand-drawn explainer, or diagram like the bundled reference; ask one focused clarification question when the subject or relationships are missing, then generate and visually verify the final image.","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwhiteboard-diagrams\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwhiteboard-diagrams\u002FSKILL.md",[],[],{"skillNo":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":105,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":20},"01M7EFF1CSQNTDMHFK4ZGY6NYK","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwebapp-testing\u002FSKILL.md",[],[],{"skillNo":110,"name":111,"nameZh":6,"description":112,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":113,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":20},"01M7EFE8106X6C28FT8PA74427","web-artifacts-builder","Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn\u002Fui). Use for complex artifacts requiring state management, routing, or shadcn\u002Fui components - not for simple single-file HTML\u002FJSX artifacts.","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fweb-artifacts-builder\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fweb-artifacts-builder\u002FSKILL.md",[],[],{"skillNo":118,"name":119,"nameZh":6,"description":120,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":89,"licenseFileUrl":6,"sourceHtmlUrl":121,"categories":122,"keywords":123,"publishedAt":20},"01M7EFCSNZM9G7ZHS6F127Q71X","verification-loop","A comprehensive verification system for Claude Code sessions.","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fverification-loop\u002FSKILL.md",[],[],{"skillNo":125,"name":126,"nameZh":6,"description":127,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":89,"licenseFileUrl":128,"sourceHtmlUrl":129,"categories":130,"keywords":131,"publishedAt":20},"01M7EFCE7EZMKPRYDDNKBQ9EEH","vercel-deploy","Deploy applications and websites to Vercel. Use when the user requests deployment actions like \"deploy my app\", \"deploy and give me the link\", \"push this live\", or \"create a preview deployment\".","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fvercel-deploy\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fvercel-deploy\u002FSKILL.md",[],[]]