gesf-vscode 1.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025–2026 greenarmor
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # GESF VS Code Extension
2
+
3
+ Real-time GDPR, security, and compliance warnings for projects using the Green Engineering Standard Framework (GESF).
4
+
5
+ ## Features
6
+
7
+ - **Real-time warnings** for missing security headers (helmet), missing CORS config, missing .gitignore, .env not in .gitignore
8
+ - **Compliance checks** for missing MFA implementation, missing encryption, missing retention policy documents
9
+ - **Status bar** showing live compliance score from `ges audit`
10
+ - **Commands** to run audit, show score, and generate reports directly from VS Code
11
+
12
+ ## Requirements
13
+
14
+ - [GESF CLI](https://www.npmjs.com/package/@greenarmor/ges) installed globally: `npm install -g @greenarmor/ges`
15
+ - Run `ges init` in your project to initialize compliance controls
16
+
17
+ ## Commands
18
+
19
+ | Command | Description |
20
+ |---------|-------------|
21
+ | `GESF: Run Compliance Audit` | Runs `ges audit` in a terminal |
22
+ | `GESF: Show Compliance Score` | Runs `ges score` in a terminal |
23
+ | `GESF: Generate Report` | Generates a compliance report (markdown/html/pdf) |
24
+
25
+ ## Warnings Detected
26
+
27
+ | Warning | Severity |
28
+ |---------|----------|
29
+ | Missing helmet middleware | High |
30
+ | Missing CORS package | Medium |
31
+ | No .gitignore file | High |
32
+ | .env not in .gitignore | Critical |
33
+ | MFA required but not implemented | High |
34
+ | Encryption required but not detected | Critical |
35
+ | Retention policy document missing | Medium |
36
+ | GESF not initialized | High |
37
+
38
+ ## License
39
+
40
+ MIT
package/build.js ADDED
@@ -0,0 +1,13 @@
1
+ const esbuild = require("esbuild");
2
+
3
+ esbuild.build({
4
+ entryPoints: ["src/extension.ts"],
5
+ bundle: true,
6
+ outfile: "dist/extension.js",
7
+ external: ["vscode"],
8
+ format: "cjs",
9
+ platform: "node",
10
+ target: "node18",
11
+ sourcemap: false,
12
+ minify: false,
13
+ }).catch(() => process.exit(1));
@@ -0,0 +1,264 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/extension.ts
31
+ var extension_exports = {};
32
+ __export(extension_exports, {
33
+ activate: () => activate,
34
+ deactivate: () => deactivate
35
+ });
36
+ module.exports = __toCommonJS(extension_exports);
37
+ var vscode = __toESM(require("vscode"));
38
+ var fs = __toESM(require("node:fs"));
39
+ var path = __toESM(require("node:path"));
40
+ var diagnosticCollection;
41
+ var statusBarItem;
42
+ function activate(context) {
43
+ diagnosticCollection = vscode.languages.createDiagnosticCollection("gesf");
44
+ context.subscriptions.push(diagnosticCollection);
45
+ statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 50);
46
+ statusBarItem.command = "gesf.showScore";
47
+ context.subscriptions.push(statusBarItem);
48
+ context.subscriptions.push(
49
+ vscode.commands.registerCommand("gesf.runAudit", runAudit)
50
+ );
51
+ context.subscriptions.push(
52
+ vscode.commands.registerCommand("gesf.showScore", showScore)
53
+ );
54
+ context.subscriptions.push(
55
+ vscode.commands.registerCommand("gesf.generateReport", generateReport)
56
+ );
57
+ context.subscriptions.push(
58
+ vscode.workspace.onDidSaveTextDocument(() => checkProject())
59
+ );
60
+ context.subscriptions.push(
61
+ vscode.window.onDidChangeActiveTextEditor(() => checkProject())
62
+ );
63
+ checkProject();
64
+ }
65
+ function getProjectRoot() {
66
+ const folders = vscode.workspace.workspaceFolders;
67
+ if (!folders || folders.length === 0) return void 0;
68
+ const root = folders[0].uri.fsPath;
69
+ if (fs.existsSync(path.join(root, ".ges", "config.json"))) return root;
70
+ return void 0;
71
+ }
72
+ function checkProject() {
73
+ const root = getProjectRoot();
74
+ if (!root) {
75
+ statusBarItem.hide();
76
+ return;
77
+ }
78
+ const warnings = detectComplianceWarnings(root);
79
+ const diagnostics = [];
80
+ for (const warning of warnings) {
81
+ const uri = vscode.Uri.file(path.join(root, warning.file));
82
+ const line = warning.line || 0;
83
+ const range = new vscode.Range(line, 0, line, 100);
84
+ const severity = warning.severity === "critical" ? vscode.DiagnosticSeverity.Error : warning.severity === "high" ? vscode.DiagnosticSeverity.Warning : vscode.DiagnosticSeverity.Information;
85
+ const diag = new vscode.Diagnostic(range, `[GESF] ${warning.message}`, severity);
86
+ diag.source = "gesf";
87
+ diagnostics.push(diag);
88
+ }
89
+ diagnosticCollection.clear();
90
+ for (const warning of warnings) {
91
+ const uri = vscode.Uri.file(path.join(root, warning.file));
92
+ const fileDiags = diagnostics.filter((_, i) => warnings[i].file === warning.file);
93
+ diagnosticCollection.set(uri, fileDiags);
94
+ }
95
+ updateStatusBar(root);
96
+ }
97
+ function detectComplianceWarnings(root) {
98
+ const warnings = [];
99
+ const configPath = path.join(root, ".ges", "config.json");
100
+ if (!fs.existsSync(configPath)) {
101
+ warnings.push({
102
+ file: "package.json",
103
+ severity: "high",
104
+ message: "GESF not initialized. Run 'ges init' to set up compliance controls."
105
+ });
106
+ return warnings;
107
+ }
108
+ let config;
109
+ try {
110
+ config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
111
+ } catch {
112
+ return warnings;
113
+ }
114
+ const pkgPath = path.join(root, "package.json");
115
+ if (fs.existsSync(pkgPath)) {
116
+ try {
117
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
118
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
119
+ if (deps.express && !deps.helmet) {
120
+ warnings.push({
121
+ file: "package.json",
122
+ severity: "high",
123
+ message: "Missing security headers. Install 'helmet' middleware."
124
+ });
125
+ }
126
+ if (deps.express && !deps.cors) {
127
+ warnings.push({
128
+ file: "package.json",
129
+ severity: "medium",
130
+ message: "No CORS configuration detected. Install 'cors' package."
131
+ });
132
+ }
133
+ } catch {
134
+ }
135
+ }
136
+ if (!fs.existsSync(path.join(root, ".gitignore"))) {
137
+ warnings.push({
138
+ file: ".gitignore",
139
+ severity: "high",
140
+ message: "No .gitignore file. Secrets may be committed accidentally."
141
+ });
142
+ }
143
+ const gitignorePath = path.join(root, ".gitignore");
144
+ if (fs.existsSync(gitignorePath)) {
145
+ const gitignore = fs.readFileSync(gitignorePath, "utf-8");
146
+ if (!gitignore.includes(".env")) {
147
+ warnings.push({
148
+ file: ".gitignore",
149
+ severity: "critical",
150
+ message: ".env not in .gitignore. Environment secrets may be committed."
151
+ });
152
+ }
153
+ }
154
+ const requirements = config.requirements;
155
+ if (requirements?.mfa?.required) {
156
+ const hasMFA = checkForMFA(root);
157
+ if (!hasMFA) {
158
+ warnings.push({
159
+ file: "package.json",
160
+ severity: "high",
161
+ message: "MFA is required by GESF config but no MFA implementation detected."
162
+ });
163
+ }
164
+ }
165
+ if (requirements?.encryption?.required) {
166
+ const hasEncryption = checkForEncryption(root);
167
+ if (!hasEncryption) {
168
+ warnings.push({
169
+ file: "package.json",
170
+ severity: "critical",
171
+ message: "Encryption is required by GESF config but no encryption detected."
172
+ });
173
+ }
174
+ }
175
+ if (requirements?.retention_policy?.required) {
176
+ if (!fs.existsSync(path.join(root, "compliance", "retention-policy.md"))) {
177
+ warnings.push({
178
+ file: "compliance/retention-policy.md",
179
+ severity: "medium",
180
+ message: "Retention policy document missing. Run 'ges generate --docs'."
181
+ });
182
+ }
183
+ }
184
+ return warnings;
185
+ }
186
+ function checkForMFA(root) {
187
+ const pkgPath = path.join(root, "package.json");
188
+ if (fs.existsSync(pkgPath)) {
189
+ try {
190
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
191
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
192
+ const mfaLibs = ["otpauth", "speakeasy", "otplib", "@simplewebauthn", "node-2fa"];
193
+ return mfaLibs.some((lib) => deps[lib] !== void 0);
194
+ } catch {
195
+ }
196
+ }
197
+ return false;
198
+ }
199
+ function checkForEncryption(root) {
200
+ const dirs = ["src", "lib", "crypto", "security"];
201
+ const patterns = [/aes-256/i, /AES_256_GCM/i, /createCipheriv/i, /ChaCha20/i, /crypto\.encrypt/i];
202
+ for (const dir of dirs) {
203
+ const dirPath = path.join(root, dir);
204
+ if (!fs.existsSync(dirPath)) continue;
205
+ try {
206
+ const entries = fs.readdirSync(dirPath, { recursive: true });
207
+ for (const entry of entries) {
208
+ const filePath = path.join(dirPath, entry.toString());
209
+ if (!fs.statSync(filePath).isFile()) continue;
210
+ const ext = path.extname(filePath);
211
+ if (![".ts", ".js"].includes(ext)) continue;
212
+ const content = fs.readFileSync(filePath, "utf-8");
213
+ if (patterns.some((p) => p.test(content))) return true;
214
+ }
215
+ } catch {
216
+ }
217
+ }
218
+ return false;
219
+ }
220
+ function updateStatusBar(root) {
221
+ const scorePath = path.join(root, ".ges", "score.json");
222
+ if (fs.existsSync(scorePath)) {
223
+ try {
224
+ const score = JSON.parse(fs.readFileSync(scorePath, "utf-8"));
225
+ const overall = score.overall || 0;
226
+ const grade = score.overall_grade || "?";
227
+ const icon = overall >= 80 ? "$(checkmark)" : overall >= 50 ? "$(warning)" : "$(error)";
228
+ statusBarItem.text = `${icon} GESF: ${overall}% (${grade})`;
229
+ } catch {
230
+ statusBarItem.text = "$(question) GESF: No score";
231
+ }
232
+ } else {
233
+ statusBarItem.text = "$(warning) GESF: Run audit";
234
+ }
235
+ statusBarItem.show();
236
+ }
237
+ async function runAudit() {
238
+ const terminal = vscode.window.createTerminal("GESF Audit");
239
+ terminal.show();
240
+ terminal.sendText("ges audit");
241
+ }
242
+ async function showScore() {
243
+ const terminal = vscode.window.createTerminal("GESF Score");
244
+ terminal.show();
245
+ terminal.sendText("ges score");
246
+ }
247
+ async function generateReport() {
248
+ const format = await vscode.window.showQuickPick(["markdown", "html", "pdf"], {
249
+ placeHolder: "Select report format"
250
+ });
251
+ if (!format) return;
252
+ const terminal = vscode.window.createTerminal("GESF Report");
253
+ terminal.show();
254
+ terminal.sendText(`ges report --format ${format}`);
255
+ }
256
+ function deactivate() {
257
+ diagnosticCollection?.clear();
258
+ statusBarItem?.hide();
259
+ }
260
+ // Annotate the CommonJS export names for ESM import in node:
261
+ 0 && (module.exports = {
262
+ activate,
263
+ deactivate
264
+ });
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "gesf-vscode",
3
+ "displayName": "GESF - Green Engineering Standard Framework",
4
+ "description": "Real-time GDPR, security, and compliance warnings for your project",
5
+ "version": "1.1.2",
6
+ "publisher": "greenarmor",
7
+ "engines": {
8
+ "vscode": "^1.80.0"
9
+ },
10
+ "categories": [
11
+ "Linters",
12
+ "Security"
13
+ ],
14
+ "activationEvents": [
15
+ "workspaceContains:.ges/config.json"
16
+ ],
17
+ "main": "./dist/extension.js",
18
+ "contributes": {
19
+ "commands": [
20
+ {
21
+ "command": "gesf.runAudit",
22
+ "title": "GESF: Run Compliance Audit"
23
+ },
24
+ {
25
+ "command": "gesf.showScore",
26
+ "title": "GESF: Show Compliance Score"
27
+ },
28
+ {
29
+ "command": "gesf.generateReport",
30
+ "title": "GESF: Generate Report"
31
+ }
32
+ ],
33
+ "jsonValidation": [
34
+ {
35
+ "fileMatch": ".ges/config.json",
36
+ "url": "https://raw.githubusercontent.com/greenarmor/gesf/main/packages/core/src/schemas/config.schema.json"
37
+ }
38
+ ]
39
+ },
40
+ "devDependencies": {
41
+ "@types/vscode": "^1.80.0",
42
+ "@types/node": "^22.0.0",
43
+ "esbuild": "^0.28.0",
44
+ "typescript": "^6.0.0"
45
+ },
46
+ "license": "MIT",
47
+ "scripts": {
48
+ "build": "node build.js",
49
+ "test": "echo \"no tests yet\""
50
+ }
51
+ }
@@ -0,0 +1,264 @@
1
+ import * as vscode from "vscode";
2
+ import * as fs from "node:fs";
3
+ import * as path from "node:path";
4
+
5
+ let diagnosticCollection: vscode.DiagnosticCollection;
6
+ let statusBarItem: vscode.StatusBarItem;
7
+
8
+ export function activate(context: vscode.ExtensionContext) {
9
+ diagnosticCollection = vscode.languages.createDiagnosticCollection("gesf");
10
+ context.subscriptions.push(diagnosticCollection);
11
+
12
+ statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 50);
13
+ statusBarItem.command = "gesf.showScore";
14
+ context.subscriptions.push(statusBarItem);
15
+
16
+ context.subscriptions.push(
17
+ vscode.commands.registerCommand("gesf.runAudit", runAudit),
18
+ );
19
+ context.subscriptions.push(
20
+ vscode.commands.registerCommand("gesf.showScore", showScore),
21
+ );
22
+ context.subscriptions.push(
23
+ vscode.commands.registerCommand("gesf.generateReport", generateReport),
24
+ );
25
+
26
+ context.subscriptions.push(
27
+ vscode.workspace.onDidSaveTextDocument(() => checkProject()),
28
+ );
29
+ context.subscriptions.push(
30
+ vscode.window.onDidChangeActiveTextEditor(() => checkProject()),
31
+ );
32
+
33
+ checkProject();
34
+ }
35
+
36
+ function getProjectRoot(): string | undefined {
37
+ const folders = vscode.workspace.workspaceFolders;
38
+ if (!folders || folders.length === 0) return undefined;
39
+ const root = folders[0].uri.fsPath;
40
+ if (fs.existsSync(path.join(root, ".ges", "config.json"))) return root;
41
+ return undefined;
42
+ }
43
+
44
+ function checkProject() {
45
+ const root = getProjectRoot();
46
+ if (!root) {
47
+ statusBarItem.hide();
48
+ return;
49
+ }
50
+
51
+ const warnings = detectComplianceWarnings(root);
52
+ const diagnostics: vscode.Diagnostic[] = [];
53
+
54
+ for (const warning of warnings) {
55
+ const uri = vscode.Uri.file(path.join(root, warning.file));
56
+ const line = warning.line || 0;
57
+ const range = new vscode.Range(line, 0, line, 100);
58
+ const severity =
59
+ warning.severity === "critical"
60
+ ? vscode.DiagnosticSeverity.Error
61
+ : warning.severity === "high"
62
+ ? vscode.DiagnosticSeverity.Warning
63
+ : vscode.DiagnosticSeverity.Information;
64
+ const diag = new vscode.Diagnostic(range, `[GESF] ${warning.message}`, severity);
65
+ diag.source = "gesf";
66
+ diagnostics.push(diag);
67
+ }
68
+
69
+ diagnosticCollection.clear();
70
+ for (const warning of warnings) {
71
+ const uri = vscode.Uri.file(path.join(root, warning.file));
72
+ const fileDiags = diagnostics.filter((_, i) => warnings[i].file === warning.file);
73
+ diagnosticCollection.set(uri, fileDiags);
74
+ }
75
+
76
+ updateStatusBar(root);
77
+ }
78
+
79
+ interface ComplianceWarning {
80
+ file: string;
81
+ line?: number;
82
+ severity: string;
83
+ message: string;
84
+ }
85
+
86
+ function detectComplianceWarnings(root: string): ComplianceWarning[] {
87
+ const warnings: ComplianceWarning[] = [];
88
+ const configPath = path.join(root, ".ges", "config.json");
89
+
90
+ if (!fs.existsSync(configPath)) {
91
+ warnings.push({
92
+ file: "package.json",
93
+ severity: "high",
94
+ message: "GESF not initialized. Run 'ges init' to set up compliance controls.",
95
+ });
96
+ return warnings;
97
+ }
98
+
99
+ let config: Record<string, unknown>;
100
+ try {
101
+ config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
102
+ } catch {
103
+ return warnings;
104
+ }
105
+
106
+ const pkgPath = path.join(root, "package.json");
107
+ if (fs.existsSync(pkgPath)) {
108
+ try {
109
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
110
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
111
+
112
+ if (deps.express && !deps.helmet) {
113
+ warnings.push({
114
+ file: "package.json",
115
+ severity: "high",
116
+ message: "Missing security headers. Install 'helmet' middleware.",
117
+ });
118
+ }
119
+
120
+ if (deps.express && !deps.cors) {
121
+ warnings.push({
122
+ file: "package.json",
123
+ severity: "medium",
124
+ message: "No CORS configuration detected. Install 'cors' package.",
125
+ });
126
+ }
127
+ } catch {}
128
+ }
129
+
130
+ if (!fs.existsSync(path.join(root, ".gitignore"))) {
131
+ warnings.push({
132
+ file: ".gitignore",
133
+ severity: "high",
134
+ message: "No .gitignore file. Secrets may be committed accidentally.",
135
+ });
136
+ }
137
+
138
+ const gitignorePath = path.join(root, ".gitignore");
139
+ if (fs.existsSync(gitignorePath)) {
140
+ const gitignore = fs.readFileSync(gitignorePath, "utf-8");
141
+ if (!gitignore.includes(".env")) {
142
+ warnings.push({
143
+ file: ".gitignore",
144
+ severity: "critical",
145
+ message: ".env not in .gitignore. Environment secrets may be committed.",
146
+ });
147
+ }
148
+ }
149
+
150
+ const requirements = config.requirements as Record<string, { required: boolean }> | undefined;
151
+ if (requirements?.mfa?.required) {
152
+ const hasMFA = checkForMFA(root);
153
+ if (!hasMFA) {
154
+ warnings.push({
155
+ file: "package.json",
156
+ severity: "high",
157
+ message: "MFA is required by GESF config but no MFA implementation detected.",
158
+ });
159
+ }
160
+ }
161
+
162
+ if (requirements?.encryption?.required) {
163
+ const hasEncryption = checkForEncryption(root);
164
+ if (!hasEncryption) {
165
+ warnings.push({
166
+ file: "package.json",
167
+ severity: "critical",
168
+ message: "Encryption is required by GESF config but no encryption detected.",
169
+ });
170
+ }
171
+ }
172
+
173
+ if (requirements?.retention_policy?.required) {
174
+ if (!fs.existsSync(path.join(root, "compliance", "retention-policy.md"))) {
175
+ warnings.push({
176
+ file: "compliance/retention-policy.md",
177
+ severity: "medium",
178
+ message: "Retention policy document missing. Run 'ges generate --docs'.",
179
+ });
180
+ }
181
+ }
182
+
183
+ return warnings;
184
+ }
185
+
186
+ function checkForMFA(root: string): boolean {
187
+ const pkgPath = path.join(root, "package.json");
188
+ if (fs.existsSync(pkgPath)) {
189
+ try {
190
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
191
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
192
+ const mfaLibs = ["otpauth", "speakeasy", "otplib", "@simplewebauthn", "node-2fa"];
193
+ return mfaLibs.some((lib) => deps[lib] !== undefined);
194
+ } catch {}
195
+ }
196
+ return false;
197
+ }
198
+
199
+ function checkForEncryption(root: string): boolean {
200
+ const dirs = ["src", "lib", "crypto", "security"];
201
+ const patterns = [/aes-256/i, /AES_256_GCM/i, /createCipheriv/i, /ChaCha20/i, /crypto\.encrypt/i];
202
+
203
+ for (const dir of dirs) {
204
+ const dirPath = path.join(root, dir);
205
+ if (!fs.existsSync(dirPath)) continue;
206
+ try {
207
+ const entries = fs.readdirSync(dirPath, { recursive: true });
208
+ for (const entry of entries) {
209
+ const filePath = path.join(dirPath, entry.toString());
210
+ if (!fs.statSync(filePath).isFile()) continue;
211
+ const ext = path.extname(filePath);
212
+ if (![".ts", ".js"].includes(ext)) continue;
213
+ const content = fs.readFileSync(filePath, "utf-8");
214
+ if (patterns.some((p) => p.test(content))) return true;
215
+ }
216
+ } catch {}
217
+ }
218
+ return false;
219
+ }
220
+
221
+ function updateStatusBar(root: string) {
222
+ const scorePath = path.join(root, ".ges", "score.json");
223
+ if (fs.existsSync(scorePath)) {
224
+ try {
225
+ const score = JSON.parse(fs.readFileSync(scorePath, "utf-8"));
226
+ const overall = score.overall || 0;
227
+ const grade = score.overall_grade || "?";
228
+ const icon = overall >= 80 ? "$(checkmark)" : overall >= 50 ? "$(warning)" : "$(error)";
229
+ statusBarItem.text = `${icon} GESF: ${overall}% (${grade})`;
230
+ } catch {
231
+ statusBarItem.text = "$(question) GESF: No score";
232
+ }
233
+ } else {
234
+ statusBarItem.text = "$(warning) GESF: Run audit";
235
+ }
236
+ statusBarItem.show();
237
+ }
238
+
239
+ async function runAudit() {
240
+ const terminal = vscode.window.createTerminal("GESF Audit");
241
+ terminal.show();
242
+ terminal.sendText("ges audit");
243
+ }
244
+
245
+ async function showScore() {
246
+ const terminal = vscode.window.createTerminal("GESF Score");
247
+ terminal.show();
248
+ terminal.sendText("ges score");
249
+ }
250
+
251
+ async function generateReport() {
252
+ const format = await vscode.window.showQuickPick(["markdown", "html", "pdf"], {
253
+ placeHolder: "Select report format",
254
+ });
255
+ if (!format) return;
256
+ const terminal = vscode.window.createTerminal("GESF Report");
257
+ terminal.show();
258
+ terminal.sendText(`ges report --format ${format}`);
259
+ }
260
+
261
+ export function deactivate() {
262
+ diagnosticCollection?.clear();
263
+ statusBarItem?.hide();
264
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "Node16",
5
+ "moduleResolution": "Node16",
6
+ "lib": ["ES2022"],
7
+ "types": ["vscode", "node"],
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "outDir": "./dist",
12
+ "rootDir": "./src"
13
+ },
14
+ "include": ["src/**/*"]
15
+ }