@greenarmor/ges 1.1.7 → 1.2.1

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 CHANGED
@@ -17,12 +17,12 @@ import { controlCommand } from "./commands/control.js";
17
17
  import { fixCommand } from "./commands/fix.js";
18
18
  import { hooksCommand } from "./commands/hooks.js";
19
19
  import { dashboardCommand } from "./commands/dashboard.js";
20
- import { GESF_VERSION } from "@greenarmor/ges-core";
20
+ import { CLI_VERSION } from "./utils/version.js";
21
21
  const program = new Command();
22
22
  program
23
23
  .name("ges")
24
24
  .description("Green Engineering Standard Framework - Compliance-as-Code CLI")
25
- .version(GESF_VERSION);
25
+ .version(CLI_VERSION);
26
26
  program.addCommand(initCommand);
27
27
  program.addCommand(auditCommand);
28
28
  program.addCommand(scoreCommand);
@@ -1,6 +1,7 @@
1
1
  import { Command } from "commander";
2
2
  import { findProjectRoot, readJsonFile } from "../utils/project.js";
3
- import { GESF_VERSION, GES_DIR } from "@greenarmor/ges-core";
3
+ import { CLI_VERSION } from "../utils/version.js";
4
+ import { GES_DIR } from "@greenarmor/ges-core";
4
5
  import { showNextStepsMenu } from "../utils/next-steps.js";
5
6
  import * as fs from "node:fs";
6
7
  import * as path from "node:path";
@@ -51,7 +52,7 @@ export const doctorCommand = new Command("doctor")
51
52
  checks.push({ name: "Frameworks", status: "OK", detail: config.frameworks.join(", ") });
52
53
  }
53
54
  }
54
- checks.push({ name: "GESF Version", status: "OK", detail: GESF_VERSION });
55
+ checks.push({ name: "GESF Version", status: "OK", detail: CLI_VERSION });
55
56
  for (const check of checks) {
56
57
  const icon = check.status === "OK" ? "✓" : check.status === "WARN" ? "!" : "✗";
57
58
  const line = ` [${icon}] ${check.name}`;
@@ -2,6 +2,25 @@ import { Command } from "commander";
2
2
  import { ensureGESInitialized } from "../utils/project.js";
3
3
  import { runAudit, deduplicateFindings } from "@greenarmor/ges-audit-engine";
4
4
  import { createAutoFixPlan, applyAutoFixAction, getNpmInstallsFromActions } from "@greenarmor/ges-mcp-server";
5
+ import { appendFixHistory, createFixHistoryEntry } from "@greenarmor/ges-core";
6
+ import { getAllPacks } from "@greenarmor/ges-policy-engine";
7
+ import * as fs from "node:fs";
8
+ import * as path from "node:path";
9
+ function loadProjectControls(root) {
10
+ try {
11
+ const configPath = path.join(root, ".ges", "config.json");
12
+ if (!fs.existsSync(configPath))
13
+ return [];
14
+ const config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
15
+ const fwLower = new Set(config.frameworks.map((f) => f.toLowerCase()));
16
+ const allPacks = getAllPacks();
17
+ const filtered = allPacks.filter(pack => fwLower.has(pack.id.toLowerCase()));
18
+ return filtered.flatMap((p) => p.controls);
19
+ }
20
+ catch {
21
+ return [];
22
+ }
23
+ }
5
24
  export const fixCommand = new Command("fix")
6
25
  .description("Automatically fix security and compliance findings")
7
26
  .option("-d, --dry-run", "Show what would be fixed without making changes")
@@ -14,6 +33,7 @@ export const fixCommand = new Command("fix")
14
33
  console.log(" Scanning project files...");
15
34
  const { findings: rawFindings, scannedFiles } = runAudit(root);
16
35
  const findings = deduplicateFindings(rawFindings);
36
+ const projectControls = loadProjectControls(root);
17
37
  console.log(` Scanned ${scannedFiles} files`);
18
38
  console.log(` Found ${findings.length} findings\n`);
19
39
  if (findings.length === 0) {
@@ -45,11 +65,35 @@ export const fixCommand = new Command("fix")
45
65
  }
46
66
  let applied = 0;
47
67
  let failed = 0;
68
+ const historyEntries = [];
48
69
  for (const action of actions) {
70
+ const matchingFindings = findings.filter(f => f.ruleId === action.ruleId);
71
+ const primaryFinding = matchingFindings[0];
72
+ const matchedControls = primaryFinding
73
+ ? projectControls.filter((c) => primaryFinding.controlIds.includes(c.id))
74
+ : [];
49
75
  if (dryRun) {
50
76
  console.log(` [${action.type}] ${action.filePath}`);
51
77
  console.log(` ${action.description} [${action.ruleId}]`);
52
78
  applied++;
79
+ historyEntries.push(createFixHistoryEntry({
80
+ source: "cli",
81
+ dry_run: true,
82
+ finding: primaryFinding ?? {
83
+ ruleId: action.ruleId,
84
+ severity: "medium",
85
+ category: "",
86
+ title: action.description,
87
+ file: "",
88
+ evidence: "",
89
+ description: action.description,
90
+ controlIds: [],
91
+ fix: action.description,
92
+ },
93
+ action,
94
+ controls: matchedControls,
95
+ applied: false,
96
+ }));
53
97
  }
54
98
  else {
55
99
  const result = applyAutoFixAction(root, action);
@@ -62,8 +106,31 @@ export const fixCommand = new Command("fix")
62
106
  console.log(` ${result.error}`);
63
107
  failed++;
64
108
  }
109
+ historyEntries.push(createFixHistoryEntry({
110
+ source: "cli",
111
+ dry_run: false,
112
+ finding: primaryFinding ?? {
113
+ ruleId: action.ruleId,
114
+ severity: "medium",
115
+ category: "",
116
+ title: action.description,
117
+ file: "",
118
+ evidence: "",
119
+ description: action.description,
120
+ controlIds: [],
121
+ fix: action.description,
122
+ },
123
+ action,
124
+ controls: matchedControls,
125
+ applied: result.applied,
126
+ error: result.applied ? undefined : result.error,
127
+ }));
65
128
  }
66
129
  }
