@greenarmor/ges-cicd-generator 1.5.5 → 1.5.6

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 CHANGED
@@ -3,9 +3,56 @@ export interface WorkflowFile {
3
3
  filePath: string;
4
4
  content: string;
5
5
  }
6
+ /**
7
+ * Compliance Gate Workflow
8
+ *
9
+ * GESF's SUPREME authority — its 9 built-in scanners are unique (no
10
+ * external tool provides them): secrets, crypto, code-security, auth,
11
+ * config, database, IaC, governance, injection.
12
+ *
13
+ * Gate behavior: `ges audit --ci` exits non-zero on critical findings.
14
+ */
6
15
  export declare function generateComplianceWorkflow(config: ProjectConfig): WorkflowFile;
7
- export declare function generateSecurityWorkflow(config: ProjectConfig): WorkflowFile;
8
- export declare function generateDependencyScanWorkflow(config: ProjectConfig): WorkflowFile;
9
- export declare function generateSecretScanWorkflow(config: ProjectConfig): WorkflowFile;
10
- export declare function generateSbomWorkflow(config: ProjectConfig): WorkflowFile;
16
+ /**
17
+ * Security Gate Workflow (Semgrep SAST)
18
+ *
19
+ * Uses the maintained Semgrep GitHub Action for SAST scanning with
20
+ * native GitHub integration (Security tab, PR annotations).
21
+ *
22
+ * Gate behavior: Semgrep exits non-zero on blocking findings.
23
+ */
24
+ export declare function generateSecurityWorkflow(_config: ProjectConfig): WorkflowFile;
25
+ /**
26
+ * Dependency Gate Workflow (Trivy + audit)
27
+ *
28
+ * Trivy filesystem scan is the primary gate (reliable exit codes).
29
+ * Package-manager audit is supplementary (continue-on-error) because
30
+ * pnpm audit exit codes are inconsistent across versions.
31
+ *
32
+ * Auto-detects npm, pnpm, or yarn via lockfile presence.
33
+ */
34
+ export declare function generateDependencyScanWorkflow(_config: ProjectConfig): WorkflowFile;
35
+ /**
36
+ * Secret Gate Workflow (Gitleaks)
37
+ *
38
+ * Uses the maintained Gitleaks GitHub Action to scan full git history.
39
+ *
40
+ * Gate behavior: Gitleaks exits non-zero on any secret detected.
41
+ */
42
+ export declare function generateSecretScanWorkflow(_config: ProjectConfig): WorkflowFile;
43
+ /**
44
+ * SBOM & Infrastructure Gate Workflow
45
+ *
46
+ * Three layers of supply chain scanning:
47
+ * 1. Filesystem SBOM (Syft + Grype) — always runs, scans source deps
48
+ * 2. Container image scan (Trivy) — runs when Dockerfile present
49
+ * 3. IaC config scan (Trivy) — runs when K8s/Docker/Terraform files present
50
+ *
51
+ * Critical for Docker/Kubernetes projects: container images bundle OS-level
52
+ * packages (apt, apk, yum) that filesystem-only scans completely miss.
53
+ *
54
+ * Gate behavior: Grype fails on HIGH+ vulns. Trivy image scan fails on
55
+ * CRITICAL/HIGH. Trivy config scan fails on misconfigurations.
56
+ */
57
+ export declare function generateSbomWorkflow(_config: ProjectConfig): WorkflowFile;
11
58
  export declare function generateAllWorkflows(config: ProjectConfig): WorkflowFile[];
package/dist/index.js CHANGED
@@ -1,30 +1,84 @@
1
+ import { GESF_VERSION } from "@greenarmor/ges-core";
1
2
  import * as path from "node:path";
