framework-mcp 1.3.0 โ 1.3.2
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/COPILOT_INTEGRATION.md +1 -1
- package/backups/README.md +31 -0
- package/backups/safeguard-manager-5-safeguards.ts +343 -0
- package/dist/core/safeguard-manager.backup.d.ts +15 -0
- package/dist/core/safeguard-manager.backup.d.ts.map +1 -0
- package/dist/core/safeguard-manager.backup.js +318 -0
- package/dist/core/safeguard-manager.backup.js.map +1 -0
- package/dist/core/safeguard-manager.d.ts +17 -0
- package/dist/core/safeguard-manager.d.ts.map +1 -1
- package/dist/core/safeguard-manager.js +5321 -44
- package/dist/core/safeguard-manager.js.map +1 -1
- package/dist/interfaces/http/http-server.js +3 -3
- package/dist/interfaces/mcp/mcp-server.js +3 -3
- package/migration/README.md +66 -0
- package/migration/integration-ready-safeguards.ts +5457 -0
- package/package.json +1 -1
- package/scripts/analyze-data-structure.cjs +74 -0
- package/scripts/clean-safeguards-data.cjs +60 -0
- package/scripts/comprehensive-validation.cjs +176 -0
- package/scripts/count-safeguards.cjs +89 -0
- package/scripts/format-safeguards-proper.cjs +44 -0
- package/scripts/validate-formatted-data.cjs +88 -0
- package/src/core/safeguard-manager.backup.ts +343 -0
- package/src/core/safeguard-manager.ts +5510 -216
- package/src/core/safeguard-manager.ts.backup-20250821_085347 +343 -0
- package/src/interfaces/http/http-server.ts +3 -3
- package/src/interfaces/mcp/mcp-server.ts +3 -3
- package/swagger.json +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "framework-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Dual-architecture server (MCP + HTTP API) for determining vendor tool capability roles against CIS Controls Framework with intelligent domain validation. Supports Microsoft Copilot custom connectors and DigitalOcean App Services deployment.",
|
|
5
5
|
"main": "dist/interfaces/http/http-server.js",
|
|
6
6
|
"type": "module",
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Data Structure Analysis Script
|
|
5
|
+
* Compares original CIS_SAFEGUARDS with current SafeguardManager interface
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
|
|
10
|
+
console.log('๐ CIS Safeguards Data Structure Analysis\n');
|
|
11
|
+
|
|
12
|
+
// Read original data
|
|
13
|
+
const originalData = fs.readFileSync('/tmp/complete_cis_safeguards.ts', 'utf8');
|
|
14
|
+
console.log('โ
Original data loaded:', originalData.split('\n').length, 'lines');
|
|
15
|
+
|
|
16
|
+
// Extract safeguard structure from first entry (1.1)
|
|
17
|
+
const match = originalData.match(/"1\.1":\s*{([^}]+(?:{[^}]*}[^}]*)*)/);
|
|
18
|
+
if (match) {
|
|
19
|
+
console.log('โ
Successfully parsed safeguard 1.1 structure\n');
|
|
20
|
+
|
|
21
|
+
// Extract field names from original data
|
|
22
|
+
const fieldPattern = /(\w+):/g;
|
|
23
|
+
const originalFields = new Set();
|
|
24
|
+
let fieldMatch;
|
|
25
|
+
|
|
26
|
+
while ((fieldMatch = fieldPattern.exec(match[1])) !== null) {
|
|
27
|
+
originalFields.add(fieldMatch[1]);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
console.log('๐ Original fields found:');
|
|
31
|
+
Array.from(originalFields).sort().forEach(field => {
|
|
32
|
+
console.log(` - ${field}`);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Required fields for SafeguardElement interface
|
|
36
|
+
const requiredFields = [
|
|
37
|
+
'id',
|
|
38
|
+
'title',
|
|
39
|
+
'description',
|
|
40
|
+
'implementationGroup',
|
|
41
|
+
'assetType',
|
|
42
|
+
'securityFunction',
|
|
43
|
+
'governanceElements',
|
|
44
|
+
'coreRequirements',
|
|
45
|
+
'subTaxonomicalElements',
|
|
46
|
+
'implementationSuggestions',
|
|
47
|
+
'relatedSafeguards',
|
|
48
|
+
'keywords'
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
console.log('\n๐ Required SafeguardElement fields:');
|
|
52
|
+
requiredFields.forEach(field => {
|
|
53
|
+
const present = originalFields.has(field);
|
|
54
|
+
console.log(` ${present ? 'โ
' : 'โ'} ${field}`);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Check for extra fields
|
|
58
|
+
const extraFields = Array.from(originalFields).filter(f => !requiredFields.includes(f));
|
|
59
|
+
if (extraFields.length > 0) {
|
|
60
|
+
console.log('\nโ ๏ธ Extra fields in original data:');
|
|
61
|
+
extraFields.forEach(field => console.log(` - ${field}`));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
console.log('\n๐ Compatibility Analysis:');
|
|
65
|
+
const missingFields = requiredFields.filter(f => !originalFields.has(f));
|
|
66
|
+
if (missingFields.length === 0) {
|
|
67
|
+
console.log('โ
Perfect compatibility - all required fields present');
|
|
68
|
+
} else {
|
|
69
|
+
console.log('โ Missing fields:', missingFields);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
} else {
|
|
73
|
+
console.log('โ Failed to parse safeguard structure');
|
|
74
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Clean and format CIS Safeguards data for SafeguardManager compatibility
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
|
|
9
|
+
console.log('๐งน Cleaning and Formatting CIS Safeguards Data\n');
|
|
10
|
+
|
|
11
|
+
// Read original data
|
|
12
|
+
const originalData = fs.readFileSync('/tmp/complete_cis_safeguards.ts', 'utf8');
|
|
13
|
+
|
|
14
|
+
// Extract just the object content (without const declaration and type annotation)
|
|
15
|
+
const objectMatch = originalData.match(/= {([\s\S]*)};\s*$/);
|
|
16
|
+
if (!objectMatch) {
|
|
17
|
+
console.log('โ Failed to extract object content');
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let objectContent = objectMatch[1];
|
|
22
|
+
|
|
23
|
+
console.log('โ
Extracted object content');
|
|
24
|
+
|
|
25
|
+
// Clean up the data:
|
|
26
|
+
// 1. Remove TypeScript comments that might break parsing
|
|
27
|
+
objectContent = objectContent.replace(/\/\/ [^\n\r]*/g, '');
|
|
28
|
+
|
|
29
|
+
// 2. Ensure consistent formatting
|
|
30
|
+
objectContent = objectContent.replace(/\s+/g, ' ').replace(/\s*,\s*/g, ',').replace(/\s*:\s*/g, ':');
|
|
31
|
+
|
|
32
|
+
// 3. Add proper indentation for readability
|
|
33
|
+
const lines = objectContent.split('\n');
|
|
34
|
+
const indentedLines = lines.map((line, index) => {
|
|
35
|
+
if (index === 0) return line; // First line stays as is
|
|
36
|
+
return ' ' + line.trim(); // Indent other lines
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
objectContent = indentedLines.join('\n');
|
|
40
|
+
|
|
41
|
+
// Create the properly formatted safeguards object content
|
|
42
|
+
const cleanedContent = ` this.safeguards = {${objectContent}
|
|
43
|
+
};`;
|
|
44
|
+
|
|
45
|
+
console.log('โ
Formatted for SafeguardManager integration');
|
|
46
|
+
|
|
47
|
+
// Write cleaned data to temporary file
|
|
48
|
+
fs.writeFileSync('/tmp/cleaned_safeguards_content.ts', cleanedContent);
|
|
49
|
+
|
|
50
|
+
console.log('โ
Cleaned data saved to /tmp/cleaned_safeguards_content.ts');
|
|
51
|
+
|
|
52
|
+
// Show a sample of the cleaned data
|
|
53
|
+
const preview = cleanedContent.substring(0, 500);
|
|
54
|
+
console.log('\n๐ Preview of cleaned data:');
|
|
55
|
+
console.log(preview + '...\n');
|
|
56
|
+
|
|
57
|
+
console.log('๐ Data Statistics:');
|
|
58
|
+
console.log(' Original size:', originalData.length, 'characters');
|
|
59
|
+
console.log(' Cleaned size:', cleanedContent.length, 'characters');
|
|
60
|
+
console.log(' Ready for SafeguardManager integration โ
');
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Comprehensive Validation Script for CIS Safeguards Migration
|
|
5
|
+
* This script will be used to validate data integrity during and after migration
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
|
|
10
|
+
class SafeguardsValidator {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.expectedCount = 153;
|
|
13
|
+
this.expectedControls = 18;
|
|
14
|
+
this.requiredFields = [
|
|
15
|
+
'id', 'title', 'description', 'implementationGroup',
|
|
16
|
+
'assetType', 'securityFunction', 'governanceElements',
|
|
17
|
+
'coreRequirements', 'subTaxonomicalElements',
|
|
18
|
+
'implementationSuggestions', 'relatedSafeguards', 'keywords'
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
validateFile(filePath) {
|
|
23
|
+
console.log(`๐ Validating: ${filePath}\n`);
|
|
24
|
+
|
|
25
|
+
if (!fs.existsSync(filePath)) {
|
|
26
|
+
console.log('โ File not found');
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
31
|
+
return this.validateContent(content);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
validateContent(content) {
|
|
35
|
+
const results = {
|
|
36
|
+
countTest: false,
|
|
37
|
+
duplicateTest: false,
|
|
38
|
+
formatTest: false,
|
|
39
|
+
syntaxTest: false,
|
|
40
|
+
fieldsTest: false,
|
|
41
|
+
controlsTest: false
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
// Extract safeguards data
|
|
46
|
+
let safeguardsData;
|
|
47
|
+
|
|
48
|
+
if (content.includes('this.safeguards = ')) {
|
|
49
|
+
// SafeguardManager format
|
|
50
|
+
const match = content.match(/this\.safeguards = ({[\s\S]*});/);
|
|
51
|
+
safeguardsData = match ? match[1] : null;
|
|
52
|
+
} else {
|
|
53
|
+
// Raw CIS_SAFEGUARDS format
|
|
54
|
+
const match = content.match(/= ({[\s\S]*});/);
|
|
55
|
+
safeguardsData = match ? match[1] : null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!safeguardsData) {
|
|
59
|
+
console.log('โ Could not extract safeguards data');
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Parse the data
|
|
64
|
+
const safeguards = eval(`(${safeguardsData})`);
|
|
65
|
+
const safeguardIds = Object.keys(safeguards);
|
|
66
|
+
|
|
67
|
+
// Test 1: Count validation
|
|
68
|
+
console.log('๐ Count Validation:');
|
|
69
|
+
console.log(` Expected: ${this.expectedCount}`);
|
|
70
|
+
console.log(` Found: ${safeguardIds.length}`);
|
|
71
|
+
results.countTest = safeguardIds.length === this.expectedCount;
|
|
72
|
+
console.log(` Result: ${results.countTest ? 'โ
' : 'โ'}\n`);
|
|
73
|
+
|
|
74
|
+
// Test 2: Duplicate check
|
|
75
|
+
console.log('๐ Duplicate Check:');
|
|
76
|
+
const duplicates = safeguardIds.filter((id, index) => safeguardIds.indexOf(id) !== index);
|
|
77
|
+
results.duplicateTest = duplicates.length === 0;
|
|
78
|
+
console.log(` Duplicates found: ${duplicates.length}`);
|
|
79
|
+
console.log(` Result: ${results.duplicateTest ? 'โ
' : 'โ'}\n`);
|
|
80
|
+
|
|
81
|
+
// Test 3: ID format validation
|
|
82
|
+
console.log('๐ Format Validation:');
|
|
83
|
+
const invalidFormats = safeguardIds.filter(id => !/^\d+\.\d+$/.test(id));
|
|
84
|
+
results.formatTest = invalidFormats.length === 0;
|
|
85
|
+
console.log(` Invalid formats: ${invalidFormats.length}`);
|
|
86
|
+
console.log(` Result: ${results.formatTest ? 'โ
' : 'โ'}\n`);
|
|
87
|
+
|
|
88
|
+
// Test 4: Syntax validation (already done by eval above)
|
|
89
|
+
console.log('โ๏ธ Syntax Validation:');
|
|
90
|
+
results.syntaxTest = true; // If we got here, syntax is valid
|
|
91
|
+
console.log(` Result: โ
\n`);
|
|
92
|
+
|
|
93
|
+
// Test 5: Required fields validation
|
|
94
|
+
console.log('๐ Fields Validation:');
|
|
95
|
+
let fieldsValid = true;
|
|
96
|
+
const sampleSafeguard = safeguards[safeguardIds[0]];
|
|
97
|
+
const missingFields = this.requiredFields.filter(field => !(field in sampleSafeguard));
|
|
98
|
+
|
|
99
|
+
if (missingFields.length > 0) {
|
|
100
|
+
console.log(` Missing fields in sample: ${missingFields.join(', ')}`);
|
|
101
|
+
fieldsValid = false;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Check a few random safeguards for field completeness
|
|
105
|
+
const testSafeguards = [safeguardIds[0], safeguardIds[Math.floor(safeguardIds.length / 2)], safeguardIds[safeguardIds.length - 1]];
|
|
106
|
+
for (const id of testSafeguards) {
|
|
107
|
+
const missing = this.requiredFields.filter(field => !(field in safeguards[id]));
|
|
108
|
+
if (missing.length > 0) {
|
|
109
|
+
console.log(` Missing fields in ${id}: ${missing.join(', ')}`);
|
|
110
|
+
fieldsValid = false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
results.fieldsTest = fieldsValid;
|
|
115
|
+
console.log(` Result: ${fieldsValid ? 'โ
' : 'โ'}\n`);
|
|
116
|
+
|
|
117
|
+
// Test 6: Control coverage
|
|
118
|
+
console.log('๐ฏ Control Coverage:');
|
|
119
|
+
const controlCounts = {};
|
|
120
|
+
safeguardIds.forEach(id => {
|
|
121
|
+
const control = parseInt(id.split('.')[0]);
|
|
122
|
+
controlCounts[control] = (controlCounts[control] || 0) + 1;
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
let allControlsPresent = true;
|
|
126
|
+
for (let i = 1; i <= this.expectedControls; i++) {
|
|
127
|
+
const count = controlCounts[i] || 0;
|
|
128
|
+
if (count === 0) {
|
|
129
|
+
console.log(` โ Control ${i}: Missing`);
|
|
130
|
+
allControlsPresent = false;
|
|
131
|
+
} else {
|
|
132
|
+
console.log(` โ
Control ${i}: ${count} safeguards`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
results.controlsTest = allControlsPresent;
|
|
137
|
+
console.log(` Result: ${allControlsPresent ? 'โ
' : 'โ'}\n`);
|
|
138
|
+
|
|
139
|
+
} catch (error) {
|
|
140
|
+
console.log('โ Validation error:', error.message);
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Overall result
|
|
145
|
+
const allTestsPassed = Object.values(results).every(test => test);
|
|
146
|
+
console.log('๐ฏ Overall Validation Result:');
|
|
147
|
+
console.log(` Status: ${allTestsPassed ? 'โ
PASSED' : 'โ FAILED'}`);
|
|
148
|
+
console.log(` Details:`, results);
|
|
149
|
+
|
|
150
|
+
return allTestsPassed;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Main execution
|
|
155
|
+
if (require.main === module) {
|
|
156
|
+
const validator = new SafeguardsValidator();
|
|
157
|
+
|
|
158
|
+
console.log('๐ CIS Safeguards Comprehensive Validation\n');
|
|
159
|
+
console.log('=' .repeat(50) + '\n');
|
|
160
|
+
|
|
161
|
+
// Test the formatted data ready for integration
|
|
162
|
+
const testFile = '/tmp/formatted_safeguards_ready.ts';
|
|
163
|
+
const isValid = validator.validateFile(testFile);
|
|
164
|
+
|
|
165
|
+
console.log('\n' + '='.repeat(50));
|
|
166
|
+
console.log(`Final Result: ${isValid ? 'โ
READY FOR INTEGRATION' : 'โ NOT READY'}`);
|
|
167
|
+
|
|
168
|
+
if (!isValid) {
|
|
169
|
+
console.log('\nโ Issues found - please fix before proceeding with integration');
|
|
170
|
+
process.exit(1);
|
|
171
|
+
} else {
|
|
172
|
+
console.log('\n๐ All validations passed - data is ready for SafeguardManager integration!');
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
module.exports = SafeguardsValidator;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Safeguard Count and Validation Script
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
|
|
9
|
+
console.log('๐ข CIS Safeguards Count and Validation\n');
|
|
10
|
+
|
|
11
|
+
const originalData = fs.readFileSync('/tmp/complete_cis_safeguards.ts', 'utf8');
|
|
12
|
+
|
|
13
|
+
// Extract all safeguard IDs using regex
|
|
14
|
+
const safeguardPattern = /"(\d+\.\d+)":\s*{/g;
|
|
15
|
+
const safeguardIds = [];
|
|
16
|
+
let match;
|
|
17
|
+
|
|
18
|
+
while ((match = safeguardPattern.exec(originalData)) !== null) {
|
|
19
|
+
safeguardIds.push(match[1]);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
console.log('๐ Safeguard Count Analysis:');
|
|
23
|
+
console.log(` Total safeguards found: ${safeguardIds.length}`);
|
|
24
|
+
|
|
25
|
+
// Sort safeguards numerically
|
|
26
|
+
const sortedIds = safeguardIds.sort((a, b) => {
|
|
27
|
+
const [aMajor, aMinor] = a.split('.').map(Number);
|
|
28
|
+
const [bMajor, bMinor] = b.split('.').map(Number);
|
|
29
|
+
return aMajor - bMajor || aMinor - bMinor;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
console.log(` First safeguard: ${sortedIds[0]}`);
|
|
33
|
+
console.log(` Last safeguard: ${sortedIds[sortedIds.length - 1]}`);
|
|
34
|
+
|
|
35
|
+
// Check for duplicates
|
|
36
|
+
const duplicates = safeguardIds.filter((id, index) => safeguardIds.indexOf(id) !== index);
|
|
37
|
+
if (duplicates.length > 0) {
|
|
38
|
+
console.log('โ Duplicate safeguards found:', duplicates);
|
|
39
|
+
} else {
|
|
40
|
+
console.log('โ
No duplicate safeguards');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Group by control
|
|
44
|
+
const byControl = {};
|
|
45
|
+
sortedIds.forEach(id => {
|
|
46
|
+
const control = id.split('.')[0];
|
|
47
|
+
if (!byControl[control]) byControl[control] = [];
|
|
48
|
+
byControl[control].push(id);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
console.log('\n๐ Safeguards by Control:');
|
|
52
|
+
for (let i = 1; i <= 18; i++) {
|
|
53
|
+
const controlSafeguards = byControl[i.toString()] || [];
|
|
54
|
+
console.log(` Control ${i}: ${controlSafeguards.length} safeguards`);
|
|
55
|
+
if (controlSafeguards.length > 0) {
|
|
56
|
+
console.log(` Range: ${controlSafeguards[0]} - ${controlSafeguards[controlSafeguards.length - 1]}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Validate expected total
|
|
61
|
+
const expectedTotal = 153;
|
|
62
|
+
console.log('\n๐ฏ Validation Results:');
|
|
63
|
+
console.log(` Expected: ${expectedTotal} safeguards`);
|
|
64
|
+
console.log(` Found: ${safeguardIds.length} safeguards`);
|
|
65
|
+
|
|
66
|
+
if (safeguardIds.length === expectedTotal) {
|
|
67
|
+
console.log('โ
Perfect count match!');
|
|
68
|
+
} else {
|
|
69
|
+
console.log(`โ Count mismatch: ${safeguardIds.length - expectedTotal} difference`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Check for missing controls
|
|
73
|
+
const missingControls = [];
|
|
74
|
+
for (let i = 1; i <= 18; i++) {
|
|
75
|
+
if (!byControl[i.toString()] || byControl[i.toString()].length === 0) {
|
|
76
|
+
missingControls.push(i);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (missingControls.length === 0) {
|
|
81
|
+
console.log('โ
All 18 CIS Controls represented');
|
|
82
|
+
} else {
|
|
83
|
+
console.log('โ Missing controls:', missingControls);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
console.log('\n๐ Sample safeguards:');
|
|
87
|
+
sortedIds.slice(0, 5).forEach(id => console.log(` - ${id}`));
|
|
88
|
+
console.log(' ...');
|
|
89
|
+
sortedIds.slice(-5).forEach(id => console.log(` - ${id}`));
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Properly format CIS Safeguards data with readable indentation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
|
|
9
|
+
console.log('โจ Properly Formatting CIS Safeguards Data\n');
|
|
10
|
+
|
|
11
|
+
// Read original data
|
|
12
|
+
const originalData = fs.readFileSync('/tmp/complete_cis_safeguards.ts', 'utf8');
|
|
13
|
+
|
|
14
|
+
// Extract just the safeguards object content (between the braces)
|
|
15
|
+
const match = originalData.match(/const CIS_SAFEGUARDS[^=]*=\s*({[\s\S]*});/);
|
|
16
|
+
if (!match) {
|
|
17
|
+
console.log('โ Failed to extract safeguards object');
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const safeguardsObject = match[1];
|
|
22
|
+
|
|
23
|
+
console.log('โ
Extracted safeguards object');
|
|
24
|
+
|
|
25
|
+
// Create properly formatted assignment for SafeguardManager
|
|
26
|
+
const formattedContent = ` // Complete CIS Controls v8.1 Framework - 153 safeguards across 18 controls
|
|
27
|
+
// Migrated from original implementation on ${new Date().toISOString().split('T')[0]}
|
|
28
|
+
this.safeguards = ${safeguardsObject};`;
|
|
29
|
+
|
|
30
|
+
// Write formatted data
|
|
31
|
+
fs.writeFileSync('/tmp/formatted_safeguards_ready.ts', formattedContent);
|
|
32
|
+
|
|
33
|
+
console.log('โ
Properly formatted data saved to /tmp/formatted_safeguards_ready.ts');
|
|
34
|
+
|
|
35
|
+
// Show preview of properly formatted data
|
|
36
|
+
const lines = formattedContent.split('\n');
|
|
37
|
+
console.log('\n๐ Preview (first 20 lines):');
|
|
38
|
+
lines.slice(0, 20).forEach((line, i) => console.log(`${i + 1}: ${line}`));
|
|
39
|
+
console.log(' ...');
|
|
40
|
+
|
|
41
|
+
console.log('\n๐ Final Statistics:');
|
|
42
|
+
console.log(' Lines:', lines.length);
|
|
43
|
+
console.log(' Size:', formattedContent.length, 'characters');
|
|
44
|
+
console.log(' Ready for direct integration into SafeguardManager โ
');
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Validate formatted safeguards data for integration readiness
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
|
|
9
|
+
console.log('๐ Validating Formatted Safeguards Data\n');
|
|
10
|
+
|
|
11
|
+
// Read formatted data
|
|
12
|
+
const formattedData = fs.readFileSync('/tmp/formatted_safeguards_ready.ts', 'utf8');
|
|
13
|
+
|
|
14
|
+
// Extract safeguard IDs from formatted data
|
|
15
|
+
const idPattern = /"(\d+\.\d+)":\s*{/g;
|
|
16
|
+
const foundIds = [];
|
|
17
|
+
let match;
|
|
18
|
+
|
|
19
|
+
while ((match = idPattern.exec(formattedData)) !== null) {
|
|
20
|
+
foundIds.push(match[1]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
console.log('๐ Validation Results:');
|
|
24
|
+
console.log(` Safeguards found: ${foundIds.length}`);
|
|
25
|
+
|
|
26
|
+
// Check for duplicates
|
|
27
|
+
const duplicates = foundIds.filter((id, index) => foundIds.indexOf(id) !== index);
|
|
28
|
+
if (duplicates.length > 0) {
|
|
29
|
+
console.log('โ Duplicates found:', duplicates);
|
|
30
|
+
} else {
|
|
31
|
+
console.log('โ
No duplicates');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Validate ID format
|
|
35
|
+
const invalidIds = foundIds.filter(id => !/^\d+\.\d+$/.test(id));
|
|
36
|
+
if (invalidIds.length > 0) {
|
|
37
|
+
console.log('โ Invalid ID formats:', invalidIds);
|
|
38
|
+
} else {
|
|
39
|
+
console.log('โ
All IDs follow X.Y format');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Sort and check sequence
|
|
43
|
+
const sortedIds = foundIds.sort((a, b) => {
|
|
44
|
+
const [aMajor, aMinor] = a.split('.').map(Number);
|
|
45
|
+
const [bMajor, bMinor] = b.split('.').map(Number);
|
|
46
|
+
return aMajor - bMajor || aMinor - bMinor;
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
console.log(` ID range: ${sortedIds[0]} to ${sortedIds[sortedIds.length - 1]}`);
|
|
50
|
+
|
|
51
|
+
// Check control coverage
|
|
52
|
+
const controlCounts = {};
|
|
53
|
+
sortedIds.forEach(id => {
|
|
54
|
+
const control = id.split('.')[0];
|
|
55
|
+
controlCounts[control] = (controlCounts[control] || 0) + 1;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
console.log('\n๐ Control Coverage:');
|
|
59
|
+
for (let i = 1; i <= 18; i++) {
|
|
60
|
+
const count = controlCounts[i.toString()] || 0;
|
|
61
|
+
console.log(` Control ${i}: ${count} safeguards ${count === 0 ? 'โ' : 'โ
'}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Syntax validation - try to evaluate as JavaScript object
|
|
65
|
+
console.log('\n๐ Syntax Validation:');
|
|
66
|
+
try {
|
|
67
|
+
// Extract just the object part for validation
|
|
68
|
+
const objectMatch = formattedData.match(/this\.safeguards = ({[\s\S]*});/);
|
|
69
|
+
if (objectMatch) {
|
|
70
|
+
// Basic syntax check by attempting to parse
|
|
71
|
+
eval(`const testObj = ${objectMatch[1]}`);
|
|
72
|
+
console.log('โ
Valid JavaScript object syntax');
|
|
73
|
+
|
|
74
|
+
// Check if object has expected safeguard count
|
|
75
|
+
eval(`const safeguardsCount = Object.keys(${objectMatch[1]}).length`);
|
|
76
|
+
console.log(`โ
Object contains ${eval(`Object.keys(${objectMatch[1]}).length`)} properties`);
|
|
77
|
+
} else {
|
|
78
|
+
console.log('โ Could not extract object for validation');
|
|
79
|
+
}
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.log('โ Syntax validation failed:', error.message);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
console.log('\n๐ฏ Final Validation Summary:');
|
|
85
|
+
console.log(` Expected: 153 safeguards`);
|
|
86
|
+
console.log(` Found: ${foundIds.length} safeguards`);
|
|
87
|
+
console.log(` Match: ${foundIds.length === 153 ? 'โ
' : 'โ'}`);
|
|
88
|
+
console.log(` Ready for integration: ${foundIds.length === 153 && duplicates.length === 0 && invalidIds.length === 0 ? 'โ
' : 'โ'}`);
|