130
+ if (historyEntries.length > 0 && !dryRun) {
131
+ appendFixHistory(root, historyEntries);
132
+ console.log(`\n Fix history recorded in .ges/fix-history.json`);
133
+ }
67
134
  console.log("");
68
135
  console.log(` Fixes ${dryRun ? "planned" : "applied"}: ${applied}${failed > 0 ? ` (${failed} failed)` : ""}`);
69
136
  if (npmInstalls.length > 0) {
@@ -1,6 +1,7 @@
1
1
  import { Command } from "commander";
2
2
  import { input, select, checkbox } from "../utils/prompts.js";
3
- import { PROJECT_TYPES, FRAMEWORKS, DEFAULT_FRAMEWORKS, GESF_VERSION, GES_DIR, COMPLIANCE_DIR, SECURITY_DIR, CONTROLS_DIR, POLICIES_DIR, CHECKLISTS_DIR, DOCS_DIR, REPORTS_DIR, } from "@greenarmor/ges-core";
3
+ import { PROJECT_TYPES, FRAMEWORKS, DEFAULT_FRAMEWORKS, GES_DIR, COMPLIANCE_DIR, SECURITY_DIR, CONTROLS_DIR, POLICIES_DIR, CHECKLISTS_DIR, DOCS_DIR, REPORTS_DIR, } from "@greenarmor/ges-core";
4
+ import { CLI_VERSION } from "../utils/version.js";
4
5
  import { getPacksForProjectType } from "@greenarmor/ges-policy-engine";
5
6
  import { generateComplianceDocs, generateSecurityDocs, generateConfigJson, generateMetadataJson, generateFrameworkVersionJson, generateScoreJson, } from "@greenarmor/ges-doc-generator";
6
7
  import { generateAllWorkflows } from "@greenarmor/ges-cicd-generator";
@@ -15,7 +16,7 @@ export const initCommand = new Command("init")
15
16
  .option("-f, --frameworks <frameworks>", "Comma-separated frameworks")
16
17
  .option("--force", "Re-initialize even if GESF is already set up")
17
18
  .action(async (options) => {
18
- console.log("\n Green Engineering Standard Framework (GESF) v" + GESF_VERSION);
19
+ console.log("\n Green Engineering Standard Framework (GESF) v" + CLI_VERSION);
19
20
  console.log(" ─────────────────────────────────────────────\n");
20
21
  const gesDir = path.join(process.cwd(), GES_DIR);
21
22
  if (fs.existsSync(gesDir)) {
@@ -71,7 +72,7 @@ export const initCommand = new Command("init")
71
72
  privacy_controls: { required: true, level: "mandatory" },
72
73
  },
73
74
  created_at: now,
74
- version: GESF_VERSION,
75
+ version: CLI_VERSION,
75
76
  };
76
77
  const dirs = [GES_DIR, COMPLIANCE_DIR, SECURITY_DIR, CONTROLS_DIR, POLICIES_DIR, CHECKLISTS_DIR, DOCS_DIR, REPORTS_DIR];
77
78
  for (const dir of dirs) {
@@ -1,10 +1,10 @@
1
1
  import { Command } from "commander";
2
- import { GESF_VERSION } from "@greenarmor/ges-core";
2
+ import { CLI_VERSION } from "../utils/version.js";
3
3
  import { showNextStepsMenu } from "../utils/next-steps.js";
4
4
  export const updateCommand = new Command("update")
5
5
  .description("Check for GESF updates")
6
6
  .action(async () => {
7
- console.log(`\n GESF Version: ${GESF_VERSION}`);
7
+ console.log(`\n GESF Version: ${CLI_VERSION}`);
8
8
  console.log(" Update check: Run 'npm update -g @greenarmor/ges' or 'pnpm update -g @greenarmor/ges'\n");
9
9
  await showNextStepsMenu("update");
10
10
  });
@@ -0,0 +1 @@
1
+ export declare const CLI_VERSION: string;
@@ -0,0 +1,8 @@
1
+ import { createRequire } from "node:module";
2
+ import * as url from "node:url";
3
+ import * as path from "node:path";
4
+ const __filename = url.fileURLToPath(import.meta.url);
5
+ const __dirname = path.dirname(__filename);
6
+ const require = createRequire(import.meta.url);
7
+ const pkg = require(path.join(__dirname, "..", "..", "package.json"));
8
+ export const CLI_VERSION = pkg.version;
package/package.json CHANGED
@@ -1,34 +1,24 @@
1
1
  {
2
- "name": "@greenarmor/ges",
3
- "version": "1.1.7",
4
- "description": "Green Engineering Standard Framework - Compliance-as-Code CLI",
5
- "type": "module",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
2
  "bin": {
9
3
  "ges": "./dist/cli.js"
10
4
  },
11
- "files": [
12
- "dist",
13
- "LICENSE",
14
- "README.md"
15
- ],
16
5
  "dependencies": {
17
- "@greenarmor/ges-audit-engine": "1.1.5",
18
- "@greenarmor/ges-cicd-generator": "1.1.5",
19
- "@greenarmor/ges-compliance-engine": "1.1.5",
20
- "@greenarmor/ges-core": "1.1.5",
21
- "@greenarmor/ges-doc-generator": "1.1.5",
22
- "@greenarmor/ges-policy-engine": "1.1.5",
23
- "@greenarmor/ges-report-generator": "1.1.5",
24
- "@greenarmor/ges-rules-engine": "1.1.5",
25
- "@greenarmor/ges-scanner-integration": "1.1.5",
26
- "@greenarmor/ges-scoring-engine": "1.1.5",
27
- "@greenarmor/ges-mcp-server": "1.1.5",
28
- "@greenarmor/ges-git-hooks": "1.1.5",
29
- "@greenarmor/ges-web-dashboard": "1.1.5",
6
+ "@greenarmor/ges-audit-engine": "1.2.1",
7
+ "@greenarmor/ges-cicd-generator": "1.2.1",
8
+ "@greenarmor/ges-compliance-engine": "1.2.1",
9
+ "@greenarmor/ges-core": "1.2.1",
10
+ "@greenarmor/ges-doc-generator": "1.2.1",
11
+ "@greenarmor/ges-git-hooks": "1.2.1",
12
+ "@greenarmor/ges-mcp-server": "1.2.1",
13
+ "@greenarmor/ges-policy-engine": "1.2.1",
14
+ "@greenarmor/ges-report-generator": "1.2.1",
15
+ "@greenarmor/ges-rules-engine": "1.2.1",
16
+ "@greenarmor/ges-scanner-integration": "1.2.1",
17
+ "@greenarmor/ges-scoring-engine": "1.2.1",
18
+ "@greenarmor/ges-web-dashboard": "1.2.1",
30
19
  "commander": "^13.0.0"
31
20
  },
21
+ "description": "Green Engineering Standard Framework - Compliance-as-Code CLI",
32
22
  "devDependencies": {
33
23
  "@types/node": "^22.0.0",
34
24
  "typescript": "^6.0.0",
@@ -37,6 +27,12 @@
37
27
  "engines": {
38
28
  "node": ">=20.0.0"
39
29
  },
30
+ "files": [
31
+ "dist",
32
+ "LICENSE",
33
+ "README.md"
34
+ ],
35
+ "homepage": "https://github.com/greenarmor/gesf",
40
36
  "keywords": [
41
37
  "compliance",
42
38
  "gdpr",
@@ -49,11 +45,15 @@
49
45
  "compliance-as-code"
50
46
  ],
51
47
  "license": "MIT",
48
+ "main": "./dist/index.js",
49
+ "name": "@greenarmor/ges",
52
50
  "repository": {
53
51
  "type": "git",
54
52
  "url": "https://github.com/greenarmor/gesf"
55
53
  },
56
- "homepage": "https://github.com/greenarmor/gesf",
54
+ "type": "module",
55
+ "types": "./dist/index.d.ts",
56
+ "version": "1.2.1",
57
57
  "scripts": {
58
58
  "build": "tsc",
59
59
  "clean": "rm -rf dist tsconfig.tsbuildinfo",