3
+ function gesfInitStep(config) {
4
+ const frameworks = config?.frameworks?.length
5
+ ? config.frameworks.join(",")
6
+ : "GDPR,OWASP,CIS,NIST";
7
+ const type = config?.project_type || "generic-web-application";
8
+ const country = config?.country || "US-CA";
9
+ const repoName = "${{ github.event.repository.name }}";
10
+ return ` run: ges init --name "${repoName}" --type "${type}" --frameworks "${frameworks}" --country "${country}" --force`;
11
+ }
12
+ function nodeSetupStep() {
13
+ return [
14
+ " - name: Setup Node.js",
15
+ " uses: actions/setup-node@v4",
16
+ " with:",
17
+ " node-version-file: '.nvmrc'",
18
+ " node-version: '22'",
19
+ ].join("\n");
20
+ }
21
+ function gesfInstallStep() {
22
+ return [
23
+ " - name: Install GESF",
24
+ ` run: npm install -g @greenarmor/ges@${GESF_VERSION}`,
25
+ ].join("\n");
26
+ }
27
+ const GATE_HEADER = `# ═══════════════════════════════════════════════════════════════
28
+ # GESF Security Gate — blocks PR merges on failures.
29
+ # To enable enforcement: Settings → Branches → Branch protection rules
30
+ # → Require status checks → add the job name below.
31
+ # ═══════════════════════════════════════════════════════════════`;
32
+ const ON_TRIGGER_DAILY = `on:
33
+ push:
34
+ pull_request:
35
+ schedule:
36
+ - cron: '0 6 * * *'
37
+
38
+ # Triggers on ALL branches and PRs. Branch protection rules
39
+ # enforce the gate on the default branch (main/master/trunk/auto).`;
40
+ const ON_TRIGGER_NOSCHEDULE = `on:
41
+ push:
42
+ pull_request:
43
+
44
+ # Triggers on ALL branches and PRs. Branch protection rules
45
+ # enforce the gate on the default branch (main/master/trunk/auto).`;
46
+ const DEFAULT_BRANCH_COND = "github.ref == format('refs/heads/{0}', github.event.repository.default_branch)";
47
+ /**
48
+ * Compliance Gate Workflow
49
+ *
50
+ * GESF's SUPREME authority — its 9 built-in scanners are unique (no
51
+ * external tool provides them): secrets, crypto, code-security, auth,
52
+ * config, database, IaC, governance, injection.
53
+ *
54
+ * Gate behavior: `ges audit --ci` exits non-zero on critical findings.
55
+ */
2
56
  export function generateComplianceWorkflow(config) {
3
57
  return {
4
58
  filePath: path.join(".github", "workflows", "compliance.yml"),
5
- content: `name: Compliance Check
59
+ content: `name: Compliance Gate
6
60
 
7
- on:
8
- push:
9
- branches: [main, develop]
10
- pull_request:
11
- branches: [main]
12
- schedule:
13
- - cron: '0 6 * * 1'
61
+ ${GATE_HEADER}
62
+
63
+ ${ON_TRIGGER_DAILY}
64
+
65
+ permissions:
66
+ contents: write
67
+ pull-requests: read
14
68
 
15
69
  jobs:
16
70
  compliance:
71
+ name: GESF Compliance Gate
17
72
  runs-on: ubuntu-latest
18
73
  steps:
19
74
  - uses: actions/checkout@v4
20
75
 
21
- - name: Setup Node.js
22
- uses: actions/setup-node@v4
23
- with:
24
- node-version: '22'
76
+ ${nodeSetupStep()}
25
77
 
26
- - name: Install GESF
27
- run: npm install -g @greenarmor/ges
78
+ ${gesfInstallStep()}
79
+
80
+ - name: Initialize GESF
81
+ ${gesfInitStep(config)}
28
82
 
29
83
  - name: Run Compliance Audit
30
84
  run: ges audit --ci
@@ -33,11 +87,11 @@ jobs:
33
87
  run: ges score --ci
34
88
 
35
89
  - name: Generate Compliance Badge
36
- if: github.event_name != 'pull_request'
90
+ if: ${DEFAULT_BRANCH_COND}
37
91
  run: ges badge
38
92
 
39
93
  - name: Commit Compliance Badge
40
- if: github.event_name != 'pull_request'
94
+ if: ${DEFAULT_BRANCH_COND}
41
95
  run: |
42
96
  git config user.name "github-actions[bot]"
43
97
  git config user.email "github-actions[bot]@users.noreply.github.com"
@@ -54,21 +108,26 @@ jobs:
54
108
  `,
55
109
  };
56
110
  }
57
- export function generateSecurityWorkflow(config) {
111
+ /**
112
+ * Security Gate Workflow (Semgrep SAST)
113
+ *
114
+ * Uses the maintained Semgrep GitHub Action for SAST scanning with
115
+ * native GitHub integration (Security tab, PR annotations).
116
+ *
117
+ * Gate behavior: Semgrep exits non-zero on blocking findings.
118
+ */
119
+ export function generateSecurityWorkflow(_config) {
58
120
  return {
59
121
  filePath: path.join(".github", "workflows", "security.yml"),
60
- content: `name: Security Scan
122
+ content: `name: Security Gate (Semgrep)
61
123
 
62
- on:
63
- push:
64
- branches: [main, develop]
65
- pull_request:
66
- branches: [main]
67
- schedule:
68
- - cron: '0 6 * * *'
124
+ ${GATE_HEADER}
125
+
126
+ ${ON_TRIGGER_DAILY}
69
127
 
70
128
  jobs:
71
- security:
129
+ semgrep:
130
+ name: Semgrep SAST
72
131
  runs-on: ubuntu-latest
73
132
  steps:
74
133
  - uses: actions/checkout@v4
@@ -77,35 +136,30 @@ jobs:
77
136
  uses: returntocorp/semgrep-action@v1
78
137
  with:
79
138
  config: auto
80
-
81
- - name: Setup Node.js
82
- uses: actions/setup-node@v4
83
- with:
84
- node-version: '22'
85
-
86
- - name: Install GESF
87
- run: npm install -g @greenarmor/ges
88
-
89
- - name: Run Security Scan
90
- run: ges scan --ci
91
139
  `,
92
140
  };
93
141
  }
