rcf-protocol 1.2.2 → 1.2.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.
|
@@ -2,6 +2,10 @@ import { ParseResult, ValidationError } from './types';
|
|
|
2
2
|
interface ValidatorOptions {
|
|
3
3
|
strict?: boolean;
|
|
4
4
|
}
|
|
5
|
+
/**
|
|
6
|
+
* [RCF:RESTRICTED]
|
|
7
|
+
* The ComplianceValidator class enforces strict adherence to RCF specification standards.
|
|
8
|
+
*/
|
|
5
9
|
export declare class ComplianceValidator {
|
|
6
10
|
private strict;
|
|
7
11
|
constructor(options?: ValidatorOptions);
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ComplianceValidator = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* [RCF:RESTRICTED]
|
|
6
|
+
* The ComplianceValidator class enforces strict adherence to RCF specification standards.
|
|
7
|
+
*/
|
|
4
8
|
class ComplianceValidator {
|
|
5
9
|
constructor(options = {}) {
|
|
6
10
|
this.strict = options.strict || false;
|
package/dist/core/constants.js
CHANGED
package/package.json
CHANGED
package/dist/cli/index.d.ts
DELETED
package/dist/cli/index.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const MarkerParser_1 = require("../core/MarkerParser");
|
|
10
|
-
const ComplianceValidator_1 = require("../core/ComplianceValidator");
|
|
11
|
-
const fs_1 = require("fs");
|
|
12
|
-
const path_1 = require("path");
|
|
13
|
-
const crypto_1 = require("crypto");
|
|
14
|
-
const pkg = JSON.parse((0, fs_1.readFileSync)((0, path_1.resolve)(__dirname, '../../package.json'), 'utf-8'));
|
|
15
|
-
const program = new commander_1.Command();
|
|
16
|
-
program
|
|
17
|
-
.name('rcf-cli')
|
|
18
|
-
.description('RCF Protocol CLI')
|
|
19
|
-
.version(pkg.version);
|
|
20
|
-
program
|
|
21
|
-
.command('scan [directory]')
|
|
22
|
-
.description('Scan directory for RCF markers')
|
|
23
|
-
.option('-f, --format <type>', 'output format', 'pretty')
|
|
24
|
-
.option('--summary', 'show summary only')
|
|
25
|
-
.action(async (directory = '.', options) => {
|
|
26
|
-
const parser = new MarkerParser_1.MarkerParser();
|
|
27
|
-
const results = await parser.scan(directory);
|
|
28
|
-
if (options.summary) {
|
|
29
|
-
printSummary(results);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
printResults(results, options.format);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
program
|
|
36
|
-
.command('validate [directory]')
|
|
37
|
-
.description('Validate RCF compliance')
|
|
38
|
-
.option('--strict', 'strict mode')
|
|
39
|
-
.action(async (directory = '.', options) => {
|
|
40
|
-
const parser = new MarkerParser_1.MarkerParser();
|
|
41
|
-
const results = await parser.scan(directory);
|
|
42
|
-
const validator = new ComplianceValidator_1.ComplianceValidator({ strict: options.strict });
|
|
43
|
-
const status = await validator.validate(results);
|
|
44
|
-
if (status.valid) {
|
|
45
|
-
console.log(chalk_1.default.green('✅ RCF compliance validated'));
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
console.log(chalk_1.default.red('❌ RCF compliance failed'));
|
|
49
|
-
status.errors.forEach(e => console.log(chalk_1.default.red(` • ${e.file}:${e.line} - ${e.message}`)));
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
program
|
|
54
|
-
.command('audit [directory]')
|
|
55
|
-
.description('Generate an RCF Audit Report (Premium Feature)')
|
|
56
|
-
.option('-k, --license-key <key>', 'RCF Audit License Key')
|
|
57
|
-
.action(async (directory = '.', options) => {
|
|
58
|
-
const licenseKey = options.licenseKey || process.env.RCF_LICENSE_KEY;
|
|
59
|
-
const uuidRegex = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/;
|
|
60
|
-
if (!licenseKey || !licenseKey.startsWith('RCF-AUDIT-') || !uuidRegex.test(licenseKey.replace('RCF-AUDIT-', ''))) {
|
|
61
|
-
console.log(chalk_1.default.red("❌ RCF-PL ERROR: The 'audit' command is a premium feature."));
|
|
62
|
-
console.log(chalk_1.default.yellow(" Please provide a valid RCF-AUDIT license key via -k/--license-key or RCF_LICENSE_KEY env variable."));
|
|
63
|
-
console.log(chalk_1.default.blue(" Visit https://rcf.aliyev.site to obtain a license."));
|
|
64
|
-
process.exit(1);
|
|
65
|
-
}
|
|
66
|
-
const parser = new MarkerParser_1.MarkerParser();
|
|
67
|
-
const results = await parser.scan(directory);
|
|
68
|
-
const auditReport = {
|
|
69
|
-
timestamp: new Date().toISOString(),
|
|
70
|
-
audit_type: "RCF-Audit as a Service",
|
|
71
|
-
protected_assets: []
|
|
72
|
-
};
|
|
73
|
-
for (const res of results) {
|
|
74
|
-
if (res.markers && res.markers.length > 0) {
|
|
75
|
-
try {
|
|
76
|
-
const fileBuffer = (0, fs_1.readFileSync)(res.file);
|
|
77
|
-
const fileHash = (0, crypto_1.createHash)('sha256').update(fileBuffer).digest('hex');
|
|
78
|
-
const uniqueMarkers = Array.from(new Set(res.markers.map((m) => m.type)));
|
|
79
|
-
const relPath = (0, path_1.relative)((0, path_1.resolve)(directory), res.file);
|
|
80
|
-
auditReport.protected_assets.push({
|
|
81
|
-
file: relPath,
|
|
82
|
-
markers: uniqueMarkers,
|
|
83
|
-
sha256: fileHash
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
catch (e) {
|
|
87
|
-
// ignore
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
const reportPath = (0, path_1.resolve)(directory, 'RCF-AUDIT-REPORT.json');
|
|
92
|
-
(0, fs_1.writeFileSync)(reportPath, JSON.stringify(auditReport, null, 2));
|
|
93
|
-
console.log(chalk_1.default.green(`✅ RCF-Audit Complete. Generated ${reportPath}`));
|
|
94
|
-
console.log(chalk_1.default.cyan(`🔒 Encrypted snapshot of ${auditReport.protected_assets.length} protected assets created.`));
|
|
95
|
-
});
|
|
96
|
-
function printSummary(results) {
|
|
97
|
-
const stats = { PUBLIC: 0, PROTECTED: 0, RESTRICTED: 0, NOTICE: 0 };
|
|
98
|
-
results.forEach(r => r.markers.forEach((m) => stats[m.type]++));
|
|
99
|
-
console.log(chalk_1.default.bold('\n📊 RCF Markers Summary:'));
|
|
100
|
-
console.log(` ${chalk_1.default.green('[RCF:PUBLIC]')}: ${stats.PUBLIC}`);
|
|
101
|
-
console.log(` ${chalk_1.default.yellow('[RCF:PROTECTED]')}: ${stats.PROTECTED}`);
|
|
102
|
-
console.log(` ${chalk_1.default.red('[RCF:RESTRICTED]')}: ${stats.RESTRICTED}`);
|
|
103
|
-
console.log(` ${chalk_1.default.blue('[RCF:NOTICE]')}: ${stats.NOTICE}`);
|
|
104
|
-
console.log(` Total files: ${results.length}\n`);
|
|
105
|
-
}
|
|
106
|
-
function printResults(results, format) {
|
|
107
|
-
if (format === 'json') {
|
|
108
|
-
console.log(JSON.stringify(results, null, 2));
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
results.forEach(({ file, markers }) => {
|
|
112
|
-
console.log(chalk_1.default.bold(`\n📄 ${file}`));
|
|
113
|
-
markers.forEach((m) => {
|
|
114
|
-
const color = m.type === 'PUBLIC' ? 'green' :
|
|
115
|
-
m.type === 'PROTECTED' ? 'yellow' :
|
|
116
|
-
m.type === 'RESTRICTED' ? 'red' : 'blue';
|
|
117
|
-
console.log(` ${chalk_1.default[color](m.marker.name)} Line ${m.line}: ${m.context.substring(0, 50)}...`);
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
program.parse();
|