@hoanghainh/komagu 2.2.1 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/assess/lsa/scripts/attack_chains.py +573 -0
  3. package/assess/lsa/scripts/baseline.py +14 -0
  4. package/assess/lsa/scripts/findings_to_sarif.py +11 -0
  5. package/assess/lsa/scripts/forecast.py +544 -0
  6. package/assess/lsa/scripts/merge_findings.py +14 -0
  7. package/assess/lsa/scripts/render_report.py +86 -0
  8. package/assess/lsa/tests/test_attack_chains.py +292 -0
  9. package/assess/lsa/tests/test_forecast.py +160 -0
  10. package/contracts/schemas/api-inventory-diff.schema.json +213 -0
  11. package/contracts/schemas/attack-chain.schema.json +181 -0
  12. package/contracts/schemas/bas-scenario.schema.json +217 -0
  13. package/contracts/schemas/evidence-manifest.schema.json +117 -0
  14. package/contracts/schemas/finding.schema.json +7 -0
  15. package/contracts/schemas/forecast.schema.json +172 -0
  16. package/governance/scs/__init__.py +21 -0
  17. package/governance/scs/mapping.py +133 -0
  18. package/governance/scs/pack.py +354 -0
  19. package/operate/cli/__init__.py +1 -1
  20. package/operate/cli/commands/evidence.py +138 -0
  21. package/operate/cli/commands/inventory.py +187 -0
  22. package/operate/cli/commands/simulate.py +175 -58
  23. package/operate/cli/main.py +7 -3
  24. package/operate/inventory/__init__.py +22 -0
  25. package/operate/inventory/api_inventory.py +566 -0
  26. package/operate/simulate/__init__.py +16 -0
  27. package/operate/simulate/engine.py +370 -0
  28. package/operate/simulate/loader.py +158 -0
  29. package/operate/simulate/scenarios/idc-frontier-ransomware.json +47 -0
  30. package/operate/simulate/scenarios/metabase-cve-2026-72898.json +84 -0
  31. package/operate/simulate/scenarios/times-car-breach.json +74 -0
  32. package/operate/simulate/scenarios.py +52 -0
  33. package/operate/tests/test_api_inventory.py +239 -0
  34. package/operate/tests/test_declarative_scenarios.py +169 -0
  35. package/operate/tests/test_evidence_pack.py +128 -0
  36. package/package.json +1 -1
