@greenarmor/ges-web-dashboard 1.2.1 → 1.2.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.
Files changed (2) hide show
  1. package/dist/index.js +50 -4
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -52,6 +52,17 @@ function loadControlsForConfig(projectPath, config) {
52
52
  }
53
53
  }
54
54
  function loadFindings(projectPath) {
55
+ try {
56
+ const auditPath = path.join(projectPath, ".ges", "last-audit.json");
57
+ if (fs.existsSync(auditPath)) {
58
+ const raw = fs.readFileSync(auditPath, "utf-8");
59
+ const data = JSON.parse(raw);
60
+ if (data.findings && Array.isArray(data.findings)) {
61
+ return data.findings;
62
+ }
63
+ }
64
+ }
65
+ catch { /* fall through to live audit */ }
55
66
  try {
56
67
  const result = runAudit(projectPath);
57
68
  return deduplicateFindings(result.findings);
@@ -60,6 +71,38 @@ function loadFindings(projectPath) {
60
71
  return [];
61
72
  }
62
73
  }
74
+ const SCANNABLE_CATEGORIES = new Set([
75
+ "encryption", "authentication", "audit", "security",
76
+ "database", "secrets", "injection", "xss",
77
+ "infrastructure", "dependencies",
78
+ ]);
79
+ function updateControlsFromFindings(controls, findings) {
80
+ const controlsWithFindings = new Set(findings.flatMap(f => f.controlIds));
81
+ return controls.map(control => {
82
+ if (control.status === "pass" || control.status === "not-applicable")
83
+ return control;
84
+ const relevantFindings = findings.filter(f => f.controlIds.includes(control.id));
85
+ if (relevantFindings.length === 0) {
86
+ if (SCANNABLE_CATEGORIES.has(control.category) && !controlsWithFindings.has(control.id)) {
87
+ return {
88
+ ...control,
89
+ checks: control.checks.map(check => ({ ...check, status: "pass" })),
90
+ status: "pass",
91
+ };
92
+ }
93
+ return control;
94
+ }
95
+ const hasCritical = relevantFindings.some(f => f.severity === "critical" || f.severity === "high");
96
+ return {
97
+ ...control,
98
+ checks: control.checks.map(check => ({
99
+ ...check,
100
+ status: hasCritical ? "fail" : "warning",
101
+ })),
102
+ status: hasCritical ? "fail" : "warning",
103
+ };
104
+ });
105
+ }
63
106
  function buildPackSummary(pack, controls, findings, installedPacks) {
64
107
  const packControlIds = new Set(pack.controls.map(c => c.id));
65
108
  const packControls = controls.filter(c => packControlIds.has(c.id));
@@ -116,8 +159,9 @@ function getInstalledPackIds(projectPath, config) {
116
159
  export function collectDashboardData(projectPath) {
117
160
  const config = loadConfig(projectPath);
118
161
  let score = loadScore(projectPath);
119
- const controls = config ? loadControlsForConfig(projectPath, config) : [];
162
+ const baseControls = config ? loadControlsForConfig(projectPath, config) : [];
120
163
  const findings = loadFindings(projectPath);
164
+ const controls = updateControlsFromFindings(baseControls, findings);
121
165
  if (config) {
122
166
  try {
123
167
  const freshScore = generateScoreFile(controls, config.frameworks, findings);
@@ -145,7 +189,7 @@ export function collectDashboardData(projectPath) {
145
189
  projectName: config?.project_name || "Unknown Project",
146
190
  projectType: config?.project_type || "unknown",
147
191
  frameworks: config?.frameworks || [],
148
- gesfVersion: "1.2.1",
192
+ gesfVersion: "1.2.2",
149
193
  score,
150
194
  controls,
151
195
  findings,
@@ -159,8 +203,9 @@ export function collectPackDetail(projectPath, packId) {
159
203
  if (!pack)
160
204
  return null;
161
205
  const config = loadConfig(projectPath);
162
- const controls = config ? loadControlsForConfig(projectPath, config) : [];
206
+ const baseControls = config ? loadControlsForConfig(projectPath, config) : [];
163
207
  const findings = loadFindings(projectPath);
208
+ const controls = updateControlsFromFindings(baseControls, findings);
164
209
  const packControlIds = new Set(pack.controls.map(c => c.id));
165
210
  const packControls = pack.controls;
166
211
  const installedPacks = getInstalledPackIds(projectPath, config || undefined);
@@ -238,8 +283,9 @@ export function collectControlDetail(projectPath, controlId) {
238
283
  const config = loadConfig(projectPath);
239
284
  if (!config)
240
285
  return null;
241
- const controls = loadControlsForConfig(projectPath, config);
286
+ const baseControls = loadControlsForConfig(projectPath, config);
242
287
  const findings = loadFindings(projectPath);
288
+ const controls = updateControlsFromFindings(baseControls, findings);
243
289
  const control = controls.find(c => c.id === controlId);
244
290
  if (!control)
245
291
  return null;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "dependencies": {
3
- "@greenarmor/ges-audit-engine": "1.2.1",
4
- "@greenarmor/ges-core": "1.2.1",
5
- "@greenarmor/ges-policy-engine": "1.2.1",
6
- "@greenarmor/ges-scoring-engine": "1.2.1"
3
+ "@greenarmor/ges-audit-engine": "1.2.2",
4
+ "@greenarmor/ges-core": "1.2.2",
5
+ "@greenarmor/ges-policy-engine": "1.2.2",
6
+ "@greenarmor/ges-scoring-engine": "1.2.2"
7
7
  },
8
8
  "description": "GESF Web Dashboard - Visual compliance dashboard for teams",
9
9
  "devDependencies": {
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "type": "module",
42
42
  "types": "./dist/index.d.ts",
43
- "version": "1.2.1",
43
+ "version": "1.2.2",
44
44
  "scripts": {
45
45
  "build": "tsc",
46
46
  "clean": "rm -rf dist tsconfig.tsbuildinfo",