@fortressjs/cli 0.1.2 → 0.1.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/dist/index.d.ts +1 -1
- package/dist/index.js +31 -7
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function runAudit(targetPath?: string): void;
|
|
1
|
+
export declare function runAudit(targetPath?: string, jsonOutput?: boolean): void;
|
package/dist/index.js
CHANGED
|
@@ -58,9 +58,7 @@ function getFilesRecursively(dir, fileList = []) {
|
|
|
58
58
|
}
|
|
59
59
|
return fileList;
|
|
60
60
|
}
|
|
61
|
-
function runAudit(targetPath) {
|
|
62
|
-
console.log(`\n${C.bold}${C.cyan}🛡️ FortressJS Security Audit CLI${C.reset}`);
|
|
63
|
-
console.log(`${C.dim}=========================================${C.reset}\n`);
|
|
61
|
+
function runAudit(targetPath, jsonOutput = false) {
|
|
64
62
|
const target = path_1.default.resolve(targetPath || process.cwd());
|
|
65
63
|
let files;
|
|
66
64
|
try {
|
|
@@ -71,11 +69,25 @@ function runAudit(targetPath) {
|
|
|
71
69
|
process.exit(1);
|
|
72
70
|
}
|
|
73
71
|
if (files.length === 0) {
|
|
72
|
+
if (jsonOutput) {
|
|
73
|
+
console.log(JSON.stringify({
|
|
74
|
+
target,
|
|
75
|
+
score: 0,
|
|
76
|
+
missing: [],
|
|
77
|
+
recommendations: [],
|
|
78
|
+
message: "No JavaScript or TypeScript files found"
|
|
79
|
+
}, null, 2));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
74
82
|
console.log(`${C.yellow}No JavaScript or TypeScript files found to scan in: ${target}${C.reset}`);
|
|
75
83
|
return;
|
|
76
84
|
}
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
if (!jsonOutput) {
|
|
86
|
+
console.log(`\n${C.bold}${C.cyan}🛡️ FortressJS Security Audit CLI${C.reset}`);
|
|
87
|
+
console.log(`${C.dim}=========================================${C.reset}\n`);
|
|
88
|
+
console.log(`${C.dim}Target: ${target}${C.reset}`);
|
|
89
|
+
console.log(`${C.dim}Scanning ${files.length} file(s)...${C.reset}\n`);
|
|
90
|
+
}
|
|
79
91
|
const scanner = new scanner_1.RegexScanner();
|
|
80
92
|
// Aggregate results across all files in the project
|
|
81
93
|
const aggregated = {
|
|
@@ -142,6 +154,16 @@ function runAudit(targetPath) {
|
|
|
142
154
|
recommendations.push("Configure fortress.headers({ strictTransportSecurity: ... }) for HSTS");
|
|
143
155
|
}
|
|
144
156
|
score = Math.max(0, score);
|
|
157
|
+
const auditResult = {
|
|
158
|
+
target,
|
|
159
|
+
score,
|
|
160
|
+
missing,
|
|
161
|
+
recommendations
|
|
162
|
+
};
|
|
163
|
+
if (jsonOutput) {
|
|
164
|
+
console.log(JSON.stringify(auditResult, null, 2));
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
145
167
|
// Pick color based on score
|
|
146
168
|
let scoreColor = C.red;
|
|
147
169
|
if (score >= 90)
|
|
@@ -166,8 +188,10 @@ function runAudit(targetPath) {
|
|
|
166
188
|
// CLI entry point
|
|
167
189
|
const args = process.argv.slice(2);
|
|
168
190
|
if (args[0] === "audit") {
|
|
169
|
-
const
|
|
170
|
-
|
|
191
|
+
const jsonOutput = args.includes("--json");
|
|
192
|
+
const target = args.find((arg) => arg !== "audit" &&
|
|
193
|
+
arg !== "--json");
|
|
194
|
+
runAudit(target, jsonOutput);
|
|
171
195
|
}
|
|
172
196
|
else {
|
|
173
197
|
console.log(`\n${C.bold}FortressJS CLI${C.reset}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fortressjs/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Security audit CLI for Express applications. Detect missing security headers, rate limits, request validation, and threat protection.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Davanesh Saminathan",
|