@@ -0,0 +1,117 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "contracts/schemas/evidence-manifest.schema.json",
4
+ "title": "METI SCS & NIST CSF 2.0 Evidence Manifest",
5
+ "description": "Cryptographically hashed manifest bundling technical evidence for METI Supply Chain Security (★3/★4) and Active Cyber Defense compliance.",
6
+ "type": "object",
7
+ "required": [
8
+ "manifest_version",
9
+ "project_name",
10
+ "generated_at",
11
+ "target_system",
12
+ "frameworks",
13
+ "overall_readiness",
14
+ "controls",
15
+ "bundled_artifacts",
16
+ "disclaimer"
17
+ ],
18
+ "properties": {
19
+ "manifest_version": {
20
+ "type": "string",
21
+ "pattern": "^[0-9]+\\.[0-9]+(\\.[0-9]+)?$",
22
+ "description": "Semantic version of the evidence manifest schema."
23
+ },
24
+ "project_name": {
25
+ "type": "string",
26
+ "minLength": 1,
27
+ "description": "Target project or organization name."
28
+ },
29
+ "generated_at": {
30
+ "type": "string",
31
+ "format": "date-time",
32
+ "description": "ISO 8601 UTC timestamp of evidence pack generation."
33
+ },
34
+ "target_system": {
35
+ "type": "string",
36
+ "description": "Target codebase or API environment evaluated."
37
+ },
38
+ "frameworks": {
39
+ "type": "array",
40
+ "items": { "type": "string" },
41
+ "description": "Compliance frameworks mapped (e.g. ['METI SCS ★3', 'METI SCS ★4', 'NIST CSF 2.0', 'Active Cyber Defense Act 2025'])."
42
+ },
43
+ "overall_readiness": {
44
+ "type": "object",
45
+ "required": ["rating", "total_controls", "covered_controls", "partial_controls", "compliance_percentage"],
46
+ "properties": {
47
+ "rating": {
48
+ "type": "string",
49
+ "enum": ["SCS-★3-READY", "SCS-★4-READY", "GAP-IDENTIFIED", "INSUFFICIENT-EVIDENCE"]
50
+ },
51
+ "total_controls": { "type": "integer", "minimum": 0 },
52
+ "covered_controls": { "type": "integer", "minimum": 0 },
53
+ "partial_controls": { "type": "integer", "minimum": 0 },
54
+ "compliance_percentage": { "type": "number", "minimum": 0, "maximum": 100 }
55
+ }
56
+ },
57
+ "controls": {
58
+ "type": "array",
59
+ "items": {
60
+ "type": "object",
61
+ "required": [
62
+ "control_id",
63
+ "category",
64
+ "name_en",
65
+ "name_ja",
66
+ "tier",
67
+ "nist_csf_v2",
68
+ "status",
69
+ "evidence_files",
70
+ "description_en",
71
+ "description_ja"
72
+ ],
73
+ "properties": {
74
+ "control_id": { "type": "string" },
75
+ "category": { "type": "string" },
76
+ "name_en": { "type": "string" },
77
+ "name_ja": { "type": "string" },
78
+ "tier": { "type": "string", "enum": ["★3", "★4", "★5"] },
79
+ "nist_csf_v2": {
80
+ "type": "array",
81
+ "items": { "type": "string" }
82
+ },
83
+ "status": {
84
+ "type": "string",
85
+ "enum": ["covered", "partially_covered", "out_of_scope_organizational", "missing_evidence"]
86
+ },
87
+ "evidence_files": {
88
+ "type": "array",
89
+ "items": { "type": "string" }
90
+ },
91
+ "description_en": { "type": "string" },
92
+ "description_ja": { "type": "string" },
93
+ "action_required_ja": { "type": "string" },
94
+ "action_required_en": { "type": "string" }
95
+ }
96
+ }
97
+ },
98
+ "bundled_artifacts": {
99
+ "type": "array",
100
+ "items": {
101
+ "type": "object",
102
+ "required": ["filename", "artifact_type", "sha256", "size_bytes"],
103
+ "properties": {
104
+ "filename": { "type": "string" },
105
+ "artifact_type": { "type": "string" },
106
+ "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
107
+ "size_bytes": { "type": "integer", "minimum": 0 },
108
+ "description": { "type": "string" }
109
+ }
110
+ }
111
+ },
112
+ "disclaimer": {
113
+ "type": "string",
114
+ "description": "Legal/governance disclaimer regarding accredited assessment."
115
+ }
116
+ }
117
+ }
@@ -354,6 +354,13 @@
354
354
  "description": "Mass assignment: request that returns the stored object, e.g. 'GET /api/profile'."
355
355
  }
356
356
  }
357
+ },
358
+ "attack_chains": {
359
+ "type": "array",
360
+ "items": {
361
+ "type": "string"
362
+ },
363
+ "description": "IDs of attack chains this finding participates in."
357
364
  }
358
365
  }
359
366
  }
