jso-protector 0.2.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/CHANGELOG.md +960 -0
- package/LICENSE +90 -0
- package/MIGRATION.md +207 -0
- package/README.md +1477 -0
- package/RELEASE.md +82 -0
- package/SECURITY.md +71 -0
- package/ai-cli.js +392 -0
- package/ai.js +176 -0
- package/bin/jso-protector.js +12066 -0
- package/browserify.d.ts +10 -0
- package/browserify.js +88 -0
- package/bun.d.ts +10 -0
- package/bun.js +41 -0
- package/ci/Jenkinsfile +82 -0
- package/ci/argo-workflows.yaml +121 -0
- package/ci/azure-pipelines.yml +56 -0
- package/ci/bitbucket-pipelines.yml +43 -0
- package/ci/buildkite.yml +50 -0
- package/ci/circleci.yml +60 -0
- package/ci/drone.yml +67 -0
- package/ci/github-actions.yml +51 -0
- package/ci/gitlab-ci.yml +39 -0
- package/ci/gocd.yaml +79 -0
- package/ci/teamcity.kts +79 -0
- package/ci/tekton.yaml +106 -0
- package/ci/verify-package.js +748 -0
- package/ci/verify-publish-metadata.js +147 -0
- package/ci/verify-templates.js +195 -0
- package/ci/woodpecker.yml +53 -0
- package/compliance/cli.js +204 -0
- package/compliance/evidence-forwarder.js +209 -0
- package/compliance/pci-dss-v4/controls.json +75 -0
- package/compliance/pci-dss-v4/index.js +2613 -0
- package/config/named-sets.js +185 -0
- package/esbuild.d.ts +16 -0
- package/esbuild.js +190 -0
- package/examples/README.md +78 -0
- package/examples/browserify/build.js +20 -0
- package/examples/bun/package.json +13 -0
- package/examples/bun/scripts/protect-release.js +28 -0
- package/examples/cli-basic/jso.config.cjs +23 -0
- package/examples/cli-basic/jso.config.json +15 -0
- package/examples/cli-basic/package.json +14 -0
- package/examples/cli-basic/scripts/build.js +10 -0
- package/examples/curl/README.md +55 -0
- package/examples/curl/protect.sh +106 -0
- package/examples/esbuild/build.js +19 -0
- package/examples/grunt/Gruntfile.js +29 -0
- package/examples/gulp/gulpfile.js +19 -0
- package/examples/helm/Chart.yaml +27 -0
- package/examples/helm/README.md +69 -0
- package/examples/helm/templates/_helpers.tpl +23 -0
- package/examples/helm/templates/_podtemplate.tpl +64 -0
- package/examples/helm/templates/job.yaml +39 -0
- package/examples/helm/templates/secret.yaml +17 -0
- package/examples/helm/values.yaml +54 -0
- package/examples/kubernetes/job.yaml +123 -0
- package/examples/metro.config.js +11 -0
- package/examples/nextjs/next.config.js +11 -0
- package/examples/node-api/protect-release.js +28 -0
- package/examples/node-api/release-summary.js +59 -0
- package/examples/parcel/package.json +13 -0
- package/examples/parcel/scripts/protect-release.js +28 -0
- package/examples/payment-page-script-inventory.json +62 -0
- package/examples/payment-page-security-headers.json +46 -0
- package/examples/pre-commit/.pre-commit-config.yaml +33 -0
- package/examples/pre-commit/README.md +45 -0
- package/examples/react-native/README.md +208 -0
- package/examples/react-native/metro.config.js +11 -0
- package/examples/rollup/rollup.config.js +20 -0
- package/examples/rspack/rspack.config.js +28 -0
- package/examples/turbopack/package.json +13 -0
- package/examples/turbopack/scripts/protect-release.js +28 -0
- package/examples/vite/vite.config.js +18 -0
- package/examples/webpack/webpack.config.js +21 -0
- package/examples/webpack-loader/webpack.config.js +22 -0
- package/governance/index.d.ts +18 -0
- package/governance/index.js +309 -0
- package/grunt.d.ts +4 -0
- package/grunt.js +111 -0
- package/gulp.d.ts +10 -0
- package/gulp.js +106 -0
- package/index.d.ts +879 -0
- package/index.js +607 -0
- package/jso.config.example.json +29 -0
- package/jso.config.schema.json +548 -0
- package/metro.d.ts +43 -0
- package/metro.js +117 -0
- package/next.d.ts +24 -0
- package/next.js +64 -0
- package/package.json +241 -0
- package/parcel.d.ts +10 -0
- package/parcel.js +40 -0
- package/react-native.d.ts +2 -0
- package/react-native.js +3 -0
- package/release-signer.js +245 -0
- package/rollup.d.ts +13 -0
- package/rollup.js +71 -0
- package/rspack-loader.d.ts +13 -0
- package/rspack-loader.js +11 -0
- package/rspack.d.ts +11 -0
- package/rspack.js +9 -0
- package/runtime/ai-script-governance.js +379 -0
- package/runtime/countermeasures.js +0 -0
- package/runtime/data-exfiltration-guard.d.ts +7 -0
- package/runtime/data-exfiltration-guard.js +161 -0
- package/runtime/environment-integrity.js +389 -0
- package/runtime/managed-integrity.d.ts +4 -0
- package/runtime/managed-integrity.js +108 -0
- package/runtime/third-party-inventory.js +437 -0
- package/turbopack.d.ts +10 -0
- package/turbopack.js +41 -0
- package/vite.d.ts +16 -0
- package/vite.js +78 -0
- package/watermark.js +126 -0
- package/webpack-loader.d.ts +15 -0
- package/webpack-loader.js +97 -0
- package/webpack.d.ts +13 -0
- package/webpack.js +143 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const fs = require("node:fs");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
|
|
8
|
+
const root = path.resolve(__dirname, "..");
|
|
9
|
+
const packagePath = path.join(root, "package.json");
|
|
10
|
+
const packageJson = JSON.parse(fs.readFileSync(packagePath, "utf8"));
|
|
11
|
+
const args = new Set(process.argv.slice(2));
|
|
12
|
+
const json = args.has("--json");
|
|
13
|
+
const allowLocal = args.has("--allow-local") || args.has("--allow-draft");
|
|
14
|
+
// Two metadata states are approved, and nothing in between:
|
|
15
|
+
//
|
|
16
|
+
// local-only : private:true + license "UNLICENSED"
|
|
17
|
+
// npm publish is blocked outright by prepublishOnly.
|
|
18
|
+
// proprietary : no private + license "SEE LICENSE IN LICENSE" + a LICENSE file
|
|
19
|
+
// publicly installable, all rights reserved. See ../LICENSE.
|
|
20
|
+
//
|
|
21
|
+
// A half-migrated package is the state worth failing loudly on: private removed
|
|
22
|
+
// but still "UNLICENSED" publishes a package that grants users nothing, and a
|
|
23
|
+
// "SEE LICENSE IN LICENSE" string with no LICENSE file on disk ships a
|
|
24
|
+
// proprietary package whose licence text is missing. Both are silent problems
|
|
25
|
+
// that only surface after the version is public and immutable.
|
|
26
|
+
const PROPRIETARY_LICENSE = "SEE LICENSE IN LICENSE";
|
|
27
|
+
const licenseFileExists = fs.existsSync(path.join(root, "LICENSE"));
|
|
28
|
+
const localOnly = packageJson.private === true && packageJson.license === "UNLICENSED";
|
|
29
|
+
const proprietaryPublic =
|
|
30
|
+
packageJson.private !== true && packageJson.license === PROPRIETARY_LICENSE;
|
|
31
|
+
|
|
32
|
+
const issues = [];
|
|
33
|
+
const warnings = [];
|
|
34
|
+
|
|
35
|
+
function issue(field, message) {
|
|
36
|
+
issues.push({ field, message });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function warning(field, message) {
|
|
40
|
+
warnings.push({ field, message });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// "jso-protector" was confirmed as the final public name on 2026-07-27 (the
|
|
44
|
+
// registry returned 404 for it, so it was unclaimed). Only an empty name is a
|
|
45
|
+
// problem now.
|
|
46
|
+
if (!packageJson.name) {
|
|
47
|
+
issue("name", "Provide the public npm package name.");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!localOnly && !proprietaryPublic) {
|
|
51
|
+
issue(
|
|
52
|
+
"private/license",
|
|
53
|
+
`Metadata is in neither approved state. Local-only is private:true + "UNLICENSED"; ` +
|
|
54
|
+
`public release is private removed + license "${PROPRIETARY_LICENSE}". ` +
|
|
55
|
+
`Found private:${JSON.stringify(packageJson.private)} license:${JSON.stringify(packageJson.license)}. ` +
|
|
56
|
+
`A half-migrated package either blocks a legitimate publish or ships granting no readable rights.`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (proprietaryPublic && !licenseFileExists) {
|
|
61
|
+
issue(
|
|
62
|
+
"license",
|
|
63
|
+
`license is "${PROPRIETARY_LICENSE}" but packages/jso-protector/LICENSE does not exist. ` +
|
|
64
|
+
`npm would publish a proprietary package with no licence text for users to read.`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (proprietaryPublic && !(packageJson.files || []).includes("LICENSE")) {
|
|
69
|
+
warning("files", "Add LICENSE to the files array. npm includes it implicitly, but being explicit keeps the packed set self-documenting.");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!packageJson.description || packageJson.description.length < 20) {
|
|
73
|
+
issue("description", "Provide a concise npm package description.");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (!packageJson.homepage) {
|
|
77
|
+
issue("homepage", "Provide a homepage that points to the npm CLI documentation.");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!packageJson.author) {
|
|
81
|
+
issue("author", "Provide the publishing organization or maintainer.");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!packageJson.bin || !packageJson.bin["jso-protector"]) {
|
|
85
|
+
issue("bin", "Expose the jso-protector CLI binary.");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (!packageJson.files || !packageJson.files.includes("README.md") || !packageJson.files.includes("SECURITY.md")) {
|
|
89
|
+
issue("files", "Pack README.md and SECURITY.md with the npm artifact.");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (!packageJson.scripts || !String(packageJson.scripts.verify || "").includes("verify:package")) {
|
|
93
|
+
warning("scripts.verify", "Consider a single npm run verify script that includes tests and package verification.");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (!packageJson.repository) {
|
|
97
|
+
if (!localOnly) {
|
|
98
|
+
warning("repository", "Add repository metadata when the public source location is final.");
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (!packageJson.bugs) {
|
|
103
|
+
if (!localOnly) {
|
|
104
|
+
warning("bugs", "Add issue/support metadata when the public support channel is final.");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const report = {
|
|
109
|
+
format: "jso-protector-publish-metadata",
|
|
110
|
+
ok: issues.length === 0,
|
|
111
|
+
publishReady: proprietaryPublic && issues.length === 0,
|
|
112
|
+
localOnly,
|
|
113
|
+
proprietaryPublic,
|
|
114
|
+
licenseFileExists,
|
|
115
|
+
localAllowed: allowLocal,
|
|
116
|
+
issues,
|
|
117
|
+
warnings
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
if (json) {
|
|
121
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
122
|
+
} else {
|
|
123
|
+
if (report.ok && localOnly && allowLocal) {
|
|
124
|
+
process.stdout.write("Local-only package metadata is locked. npm publish remains blocked by prepublishOnly.\n");
|
|
125
|
+
} else if (report.ok && localOnly) {
|
|
126
|
+
process.stdout.write("Package is intentionally local-only. Refusing publish-ready mode while private:true and UNLICENSED are set.\n");
|
|
127
|
+
} else if (report.publishReady) {
|
|
128
|
+
process.stdout.write(
|
|
129
|
+
`Publish metadata is ready: proprietary release, license "${PROPRIETARY_LICENSE}", LICENSE file present.\n`
|
|
130
|
+
);
|
|
131
|
+
for (const item of warnings) {
|
|
132
|
+
process.stdout.write(`WARNING ${item.field}: ${item.message}\n`);
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
process.stdout.write(`Package metadata has ${issues.length} blocking issue(s) and ${warnings.length} warning(s).\n`);
|
|
136
|
+
for (const item of issues) {
|
|
137
|
+
process.stdout.write(`BLOCKER ${item.field}: ${item.message}\n`);
|
|
138
|
+
}
|
|
139
|
+
for (const item of warnings) {
|
|
140
|
+
process.stdout.write(`WARNING ${item.field}: ${item.message}\n`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if ((!allowLocal && localOnly) || (issues.length && !allowLocal)) {
|
|
146
|
+
process.exitCode = 1;
|
|
147
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// Smoke validator for the shipped CI templates.
|
|
5
|
+
//
|
|
6
|
+
// Verifies that every template ships with consistent conventions so we never
|
|
7
|
+
// publish a broken one. Checks:
|
|
8
|
+
//
|
|
9
|
+
// 1. File exists, is non-empty, is readable.
|
|
10
|
+
// 2. YAML files: no tab characters in indentation (YAML forbids it).
|
|
11
|
+
// 3. Every template calls jso-protector with --label and --report so audit
|
|
12
|
+
// and symbolication conventions stay uniform across CI systems.
|
|
13
|
+
// 4. Jenkinsfile: balanced { } and pipeline { ... } opener.
|
|
14
|
+
// 5. The GitHub composite Action exposes source-free migration preflight
|
|
15
|
+
// reports as inputs and outputs.
|
|
16
|
+
//
|
|
17
|
+
// Exit code: 0 if all clean, 1 otherwise. Used by `npm run verify:ci`.
|
|
18
|
+
|
|
19
|
+
const fs = require("node:fs");
|
|
20
|
+
const path = require("node:path");
|
|
21
|
+
|
|
22
|
+
const CI_DIR = path.join(__dirname);
|
|
23
|
+
const GITHUB_ACTION_FILE = path.resolve(__dirname, "..", "..", "jso-github-action", "action.yml");
|
|
24
|
+
|
|
25
|
+
const YAML_TEMPLATES = [
|
|
26
|
+
"github-actions.yml",
|
|
27
|
+
"gitlab-ci.yml",
|
|
28
|
+
"circleci.yml",
|
|
29
|
+
"azure-pipelines.yml",
|
|
30
|
+
"bitbucket-pipelines.yml",
|
|
31
|
+
"drone.yml",
|
|
32
|
+
"buildkite.yml",
|
|
33
|
+
"woodpecker.yml",
|
|
34
|
+
"tekton.yaml",
|
|
35
|
+
"gocd.yaml",
|
|
36
|
+
"argo-workflows.yaml"
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
// Jenkinsfile (Groovy) and teamcity.kts (Kotlin) get language-specific checks.
|
|
40
|
+
const SPECIAL_TEMPLATES = ["Jenkinsfile", "teamcity.kts"];
|
|
41
|
+
|
|
42
|
+
function fail(msg) {
|
|
43
|
+
console.error("verify-templates: " + msg);
|
|
44
|
+
process.exitCode = 1;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function checkExistsAndNonEmpty(file) {
|
|
48
|
+
const p = path.join(CI_DIR, file);
|
|
49
|
+
if (!fs.existsSync(p)) { fail(file + ": missing"); return null; }
|
|
50
|
+
const text = fs.readFileSync(p, "utf8");
|
|
51
|
+
if (!text.trim()) { fail(file + ": empty"); return null; }
|
|
52
|
+
return text;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function checkYamlIndentation(file, text) {
|
|
56
|
+
// YAML forbids tabs in indentation. Skip lines that are entirely inside a
|
|
57
|
+
// quoted string (best-effort: we only flag leading-tab lines, which is the
|
|
58
|
+
// most common mistake when copy-pasting from a Jenkinsfile).
|
|
59
|
+
const lines = text.split(/\r?\n/);
|
|
60
|
+
for (let i = 0; i < lines.length; i++) {
|
|
61
|
+
if (/^\t/.test(lines[i])) {
|
|
62
|
+
fail(file + ":" + (i + 1) + ": YAML disallows leading tab characters");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function checkLabelAndReport(file, text) {
|
|
68
|
+
// Every template must invoke jso-protector with --label and --report so
|
|
69
|
+
// audit and symbolication conventions stay uniform across CI systems.
|
|
70
|
+
if (!/--label\b/.test(text)) fail(file + ": missing --label invocation");
|
|
71
|
+
if (!/--report\b/.test(text)) fail(file + ": missing --report invocation");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function checkSupplyChainHint(file, text) {
|
|
75
|
+
// Every template must carry the "Optional: migration and supply-chain"
|
|
76
|
+
// commented-out hint block so customers using a non-GitHub CI system can
|
|
77
|
+
// discover --competitor-gap-report, source-map evidence,
|
|
78
|
+
// payment-page inventory audit and HAR-to-header evidence,
|
|
79
|
+
// --ai-precheck, --watermark, and --sign-release without hunting through
|
|
80
|
+
// docs. Block is commented out by default: opt-in, no behavior change to
|
|
81
|
+
// existing pipelines.
|
|
82
|
+
if (!/Optional: migration and supply-chain checks/.test(text)) {
|
|
83
|
+
fail(file + ": missing 'Optional: migration and supply-chain checks' hint block " +
|
|
84
|
+
"(see _add-supply-chain-block.js for the canonical block content)");
|
|
85
|
+
}
|
|
86
|
+
// The flags listed must all appear in the commented block; a future
|
|
87
|
+
// template can't ship advertising only some of the surface.
|
|
88
|
+
for (const flag of [
|
|
89
|
+
"--competitor-gap-report",
|
|
90
|
+
"--source-map-evidence",
|
|
91
|
+
"--script-inventory-audit",
|
|
92
|
+
"--runtime-inventory-snapshot",
|
|
93
|
+
"--script-inventory-audit-output",
|
|
94
|
+
"--payment-page-headers-from-har",
|
|
95
|
+
"--payment-page-headers-baseline",
|
|
96
|
+
"--payment-page-headers-output",
|
|
97
|
+
"--ai-precheck",
|
|
98
|
+
"--estimate",
|
|
99
|
+
"--watermark",
|
|
100
|
+
"--sign-release"
|
|
101
|
+
]) {
|
|
102
|
+
if (!text.includes(flag)) {
|
|
103
|
+
fail(file + ": migration/supply-chain hint block missing flag " + flag);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function checkJenkinsfile(text) {
|
|
108
|
+
const opens = (text.match(/\{/g) || []).length;
|
|
109
|
+
const closes = (text.match(/\}/g) || []).length;
|
|
110
|
+
if (opens !== closes) fail("Jenkinsfile: unbalanced braces (" + opens + " { vs " + closes + " })");
|
|
111
|
+
if (!/^\s*pipeline\s*\{/m.test(text)) fail("Jenkinsfile: missing top-level `pipeline {` block");
|
|
112
|
+
if (!/--label/.test(text)) fail("Jenkinsfile: missing --label invocation");
|
|
113
|
+
if (!/--report/.test(text)) fail("Jenkinsfile: missing --report invocation");
|
|
114
|
+
checkSupplyChainHint("Jenkinsfile", text);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function checkTeamCityKts(text) {
|
|
118
|
+
const opens = (text.match(/\{/g) || []).length;
|
|
119
|
+
const closes = (text.match(/\}/g) || []).length;
|
|
120
|
+
if (opens !== closes) fail("teamcity.kts: unbalanced braces (" + opens + " { vs " + closes + " })");
|
|
121
|
+
if (!/object\s+\w+\s*:\s*BuildType/.test(text)) fail("teamcity.kts: missing BuildType object declaration");
|
|
122
|
+
if (!/--label/.test(text)) fail("teamcity.kts: missing --label invocation");
|
|
123
|
+
if (!/--report/.test(text)) fail("teamcity.kts: missing --report invocation");
|
|
124
|
+
checkSupplyChainHint("teamcity.kts", text);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function checkGitHubActionContract() {
|
|
128
|
+
if (!fs.existsSync(GITHUB_ACTION_FILE)) {
|
|
129
|
+
fail("jso-github-action/action.yml: missing");
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const text = fs.readFileSync(GITHUB_ACTION_FILE, "utf8");
|
|
133
|
+
for (const token of [
|
|
134
|
+
"release-check:",
|
|
135
|
+
"release-check-report:",
|
|
136
|
+
"competitor-gap-report:",
|
|
137
|
+
"competitor-gap-report-path:",
|
|
138
|
+
"payment-script-inventory:",
|
|
139
|
+
"runtime-inventory-snapshot:",
|
|
140
|
+
"script-inventory-audit-report:",
|
|
141
|
+
"payment-page-har:",
|
|
142
|
+
"payment-page-headers-baseline:",
|
|
143
|
+
"payment-page-url-pattern:",
|
|
144
|
+
"payment-page-headers-report:",
|
|
145
|
+
"pci-dss-v4-evidence:",
|
|
146
|
+
"pci-dss-v4-report:",
|
|
147
|
+
"pci-dss-v4-json-report:",
|
|
148
|
+
"source-map-evidence:",
|
|
149
|
+
"source-map-evidence-report:",
|
|
150
|
+
"--release-check",
|
|
151
|
+
"--competitor-gap-report",
|
|
152
|
+
"--source-map-evidence",
|
|
153
|
+
"--script-inventory-audit",
|
|
154
|
+
"--payment-page-headers-from-har",
|
|
155
|
+
"--payment-page-headers-baseline",
|
|
156
|
+
"compliance\" \"pci-dss-v4",
|
|
157
|
+
"steps.release-check.outputs.release-check-report",
|
|
158
|
+
"steps.competitor-gap.outputs.competitor-gap-report-path",
|
|
159
|
+
"steps.script-inventory-audit.outputs.script-inventory-audit-report",
|
|
160
|
+
"steps.payment-page-headers.outputs.payment-page-headers-report",
|
|
161
|
+
"steps.pci-dss-v4-evidence.outputs.pci-dss-v4-report",
|
|
162
|
+
"steps.pci-dss-v4-evidence.outputs.pci-dss-v4-json-report",
|
|
163
|
+
"steps.source-map-evidence.outputs.source-map-evidence-report"
|
|
164
|
+
]) {
|
|
165
|
+
if (!text.includes(token)) {
|
|
166
|
+
fail("jso-github-action/action.yml: missing " + token);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
let checked = 0;
|
|
172
|
+
for (const file of YAML_TEMPLATES) {
|
|
173
|
+
const text = checkExistsAndNonEmpty(file);
|
|
174
|
+
if (text == null) continue;
|
|
175
|
+
checkYamlIndentation(file, text);
|
|
176
|
+
checkLabelAndReport(file, text);
|
|
177
|
+
checkSupplyChainHint(file, text);
|
|
178
|
+
checked++;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
for (const file of SPECIAL_TEMPLATES) {
|
|
182
|
+
const text = checkExistsAndNonEmpty(file);
|
|
183
|
+
if (text == null) continue;
|
|
184
|
+
if (file === "Jenkinsfile") checkJenkinsfile(text);
|
|
185
|
+
else if (file === "teamcity.kts") checkTeamCityKts(text);
|
|
186
|
+
checked++;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
checkGitHubActionContract();
|
|
190
|
+
|
|
191
|
+
if (process.exitCode) {
|
|
192
|
+
console.error("verify-templates: FAILED (" + checked + " templates inspected)");
|
|
193
|
+
} else {
|
|
194
|
+
console.log("verify-templates: OK (" + checked + " templates inspected, action preflight contract checked)");
|
|
195
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Woodpecker CI template for jso-protector.
|
|
2
|
+
#
|
|
3
|
+
# Drop this at .woodpecker.yml in your repo. Add JSO_API_KEY and
|
|
4
|
+
# JSO_API_PASSWORD as Woodpecker secrets (Settings �?Secrets, scoped to the
|
|
5
|
+
# repo or organization).
|
|
6
|
+
#
|
|
7
|
+
# Every protection run is tagged with $CI_COMMIT_SHA via --label, and the
|
|
8
|
+
# API report rides alongside the protected dist as a pipeline artifact for
|
|
9
|
+
# later symbolication.
|
|
10
|
+
|
|
11
|
+
when:
|
|
12
|
+
- branch: main
|
|
13
|
+
- event: push
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
install:
|
|
17
|
+
image: node:22
|
|
18
|
+
commands:
|
|
19
|
+
- npm ci
|
|
20
|
+
|
|
21
|
+
build:
|
|
22
|
+
image: node:22
|
|
23
|
+
commands:
|
|
24
|
+
- npm run build
|
|
25
|
+
|
|
26
|
+
protect:
|
|
27
|
+
image: node:22
|
|
28
|
+
secrets: [ jso_api_key, jso_api_password ]
|
|
29
|
+
environment:
|
|
30
|
+
JSO_API_KEY:
|
|
31
|
+
from_secret: jso_api_key
|
|
32
|
+
JSO_API_PASSWORD:
|
|
33
|
+
from_secret: jso_api_password
|
|
34
|
+
commands:
|
|
35
|
+
- npx jso-protector --config jso.config.json --release-check --json
|
|
36
|
+
- >
|
|
37
|
+
npx jso-protector
|
|
38
|
+
--config jso.config.json
|
|
39
|
+
--label "$CI_COMMIT_SHA"
|
|
40
|
+
--manifest dist-protected/jso-manifest.json
|
|
41
|
+
--report dist-protected/jso-report.json
|
|
42
|
+
# Optional: migration and supply-chain checks. Copy into a preflight/protect step as needed.
|
|
43
|
+
# Configure JSO_WATERMARK_KEY as a masked secret; check in ci-key.pub.pem,
|
|
44
|
+
# store ci-key.priv.pem in a CI file secret. See WireFormat.aspx#watermark.
|
|
45
|
+
# npx jso-protector --config jso.config.json --competitor-gap-report --json # competitor migration gap report
|
|
46
|
+
# npx jso-protector --source-map-evidence dist-protected/jso-manifest.json --source-map-evidence-output reports/source-map-evidence.json --json # source-map absence evidence
|
|
47
|
+
# npx jso-protector --script-inventory-audit reports/payment-script-inventory.json --runtime-inventory-snapshot reports/runtime-inventory.json --script-inventory-audit-output reports/payment-script-inventory-audit.json --json # payment-page script drift gate
|
|
48
|
+
# npx jso-protector --payment-page-headers-from-har reports/checkout.har --payment-page-headers-baseline reports/payment-page-headers.baseline.json --payment-page-headers-output reports/payment-page-headers.json --payment-page-url-pattern "checkout|payment|wallet" --json # payment-page security-header evidence
|
|
49
|
+
# --ai-precheck --ai-precheck-fail-on error # AI compat scan gate
|
|
50
|
+
# --estimate # pre-flight quota gate
|
|
51
|
+
# --watermark "$COMMIT_SHA" # HMAC marker (needs JSO_WATERMARK_KEY env)
|
|
52
|
+
# --sign-release ci-key.priv.pem # Ed25519 attestation -> .manifest.json.sig
|
|
53
|
+
- npm run smoke --if-present
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// `jso-protector compliance <framework>` CLI dispatch.
|
|
4
|
+
//
|
|
5
|
+
// Today the only framework is pci-dss-v4. The structure is open-ended
|
|
6
|
+
// so SOC 2 evidence / ISO 27001 / EU DSA reports can be added as
|
|
7
|
+
// peer subcommands without re-shuffling the layout.
|
|
8
|
+
//
|
|
9
|
+
// jso-protector.js intercepts argv[0] === "compliance" and forwards
|
|
10
|
+
// the remaining argv here.
|
|
11
|
+
|
|
12
|
+
const fs = require("node:fs");
|
|
13
|
+
const path = require("node:path");
|
|
14
|
+
|
|
15
|
+
const FRAMEWORKS = {
|
|
16
|
+
"pci-dss-v4": require("./pci-dss-v4/index.js"),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function printHelp(stream) {
|
|
20
|
+
stream = stream || process.stdout;
|
|
21
|
+
stream.write(
|
|
22
|
+
`jso-protector compliance <framework> [options]
|
|
23
|
+
|
|
24
|
+
Frameworks:
|
|
25
|
+
pci-dss-v4 PCI DSS v4.0.1 evidence report (controls 6.4.3, 11.6.1).
|
|
26
|
+
|
|
27
|
+
Common options (any framework):
|
|
28
|
+
--manifest <path> Path to .manifest.json.sig (signed) or
|
|
29
|
+
.manifest.json (with --allow-unsigned).
|
|
30
|
+
REQUIRED.
|
|
31
|
+
--root <dir> Re-hash files on disk and inspect watermarks.
|
|
32
|
+
--watermark-key <key> HMAC key used at build time. With this, the
|
|
33
|
+
reporter validates every per-file watermark
|
|
34
|
+
signature; without, presence-only.
|
|
35
|
+
--beacon-url <url> BeaconUrl that runtime defense events post
|
|
36
|
+
to. Wired => 11.6.1.a/b can be evidenced.
|
|
37
|
+
--siem <name> SIEM adapter wired downstream of the beacon.
|
|
38
|
+
splunk-hec | elasticsearch | webhook
|
|
39
|
+
--runtime-incidents <csv|json>
|
|
40
|
+
Dashboard Monitoring incident CSV or JSON export.
|
|
41
|
+
Summarized as source-free 11.6.1 evidence.
|
|
42
|
+
--script-inventory <csv|json>
|
|
43
|
+
Payment-page script inventory export with
|
|
44
|
+
authorization and justification fields.
|
|
45
|
+
--script-inventory-audit <json>
|
|
46
|
+
JSON output from --script-inventory-audit --json.
|
|
47
|
+
Summarized as source-free inventory reconciliation evidence.
|
|
48
|
+
--payment-page-headers <csv|json>
|
|
49
|
+
Payment-page security-header snapshot with CSP,
|
|
50
|
+
frame, HSTS, referrer-policy, monitor, alert-route,
|
|
51
|
+
and baseline-hash metadata. Summarized as source-free
|
|
52
|
+
11.6.1 evidence.
|
|
53
|
+
--organization <name> Customer name to embed in the report header.
|
|
54
|
+
--build-label <label> Override the manifest's label field.
|
|
55
|
+
--output <path> Write Markdown to this path; otherwise stdout.
|
|
56
|
+
--json Emit JSON envelope to stdout (overrides Markdown).
|
|
57
|
+
--json-output <path> Write JSON envelope to this path.
|
|
58
|
+
--allow-unsigned Accept a bare manifest.json (partial report
|
|
59
|
+
only; req 6.4.3.b will FAIL).
|
|
60
|
+
--push <profile> After generating, push the report to a GRC
|
|
61
|
+
platform as evidence. profile: generic | drata | vanta.
|
|
62
|
+
--push-endpoint <url> GRC evidence endpoint (or env JSO_GRC_ENDPOINT).
|
|
63
|
+
Tenant-specific; you supply it.
|
|
64
|
+
--push-token <token> Bearer token for the GRC API (or env JSO_GRC_TOKEN).
|
|
65
|
+
--push-secret <secret> HMAC secret for the generic profile (or env
|
|
66
|
+
JSO_GRC_SECRET); signs the body like the
|
|
67
|
+
jso-beacon-slack webhook adapter.
|
|
68
|
+
-h, --help Show this help.
|
|
69
|
+
|
|
70
|
+
Exit codes:
|
|
71
|
+
0 Every PCI DSS sub-requirement passes.
|
|
72
|
+
1 Evidence gaps (partial or fail) that need operator action.
|
|
73
|
+
2 Manifest is unsigned or unreadable.
|
|
74
|
+
|
|
75
|
+
Examples:
|
|
76
|
+
|
|
77
|
+
# Smoke a freshly-built signed manifest.
|
|
78
|
+
jso-protector compliance pci-dss-v4 \\
|
|
79
|
+
--manifest dist/build.manifest.json.sig \\
|
|
80
|
+
--root dist \\
|
|
81
|
+
--watermark-key "\${JSO_WATERMARK_KEY}" \\
|
|
82
|
+
--beacon-url "https://beacon.example.com/v1/jso" \\
|
|
83
|
+
--siem splunk-hec \\
|
|
84
|
+
--script-inventory reports/payment-script-inventory.json \\
|
|
85
|
+
--script-inventory-audit reports/payment-script-inventory-audit.json \\
|
|
86
|
+
--payment-page-headers reports/payment-page-headers.json \\
|
|
87
|
+
--runtime-incidents reports/runtime-incidents.csv \\
|
|
88
|
+
--organization "Example Corp" \\
|
|
89
|
+
--output reports/pci-dss-v4.md
|
|
90
|
+
|
|
91
|
+
# JSON for tooling.
|
|
92
|
+
jso-protector compliance pci-dss-v4 \\
|
|
93
|
+
--manifest dist/build.manifest.json.sig --json | jq .summary
|
|
94
|
+
`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function main(argv) {
|
|
98
|
+
if (!Array.isArray(argv)) argv = [];
|
|
99
|
+
if (argv.length === 0 || argv[0] === "-h" || argv[0] === "--help") {
|
|
100
|
+
printHelp();
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
const framework = argv[0];
|
|
104
|
+
const generator = FRAMEWORKS[framework];
|
|
105
|
+
if (!generator) {
|
|
106
|
+
process.stderr.write("Unknown compliance framework: " + framework + "\n");
|
|
107
|
+
process.stderr.write("Supported: " + Object.keys(FRAMEWORKS).join(", ") + "\n");
|
|
108
|
+
return 2;
|
|
109
|
+
}
|
|
110
|
+
const opts = parseArgs(argv.slice(1));
|
|
111
|
+
if (opts.help) { printHelp(); return 0; }
|
|
112
|
+
if (!opts.manifest) {
|
|
113
|
+
process.stderr.write("--manifest <path> is required\n");
|
|
114
|
+
return 2;
|
|
115
|
+
}
|
|
116
|
+
const result = generator.generateReport({
|
|
117
|
+
manifestPath: opts.manifest,
|
|
118
|
+
rootDir: opts.root || null,
|
|
119
|
+
watermarkKey: opts.watermarkKey || process.env.JSO_WATERMARK_KEY || null,
|
|
120
|
+
beaconUrl: opts.beaconUrl || null,
|
|
121
|
+
siemAdapter: opts.siem || null,
|
|
122
|
+
runtimeIncidentsPath: opts.runtimeIncidents || null,
|
|
123
|
+
scriptInventoryPath: opts.scriptInventory || null,
|
|
124
|
+
scriptInventoryAuditPath: opts.scriptInventoryAudit || null,
|
|
125
|
+
securityHeadersPath: opts.paymentPageHeaders || null,
|
|
126
|
+
organizationName: opts.organization || null,
|
|
127
|
+
buildLabel: opts.buildLabel || null,
|
|
128
|
+
includeUnsignedManifest: !!opts.allowUnsigned,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
if (opts.jsonOutput) {
|
|
132
|
+
fs.writeFileSync(opts.jsonOutput, JSON.stringify(result.json, null, 2) + "\n", "utf8");
|
|
133
|
+
}
|
|
134
|
+
if (opts.json) {
|
|
135
|
+
process.stdout.write(JSON.stringify(result.json, null, 2) + "\n");
|
|
136
|
+
} else {
|
|
137
|
+
if (opts.output) {
|
|
138
|
+
fs.writeFileSync(opts.output, result.markdown, "utf8");
|
|
139
|
+
process.stderr.write("compliance report written: " + opts.output + " (exit " + result.exitCode + ")\n");
|
|
140
|
+
} else {
|
|
141
|
+
process.stdout.write(result.markdown);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Optional: push the generated report to a GRC platform as evidence.
|
|
146
|
+
// Transport failure is reported but does NOT change the compliance
|
|
147
|
+
// exit code — the report's own verdict is the authority; forwarding
|
|
148
|
+
// is a side channel.
|
|
149
|
+
if (opts.push) {
|
|
150
|
+
const { createEvidenceForwarder } = require("./evidence-forwarder.js");
|
|
151
|
+
const forward = createEvidenceForwarder({
|
|
152
|
+
profile: opts.push,
|
|
153
|
+
endpoint: opts.pushEndpoint || process.env.JSO_GRC_ENDPOINT,
|
|
154
|
+
token: opts.pushToken || process.env.JSO_GRC_TOKEN,
|
|
155
|
+
secret: opts.pushSecret || process.env.JSO_GRC_SECRET,
|
|
156
|
+
organizationName: opts.organization || null,
|
|
157
|
+
});
|
|
158
|
+
const res = await forward(result.json);
|
|
159
|
+
if (res.ok) {
|
|
160
|
+
process.stderr.write("evidence pushed to " + opts.push + " (status " + res.status + ", artifact " + (res.artifactSha256 || "").slice(0, 12) + "...)\n");
|
|
161
|
+
} else {
|
|
162
|
+
process.stderr.write("evidence push to " + opts.push + " FAILED: " + (res.error || ("status " + res.status)) + "\n");
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return result.exitCode;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function parseArgs(argv) {
|
|
169
|
+
const out = { help: false };
|
|
170
|
+
for (let i = 0; i < argv.length; i++) {
|
|
171
|
+
const a = argv[i];
|
|
172
|
+
switch (a) {
|
|
173
|
+
case "-h": case "--help": out.help = true; break;
|
|
174
|
+
case "--manifest": out.manifest = argv[++i]; break;
|
|
175
|
+
case "--root": out.root = argv[++i]; break;
|
|
176
|
+
case "--watermark-key": out.watermarkKey = argv[++i]; break;
|
|
177
|
+
case "--beacon-url": out.beaconUrl = argv[++i]; break;
|
|
178
|
+
case "--siem": out.siem = argv[++i]; break;
|
|
179
|
+
case "--runtime-incidents": out.runtimeIncidents = argv[++i]; break;
|
|
180
|
+
case "--script-inventory": out.scriptInventory = argv[++i]; break;
|
|
181
|
+
case "--script-inventory-audit": out.scriptInventoryAudit = argv[++i]; break;
|
|
182
|
+
case "--payment-page-headers": out.paymentPageHeaders = argv[++i]; break;
|
|
183
|
+
case "--organization": out.organization = argv[++i]; break;
|
|
184
|
+
case "--build-label": out.buildLabel = argv[++i]; break;
|
|
185
|
+
case "--output": out.output = argv[++i]; break;
|
|
186
|
+
case "--json": out.json = true; break;
|
|
187
|
+
case "--json-output": out.jsonOutput = argv[++i]; break;
|
|
188
|
+
case "--allow-unsigned": out.allowUnsigned = true; break;
|
|
189
|
+
case "--push": out.push = argv[++i]; break;
|
|
190
|
+
case "--push-endpoint": out.pushEndpoint = argv[++i]; break;
|
|
191
|
+
case "--push-token": out.pushToken = argv[++i]; break;
|
|
192
|
+
case "--push-secret": out.pushSecret = argv[++i]; break;
|
|
193
|
+
default:
|
|
194
|
+
if (a.startsWith("--")) {
|
|
195
|
+
process.stderr.write("Unknown flag: " + a + "\n");
|
|
196
|
+
throw new Error("usage error: " + a);
|
|
197
|
+
}
|
|
198
|
+
// ignore positional after subcommand
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return out;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
module.exports = { main: main, printHelp: printHelp, FRAMEWORKS: FRAMEWORKS };
|