@greenarmor/ges 0.3.5 → 0.4.0
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/cli.js +2 -0
- package/dist/commands/audit.js +1 -1
- package/dist/commands/badge.d.ts +2 -0
- package/dist/commands/badge.js +42 -0
- package/dist/commands/compliance.js +4 -1
- package/dist/commands/score.js +3 -12
- package/package.json +12 -12
package/dist/cli.js
CHANGED
|
@@ -12,6 +12,7 @@ import { generateCommand } from "./commands/generate.js";
|
|
|
12
12
|
import { policyCommand } from "./commands/policy.js";
|
|
13
13
|
import { updateCommand } from "./commands/update.js";
|
|
14
14
|
import { mcpCommand } from "./commands/mcp.js";
|
|
15
|
+
import { badgeCommand } from "./commands/badge.js";
|
|
15
16
|
import { GESF_VERSION } from "@greenarmor/ges-core";
|
|
16
17
|
const program = new Command();
|
|
17
18
|
program
|
|
@@ -30,4 +31,5 @@ program.addCommand(generateCommand);
|
|
|
30
31
|
program.addCommand(policyCommand);
|
|
31
32
|
program.addCommand(updateCommand);
|
|
32
33
|
program.addCommand(mcpCommand);
|
|
34
|
+
program.addCommand(badgeCommand);
|
|
33
35
|
program.parse();
|
package/dist/commands/audit.js
CHANGED
|
@@ -21,7 +21,7 @@ export const auditCommand = new Command("audit")
|
|
|
21
21
|
const frameworks = (config?.frameworks || ["GDPR", "OWASP"]);
|
|
22
22
|
const controls = getAllPacks().flatMap(p => p.controls);
|
|
23
23
|
const updatedControls = updateControlsFromFindings(controls, findings);
|
|
24
|
-
const scoreData = generateScoreFile(updatedControls, frameworks);
|
|
24
|
+
const scoreData = generateScoreFile(updatedControls, frameworks, findings);
|
|
25
25
|
writeJsonFile(path.join(root, ".ges", "score.json"), scoreData);
|
|
26
26
|
const critical = findings.filter(f => f.severity === "critical");
|
|
27
27
|
const high = findings.filter(f => f.severity === "high");
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { ensureGESInitialized, readJsonFile } from "../utils/project.js";
|
|
3
|
+
import { generateBadgeSvg, injectBadgeIntoReadme, computeGrade } from "@greenarmor/ges-scoring-engine";
|
|
4
|
+
import { showNextStepsMenu } from "../utils/next-steps.js";
|
|
5
|
+
import * as fs from "node:fs";
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
export const badgeCommand = new Command("badge")
|
|
8
|
+
.description("Generate compliance score badge for README")
|
|
9
|
+
.option("-o, --output <path>", "Output path for badge SVG", ".ges/badge.svg")
|
|
10
|
+
.option("--readme <path>", "README file to inject badge into", "README.md")
|
|
11
|
+
.option("--no-readme", "Do not inject badge into README")
|
|
12
|
+
.action(async (options) => {
|
|
13
|
+
const root = ensureGESInitialized();
|
|
14
|
+
const scorePath = path.join(root, ".ges", "score.json");
|
|
15
|
+
const score = readJsonFile(scorePath);
|
|
16
|
+
if (!score || !score.frameworks || Object.keys(score.frameworks).length === 0) {
|
|
17
|
+
console.log("\n No compliance score available. Run 'ges audit' first.\n");
|
|
18
|
+
await showNextStepsMenu("badge");
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const svg = generateBadgeSvg(score);
|
|
22
|
+
const outputPath = path.resolve(root, options.output);
|
|
23
|
+
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
|
|
24
|
+
fs.writeFileSync(outputPath, svg);
|
|
25
|
+
console.log(`\n Badge generated: ${options.output}`);
|
|
26
|
+
console.log(` Score: ${score.overall}% (${score.overall_grade ?? computeGrade(score.overall)})`);
|
|
27
|
+
if (options.readme !== false) {
|
|
28
|
+
const readmePath = path.resolve(root, options.readme);
|
|
29
|
+
if (fs.existsSync(readmePath)) {
|
|
30
|
+
const readmeContent = fs.readFileSync(readmePath, "utf-8");
|
|
31
|
+
const relativeBadgePath = path.relative(path.dirname(readmePath), outputPath);
|
|
32
|
+
const updated = injectBadgeIntoReadme(readmeContent, relativeBadgePath);
|
|
33
|
+
fs.writeFileSync(readmePath, updated);
|
|
34
|
+
console.log(` Badge injected into ${options.readme}`);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
console.log(` ${options.readme} not found — skipping badge injection`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
console.log("");
|
|
41
|
+
await showNextStepsMenu("badge");
|
|
42
|
+
});
|
|
@@ -25,7 +25,10 @@ export const complianceCommand = new Command("compliance")
|
|
|
25
25
|
const controls = readJsonFile(controlsFile);
|
|
26
26
|
const total = controls?.length || 0;
|
|
27
27
|
const passed = controls?.filter(c => c.status === "pass").length || 0;
|
|
28
|
-
|
|
28
|
+
const failed = controls?.filter(c => c.status === "fail").length || 0;
|
|
29
|
+
const criticalFailed = controls?.filter(c => c.status === "fail" && c.severity === "critical").length || 0;
|
|
30
|
+
const statusTag = criticalFailed > 0 ? " ⚠" : "";
|
|
31
|
+
console.log(` ${pack.id.padEnd(15)} ${passed}/${total} passed ${failed} failed${statusTag}`);
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
console.log("");
|
package/dist/commands/score.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { ensureGESInitialized, readJsonFile } from "../utils/project.js";
|
|
3
|
+
import { formatScoreOutput } from "@greenarmor/ges-scoring-engine";
|
|
3
4
|
import { showNextStepsMenu } from "../utils/next-steps.js";
|
|
4
5
|
import * as path from "node:path";
|
|
5
6
|
export const scoreCommand = new Command("score")
|
|
@@ -18,18 +19,8 @@ export const scoreCommand = new Command("score")
|
|
|
18
19
|
console.log(JSON.stringify(score, null, 2));
|
|
19
20
|
}
|
|
20
21
|
else {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const padding = Math.max(1, 20 - fw.length);
|
|
24
|
-
const dots = ".".repeat(padding);
|
|
25
|
-
lines.push(` ${fw} ${dots} ${data.score}%`);
|
|
26
|
-
}
|
|
27
|
-
const overallPadding = Math.max(1, 20 - "Overall".length);
|
|
28
|
-
lines.push(` Overall ${".".repeat(overallPadding)} ${score.overall}%`);
|
|
29
|
-
lines.push("");
|
|
30
|
-
lines.push(` Last evaluated: ${score.evaluated_at}`);
|
|
31
|
-
lines.push("");
|
|
32
|
-
console.log(lines.join("\n"));
|
|
22
|
+
console.log(formatScoreOutput(score));
|
|
23
|
+
console.log(` Last evaluated: ${score.evaluated_at}\n`);
|
|
33
24
|
}
|
|
34
25
|
await showNextStepsMenu("score");
|
|
35
26
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@greenarmor/ges",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Green Engineering Standard Framework - Compliance-as-Code CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -13,17 +13,17 @@
|
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"commander": "^13.0.0",
|
|
16
|
-
"@greenarmor/ges-audit-engine": "0.
|
|
17
|
-
"@greenarmor/ges-cicd-generator": "0.
|
|
18
|
-
"@greenarmor/ges-
|
|
19
|
-
"@greenarmor/ges-
|
|
20
|
-
"@greenarmor/ges-report-generator": "0.
|
|
21
|
-
"@greenarmor/ges-
|
|
22
|
-
"@greenarmor/ges-
|
|
23
|
-
"@greenarmor/ges-scoring-engine": "0.
|
|
24
|
-
"@greenarmor/ges-
|
|
25
|
-
"@greenarmor/ges-
|
|
26
|
-
"@greenarmor/ges-
|
|
16
|
+
"@greenarmor/ges-audit-engine": "0.4.0",
|
|
17
|
+
"@greenarmor/ges-cicd-generator": "0.4.0",
|
|
18
|
+
"@greenarmor/ges-policy-engine": "0.4.0",
|
|
19
|
+
"@greenarmor/ges-core": "0.4.0",
|
|
20
|
+
"@greenarmor/ges-report-generator": "0.4.0",
|
|
21
|
+
"@greenarmor/ges-compliance-engine": "0.4.0",
|
|
22
|
+
"@greenarmor/ges-scanner-integration": "0.4.0",
|
|
23
|
+
"@greenarmor/ges-scoring-engine": "0.4.0",
|
|
24
|
+
"@greenarmor/ges-rules-engine": "0.4.0",
|
|
25
|
+
"@greenarmor/ges-mcp-server": "0.4.0",
|
|
26
|
+
"@greenarmor/ges-doc-generator": "0.4.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^22.0.0",
|