@@ -0,0 +1,172 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "lsa/forecast.schema.json",
4
+ "title": "Komagu security debt forecast",
5
+ "type": "object",
6
+ "required": [
7
+ "version",
8
+ "generated_at",
9
+ "has_enough_history",
10
+ "history_summary",
11
+ "projections"
12
+ ],
13
+ "properties": {
14
+ "version": {
15
+ "type": "integer",
16
+ "enum": [
17
+ 1
18
+ ]
19
+ },
20
+ "generated_at": {
21
+ "type": "string"
22
+ },
23
+ "has_enough_history": {
24
+ "type": "boolean"
25
+ },
26
+ "reason_if_insufficient": {
27
+ "type": "string"
28
+ },
29
+ "history_summary": {
30
+ "type": "object",
31
+ "required": [
32
+ "snapshot_count",
33
+ "span_days"
34
+ ],
35
+ "properties": {
36
+ "snapshot_count": {
37
+ "type": "integer"
38
+ },
39
+ "span_days": {
40
+ "type": "integer"
41
+ },
42
+ "start_date": {
43
+ "type": [
44
+ "string",
45
+ "null"
46
+ ]
47
+ },
48
+ "end_date": {
49
+ "type": [
50
+ "string",
51
+ "null"
52
+ ]
53
+ }
54
+ }
55
+ },
56
+ "rates": {
57
+ "type": "object",
58
+ "properties": {
59
+ "arrival_rate_per_week": {
60
+ "type": "number"
61
+ },
62
+ "fix_rate_per_week": {
63
+ "type": "number"
64
+ },
65
+ "net_rate_per_week": {
66
+ "type": "number"
67
+ }
68
+ }
69
+ },
70
+ "projections": {
71
+ "type": "array",
72
+ "items": {
73
+ "type": "object",
74
+ "required": [
75
+ "severity",
76
+ "current_open",
77
+ "status"
78
+ ],
79
+ "properties": {
80
+ "severity": {
81
+ "type": "string"
82
+ },
83
+ "current_open": {
84
+ "type": "integer"
85
+ },
86
+ "status": {
87
+ "type": "string",
88
+ "enum": [
89
+ "converging",
90
+ "flat",
91
+ "diverging",
92
+ "insufficient_history"
93
+ ]
94
+ },
95
+ "net_weekly_change": {
96
+ "type": "number"
97
+ },
98
+ "target_zero_date_p10": {
99
+ "type": [
100
+ "string",
101
+ "null"
102
+ ]
103
+ },
104
+ "target_zero_date_p50": {
105
+ "type": [
106
+ "string",
107
+ "null"
108
+ ]
109
+ },
110
+ "target_zero_date_p90": {
111
+ "type": [
112
+ "string",
113
+ "null"
114
+ ]
115
+ },
116
+ "target_date": {
117
+ "type": [
118
+ "string",
119
+ "null"
120
+ ]
121
+ },
122
+ "target_status": {
123
+ "type": [
124
+ "string",
125
+ "null"
126
+ ],
127
+ "enum": [
128
+ "on_track",
129
+ "at_risk",
130
+ "off_track",
131
+ "not_converging",
132
+ null
133
+ ]
134
+ },
135
+ "required_fix_rate_per_week": {
136
+ "type": [
137
+ "number",
138
+ "null"
139
+ ]
140
+ }
141
+ }
142
+ }
143
+ },
144
+ "scenarios": {
145
+ "type": "array",
146
+ "items": {
147
+ "type": "object",
148
+ "required": [
149
+ "scenario_id",
150
+ "description"
151
+ ],
152
+ "properties": {
153
+ "scenario_id": {
154
+ "type": "string"
155
+ },
156
+ "description": {
157
+ "type": "string"
158
+ },
159
+ "projected_date_range": {
160
+ "type": [
161
+ "string",
162
+ "null"
163
+ ]
164
+ },
165
+ "net_weekly_change": {
166
+ "type": "number"
167
+ }
168
+ }
169
+ }
170
+ }
171
+ }
172
+ }
@@ -0,0 +1,21 @@
1
+ """Komagu Governance & METI Supply Chain Security (SCS) Module (#271)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from governance.scs.mapping import (
6
+ LEGAL_DISCLAIMER_EN,
7
+ LEGAL_DISCLAIMER_JA,
8
+ SCS_CONTROLS,
9
+ )
10
+ from governance.scs.pack import (
11
+ EvidencePackBuilder,
12
+ compute_file_sha256,
13
+ )
14
+
15
+ __all__ = [
16
+ "SCS_CONTROLS",
17
+ "LEGAL_DISCLAIMER_JA",
18
+ "LEGAL_DISCLAIMER_EN",
19
+ "EvidencePackBuilder",
20
+ "compute_file_sha256",
21
+ ]
@@ -0,0 +1,133 @@
1
+ #!/usr/bin/env python3
2
+ """METI Supply Chain Security (SCS ★3/★4) & NIST CSF 2.0 Mapping Knowledge Base.
3
+
4
+ Maps Komagu technical audit outputs (SARIF, SBOM, BAS evidence, API inventory diffs,
5
+ Coraza WAF rules, Cross-user test reports) into official METI Supply Chain Security
6
+ evaluation requirements and NIST Cybersecurity Framework 2.0 subcategories.
7
+
8
+ Standard library only (Python 3.8+) per ADR-0006.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from typing import Any, Dict, List
14
+
15
+ LEGAL_DISCLAIMER_JA = (
16
+ "【重要事項・法的免責事項】本エビデンスパックおよびギャップ分析レポートは、"
17
+ "Komagu Modernization Platformが自律生成した技術的監査成果物をMETIサプライチェーン・"
18
+ "サイバーセキュリティ評価制度(SCS ★3/★4)およびNIST CSF 2.0の統制項目に機械的に照合した技術支援資料です。"
19
+ "本資料は経産省公認の認証機関による正式な適合性評価または認証を代替するものではありません。"
20
+ )
21
+
22
+ LEGAL_DISCLAIMER_EN = (
23
+ "IMPORTANT DISCLAIMER: This evidence pack and gap analysis report represents technical mapping "
24
+ "of automated Komagu audit artifacts against METI Supply Chain Security (SCS ★3/★4) and NIST CSF 2.0 controls. "
25
+ "This pack supports, but does not replace or constitute, a formal accredited assessment by a certified evaluation authority."
26
+ )
27
+
28
+ SCS_CONTROLS: List[Dict[str, Any]] = [
29
+ {
30
+ "control_id": "SCS-AM-01",
31
+ "category": "Asset & Surface Management",
32
+ "name_en": "Comprehensive Software & API Inventory",
33
+ "name_ja": "ソフトウェア資産およびAPIエンドポイント台帳の網羅的把握",
34
+ "tier": "★3",
35
+ "nist_csf_v2": ["ID.AM-01", "ID.AM-02"],
36
+ "expected_artifacts": ["api-inventory-diff.json", "routes.json", "route-inventory.json"],
37
+ "description_en": "Complete visibility of implemented routes, published API contracts, and active gateway traffic to eliminate undocumented shadow and zombie APIs.",
38
+ "description_ja": "ソースコード実装ルート、OpenAPI公開仕様、ゲートウェイ実トラフィックを突き合わせ、未管理のShadow APIおよび非推奨Zombie APIを網羅的に特定・管理する。",
39
+ "action_required_en": "Review detected Shadow APIs and register them in OpenAPI specification, or decommission Zombie APIs.",
40
+ "action_required_ja": "未記載のShadow APIをOpenAPI仕様書に登録するか、稼働中のZombie APIを廃止してください。",
41
+ },
42
+ {
43
+ "control_id": "SCS-AM-02",
44
+ "category": "Supply Chain Integrity",
45
+ "name_en": "Software Bill of Materials (SBOM) & Component Provenance",
46
+ "name_ja": "ソフトウェア部品表 (SBOM) の生成および依存関係リスク管理",
47
+ "tier": "★3",
48
+ "nist_csf_v2": ["ID.AM-05"],
49
+ "expected_artifacts": ["sbom-cyclonedx.json", "sbom-spdx.json", "sbom.json"],
50
+ "description_en": "Generation and tracking of standard CycloneDX 1.5 or SPDX 2.3 SBOM for all direct and transitive third-party dependencies.",
51
+ "description_ja": "すべての直接・推移的サードパーティライブラリについて、標準規格(CycloneDX 1.5 / SPDX 2.3)に準拠したSBOMを作成・追跡する。",
52
+ "action_required_en": "Update third-party dependencies with identified High/Critical CVEs or unmaintained licenses.",
53
+ "action_required_ja": "重大な脆弱性(CVE)または非推奨ライセンスが検出されたサードパーティ依存関係を更新・パッチ適用してください。",
54
+ },
55
+ {
56
+ "control_id": "SCS-AA-01",
57
+ "category": "Identity & Access Control",
58
+ "name_en": "Object-Level Access Control & BOLA/BFLA Defenses",
59
+ "name_ja": "オブジェクトレベル認可制御およびBOLA/IDOR侵害の防止",
60
+ "tier": "★3",
61
+ "nist_csf_v2": ["PR.AA-01", "PR.AA-05"],
62
+ "expected_artifacts": ["findings.sarif", "findings.json", "cross-user-test.json"],
63
+ "description_en": "Enforcement of strict object ownership checks maintaining the HTTP 404 invariant across tenant boundaries.",
64
+ "description_ja": "他テナント・他ユーザーのリソースへのアクセス試行に対し、厳格なHTTP 404 Not Found不変性を維持しデータ漏洩を防止する。",
65
+ "action_required_en": "Apply @RequireOwnership decorators or in-place parameter checks on unprotected endpoints.",
66
+ "action_required_ja": "未保護エンドポイントに対し、所有権検証デコレータまたはKomagu Boilerplate 1認可制御を実装してください。",
67
+ },
68
+ {
69
+ "control_id": "SCS-PS-01",
70
+ "category": "Platform & Perimeter Security",
71
+ "name_en": "Perimeter Virtual Patching & Edge Defense",
72
+ "name_ja": "境界防御ゲートウェイおよび脆弱性バーチャルパッチの適用",
73
+ "tier": "★3",
74
+ "nist_csf_v2": ["PR.PS-01", "PR.PS-02"],
75
+ "expected_artifacts": ["coraza.conf", "kong.yml", "waf-rules.conf"],
76
+ "description_en": "Deployment of zero-code perimeter virtual patches (OWASP Core Rule Set / Coraza WAF) intercepting zero-day probes and injection attacks.",
77
+ "description_ja": "エッジゲートウェイ(Kong / Coraza WAF)によるゼロコード・バーチャルパッチを配備し、既知・未知のインジェクション攻撃を遮断する。",
78
+ "action_required_en": "Ensure edge gateway Coraza WAF plugin is enabled with blocking mode on public endpoints.",
79
+ "action_required_ja": "公開エンドポイントに対し、Coraza WAFのブロッキングモードおよびカスタムSecRuleが有効化されていることを確認してください。",
80
+ },
81
+ {
82
+ "control_id": "SCS-CM-01",
83
+ "category": "Continuous Monitoring & Testing",
84
+ "name_en": "Automated Code Auditing & CI/CD Security Gating",
85
+ "name_ja": "継続的静的コード監査およびCI/CDセキュリティゲートウェイ運用",
86
+ "tier": "★3",
87
+ "nist_csf_v2": ["DE.CM-01"],
88
+ "expected_artifacts": ["findings.sarif", "baseline.json", "audit.sarif"],
89
+ "description_en": "Automated security scanning integrated into CI pipelines with baseline regression tracking and strict break-glass suppression governance.",
90
+ "description_ja": "CI/CDパイプラインと統合された自動セキュリティスキャン、ベースライン回帰検出、および監査ログ付き例外管理を実施する。",
91
+ "action_required_en": "Resolve unresolved Critical/High security findings prior to production deployment.",
92
+ "action_required_ja": "本番リリース前に、未解決のCritical/High脆弱性を解消するか、正式な例外申請(suppressions.json)を記録してください。",
93
+ },
94
+ {
95
+ "control_id": "SCS-IR-01",
96
+ "category": "Active Defense & Incident Response",
97
+ "name_en": "Empirical Breach & Attack Simulation (BAS)",
98
+ "name_ja": "実戦的サイバー攻撃シミュレーション(能動的サイバー防御訓練)",
99
+ "tier": "★4",
100
+ "nist_csf_v2": ["RS.MI-01", "RS.MI-02"],
101
+ "expected_artifacts": ["bas-evidence.json", "bas-report.md"],
102
+ "description_en": "Rehearsal of landmark real-world enterprise cyber attacks (Times Car BOLA, Metabase zero-day SQLi, ransomware disasters) to measure empirical resilience.",
103
+ "description_ja": "著名な実事故(Times Car大規模BOLA、MetabaseゼロデイSQLi、ランサムウェア破壊)に基づくシミュレーションを実施し、組織の能動的防御力を実証する。",
104
+ "action_required_en": "Run BAS simulations quarterly and maintain an overall Platform Resilience Index of >= 90%.",
105
+ "action_required_ja": "四半期ごとにBASシミュレーションを実行し、プラットフォーム耐性スコア(Resilience Index)90%以上を維持してください。",
106
+ },
107
+ {
108
+ "control_id": "SCS-DS-01",
109
+ "category": "Data Security & Resilience",
110
+ "name_en": "Ransomware-Resilient Immutable Storage (WORM Backup)",
111
+ "name_ja": "ランサムウェア耐性不変バックアップ(WORMストレージ保護)",
112
+ "tier": "★4",
113
+ "nist_csf_v2": ["PR.DS-11"],
114
+ "expected_artifacts": ["bas-evidence.json"],
115
+ "description_en": "Verification of Write-Once-Read-Many (WORM) storage locks and S3 Object Lock in COMPLIANCE mode preventing backup truncation and tampering.",
116
+ "description_ja": "Write-Once-Read-Many(WORM)ストレージ保護およびS3 Object Lock(コンプライアンスモード)の検証により、バックアップの改ざん・消去を防止する。",
117
+ "action_required_en": "Configure cloud storage archives with COMPLIANCE mode object lock and cross-region replication.",
118
+ "action_required_ja": "バックアップ保管先に対してコンプライアンスモードのオブジェクトロックおよびクロスリージョンレプリケーションを有効化してください。",
119
+ },
120
+ {
121
+ "control_id": "SCS-OG-01",
122
+ "category": "Organizational Governance",
123
+ "name_en": "CSIRT Incident Reporting & Vendor Notification Protocol",
124
+ "name_ja": "CSIRTインシデント報告体制およびサプライチェーン連絡網の整備",
125
+ "tier": "★3",
126
+ "nist_csf_v2": ["GV.OC-01", "GV.PO-01"],
127
+ "expected_artifacts": ["usage-policy.md", "auth-model.md"],
128
+ "description_en": "Establishment of formal incident communication channels and designated reporting protocols complying with the Active Cyber Defense Act 2025.",
129
+ "description_ja": "能動的サイバー防御法(2025年制定)に基づく重要インフラ・サプライチェーンインシデント通報手順およびCSIRT連携体制を整備・文書化する。",
130
+ "action_required_en": "Document CSIRT contact escalation matrix and prime contractor emergency notification workflow.",
131
+ "action_required_ja": "CSIRT連絡エスカレーションマトリクスおよび元請事業者・所管官庁への緊急通報手順書を策定・保管してください。",
132
+ },
133
+ ]