94
- export function generateDependencyScanWorkflow(config) {
142
+ /**
143
+ * Dependency Gate Workflow (Trivy + audit)
144
+ *
145
+ * Trivy filesystem scan is the primary gate (reliable exit codes).
146
+ * Package-manager audit is supplementary (continue-on-error) because
147
+ * pnpm audit exit codes are inconsistent across versions.
148
+ *
149
+ * Auto-detects npm, pnpm, or yarn via lockfile presence.
150
+ */
151
+ export function generateDependencyScanWorkflow(_config) {
95
152
  return {
96
153
  filePath: path.join(".github", "workflows", "dependency-scan.yml"),
97
- content: `name: Dependency Scan
154
+ content: `name: Dependency Gate (Trivy)
98
155
 
99
- on:
100
- push:
101
- branches: [main, develop]
102
- pull_request:
103
- branches: [main]
104
- schedule:
105
- - cron: '0 6 * * *'
156
+ ${GATE_HEADER}
157
+
158
+ ${ON_TRIGGER_DAILY}
106
159
 
107
160
  jobs:
108
161
  dependency-scan:
162
+ name: Trivy + Dependency Audit
109
163
  runs-on: ubuntu-latest
110
164
  steps:
111
165
  - uses: actions/checkout@v4
@@ -116,34 +170,50 @@ jobs:
116
170
  scan-type: 'fs'
117
171
  scan-ref: '.'
118
172
  severity: 'CRITICAL,HIGH'
173
+ exit-code: '1'
119
174
 
120
- - name: Setup Node.js
121
- uses: actions/setup-node@v4
122
- with:
123
- node-version: '22'
175
+ ${nodeSetupStep()}
124
176
 
125
- - name: Install dependencies
126
- run: npm ci
177
+ - name: Setup pnpm
178
+ if: hashFiles('pnpm-lock.yaml') != ''
179
+ uses: pnpm/action-setup@v4
180
+
181
+ - name: Install and audit (pnpm)
182
+ if: hashFiles('pnpm-lock.yaml') != ''
183
+ run: pnpm install --frozen-lockfile && pnpm audit --audit-level=high
184
+ continue-on-error: true
127
185
 
128
- - name: Run npm audit
129
- run: npm audit --audit-level=high
186
+ - name: Install and audit (npm)
187
+ if: hashFiles('pnpm-lock.yaml') == '' && hashFiles('package-lock.json') != ''
188
+ run: npm ci && npm audit --audit-level=high
189
+ continue-on-error: true
190
+
191
+ - name: Install and audit (yarn)
192
+ if: hashFiles('pnpm-lock.yaml') == '' && hashFiles('package-lock.json') == '' && hashFiles('yarn.lock') != ''
193
+ run: yarn install --frozen-lockfile && yarn audit --level high
130
194
  continue-on-error: true
131
195
  `,
132
196
  };
133
197
  }
134
- export function generateSecretScanWorkflow(config) {
198
+ /**
199
+ * Secret Gate Workflow (Gitleaks)
200
+ *
201
+ * Uses the maintained Gitleaks GitHub Action to scan full git history.
202
+ *
203
+ * Gate behavior: Gitleaks exits non-zero on any secret detected.
204
+ */
205
+ export function generateSecretScanWorkflow(_config) {
135
206
  return {
136
207
  filePath: path.join(".github", "workflows", "secret-scan.yml"),
137
- content: `name: Secret Scan
208
+ content: `name: Secret Gate (Gitleaks)
138
209
 
139
- on:
140
- push:
141
- branches: [main, develop]
142
- pull_request:
143
- branches: [main]
210
+ ${GATE_HEADER}
211
+
212
+ ${ON_TRIGGER_NOSCHEDULE}
144
213
 
145
214
  jobs:
146
215
  secret-scan:
216
+ name: Gitleaks
147
217
  runs-on: ubuntu-latest
148
218
  steps:
149
219
  - uses: actions/checkout@v4
@@ -157,21 +227,36 @@ jobs:
157
227
  `,
158
228
  };
159
229
  }
160
- export function generateSbomWorkflow(config) {
230
+ /**
231
+ * SBOM & Infrastructure Gate Workflow
232
+ *
233
+ * Three layers of supply chain scanning:
234
+ * 1. Filesystem SBOM (Syft + Grype) — always runs, scans source deps
235
+ * 2. Container image scan (Trivy) — runs when Dockerfile present
236
+ * 3. IaC config scan (Trivy) — runs when K8s/Docker/Terraform files present
237
+ *
238
+ * Critical for Docker/Kubernetes projects: container images bundle OS-level
239
+ * packages (apt, apk, yum) that filesystem-only scans completely miss.
240
+ *
241
+ * Gate behavior: Grype fails on HIGH+ vulns. Trivy image scan fails on
242
+ * CRITICAL/HIGH. Trivy config scan fails on misconfigurations.
243
+ */
244
+ export function generateSbomWorkflow(_config) {
161
245
  return {
162
246
  filePath: path.join(".github", "workflows", "sbom-scan.yml"),
163
- content: `name: SBOM Generation & Scan
247
+ content: `name: SBOM & Infrastructure Gate
164
248
 
165
- on:
166
- push:
167
- branches: [main, develop]
168
- pull_request:
169
- branches: [main]
170
- schedule:
171
- - cron: '0 6 * * 1'
249
+ # ═══════════════════════════════════════════════════════════════
250
+ # Supply chain gate — SBOM generation + container/IaC scanning.
251
+ # Especially critical for Docker/Kubernetes projects: catches
252
+ # OS-level CVEs in base images that filesystem scans miss.
253
+ # ═══════════════════════════════════════════════════════════════
254
+
255
+ ${ON_TRIGGER_DAILY}
172
256
 
173
257
  jobs:
174
258
  sbom:
259
+ name: Filesystem SBOM (Syft + Grype)
175
260
  runs-on: ubuntu-latest
176
261
  steps:
177
262
  - uses: actions/checkout@v4
@@ -182,32 +267,83 @@ jobs:
182
267
  image: ""
183
268
  path: .
184
269
  format: cyclonedx-json
185
- output-file: sbom.json
270
+ output-file: sbom-filesystem.json
186
271
  fail-build: false
187
272
 
188
273
  - name: Scan SBOM for vulnerabilities with Grype
189
274
  uses: anchore/scan-action@v6
190
275
  with:
191
- sbom: sbom.json
276
+ sbom: sbom-filesystem.json
192
277
  fail-build: true
193
278
  severity-cutoff: high
194
279
 
195
- - name: Generate SBOM with Trivy
280
+ - name: Upload filesystem SBOM
281
+ if: always()
282
+ uses: actions/upload-artifact@v4
283
+ with:
284
+ name: sbom-filesystem
285
+ path: sbom-filesystem.json
286
+ retention-days: 90
287
+
288
+ container-scan:
289
+ name: Container Image Scan (Trivy)
290
+ runs-on: ubuntu-latest
291
+ # Auto-aware: only runs when a Dockerfile is present
292
+ if: hashFiles('Dockerfile', '**/Dockerfile', 'docker-compose.yml', 'docker-compose.yaml') != ''
293
+ steps:
294
+ - uses: actions/checkout@v4
295
+
296
+ - name: Set up Docker Buildx
297
+ uses: docker/setup-buildx-action@v3
298
+
299
+ - name: Build Docker image
300
+ uses: docker/build-push-action@v6
301
+ with:
302
+ context: .
303
+ load: true
304
+ tags: gesf-scan:latest
305
+
306
+ - name: Scan Docker image with Trivy
196
307
  uses: aquasecurity/trivy-action@master
197
308
  with:
198
- scan-type: 'fs'
309
+ image-ref: gesf-scan:latest
310
+ format: 'sarif'
311
+ output: 'trivy-container.sarif'
312
+ severity: 'CRITICAL,HIGH'
313
+ exit-code: '1'
314
+
315
+ - name: Upload container scan results
316
+ if: always()
317
+ uses: actions/upload-artifact@v4
318
+ with:
319
+ name: container-scan
320
+ path: trivy-container.sarif
321
+ retention-days: 90
322
+
323
+ iac-scan:
324
+ name: Infrastructure Config Scan (Trivy)
325
+ runs-on: ubuntu-latest
326
+ # Auto-aware: only runs when IaC files are present
327
+ if: hashFiles('k8s/**', 'kubernetes/**', 'helm/**', 'terraform/**', 'tf/**', '*.tf', '**/*.tf', 'docker-compose*.yml', 'docker-compose*.yaml') != ''
328
+ steps:
329
+ - uses: actions/checkout@v4
330
+
331
+ - name: Scan IaC configs with Trivy
332
+ uses: aquasecurity/trivy-action@master
333
+ with:
334
+ scan-type: 'config'
199
335
  scan-ref: '.'
200
- format: 'cyclonedx'
201
- output: 'trivy-sbom.json'
336
+ format: 'sarif'
337
+ output: 'trivy-iac.sarif'
338
+ severity: 'CRITICAL,HIGH'
339
+ exit-code: '1'
202
340
 
203
- - name: Upload SBOM artifacts
341
+ - name: Upload IaC scan results
204
342
  if: always()
205
343
  uses: actions/upload-artifact@v4
206
344
  with:
207
- name: sbom-artifacts
208
- path: |
209
- sbom.json
210
- trivy-sbom.json
345
+ name: iac-scan
346
+ path: trivy-iac.sarif
211
347
  retention-days: 90
212
348
  `,
213
349
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "dependencies": {
3
- "@greenarmor/ges-core": "1.5.5"
3
+ "@greenarmor/ges-core": "1.5.6"
4
4
  },
5
5
  "description": "GESF CI/CD Generator - GitHub Actions workflow generation",
6
6
  "devDependencies": {
@@ -24,7 +24,7 @@
24
24
  "name": "@greenarmor/ges-cicd-generator",
25
25
  "type": "module",
26
26
  "types": "./dist/index.d.ts",
27
- "version": "1.5.5",
27
+ "version": "1.5.6",
28
28
  "scripts": {
29
29
  "build": "tsc",
30
30
  "clean": "rm -rf dist tsconfig.tsbuildinfo",