[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6AEZ30FJ41SN7WZN5TN8BC4":3,"skill-same:01M6AEZ30FJ41SN7WZN5TN8BC4":126},{"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":6,"sourceHtmlUrl":16,"categories":17,"keywords":28,"publishedAt":48,"linkOnly":49,"markdownContent":50,"markdownBody":51,"frontMatter":52,"refName":65,"commitSha":66,"skillDirectory":67,"forksCount":68,"repositoryHtmlUrl":69,"repositoryHomepageUrl":70,"ownerHtmlUrl":71,"ownerBlogUrl":72,"ownerDescription":73,"updatedAt":74,"install":75,"resources":88},"01M6AEZ30FJ41SN7WZN5TN8BC4","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.","mukul975\u002FAnthropic-Cybersecurity-Skills","mukul975","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F42860185?v=4","01M6ADEQR8T5M4EEG6C67BQCWF","Mahipal","01M6ADJPMYWG1E5GM1FWBE3128",35990,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fimplementing-api-security-posture-management\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47],"security","implementing api security posture management","api-inventory","sast","risk-scoring","api-posture-management","aspm","risk","continuous-monitoring","t1059","api-governance","policy","api-discovery","dast","api-security","monitoring","pr","governance","cybersecurity","2026-11-10 10:12:30",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":53,"author":54,"domain":47,"license":15,"version":55,"nist_csf":56,"subdomain":43,"description":7,"mitre_attack":61},[43,35,34,41,33,39,37,31],"mahipal","1.0",[57,58,59,60],"PR.PS-01","ID.RA-01","PR.DS-10","DE.CM-01",[62,63,64],"T1190","T1059.007","T1552.001","main","54a798831d2266a3ca61ce68a7acb80b81160d57","skills\u002Fimplementing-api-security-posture-management",4395,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills","https:\u002F\u002Fmahipal.engineer\u002FAnthropic-Cybersecurity-Skills\u002F","https:\u002F\u002Fgithub.com\u002Fmukul975","Mahipal.engineer","🔐 Cybersecurity | 💻 Dev | 📷 Street Photographer\r\n🎓 MSc | 📚 Research & AI Security","2026-08-31 12:32:44",{"source":8,"skillName":5,"commands":76,"prompt":86,"zipAvailable":87},[77,80,83],{"tool":78,"command":79},"npx","npx skills add mukul975\u002FAnthropic-Cybersecurity-Skills --skill implementing-api-security-posture-management",{"tool":81,"command":82},"bunx","bunx skills add mukul975\u002FAnthropic-Cybersecurity-Skills --skill implementing-api-security-posture-management",{"tool":84,"command":85},"pnpm","pnpm dlx skills add mukul975\u002FAnthropic-Cybersecurity-Skills --skill implementing-api-security-posture-management","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fimplementing-api-security-posture-management\u002FSKILL.md",true,[89,95,99,104,110,114,118,122],{"path":90,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":93,"sourceHtmlUrl":94},"bin\u002Fresolve_caller_target.sh","SCRIPT","脚本",634,"https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fcmux-goal\u002Fbin\u002Fresolve_caller_target.sh",{"path":96,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":97,"sourceHtmlUrl":98},"bin\u002Fself_goal.py",9213,"https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fcmux-goal\u002Fbin\u002Fself_goal.py",{"path":100,"resourceType":100,"resourceTypeDesc":101,"sizeBytes":102,"sourceHtmlUrl":103},"LICENSE","许可证",11255,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fimplementing-api-security-posture-management\u002FLICENSE",{"path":105,"resourceType":106,"resourceTypeDesc":107,"sizeBytes":108,"sourceHtmlUrl":109},"references\u002Fapi-reference.md","REFERENCE","参考文档",1466,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fimplementing-api-security-posture-management\u002Freferences\u002Fapi-reference.md",{"path":111,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":112,"sourceHtmlUrl":113},"scripts\u002Fagent.py",6253,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fimplementing-api-security-posture-management\u002Fscripts\u002Fagent.py",{"path":115,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":116,"sourceHtmlUrl":117},"tests\u002Ftest_caller_targeting.sh",1222,"https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fcmux-goal\u002Ftests\u002Ftest_caller_targeting.sh",{"path":119,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":120,"sourceHtmlUrl":121},"tests\u002Ftest_self_goal.py",12588,"https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fcmux-goal\u002Ftests\u002Ftest_self_goal.py",{"path":123,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":124,"sourceHtmlUrl":125},"tests\u002Ftest_self_goal.sh",1713,"https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fcmux-goal\u002Ftests\u002Ftest_self_goal.sh",[127,154,177,205,231,257],{"skillNo":128,"name":129,"nameZh":6,"description":130,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":131,"categories":132,"keywords":136,"publishedAt":48},"01M6AGDM3HJXTKXX15ZZ0ZVCJ3","verifying-build-provenance-with-slsa-sigstore","Verifies artifact signatures and SLSA provenance using Sigstore's cosign (verify, verify-attestation, verify-blob-attestation) and slsa-verifier (verify-artifact), enforcing keyless OIDC builder identity and source repo against SLSA Build levels. Use in CI\u002FCD before deploying artifacts, when consuming third-party attestations, establishing a SLSA Build L3 pipeline, or confirming provenance during incident response or admission control.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fverifying-build-provenance-with-slsa-sigstore\u002FSKILL.md",[133],{"categoryNo":134,"categoryName":135,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[137,138,139,140,29,47,141,142,45,143,144,145,146,147,148,149,150,151,152,153],"sigstore","provenance","slsa","verifying build provenance with slsa sigstore","incident response","identity","code","artifacts","ci","supply-chain","pipeline","supply-chain-security","t1195","attestation","code-signing","cosign","keyless",{"skillNo":155,"name":156,"nameZh":6,"description":157,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":158,"categories":159,"keywords":161,"publishedAt":48},"01M6AGDGBPWYVZ2F11GFKJ4HZ9","validating-tpm-measured-boot-attestation","Verifies TPM 2.0 measured-boot integrity and remote attestation with tpm2-tools -- reading PCRs (tpm2_pcrread), replaying the boot event log, generating and checking signed quotes (tpm2_quote\u002Ftpm2_checkquote), and sealing secrets to a PCR policy. Use to confirm a system booted trusted firmware\u002Fkernel for Zero Trust device posture, detect boot-chain tampering via PCR drift, or build a golden-value baseline for fleet attestation.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fvalidating-tpm-measured-boot-attestation\u002FSKILL.md",[160],{"categoryNo":134,"categoryName":135,"taxonomyType":21,"taxonomyTypeDesc":22},[162,150,163,164,29,40,47,45,165,166,167,168,169,170,171,172,173,174,175,176],"boot","TPM","validating tpm measured boot attestation","verification","ZeRO","firmware","Tools","measured-boot","PCR","integrity","secrets","remote-attestation","tpm2-tools","integrity-verification","trusted-computing",{"skillNo":178,"name":179,"nameZh":6,"description":180,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":181,"categories":182,"keywords":187,"publishedAt":48},"01M6AGDCW0Y4FXZ3362GT1941M","validating-backup-integrity-for-recovery","Validates backup integrity through cryptographic hash verification, automated restore testing, corruption detection, and recoverability checks to confirm backups are reliable for disaster recovery and ransomware response. Use before relying on backups for recovery, when building post-backup validation pipelines, auditing backup infrastructure for compliance, or checking immutable\u002Fair-gapped backups for silent corruption or tampering.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fvalidating-backup-integrity-for-recovery\u002FSKILL.md",[183,186],{"categoryNo":184,"categoryName":185,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量",{"categoryNo":134,"categoryName":135,"taxonomyType":21,"taxonomyTypeDesc":22},[171,188,189,190,191,47,192,193,165,194,195,196,197,198,199,200,201,202,203,204],"backup","recovery","validating backup integrity for recovery","testing","infrastructure","validation","compliance","hash-verification","incident-response","ransomware","cryptocurrency","detection","t1078","t1490","immutable","disaster-recovery","restore-testing",{"skillNo":206,"name":207,"nameZh":6,"description":208,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":209,"categories":210,"keywords":212,"publishedAt":48},"01M6AGD9GBG2KZ336AE763J3WH","triaging-windows-with-kape","Runs KAPE (Kroll Artifact Parser and Extractor) to collect targeted forensic artifacts (registry hives, $MFT, event logs, prefetch, browser data) via Targets and parse them with Modules wrapping Eric Zimmerman's EZ Tools (PECmd, MFTECmd, RECmd). Use during early incident containment\u002Ftriage when full disk imaging is impractical but a defensible, parseable Windows artifact set is needed quickly, including at-scale remote collection.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Ftriaging-windows-with-kape\u002FSKILL.md",[211],{"categoryNo":134,"categoryName":135,"taxonomyType":21,"taxonomyTypeDesc":22},[213,214,215,47,216,217,218,219,220,221,222,223,224,225,226,227,168,228,229,230],"windows","kape","triaging windows with kape","registry","browser","logs","windows-forensics","dfir","mft","mftecmd","data","prefetch","eric-zimmerman","digital-forensics","SET","collection","pecmd","artifact-collection",{"skillNo":232,"name":233,"nameZh":6,"description":234,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":235,"categories":236,"keywords":238,"publishedAt":48},"01M6AGD5PW5J4EVZM958WD74ZQ","triaging-vulnerabilities-with-ssvc-framework","Triages and prioritizes vulnerabilities with CISA's Stakeholder-Specific Vulnerability Categorization (SSVC) decision tree, weighing exploitation status (via the CISA KEV catalog and FIRST EPSS API), technical impact, automatability, and mission prevalence to output Track\u002FTrack*\u002FAttend\u002FAct decisions. Use when prioritizing vulnerability scan results (OpenVAS, Nessus, Qualys) for remediation planning beyond raw CVSS scores.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Ftriaging-vulnerabilities-with-ssvc-framework\u002FSKILL.md",[237],{"categoryNo":134,"categoryName":135,"taxonomyType":21,"taxonomyTypeDesc":22},[239,240,241,47,242,243,244,245,246,247,248,249,250,251,36,252,253,254,255,256],"vulnerabilities","framework","triaging vulnerabilities with ssvc framework","status","planning","CISA","vulnerability-management","risk-management","nessus","qualys","openvas","cvss","remediation","vulnerability","api","prioritization","ssvc","decision-tree",{"skillNo":258,"name":259,"nameZh":6,"description":260,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":261,"categories":262,"keywords":264,"publishedAt":48},"01M6AGD24TTQQM4CXG69E3B9TJ","triaging-security-incident","Performs initial triage of security incidents using the NIST SP 800-61r3 and SANS PICERL frameworks, classifying incident type, assigning priority by business impact, and routing to the appropriate response team. Use when a SIEM\u002FEDR alert needs human classification, concurrent alerts must be prioritized, or a user report or threat-intel IOC match requires initial incident categorization.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Ftriaging-security-incident\u002FSKILL.md",[263],{"categoryNo":134,"categoryName":135,"taxonomyType":21,"taxonomyTypeDesc":22},[29,265,47,266,267,268,269,270,271,272,273,200,274,201,275,276,277,278,279,280],"triaging security incident","siem","file","ioc","soc","NIST-800-61","NIST","severity","edr","execution","analysis","classification","severity-classification","incident-triage","SANS-PICERL","SOC-operations"]