@nahisaho/musubix-security 3.4.5 → 3.7.3
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.
- package/LICENSE +21 -0
- package/dist/filters/index.d.ts +10 -0
- package/dist/filters/index.d.ts.map +1 -0
- package/dist/filters/index.js +10 -0
- package/dist/filters/index.js.map +1 -0
- package/dist/filters/sensitive-data-filter.d.ts +31 -0
- package/dist/filters/sensitive-data-filter.d.ts.map +1 -0
- package/dist/filters/sensitive-data-filter.js +238 -0
- package/dist/filters/sensitive-data-filter.js.map +1 -0
- package/dist/filters/types.d.ts +131 -0
- package/dist/filters/types.d.ts.map +1 -0
- package/dist/filters/types.js +152 -0
- package/dist/filters/types.js.map +1 -0
- package/dist/integrations/refactor-cleaner-bridge.d.ts +16 -0
- package/dist/integrations/refactor-cleaner-bridge.d.ts.map +1 -0
- package/dist/integrations/refactor-cleaner-bridge.js +576 -0
- package/dist/integrations/refactor-cleaner-bridge.js.map +1 -0
- package/dist/integrations/refactor-cleaner-types.d.ts +236 -0
- package/dist/integrations/refactor-cleaner-types.d.ts.map +1 -0
- package/dist/integrations/refactor-cleaner-types.js +25 -0
- package/dist/integrations/refactor-cleaner-types.js.map +1 -0
- package/package.json +11 -11
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 nahisaho
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/filters/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/filters/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sensitive Data Filter Implementation
|
|
3
|
+
*
|
|
4
|
+
* REQ-INT-004: SensitiveDataFilter - 機密情報のフィルタリング
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import { type FilterConfig, type FilterResult, type SensitiveDataFilter } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* SensitiveDataFilter を作成
|
|
11
|
+
*
|
|
12
|
+
* REQ-INT-004: 機密情報のフィルタリング
|
|
13
|
+
*/
|
|
14
|
+
export declare function createSensitiveDataFilter(config?: Partial<FilterConfig>): SensitiveDataFilter;
|
|
15
|
+
/**
|
|
16
|
+
* デフォルトフィルターを取得
|
|
17
|
+
*/
|
|
18
|
+
export declare function getDefaultFilter(): SensitiveDataFilter;
|
|
19
|
+
/**
|
|
20
|
+
* テキストをフィルタリング(ユーティリティ関数)
|
|
21
|
+
*/
|
|
22
|
+
export declare function filterSensitiveData(text: string): FilterResult;
|
|
23
|
+
/**
|
|
24
|
+
* 機密データが含まれるかチェック(ユーティリティ関数)
|
|
25
|
+
*/
|
|
26
|
+
export declare function containsSensitiveData(text: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* フィルター結果をMarkdown形式でフォーマット
|
|
29
|
+
*/
|
|
30
|
+
export declare function formatFilterResultAsMarkdown(result: FilterResult): string;
|
|
31
|
+
//# sourceMappingURL=sensitive-data-filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sensitive-data-filter.d.ts","sourceRoot":"","sources":["../../src/filters/sensitive-data-filter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,YAAY,EAGjB,KAAK,mBAAmB,EAGzB,MAAM,YAAY,CAAC;AAgKpB;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,GAAE,OAAO,CAAC,YAAY,CAAM,GACjC,mBAAmB,CAqDrB;AAOD;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,mBAAmB,CAKtD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAE9D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAiCzE"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sensitive Data Filter Implementation
|
|
3
|
+
*
|
|
4
|
+
* REQ-INT-004: SensitiveDataFilter - 機密情報のフィルタリング
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import { DEFAULT_FILTER_CONFIG, DEFAULT_SENSITIVE_PATTERNS, } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* 重要度の優先順位
|
|
11
|
+
*/
|
|
12
|
+
const SEVERITY_PRIORITY = {
|
|
13
|
+
high: 3,
|
|
14
|
+
medium: 2,
|
|
15
|
+
low: 1,
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* 重要度が閾値以上かチェック
|
|
19
|
+
*/
|
|
20
|
+
function isSeverityAboveThreshold(severity, minSeverity) {
|
|
21
|
+
return SEVERITY_PRIORITY[severity] >= SEVERITY_PRIORITY[minSeverity];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* テキストから機密データを検出
|
|
25
|
+
*/
|
|
26
|
+
function detectSensitiveData(text, patterns, config) {
|
|
27
|
+
const detections = [];
|
|
28
|
+
for (const patternDef of patterns) {
|
|
29
|
+
// 有効なタイプかチェック
|
|
30
|
+
if (!config.enabledTypes.includes(patternDef.type)) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
// 重要度チェック
|
|
34
|
+
if (!isSeverityAboveThreshold(patternDef.severity, config.minSeverity)) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
// パターンのフラグをリセット(グローバルマッチの場合)
|
|
38
|
+
const pattern = new RegExp(patternDef.pattern.source, patternDef.pattern.flags);
|
|
39
|
+
let match;
|
|
40
|
+
while ((match = pattern.exec(text)) !== null) {
|
|
41
|
+
detections.push({
|
|
42
|
+
type: patternDef.type,
|
|
43
|
+
startIndex: match.index,
|
|
44
|
+
endIndex: match.index + match[0].length,
|
|
45
|
+
masked: patternDef.replacement,
|
|
46
|
+
severity: patternDef.severity,
|
|
47
|
+
description: patternDef.description,
|
|
48
|
+
});
|
|
49
|
+
// 無限ループ防止
|
|
50
|
+
if (!pattern.global)
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// 位置でソート
|
|
55
|
+
return detections.sort((a, b) => a.startIndex - b.startIndex);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 検出結果を統合(重複を除去)
|
|
59
|
+
*/
|
|
60
|
+
function mergeDetections(detections) {
|
|
61
|
+
if (detections.length <= 1)
|
|
62
|
+
return detections;
|
|
63
|
+
const merged = [];
|
|
64
|
+
let current = detections[0];
|
|
65
|
+
for (let i = 1; i < detections.length; i++) {
|
|
66
|
+
const next = detections[i];
|
|
67
|
+
// 重複チェック(範囲が重なっている場合)
|
|
68
|
+
if (next.startIndex < current.endIndex) {
|
|
69
|
+
// より高い重要度を優先
|
|
70
|
+
if (SEVERITY_PRIORITY[next.severity] > SEVERITY_PRIORITY[current.severity]) {
|
|
71
|
+
current = next;
|
|
72
|
+
}
|
|
73
|
+
else if (next.endIndex > current.endIndex) {
|
|
74
|
+
// より長いマッチを採用
|
|
75
|
+
current = {
|
|
76
|
+
...current,
|
|
77
|
+
endIndex: next.endIndex,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
merged.push(current);
|
|
83
|
+
current = next;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
merged.push(current);
|
|
87
|
+
return merged;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* テキストをフィルタリング
|
|
91
|
+
*/
|
|
92
|
+
function filterText(text, detections) {
|
|
93
|
+
if (detections.length === 0)
|
|
94
|
+
return text;
|
|
95
|
+
const parts = [];
|
|
96
|
+
let lastIndex = 0;
|
|
97
|
+
for (const detection of detections) {
|
|
98
|
+
// マッチ前の部分を追加
|
|
99
|
+
if (detection.startIndex > lastIndex) {
|
|
100
|
+
parts.push(text.slice(lastIndex, detection.startIndex));
|
|
101
|
+
}
|
|
102
|
+
// マスクされた値を追加
|
|
103
|
+
parts.push(detection.masked);
|
|
104
|
+
lastIndex = detection.endIndex;
|
|
105
|
+
}
|
|
106
|
+
// 残りの部分を追加
|
|
107
|
+
if (lastIndex < text.length) {
|
|
108
|
+
parts.push(text.slice(lastIndex));
|
|
109
|
+
}
|
|
110
|
+
return parts.join('');
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* フィルタリング統計を生成
|
|
114
|
+
*/
|
|
115
|
+
function generateStats(detections, processingTimeMs) {
|
|
116
|
+
const byType = {};
|
|
117
|
+
const bySeverity = {
|
|
118
|
+
high: 0,
|
|
119
|
+
medium: 0,
|
|
120
|
+
low: 0,
|
|
121
|
+
};
|
|
122
|
+
for (const detection of detections) {
|
|
123
|
+
byType[detection.type] = (byType[detection.type] ?? 0) + 1;
|
|
124
|
+
bySeverity[detection.severity]++;
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
totalDetections: detections.length,
|
|
128
|
+
byType,
|
|
129
|
+
bySeverity,
|
|
130
|
+
processingTimeMs,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* SensitiveDataFilter を作成
|
|
135
|
+
*
|
|
136
|
+
* REQ-INT-004: 機密情報のフィルタリング
|
|
137
|
+
*/
|
|
138
|
+
export function createSensitiveDataFilter(config = {}) {
|
|
139
|
+
const mergedConfig = {
|
|
140
|
+
...DEFAULT_FILTER_CONFIG,
|
|
141
|
+
...config,
|
|
142
|
+
enabledTypes: config.enabledTypes ?? DEFAULT_FILTER_CONFIG.enabledTypes,
|
|
143
|
+
customPatterns: config.customPatterns ?? DEFAULT_FILTER_CONFIG.customPatterns,
|
|
144
|
+
};
|
|
145
|
+
const patterns = [
|
|
146
|
+
...DEFAULT_SENSITIVE_PATTERNS,
|
|
147
|
+
...mergedConfig.customPatterns,
|
|
148
|
+
];
|
|
149
|
+
return {
|
|
150
|
+
filter(text) {
|
|
151
|
+
const startTime = performance.now();
|
|
152
|
+
const rawDetections = detectSensitiveData(text, patterns, mergedConfig);
|
|
153
|
+
const detections = mergeDetections(rawDetections);
|
|
154
|
+
const filtered = filterText(text, detections);
|
|
155
|
+
const processingTimeMs = performance.now() - startTime;
|
|
156
|
+
return {
|
|
157
|
+
filtered,
|
|
158
|
+
detections,
|
|
159
|
+
wasModified: detections.length > 0,
|
|
160
|
+
stats: generateStats(detections, processingTimeMs),
|
|
161
|
+
};
|
|
162
|
+
},
|
|
163
|
+
containsSensitiveData(text) {
|
|
164
|
+
const detections = detectSensitiveData(text, patterns, mergedConfig);
|
|
165
|
+
return detections.length > 0;
|
|
166
|
+
},
|
|
167
|
+
detect(text) {
|
|
168
|
+
const rawDetections = detectSensitiveData(text, patterns, mergedConfig);
|
|
169
|
+
return mergeDetections(rawDetections);
|
|
170
|
+
},
|
|
171
|
+
getConfig() {
|
|
172
|
+
return { ...mergedConfig };
|
|
173
|
+
},
|
|
174
|
+
addPattern(pattern) {
|
|
175
|
+
patterns.push(pattern);
|
|
176
|
+
},
|
|
177
|
+
getPatterns() {
|
|
178
|
+
return [...patterns];
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* デフォルトのフィルターインスタンス
|
|
184
|
+
*/
|
|
185
|
+
let defaultFilter = null;
|
|
186
|
+
/**
|
|
187
|
+
* デフォルトフィルターを取得
|
|
188
|
+
*/
|
|
189
|
+
export function getDefaultFilter() {
|
|
190
|
+
if (!defaultFilter) {
|
|
191
|
+
defaultFilter = createSensitiveDataFilter();
|
|
192
|
+
}
|
|
193
|
+
return defaultFilter;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* テキストをフィルタリング(ユーティリティ関数)
|
|
197
|
+
*/
|
|
198
|
+
export function filterSensitiveData(text) {
|
|
199
|
+
return getDefaultFilter().filter(text);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* 機密データが含まれるかチェック(ユーティリティ関数)
|
|
203
|
+
*/
|
|
204
|
+
export function containsSensitiveData(text) {
|
|
205
|
+
return getDefaultFilter().containsSensitiveData(text);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* フィルター結果をMarkdown形式でフォーマット
|
|
209
|
+
*/
|
|
210
|
+
export function formatFilterResultAsMarkdown(result) {
|
|
211
|
+
if (!result.wasModified) {
|
|
212
|
+
return '✅ 機密データは検出されませんでした';
|
|
213
|
+
}
|
|
214
|
+
const lines = [
|
|
215
|
+
'⚠️ **機密データが検出されました**',
|
|
216
|
+
'',
|
|
217
|
+
`**検出数**: ${result.stats.totalDetections}`,
|
|
218
|
+
`**処理時間**: ${result.stats.processingTimeMs.toFixed(2)}ms`,
|
|
219
|
+
'',
|
|
220
|
+
'## 検出された機密データ',
|
|
221
|
+
'',
|
|
222
|
+
'| 種類 | 重要度 | 説明 |',
|
|
223
|
+
'|------|--------|------|',
|
|
224
|
+
];
|
|
225
|
+
for (const detection of result.detections) {
|
|
226
|
+
lines.push(`| ${detection.type} | ${detection.severity} | ${detection.description} |`);
|
|
227
|
+
}
|
|
228
|
+
if (Object.keys(result.stats.byType).length > 0) {
|
|
229
|
+
lines.push('', '## 種類別集計', '');
|
|
230
|
+
for (const [type, count] of Object.entries(result.stats.byType)) {
|
|
231
|
+
if (count > 0) {
|
|
232
|
+
lines.push(`- **${type}**: ${count}件`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return lines.join('\n');
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=sensitive-data-filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sensitive-data-filter.js","sourceRoot":"","sources":["../../src/filters/sensitive-data-filter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,qBAAqB,EACrB,0BAA0B,GAQ3B,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,iBAAiB,GAA8C;IACnE,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,GAAG,EAAE,CAAC;CACP,CA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C,WAAW,IAAI,CAC3E,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChD,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC;QAC/B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YAChE,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;gBACd,KAAK,CAAC,IAAI,CAAC,OAAO,IAAI,OAAO,KAAK,GAAG,CAAC,CAAC;YACzC,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sensitive Data Filter Types
|
|
3
|
+
*
|
|
4
|
+
* REQ-INT-004: SensitiveDataFilter - 機密情報のフィルタリング
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* 機密データの種類
|
|
10
|
+
*/
|
|
11
|
+
export type SensitiveDataType = 'api_key' | 'password' | 'secret' | 'aws_key' | 'private_key' | 'oauth_token' | 'bearer_token' | 'jwt' | 'connection_string' | 'ssh_key' | 'pgp_key' | 'certificate' | 'credit_card' | 'ssn' | 'email' | 'phone' | 'ip_address' | 'custom';
|
|
12
|
+
/**
|
|
13
|
+
* 機密データパターン定義
|
|
14
|
+
*/
|
|
15
|
+
export interface SensitiveDataPattern {
|
|
16
|
+
/** パターン種別 */
|
|
17
|
+
readonly type: SensitiveDataType;
|
|
18
|
+
/** 検出用正規表現 */
|
|
19
|
+
readonly pattern: RegExp;
|
|
20
|
+
/** 説明 */
|
|
21
|
+
readonly description: string;
|
|
22
|
+
/** 重要度(high: 即座にマスク, medium: 警告付きマスク, low: オプションでマスク) */
|
|
23
|
+
readonly severity: 'high' | 'medium' | 'low';
|
|
24
|
+
/** マスク時の置換文字列 */
|
|
25
|
+
readonly replacement: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* フィルタリング結果
|
|
29
|
+
*/
|
|
30
|
+
export interface FilterResult {
|
|
31
|
+
/** フィルタリング後のテキスト */
|
|
32
|
+
readonly filtered: string;
|
|
33
|
+
/** 検出された機密データ */
|
|
34
|
+
readonly detections: SensitiveDataDetection[];
|
|
35
|
+
/** 元のテキストが変更されたか */
|
|
36
|
+
readonly wasModified: boolean;
|
|
37
|
+
/** フィルタリング統計 */
|
|
38
|
+
readonly stats: FilterStats;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 機密データ検出結果
|
|
42
|
+
*/
|
|
43
|
+
export interface SensitiveDataDetection {
|
|
44
|
+
/** 検出された種類 */
|
|
45
|
+
readonly type: SensitiveDataType;
|
|
46
|
+
/** 検出位置(開始) */
|
|
47
|
+
readonly startIndex: number;
|
|
48
|
+
/** 検出位置(終了) */
|
|
49
|
+
readonly endIndex: number;
|
|
50
|
+
/** マスク後の文字列 */
|
|
51
|
+
readonly masked: string;
|
|
52
|
+
/** 重要度 */
|
|
53
|
+
readonly severity: 'high' | 'medium' | 'low';
|
|
54
|
+
/** パターン説明 */
|
|
55
|
+
readonly description: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* フィルタリング統計
|
|
59
|
+
*/
|
|
60
|
+
export interface FilterStats {
|
|
61
|
+
/** 検出された機密データの総数 */
|
|
62
|
+
readonly totalDetections: number;
|
|
63
|
+
/** 種類別の検出数 */
|
|
64
|
+
readonly byType: Record<SensitiveDataType, number>;
|
|
65
|
+
/** 重要度別の検出数 */
|
|
66
|
+
readonly bySeverity: Record<'high' | 'medium' | 'low', number>;
|
|
67
|
+
/** 処理時間(ミリ秒) */
|
|
68
|
+
readonly processingTimeMs: number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* フィルター設定
|
|
72
|
+
*/
|
|
73
|
+
export interface FilterConfig {
|
|
74
|
+
/** 有効なパターン種別 */
|
|
75
|
+
readonly enabledTypes: readonly SensitiveDataType[];
|
|
76
|
+
/** 最小重要度(これ以上のみフィルタリング) */
|
|
77
|
+
readonly minSeverity: 'high' | 'medium' | 'low';
|
|
78
|
+
/** カスタムパターン */
|
|
79
|
+
readonly customPatterns: readonly SensitiveDataPattern[];
|
|
80
|
+
/** マスク文字 */
|
|
81
|
+
readonly maskChar: string;
|
|
82
|
+
/** マスク長(固定長の場合) */
|
|
83
|
+
readonly maskLength?: number;
|
|
84
|
+
/** 元の長さを保持するか */
|
|
85
|
+
readonly preserveLength: boolean;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* デフォルト機密データパターン
|
|
89
|
+
*/
|
|
90
|
+
export declare const DEFAULT_SENSITIVE_PATTERNS: readonly SensitiveDataPattern[];
|
|
91
|
+
/**
|
|
92
|
+
* デフォルトフィルター設定
|
|
93
|
+
*/
|
|
94
|
+
export declare const DEFAULT_FILTER_CONFIG: FilterConfig;
|
|
95
|
+
/**
|
|
96
|
+
* SensitiveDataFilter インターフェース
|
|
97
|
+
*/
|
|
98
|
+
export interface SensitiveDataFilter {
|
|
99
|
+
/**
|
|
100
|
+
* テキストから機密データをフィルタリング
|
|
101
|
+
* @param text フィルタリング対象のテキスト
|
|
102
|
+
* @returns フィルタリング結果
|
|
103
|
+
*/
|
|
104
|
+
filter(text: string): FilterResult;
|
|
105
|
+
/**
|
|
106
|
+
* テキストに機密データが含まれるかチェック
|
|
107
|
+
* @param text チェック対象のテキスト
|
|
108
|
+
* @returns 機密データが含まれる場合 true
|
|
109
|
+
*/
|
|
110
|
+
containsSensitiveData(text: string): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* 機密データを検出(マスクせず)
|
|
113
|
+
* @param text 検出対象のテキスト
|
|
114
|
+
* @returns 検出結果の配列
|
|
115
|
+
*/
|
|
116
|
+
detect(text: string): SensitiveDataDetection[];
|
|
117
|
+
/**
|
|
118
|
+
* 設定を取得
|
|
119
|
+
*/
|
|
120
|
+
getConfig(): FilterConfig;
|
|
121
|
+
/**
|
|
122
|
+
* カスタムパターンを追加
|
|
123
|
+
* @param pattern 追加するパターン
|
|
124
|
+
*/
|
|
125
|
+
addPattern(pattern: SensitiveDataPattern): void;
|
|
126
|
+
/**
|
|
127
|
+
* 全パターンを取得
|
|
128
|
+
*/
|
|
129
|
+
getPatterns(): readonly SensitiveDataPattern[];
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/filters/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,SAAS,GACT,UAAU,GACV,QAAQ,GACR,SAAS,GACT,aAAa,GACb,aAAa,GACb,cAAc,GACd,KAAK,GACL,mBAAmB,GACnB,SAAS,GACT,SAAS,GACT,aAAa,GACb,aAAa,GACb,KAAK,GACL,OAAO,GACP,OAAO,GACP,YAAY,GACZ,QAAQ,CAAC;AAEb;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,aAAa;IACb,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,cAAc;IACd,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,SAAS;IACT,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IAC7C,iBAAiB;IACjB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,oBAAoB;IACpB,QAAQ,CAAC,QAAQ,EAA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D,YAAY;IACZ,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,mBAAmB;IACnB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,iBAAiB;IACjB,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;CAClC;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,oBAAoB,EAiI5D,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,YAkBnC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAAC;IAEnC;;;;OAIG;IACH,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAE7C;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,sBAAsB,EAAE,CAAC;IAE/C;;OAEG;IACH,SAAS,IAAI,YAAY,CAAC;IAE1B;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAEhD;;OAEG;IACH,WAAW,IAAI,SAAS,oBAAoB,EAAE,CAAC;CAChD"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sensitive Data Filter Types
|
|
3
|
+
*
|
|
4
|
+
* REQ-INT-004: SensitiveDataFilter - 機密情報のフィルタリング
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* デフォルト機密データパターン
|
|
10
|
+
*/
|
|
11
|
+
export const DEFAULT_SENSITIVE_PATTERNS = [
|
|
12
|
+
// API Keys
|
|
13
|
+
{
|
|
14
|
+
type: 'api_key',
|
|
15
|
+
pattern: /(?:api[_-]?key|apikey)[=:\s]+["']?([a-zA-Z0-9_\-]{20,})["']?/gi,
|
|
16
|
+
description: 'API Key',
|
|
17
|
+
severity: 'high',
|
|
18
|
+
replacement: '[API_KEY_REDACTED]',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
type: 'api_key',
|
|
22
|
+
pattern: /(?:x-api-key|authorization)[=:\s]+["']?([a-zA-Z0-9_\-]{20,})["']?/gi,
|
|
23
|
+
description: 'API Key Header',
|
|
24
|
+
severity: 'high',
|
|
25
|
+
replacement: '[API_KEY_REDACTED]',
|
|
26
|
+
},
|
|
27
|
+
// Passwords
|
|
28
|
+
{
|
|
29
|
+
type: 'password',
|
|
30
|
+
pattern: /(?:password|passwd|pwd)[=:\s]+["']?([^\s"']{4,})["']?/gi,
|
|
31
|
+
description: 'Password',
|
|
32
|
+
severity: 'high',
|
|
33
|
+
replacement: '[PASSWORD_REDACTED]',
|
|
34
|
+
},
|
|
35
|
+
// Secrets
|
|
36
|
+
{
|
|
37
|
+
type: 'secret',
|
|
38
|
+
pattern: /(?:secret|client[_-]?secret)[=:\s]+["']?([a-zA-Z0-9_\-]{16,})["']?/gi,
|
|
39
|
+
description: 'Secret Key',
|
|
40
|
+
severity: 'high',
|
|
41
|
+
replacement: '[SECRET_REDACTED]',
|
|
42
|
+
},
|
|
43
|
+
// AWS Keys
|
|
44
|
+
{
|
|
45
|
+
type: 'aws_key',
|
|
46
|
+
pattern: /(?:AKIA|ABIA|ACCA|ASIA)[A-Z0-9]{16}/g,
|
|
47
|
+
description: 'AWS Access Key ID',
|
|
48
|
+
severity: 'high',
|
|
49
|
+
replacement: '[AWS_KEY_REDACTED]',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
type: 'aws_key',
|
|
53
|
+
pattern: /(?:aws[_-]?secret[_-]?access[_-]?key)[=:\s]+["']?([a-zA-Z0-9/+=]{40})["']?/gi,
|
|
54
|
+
description: 'AWS Secret Access Key',
|
|
55
|
+
severity: 'high',
|
|
56
|
+
replacement: '[AWS_SECRET_REDACTED]',
|
|
57
|
+
},
|
|
58
|
+
// Private Keys
|
|
59
|
+
{
|
|
60
|
+
type: 'private_key',
|
|
61
|
+
pattern: /-----BEGIN (?:RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----/g,
|
|
62
|
+
description: 'Private Key',
|
|
63
|
+
severity: 'high',
|
|
64
|
+
replacement: '[PRIVATE_KEY_REDACTED]',
|
|
65
|
+
},
|
|
66
|
+
// OAuth/Bearer Tokens
|
|
67
|
+
{
|
|
68
|
+
type: 'oauth_token',
|
|
69
|
+
pattern: /(?:oauth[_-]?token|access[_-]?token)[=:\s]+["']?([a-zA-Z0-9_\-.]{20,})["']?/gi,
|
|
70
|
+
description: 'OAuth Token',
|
|
71
|
+
severity: 'high',
|
|
72
|
+
replacement: '[OAUTH_TOKEN_REDACTED]',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
type: 'bearer_token',
|
|
76
|
+
pattern: /Bearer\s+([a-zA-Z0-9_\-.]{20,})/gi,
|
|
77
|
+
description: 'Bearer Token',
|
|
78
|
+
severity: 'high',
|
|
79
|
+
replacement: 'Bearer [TOKEN_REDACTED]',
|
|
80
|
+
},
|
|
81
|
+
// JWT
|
|
82
|
+
{
|
|
83
|
+
type: 'jwt',
|
|
84
|
+
pattern: /eyJ[a-zA-Z0-9_-]*\.eyJ[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]*/g,
|
|
85
|
+
description: 'JSON Web Token',
|
|
86
|
+
severity: 'high',
|
|
87
|
+
replacement: '[JWT_REDACTED]',
|
|
88
|
+
},
|
|
89
|
+
// Connection Strings
|
|
90
|
+
{
|
|
91
|
+
type: 'connection_string',
|
|
92
|
+
pattern: /(?:mongodb|mysql|postgres|redis|amqp):\/\/[^\s"']+:[^\s"']+@[^\s"']+/gi,
|
|
93
|
+
description: 'Database Connection String',
|
|
94
|
+
severity: 'high',
|
|
95
|
+
replacement: '[CONNECTION_STRING_REDACTED]',
|
|
96
|
+
},
|
|
97
|
+
// SSH Keys
|
|
98
|
+
{
|
|
99
|
+
type: 'ssh_key',
|
|
100
|
+
pattern: /ssh-(?:rsa|dss|ed25519|ecdsa)\s+[A-Za-z0-9+/=]{100,}/g,
|
|
101
|
+
description: 'SSH Public Key',
|
|
102
|
+
severity: 'medium',
|
|
103
|
+
replacement: '[SSH_KEY_REDACTED]',
|
|
104
|
+
},
|
|
105
|
+
// Credit Card Numbers
|
|
106
|
+
{
|
|
107
|
+
type: 'credit_card',
|
|
108
|
+
pattern: /\b(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|6(?:011|5[0-9]{2})[0-9]{12})\b/g,
|
|
109
|
+
description: 'Credit Card Number',
|
|
110
|
+
severity: 'high',
|
|
111
|
+
replacement: '[CREDIT_CARD_REDACTED]',
|
|
112
|
+
},
|
|
113
|
+
// Email (medium severity - context dependent)
|
|
114
|
+
{
|
|
115
|
+
type: 'email',
|
|
116
|
+
pattern: /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/g,
|
|
117
|
+
description: 'Email Address',
|
|
118
|
+
severity: 'medium',
|
|
119
|
+
replacement: '[EMAIL_REDACTED]',
|
|
120
|
+
},
|
|
121
|
+
// IP Addresses (low severity)
|
|
122
|
+
{
|
|
123
|
+
type: 'ip_address',
|
|
124
|
+
pattern: /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/g,
|
|
125
|
+
description: 'IPv4 Address',
|
|
126
|
+
severity: 'low',
|
|
127
|
+
replacement: '[IP_REDACTED]',
|
|
128
|
+
},
|
|
129
|
+
];
|
|
130
|
+
/**
|
|
131
|
+
* デフォルトフィルター設定
|
|
132
|
+
*/
|
|
133
|
+
export const DEFAULT_FILTER_CONFIG = {
|
|
134
|
+
enabledTypes: [
|
|
135
|
+
'api_key',
|
|
136
|
+
'password',
|
|
137
|
+
'secret',
|
|
138
|
+
'aws_key',
|
|
139
|
+
'private_key',
|
|
140
|
+
'oauth_token',
|
|
141
|
+
'bearer_token',
|
|
142
|
+
'jwt',
|
|
143
|
+
'connection_string',
|
|
144
|
+
'ssh_key',
|
|
145
|
+
'credit_card',
|
|
146
|
+
],
|
|
147
|
+
minSeverity: 'medium',
|
|
148
|
+
customPatterns: [],
|
|
149
|
+
maskChar: '*',
|
|
150
|
+
preserveLength: false,
|
|
151
|
+
};
|
|
152
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/filters/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAyGH;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAoC;IACzE,WAAW;IACX;QACE,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,gEAAgE;QACzE,WAAW,EAAE,SAAS;QACtB,QAAQ,EAAE,MAAM;QAChB,WAAW,EAAE,oBAAoB;KAClC;IACD;QACE,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,qEAAqE;QAC9E,WAAW,EAAE,gBAAgB;QAC7B,QAAQ,EAAE,MAAM;QAChB,WAAW,EAAE,oBAAoB;KAClC;IAED,YAAY;IACZ;QACE,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,yDAAyD;QAClE,WAAW,EAAE,UAAU;QACvB,QAAQ,EAAE,MAAM;QAChB,WAAW,EAAE,qBAAqB;KACnC;IAED,UAAU;IACV;QACE,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,sEAAsE;QAC/E,WAAW,EAAE,YAAY;QACzB,QAAQ,EAAE,MAAM;QAChB,WAAW,EAAE,mBAAmB;KACjC;IAED,WAAW;IACX;QACE,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,sCAAsC;QAC/C,WAAW,EAAE,mBAAmB;QAChC,QAAQ,EAAE,MAAM;QAChB,WAAW,EAAE,oBAAoB;KAClC;IACD;QACE,IAAI,EAAE,SAAS;QACf,OAAO,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AE,eAAe;QAC5B,QAAQ,EAAE,QAAQ;QAClB,WAAW,EAAE,kBAAkB;KAChC;IAED,8BAA8B;IAC9B;QACE,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,gGAAgG;QACzG,WAAW,EAAE,cAAc;QAC3B,QAAQ,EAAE,KAAK;QACf,WAAW,EAAE,eAAe;KAC7B;CACO,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAiB;IACjD,YAAY,EAAE;QACZ,SAAS;QACT,UAAU;QACV,QAAQ;QACR,SAAS;QACT,aAAa;QACb,aAAa;QACb,cAAc;QACd,KAAK;QACL,mBAAmB;QACnB,SAAS;QACT,aAAa;KACd;IACD,WAAW,EAAE,QAAQ;IACrB,cAAc,EAAE,EAAE;IAClB,QAAQ,EAAE,GAAG;IACb,cAAc,EAAE,KAAK;CACtB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Refactor Cleaner Bridge Implementation for Agent Skills Integration
|
|
3
|
+
* @traceability REQ-RC-001, REQ-RC-002, REQ-RC-003, REQ-RC-004
|
|
4
|
+
*/
|
|
5
|
+
import type { RefactorCleanerBridge, RefactorCleanerBridgeConfig, DeadCodeItem } from './refactor-cleaner-types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Create a Refactor Cleaner Bridge for Agent Skills integration
|
|
8
|
+
* @param config Bridge configuration
|
|
9
|
+
* @returns RefactorCleanerBridge instance
|
|
10
|
+
*/
|
|
11
|
+
export declare function createRefactorCleanerBridge(config?: Partial<RefactorCleanerBridgeConfig>): RefactorCleanerBridge;
|
|
12
|
+
/**
|
|
13
|
+
* Parse knip output from text format (fallback)
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseKnipTextOutput(output: string): DeadCodeItem[];
|
|
16
|
+
//# sourceMappingURL=refactor-cleaner-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refactor-cleaner-bridge.d.ts","sourceRoot":"","sources":["../../src/integrations/refactor-cleaner-bridge.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EACV,qBAAqB,EACrB,2BAA2B,EAC3B,YAAY,EASb,MAAM,6BAA6B,CAAC;AAKrC;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,GAAE,OAAO,CAAC,2BAA2B,CAAM,GAChD,qBAAqB,CAyNvB;AAuaD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,EAAE,CA4BlE"}
|