musubix 1.7.0 → 1.8.5

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.
@@ -23,10 +23,12 @@
23
23
  17. [YATA Global](#yata-global) *(v1.6.3)*
24
24
  18. [KGPR - Knowledge Graph Pull Request](#kgpr---knowledge-graph-pull-request) *(v1.6.4)*
25
25
  19. [YATA プラットフォーム拡張](#yata-プラットフォーム拡張) *(v1.7.0)*
26
- 20. [MCPサーバー連携](#mcpサーバー連携)
27
- 21. [YATA知識グラフ](#yata知識グラフ)
28
- 22. [ベストプラクティス](#ベストプラクティス)
29
- 23. [トラブルシューティング](#トラブルシューティング)
26
+ 20. [形式検証](#形式検証) *(v1.7.5)*
27
+ 21. [セキュリティ分析](#セキュリティ分析) *(v1.8.0)*
28
+ 22. [MCPサーバー連携](#mcpサーバー連携)
29
+ 23. [YATA知識グラフ](#yata知識グラフ)
30
+ 24. [ベストプラクティス](#ベストプラクティス)
31
+ 25. [トラブルシューティング](#トラブルシューティング)
30
32
 
31
33
  ---
32
34
 
@@ -1551,6 +1553,283 @@ console.log(`UI: ${server.getUrl()}`);
1551
1553
 
1552
1554
  ---
1553
1555
 
1556
+ ## 形式検証
1557
+
1558
+ *(v1.7.5)*
1559
+
1560
+ `@nahisaho/musubix-formal-verify` パッケージは、Z3 SMTソルバーを使用した形式検証機能を提供します。
1561
+
1562
+ ### インストール
1563
+
1564
+ ```bash
1565
+ npm install @nahisaho/musubix-formal-verify
1566
+ # オプション: WebAssemblyサポート用にz3-solverをインストール
1567
+ npm install z3-solver
1568
+ ```
1569
+
1570
+ ### Z3 SMTソルバー統合
1571
+
1572
+ ```typescript
1573
+ import { Z3Adapter, PreconditionVerifier, PostconditionVerifier } from '@nahisaho/musubix-formal-verify';
1574
+
1575
+ // Z3アダプター作成(バックエンド自動選択)
1576
+ const z3 = await Z3Adapter.create();
1577
+
1578
+ // 事前条件検証
1579
+ const preVerifier = new PreconditionVerifier(z3);
1580
+ const result = await preVerifier.verify({
1581
+ condition: { expression: 'amount > 0 && balance >= amount', format: 'javascript' },
1582
+ variables: [
1583
+ { name: 'amount', type: 'Int' },
1584
+ { name: 'balance', type: 'Int' },
1585
+ ],
1586
+ });
1587
+
1588
+ console.log(result.status); // 'valid' | 'invalid' | 'unknown' | 'error'
1589
+ ```
1590
+
1591
+ ### Hoareトリプル検証
1592
+
1593
+ ```typescript
1594
+ // {P} C {Q} の検証
1595
+ const postVerifier = new PostconditionVerifier(z3);
1596
+ const hoareResult = await postVerifier.verify({
1597
+ precondition: { expression: 'balance >= amount', format: 'javascript' },
1598
+ postcondition: { expression: 'balance_new == balance - amount', format: 'javascript' },
1599
+ preVariables: [{ name: 'balance', type: 'Int' }, { name: 'amount', type: 'Int' }],
1600
+ postVariables: [{ name: 'balance_new', type: 'Int' }],
1601
+ transition: 'balance_new == balance - amount',
1602
+ });
1603
+ ```
1604
+
1605
+ ### EARS→SMT変換
1606
+
1607
+ ```typescript
1608
+ import { EarsToSmtConverter } from '@nahisaho/musubix-formal-verify';
1609
+
1610
+ const converter = new EarsToSmtConverter();
1611
+
1612
+ // EARS要件をSMT-LIB2に変換
1613
+ const results = converter.convertMultiple([
1614
+ 'THE system SHALL validate inputs', // ubiquitous
1615
+ 'WHEN error, THE system SHALL notify user', // event-driven
1616
+ 'WHILE busy, THE system SHALL queue requests', // state-driven
1617
+ 'THE system SHALL NOT expose secrets', // unwanted
1618
+ 'IF admin, THEN THE system SHALL allow edit', // optional
1619
+ ]);
1620
+
1621
+ results.forEach(r => {
1622
+ console.log(`パターン: ${r.formula?.metadata.earsPattern.type}`);
1623
+ console.log(`SMT: ${r.formula?.smtLib2}`);
1624
+ });
1625
+ ```
1626
+
1627
+ ### トレーサビリティデータベース
1628
+
1629
+ ```typescript
1630
+ import { TraceabilityDB, ImpactAnalyzer } from '@nahisaho/musubix-formal-verify';
1631
+
1632
+ // SQLiteベースのトレーサビリティDB作成
1633
+ const db = new TraceabilityDB('./trace.db');
1634
+
1635
+ // ノード追加
1636
+ await db.addNode({ id: 'REQ-001', type: 'requirement', title: 'ユーザー認証' });
1637
+ await db.addNode({ id: 'DES-001', type: 'design', title: 'AuthService' });
1638
+ await db.addNode({ id: 'CODE-001', type: 'code', title: 'auth.ts' });
1639
+
1640
+ // トレーサビリティリンク追加
1641
+ await db.addLink({ source: 'DES-001', target: 'REQ-001', type: 'satisfies' });
1642
+ await db.addLink({ source: 'CODE-001', target: 'DES-001', type: 'implements' });
1643
+
1644
+ // 影響分析
1645
+ const analyzer = new ImpactAnalyzer(db);
1646
+ const impact = await analyzer.analyze('REQ-001');
1647
+ console.log(`影響ノード数: ${impact.totalImpacted}`);
1648
+ ```
1649
+
1650
+ ### v1.7.5 パッケージ概要
1651
+
1652
+ | パッケージ | 説明 |
1653
+ |-----------|------|
1654
+ | `@nahisaho/musubix-formal-verify` | Z3統合、Hoare検証、EARS→SMT、トレーサビリティDB |
1655
+
1656
+ ### サポートされる変数型
1657
+
1658
+ | 型 | 説明 |
1659
+ |----|------|
1660
+ | `Int` | 整数値 |
1661
+ | `Real` | 実数 |
1662
+ | `Bool` | 真偽値 |
1663
+ | `String` | 文字列 |
1664
+ | `Array` | 配列型 |
1665
+ | `BitVec` | ビットベクトル |
1666
+
1667
+ ---
1668
+
1669
+ ## セキュリティ分析
1670
+
1671
+ *(v1.8.0)*
1672
+
1673
+ `@nahisaho/musubix-security` パッケージは、TypeScript/JavaScriptプロジェクト向けの包括的なセキュリティ分析機能を提供します。
1674
+
1675
+ ### インストール
1676
+
1677
+ ```bash
1678
+ npm install @nahisaho/musubix-security
1679
+ ```
1680
+
1681
+ ### 脆弱性スキャン
1682
+
1683
+ AST解析によりOWASP Top 10およびCWE Top 25の脆弱性を検出します:
1684
+
1685
+ ```typescript
1686
+ import { VulnerabilityScanner, createSecurityService } from '@nahisaho/musubix-security';
1687
+
1688
+ // 単一ファイルのスキャン
1689
+ const scanner = new VulnerabilityScanner();
1690
+ const vulnerabilities = scanner.scanFile('src/api.ts');
1691
+
1692
+ // ディレクトリのスキャン
1693
+ const result = await scanner.scanDirectory('./src');
1694
+ console.log(`検出された脆弱性: ${result.vulnerabilities.length}`);
1695
+ console.log(`スキャンしたファイル: ${result.scannedFiles}`);
1696
+ ```
1697
+
1698
+ ### 検出可能な脆弱性
1699
+
1700
+ | カテゴリ | CWE | 重要度 |
1701
+ |---------|-----|--------|
1702
+ | SQLインジェクション | CWE-89 | Critical |
1703
+ | コマンドインジェクション | CWE-78 | Critical |
1704
+ | XSS | CWE-79 | High |
1705
+ | パストラバーサル | CWE-22 | High |
1706
+ | コードインジェクション | CWE-94 | Critical |
1707
+ | NoSQLインジェクション | CWE-943 | High |
1708
+
1709
+ ### シークレット検出
1710
+
1711
+ ハードコードされた認証情報や機密情報を検出します:
1712
+
1713
+ ```typescript
1714
+ import { SecretDetector } from '@nahisaho/musubix-security';
1715
+
1716
+ const detector = new SecretDetector();
1717
+ const secrets = detector.scanContent(content, 'config.ts');
1718
+ const result = await detector.scan('./src');
1719
+
1720
+ console.log(`検出されたシークレット: ${result.summary.total}`);
1721
+ ```
1722
+
1723
+ ### 検出可能なシークレットタイプ
1724
+
1725
+ | タイプ | パターン |
1726
+ |--------|--------|
1727
+ | AWS Access Key | `AKIA...` |
1728
+ | AWS Secret Key | 40文字のbase64 |
1729
+ | GitHub Token | `ghp_*`, `gho_*`, `ghu_*` |
1730
+ | 秘密鍵 | PEM形式 |
1731
+ | データベースURL | `postgres://`, `mongodb://` |
1732
+ | JWTシークレット | JWT署名シークレット |
1733
+ | Stripe Key | `sk_live_*`, `sk_test_*` |
1734
+
1735
+ ### テイント解析
1736
+
1737
+ ユーザー入力(ソース)から危険な関数(シンク)へのデータフローを追跡します:
1738
+
1739
+ ```typescript
1740
+ import { TaintAnalyzer } from '@nahisaho/musubix-security';
1741
+
1742
+ const analyzer = new TaintAnalyzer();
1743
+ const result = analyzer.analyze('./src');
1744
+
1745
+ console.log(`ソース: ${result.sources.length}`);
1746
+ console.log(`シンク: ${result.sinks.length}`);
1747
+ console.log(`テイントパス: ${result.paths.length}`);
1748
+ ```
1749
+
1750
+ ### 依存関係監査
1751
+
1752
+ npm auditと統合して脆弱な依存関係を検出します:
1753
+
1754
+ ```typescript
1755
+ import { DependencyAuditor } from '@nahisaho/musubix-security';
1756
+
1757
+ const auditor = new DependencyAuditor();
1758
+ const result = await auditor.audit('./project');
1759
+
1760
+ console.log(`Critical: ${result.summary.critical}`);
1761
+ console.log(`High: ${result.summary.high}`);
1762
+ ```
1763
+
1764
+ ### 統合セキュリティサービス
1765
+
1766
+ すべてのセキュリティ分析機能を統合:
1767
+
1768
+ ```typescript
1769
+ import { createSecurityService } from '@nahisaho/musubix-security';
1770
+
1771
+ const service = createSecurityService();
1772
+
1773
+ // フルセキュリティスキャン
1774
+ const result = await service.scan({
1775
+ target: './src',
1776
+ vulnerabilities: true,
1777
+ taint: true,
1778
+ secrets: true,
1779
+ dependencies: true,
1780
+ generateFixes: true,
1781
+ });
1782
+
1783
+ console.log(`総脆弱性数: ${result.summary.totalVulnerabilities}`);
1784
+ console.log(`総シークレット数: ${result.summary.totalSecrets}`);
1785
+ console.log(`生成された修正: ${result.summary.fixesGenerated}`);
1786
+ ```
1787
+
1788
+ ### レポート生成
1789
+
1790
+ 複数のフォーマットでレポートを生成:
1791
+
1792
+ ```typescript
1793
+ // SARIF形式(GitHub Code Scanning対応)
1794
+ const sarifReport = await service.generateReport(result, 'sarif');
1795
+
1796
+ // Markdown形式
1797
+ const mdReport = await service.generateReport(result, 'markdown');
1798
+
1799
+ // HTML形式
1800
+ const htmlReport = await service.generateReport(result, 'html');
1801
+ ```
1802
+
1803
+ ### CLIの使い方
1804
+
1805
+ ```bash
1806
+ # フルセキュリティスキャン
1807
+ npx musubix-security scan ./src
1808
+
1809
+ # 脆弱性スキャンのみ
1810
+ npx musubix-security scan ./src --vulnerabilities-only
1811
+
1812
+ # シークレット検出
1813
+ npx musubix-security secrets ./src
1814
+
1815
+ # テイント解析
1816
+ npx musubix-security taint ./src
1817
+
1818
+ # 依存関係監査
1819
+ npx musubix-security audit ./project
1820
+
1821
+ # SARIFレポート生成
1822
+ npx musubix-security scan ./src --format sarif --output report.sarif
1823
+ ```
1824
+
1825
+ ### v1.8.0 パッケージ概要
1826
+
1827
+ | パッケージ | 説明 |
1828
+ |-----------|------|
1829
+ | `@nahisaho/musubix-security` | 脆弱性スキャン、シークレット検出、テイント解析、依存関係監査 |
1830
+
1831
+ ---
1832
+
1554
1833
  ## MCPサーバー連携
1555
1834
 
1556
1835
  ### MCPサーバーの起動
@@ -1863,6 +2142,6 @@ const client = createYATAClient({
1863
2142
 
1864
2143
  ---
1865
2144
 
1866
- **バージョン**: 1.6.0
2145
+ **バージョン**: 1.8.0
1867
2146
  **最終更新**: 2026-01-06
1868
2147
  **MUSUBIX Project**