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.
Files changed (119) hide show
  1. package/CHANGELOG.md +960 -0
  2. package/LICENSE +90 -0
  3. package/MIGRATION.md +207 -0
  4. package/README.md +1477 -0
  5. package/RELEASE.md +82 -0
  6. package/SECURITY.md +71 -0
  7. package/ai-cli.js +392 -0
  8. package/ai.js +176 -0
  9. package/bin/jso-protector.js +12066 -0
  10. package/browserify.d.ts +10 -0
  11. package/browserify.js +88 -0
  12. package/bun.d.ts +10 -0
  13. package/bun.js +41 -0
  14. package/ci/Jenkinsfile +82 -0
  15. package/ci/argo-workflows.yaml +121 -0
  16. package/ci/azure-pipelines.yml +56 -0
  17. package/ci/bitbucket-pipelines.yml +43 -0
  18. package/ci/buildkite.yml +50 -0
  19. package/ci/circleci.yml +60 -0
  20. package/ci/drone.yml +67 -0
  21. package/ci/github-actions.yml +51 -0
  22. package/ci/gitlab-ci.yml +39 -0
  23. package/ci/gocd.yaml +79 -0
  24. package/ci/teamcity.kts +79 -0
  25. package/ci/tekton.yaml +106 -0
  26. package/ci/verify-package.js +748 -0
  27. package/ci/verify-publish-metadata.js +147 -0
  28. package/ci/verify-templates.js +195 -0
  29. package/ci/woodpecker.yml +53 -0
  30. package/compliance/cli.js +204 -0
  31. package/compliance/evidence-forwarder.js +209 -0
  32. package/compliance/pci-dss-v4/controls.json +75 -0
  33. package/compliance/pci-dss-v4/index.js +2613 -0
  34. package/config/named-sets.js +185 -0
  35. package/esbuild.d.ts +16 -0
  36. package/esbuild.js +190 -0
  37. package/examples/README.md +78 -0
  38. package/examples/browserify/build.js +20 -0
  39. package/examples/bun/package.json +13 -0
  40. package/examples/bun/scripts/protect-release.js +28 -0
  41. package/examples/cli-basic/jso.config.cjs +23 -0
  42. package/examples/cli-basic/jso.config.json +15 -0
  43. package/examples/cli-basic/package.json +14 -0
  44. package/examples/cli-basic/scripts/build.js +10 -0
  45. package/examples/curl/README.md +55 -0
  46. package/examples/curl/protect.sh +106 -0
  47. package/examples/esbuild/build.js +19 -0
  48. package/examples/grunt/Gruntfile.js +29 -0
  49. package/examples/gulp/gulpfile.js +19 -0
  50. package/examples/helm/Chart.yaml +27 -0
  51. package/examples/helm/README.md +69 -0
  52. package/examples/helm/templates/_helpers.tpl +23 -0
  53. package/examples/helm/templates/_podtemplate.tpl +64 -0
  54. package/examples/helm/templates/job.yaml +39 -0
  55. package/examples/helm/templates/secret.yaml +17 -0
  56. package/examples/helm/values.yaml +54 -0
  57. package/examples/kubernetes/job.yaml +123 -0
  58. package/examples/metro.config.js +11 -0
  59. package/examples/nextjs/next.config.js +11 -0
  60. package/examples/node-api/protect-release.js +28 -0
  61. package/examples/node-api/release-summary.js +59 -0
  62. package/examples/parcel/package.json +13 -0
  63. package/examples/parcel/scripts/protect-release.js +28 -0
  64. package/examples/payment-page-script-inventory.json +62 -0
  65. package/examples/payment-page-security-headers.json +46 -0
  66. package/examples/pre-commit/.pre-commit-config.yaml +33 -0
  67. package/examples/pre-commit/README.md +45 -0
  68. package/examples/react-native/README.md +208 -0
  69. package/examples/react-native/metro.config.js +11 -0
  70. package/examples/rollup/rollup.config.js +20 -0
  71. package/examples/rspack/rspack.config.js +28 -0
  72. package/examples/turbopack/package.json +13 -0
  73. package/examples/turbopack/scripts/protect-release.js +28 -0
  74. package/examples/vite/vite.config.js +18 -0
  75. package/examples/webpack/webpack.config.js +21 -0
  76. package/examples/webpack-loader/webpack.config.js +22 -0
  77. package/governance/index.d.ts +18 -0
  78. package/governance/index.js +309 -0
  79. package/grunt.d.ts +4 -0
  80. package/grunt.js +111 -0
  81. package/gulp.d.ts +10 -0
  82. package/gulp.js +106 -0
  83. package/index.d.ts +879 -0
  84. package/index.js +607 -0
  85. package/jso.config.example.json +29 -0
  86. package/jso.config.schema.json +548 -0
  87. package/metro.d.ts +43 -0
  88. package/metro.js +117 -0
  89. package/next.d.ts +24 -0
  90. package/next.js +64 -0
  91. package/package.json +241 -0
  92. package/parcel.d.ts +10 -0
  93. package/parcel.js +40 -0
  94. package/react-native.d.ts +2 -0
  95. package/react-native.js +3 -0
  96. package/release-signer.js +245 -0
  97. package/rollup.d.ts +13 -0
  98. package/rollup.js +71 -0
  99. package/rspack-loader.d.ts +13 -0
  100. package/rspack-loader.js +11 -0
  101. package/rspack.d.ts +11 -0
  102. package/rspack.js +9 -0
  103. package/runtime/ai-script-governance.js +379 -0
  104. package/runtime/countermeasures.js +0 -0
  105. package/runtime/data-exfiltration-guard.d.ts +7 -0
  106. package/runtime/data-exfiltration-guard.js +161 -0
  107. package/runtime/environment-integrity.js +389 -0
  108. package/runtime/managed-integrity.d.ts +4 -0
  109. package/runtime/managed-integrity.js +108 -0
  110. package/runtime/third-party-inventory.js +437 -0
  111. package/turbopack.d.ts +10 -0
  112. package/turbopack.js +41 -0
  113. package/vite.d.ts +16 -0
  114. package/vite.js +78 -0
  115. package/watermark.js +126 -0
  116. package/webpack-loader.d.ts +15 -0
  117. package/webpack-loader.js +97 -0
  118. package/webpack.d.ts +13 -0
  119. package/webpack.js +143 -0
@@ -0,0 +1,10 @@
1
+ import type { ProtectionOptions } from "./index";
2
+
3
+ export interface JsoProtectorBrowserifyOptions extends ProtectionOptions {
4
+ fileName?: string;
5
+ }
6
+
7
+ declare function jsoProtectorBrowserify(file: string, options?: JsoProtectorBrowserifyOptions): NodeJS.ReadWriteStream;
8
+
9
+ export { jsoProtectorBrowserify };
10
+ export default jsoProtectorBrowserify;
package/browserify.js ADDED
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ const path = require("path");
4
+ const { Transform } = require("stream");
5
+ const { assertSizeBudgets, buildItemsManifest, buildProtectionItemsFromInputItems, composeProtectionItemOutput, createProtectionConfig, isExcluded, protectItems, writeManifest } = require("./index.js");
6
+
7
+ function jsoProtectorBrowserify(file, options = {}) {
8
+ const config = createProtectionConfig(options);
9
+ const fileName = normalizeName(options.fileName || assetNameForFile(file, config));
10
+ const shouldProtect = shouldProtectFile(fileName, config);
11
+ const chunks = [];
12
+
13
+ return new Transform({
14
+ transform(chunk, _encoding, callback) {
15
+ if (!shouldProtect) {
16
+ this.push(chunk);
17
+ } else {
18
+ chunks.push(Buffer.from(chunk));
19
+ }
20
+ callback();
21
+ },
22
+ async flush(callback) {
23
+ if (!shouldProtect) {
24
+ callback();
25
+ return;
26
+ }
27
+
28
+ try {
29
+ const code = Buffer.concat(chunks).toString("utf8");
30
+ const inputItems = [{
31
+ FileName: fileName,
32
+ FileCode: code,
33
+ SourcePath: file || fileName,
34
+ OutputPath: file || fileName
35
+ }];
36
+ const protection = buildProtectionItemsFromInputItems(config, inputItems);
37
+ const result = await protectItems(config, protection.items);
38
+ const manifest = buildItemsManifest(config, inputItems, result, () => file || fileName, protection.transforms);
39
+ assertSizeBudgets(manifest, config);
40
+
41
+ if (config.manifest) writeManifest(config.manifest, manifest);
42
+ this.push(composeProtectionItemOutput(fileName, result, protection.transforms, config));
43
+ callback();
44
+ } catch (error) {
45
+ callback(error);
46
+ }
47
+ }
48
+ });
49
+ }
50
+
51
+ function assetNameForFile(file, config) {
52
+ if (!file) return "module.js";
53
+ const normalizedFile = normalizeName(file);
54
+ const input = config.input ? normalizeName(path.resolve(config.input)) : "";
55
+ const resolvedFile = normalizeName(path.resolve(file));
56
+ if (input && resolvedFile.startsWith(`${input}/`)) {
57
+ return resolvedFile.slice(input.length + 1);
58
+ }
59
+ const cwd = normalizeName(process.cwd());
60
+ if (resolvedFile.startsWith(`${cwd}/`)) {
61
+ return resolvedFile.slice(cwd.length + 1);
62
+ }
63
+ return path.basename(normalizedFile);
64
+ }
65
+
66
+ function shouldProtectFile(fileName, config) {
67
+ if (!matchesProtectedScriptExtension(fileName, config)) return false;
68
+ if (Array.isArray(config.include) && config.include.length && !isExcluded(fileName, config.include)) {
69
+ return false;
70
+ }
71
+ return !isExcluded(fileName, config.exclude || []);
72
+ }
73
+
74
+ function matchesProtectedScriptExtension(fileName, config) {
75
+ const normalizedName = normalizeName(fileName).toLowerCase();
76
+ const extensions = Array.isArray(config.extensions) && config.extensions.length
77
+ ? config.extensions
78
+ : [".js"];
79
+ return extensions.some((extension) => normalizedName.endsWith(String(extension || "").toLowerCase()));
80
+ }
81
+
82
+ function normalizeName(name) {
83
+ return String(name || "").replace(/\\/g, "/");
84
+ }
85
+
86
+ module.exports = jsoProtectorBrowserify;
87
+ module.exports.jsoProtectorBrowserify = jsoProtectorBrowserify;
88
+ module.exports.default = jsoProtectorBrowserify;
package/bun.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { ProtectionOptions, ProtectionPlan, ProtectionRunResult, ResolvedProtectionConfig } from "./index";
2
+
3
+ export interface JsoProtectorBunOptions extends ProtectionOptions {}
4
+
5
+ declare function protectBunBuild(options?: JsoProtectorBunOptions): Promise<ProtectionRunResult>;
6
+ declare function createBunProtectionConfig(options?: JsoProtectorBunOptions): ResolvedProtectionConfig;
7
+ declare function planBunBuild(options?: JsoProtectorBunOptions): ProtectionPlan;
8
+
9
+ export { createBunProtectionConfig, planBunBuild, protectBunBuild };
10
+ export default protectBunBuild;
package/bun.js ADDED
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ const { createProtectionConfig, planProtection, protectFiles } = require("./index.js");
4
+
5
+ function createBunProtectionConfig(options = {}) {
6
+ return createProtectionConfig({
7
+ input: "dist",
8
+ output: "dist-protected",
9
+ preset: "balanced",
10
+ exclude: ["**/*.map", "**/vendor/**"],
11
+ assetExclude: ["**/*.map"],
12
+ maxOutputBytes: 250000,
13
+ maxGrowthRatio: 8,
14
+ manifest: defaultManifestForOutput(options, "dist-protected/jso-manifest.json"),
15
+ ...options
16
+ });
17
+ }
18
+
19
+ function planBunBuild(options = {}) {
20
+ return planProtection(createBunProtectionConfig(options));
21
+ }
22
+
23
+ async function protectBunBuild(options = {}) {
24
+ return protectFiles(createBunProtectionConfig(options));
25
+ }
26
+
27
+ function defaultManifestForOutput(options, fallback) {
28
+ if (Object.prototype.hasOwnProperty.call(options || {}, "manifest")) {
29
+ return options.manifest;
30
+ }
31
+ if (options && options.output) {
32
+ return `${String(options.output).replace(/[\\/]$/, "")}/jso-manifest.json`;
33
+ }
34
+ return fallback;
35
+ }
36
+
37
+ module.exports = protectBunBuild;
38
+ module.exports.createBunProtectionConfig = createBunProtectionConfig;
39
+ module.exports.planBunBuild = planBunBuild;
40
+ module.exports.protectBunBuild = protectBunBuild;
41
+ module.exports.default = protectBunBuild;
package/ci/Jenkinsfile ADDED
@@ -0,0 +1,82 @@
1
+ // Declarative Jenkinsfile for jso-protector.
2
+ //
3
+ // Drop this at the root of your repo. The pipeline expects credentials stored
4
+ // in Jenkins as two Secret Text bindings: jso-api-key and jso-api-password.
5
+ // They are exported into the env at step time so jso-protector picks them up
6
+ // without echoing them in build logs.
7
+ //
8
+ // Every protection run is tagged with $GIT_COMMIT so the JSO dashboard audit
9
+ // log groups by commit. The API report is archived as a Jenkins artifact and
10
+ // can be retrieved later for stack-trace symbolication via jso-symbolicate.
11
+
12
+ pipeline {
13
+ agent any
14
+
15
+ tools {
16
+ nodejs 'node-22'
17
+ }
18
+
19
+ environment {
20
+ JSO_API_KEY = credentials('jso-api-key')
21
+ JSO_API_PASSWORD = credentials('jso-api-password')
22
+ }
23
+
24
+ stages {
25
+ stage('Install') {
26
+ steps {
27
+ sh 'npm ci'
28
+ }
29
+ }
30
+
31
+ stage('Build') {
32
+ steps {
33
+ sh 'npm run build'
34
+ }
35
+ }
36
+
37
+ stage('Release preflight') {
38
+ steps {
39
+ sh 'npx jso-protector --config jso.config.json --release-check --json'
40
+ }
41
+ }
42
+
43
+ stage('Protect JavaScript') {
44
+ steps {
45
+ sh '''
46
+ npx jso-protector \
47
+ --config jso.config.json \
48
+ --label "$GIT_COMMIT" \
49
+ --manifest dist-protected/jso-manifest.json \
50
+ --report dist-protected/jso-report.json
51
+ # Optional: migration and supply-chain checks. Copy into a preflight/protect step as needed.
52
+ # Configure JSO_WATERMARK_KEY as a masked secret; check in ci-key.pub.pem,
53
+ # store ci-key.priv.pem in a CI file secret. See WireFormat.aspx#watermark.
54
+ # npx jso-protector --config jso.config.json --competitor-gap-report --json # competitor migration gap report
55
+ # 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
56
+ # 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
57
+ # 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
58
+ # --ai-precheck --ai-precheck-fail-on error // AI compat scan gate
59
+ # --estimate // pre-flight quota gate
60
+ # --watermark "$COMMIT_SHA" // HMAC marker (needs JSO_WATERMARK_KEY env)
61
+ # --sign-release ci-key.priv.pem // Ed25519 attestation -> .manifest.json.sig
62
+ '''
63
+ }
64
+ }
65
+
66
+ stage('Smoke') {
67
+ steps {
68
+ sh 'npm run smoke --if-present'
69
+ }
70
+ }
71
+ }
72
+
73
+ post {
74
+ always {
75
+ // Archive both the protected dist and the report. Keep the report
76
+ // in a separate fingerprinted artifact so support can pull "just
77
+ // the symbolication map" without re-downloading megabytes of dist.
78
+ archiveArtifacts artifacts: 'dist-protected/**', fingerprint: true, allowEmptyArchive: false
79
+ archiveArtifacts artifacts: 'dist-protected/jso-report.json', fingerprint: true, allowEmptyArchive: false
80
+ }
81
+ }
82
+ }
@@ -0,0 +1,121 @@
1
+ # Argo Workflows template for jso-protector.
2
+ #
3
+ # Drop this into your Argo install and submit with:
4
+ # argo submit argo-workflows.yaml -p repo-url=https://github.com/your-org/your-repo \
5
+ # -p commit-sha=$(git rev-parse HEAD)
6
+ #
7
+ # Add a Kubernetes Secret named `jso-credentials` with keys JSO_API_KEY and
8
+ # JSO_API_PASSWORD before submitting.
9
+ #
10
+ # Every protection run is tagged with the commit SHA via --label, and the
11
+ # API report rides as a workflow artifact for later symbolication.
12
+
13
+ apiVersion: argoproj.io/v1alpha1
14
+ kind: Workflow
15
+ metadata:
16
+ generateName: jso-protect-
17
+ labels:
18
+ app.kubernetes.io/name: jso-protector
19
+ spec:
20
+ entrypoint: protect-release
21
+
22
+ arguments:
23
+ parameters:
24
+ - name: repo-url
25
+ value: "https://github.com/your-org/your-repo.git"
26
+ - name: commit-sha
27
+ value: "main"
28
+ - name: preset
29
+ value: "balanced"
30
+
31
+ volumeClaimTemplates:
32
+ - metadata:
33
+ name: workspace
34
+ spec:
35
+ accessModes: [ "ReadWriteOnce" ]
36
+ resources:
37
+ requests:
38
+ storage: 2Gi
39
+
40
+ templates:
41
+ - name: protect-release
42
+ steps:
43
+ - - name: checkout
44
+ template: git-clone
45
+ - - name: build
46
+ template: npm-build
47
+ - - name: protect
48
+ template: jso-protect
49
+
50
+ - name: git-clone
51
+ container:
52
+ image: alpine/git:2.43.0
53
+ command: [ sh, -c ]
54
+ args:
55
+ - |
56
+ set -eu
57
+ cd /workspace
58
+ git clone --depth 1 --branch "{{workflow.parameters.commit-sha}}" \
59
+ "{{workflow.parameters.repo-url}}" .
60
+ echo "Checked out $(git rev-parse HEAD)"
61
+ volumeMounts:
62
+ - name: workspace
63
+ mountPath: /workspace
64
+
65
+ - name: npm-build
66
+ container:
67
+ image: node:22
68
+ workingDir: /workspace
69
+ command: [ sh, -c ]
70
+ args:
71
+ - |
72
+ set -eu
73
+ npm ci --no-audit --no-fund
74
+ npm run build
75
+ volumeMounts:
76
+ - name: workspace
77
+ mountPath: /workspace
78
+
79
+ - name: jso-protect
80
+ container:
81
+ image: node:22
82
+ workingDir: /workspace
83
+ envFrom:
84
+ - secretRef:
85
+ name: jso-credentials
86
+ command: [ sh, -c ]
87
+ args:
88
+ - |
89
+ set -eu
90
+ SHA="$(git rev-parse HEAD 2>/dev/null || echo unknown)"
91
+ npx jso-protector --config jso.config.json --release-check --json
92
+ npx jso-protector \
93
+ --config jso.config.json \
94
+ --preset "{{workflow.parameters.preset}}" \
95
+ --label "$SHA" \
96
+ --manifest dist-protected/jso-manifest.json \
97
+ --report dist-protected/jso-report.json
98
+ # Optional: migration and supply-chain checks. Copy into a preflight/protect step as needed.
99
+ # Configure JSO_WATERMARK_KEY as a masked secret; check in ci-key.pub.pem,
100
+ # store ci-key.priv.pem in a CI file secret. See WireFormat.aspx#watermark.
101
+ # npx jso-protector --config jso.config.json --competitor-gap-report --json # competitor migration gap report
102
+ # 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
103
+ # 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
104
+ # 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
105
+ # --ai-precheck --ai-precheck-fail-on error # AI compat scan gate
106
+ # --estimate # pre-flight quota gate
107
+ # --watermark "$COMMIT_SHA" # HMAC marker (needs JSO_WATERMARK_KEY env)
108
+ # --sign-release ci-key.priv.pem # Ed25519 attestation -> .manifest.json.sig
109
+ npm run smoke --if-present
110
+ volumeMounts:
111
+ - name: workspace
112
+ mountPath: /workspace
113
+ outputs:
114
+ artifacts:
115
+ - name: protected-dist
116
+ path: /workspace/dist-protected
117
+ archive:
118
+ tar:
119
+ compressionLevel: 6
120
+ - name: jso-report
121
+ path: /workspace/dist-protected/jso-report.json
@@ -0,0 +1,56 @@
1
+ trigger: none
2
+
3
+ pool:
4
+ vmImage: ubuntu-latest
5
+
6
+ steps:
7
+ - task: NodeTool@0
8
+ inputs:
9
+ versionSpec: "22.x"
10
+ displayName: Use Node.js
11
+
12
+ - script: npm ci
13
+ displayName: Install dependencies
14
+
15
+ - script: npm run build
16
+ displayName: Build
17
+
18
+ - script: npm run verify:package --if-present
19
+ displayName: Verify package install
20
+
21
+ - script: npm run verify:publish-metadata --if-present
22
+ displayName: Verify publish metadata
23
+
24
+ - script: npx jso-protector --config jso.config.json --release-check --json
25
+ displayName: Release preflight
26
+ env:
27
+ JSO_API_KEY: $(JSO_API_KEY)
28
+ JSO_API_PASSWORD: $(JSO_API_PASSWORD)
29
+
30
+ - script: |
31
+ npx jso-protector \
32
+ --config jso.config.json \
33
+ --label "$(Build.SourceVersion)" \
34
+ --manifest dist-protected/jso-manifest.json \
35
+ --report dist-protected/jso-report.json
36
+ # Optional: migration and supply-chain checks. Copy into a preflight/protect step as needed.
37
+ # Configure JSO_WATERMARK_KEY as a masked secret; check in ci-key.pub.pem,
38
+ # store ci-key.priv.pem in a CI file secret. See WireFormat.aspx#watermark.
39
+ # npx jso-protector --config jso.config.json --competitor-gap-report --json # competitor migration gap report
40
+ # 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
41
+ # 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
42
+ # 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
43
+ # --ai-precheck --ai-precheck-fail-on error # AI compat scan gate
44
+ # --estimate # pre-flight quota gate
45
+ # --watermark "$COMMIT_SHA" # HMAC marker (needs JSO_WATERMARK_KEY env)
46
+ # --sign-release ci-key.priv.pem # Ed25519 attestation -> .manifest.json.sig
47
+ displayName: Protect JavaScript
48
+ env:
49
+ JSO_API_KEY: $(JSO_API_KEY)
50
+ JSO_API_PASSWORD: $(JSO_API_PASSWORD)
51
+
52
+ - script: npm run smoke
53
+ displayName: Smoke test
54
+
55
+ - publish: dist-protected
56
+ artifact: protected-dist
@@ -0,0 +1,43 @@
1
+ # Bitbucket Pipelines template for jso-protector.
2
+ #
3
+ # Drop this at bitbucket-pipelines.yml in your repo. Add JSO_API_KEY and
4
+ # JSO_API_PASSWORD as repository variables (Settings �?Pipelines �?Repository
5
+ # variables, secured).
6
+ #
7
+ # Every protection run is tagged with $BITBUCKET_COMMIT and the API report
8
+ # travels alongside the protected dist as a pipeline artifact for later
9
+ # stack-trace symbolication.
10
+
11
+ image: node:22
12
+
13
+ pipelines:
14
+ branches:
15
+ main:
16
+ - step:
17
+ name: Build and protect
18
+ caches:
19
+ - node
20
+ script:
21
+ - npm ci
22
+ - npm run build
23
+ - npx jso-protector --config jso.config.json --release-check --json
24
+ - >
25
+ npx jso-protector
26
+ --config jso.config.json
27
+ --label "$BITBUCKET_COMMIT"
28
+ --manifest dist-protected/jso-manifest.json
29
+ --report dist-protected/jso-report.json
30
+ # Optional: migration and supply-chain checks. Copy into a preflight/protect step as needed.
31
+ # Configure JSO_WATERMARK_KEY as a masked secret; check in ci-key.pub.pem,
32
+ # store ci-key.priv.pem in a CI file secret. See WireFormat.aspx#watermark.
33
+ # npx jso-protector --config jso.config.json --competitor-gap-report --json # competitor migration gap report
34
+ # 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
35
+ # 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
36
+ # 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
37
+ # --ai-precheck --ai-precheck-fail-on error # AI compat scan gate
38
+ # --estimate # pre-flight quota gate
39
+ # --watermark "$COMMIT_SHA" # HMAC marker (needs JSO_WATERMARK_KEY env)
40
+ # --sign-release ci-key.priv.pem # Ed25519 attestation -> .manifest.json.sig
41
+ - npm run smoke --if-present
42
+ artifacts:
43
+ - dist-protected/**
@@ -0,0 +1,50 @@
1
+ # Buildkite template for jso-protector.
2
+ #
3
+ # Drop this at .buildkite/pipeline.yml in your repo. Expose JSO_API_KEY and
4
+ # JSO_API_PASSWORD via your Buildkite secrets manager or the agent
5
+ # environment hook (recommended over plain pipeline env).
6
+ #
7
+ # Every protection run is tagged with $BUILDKITE_COMMIT via --label and the
8
+ # API report is uploaded as a build artifact for later symbolication.
9
+
10
+ steps:
11
+ - label: ":hammer: install"
12
+ key: install
13
+ command: npm ci
14
+
15
+ - label: ":package: build"
16
+ key: build
17
+ depends_on: install
18
+ command: npm run build
19
+
20
+ - label: ":lock: protect"
21
+ key: protect
22
+ depends_on: build
23
+ command: |
24
+ set -euo pipefail
25
+ npx jso-protector --config jso.config.json --release-check --json
26
+ npx jso-protector \
27
+ --config jso.config.json \
28
+ --label "$BUILDKITE_COMMIT" \
29
+ --manifest dist-protected/jso-manifest.json \
30
+ --report dist-protected/jso-report.json
31
+ # Optional: migration and supply-chain checks. Copy into a preflight/protect step as needed.
32
+ # Configure JSO_WATERMARK_KEY as a masked secret; check in ci-key.pub.pem,
33
+ # store ci-key.priv.pem in a CI file secret. See WireFormat.aspx#watermark.
34
+ # npx jso-protector --config jso.config.json --competitor-gap-report --json # competitor migration gap report
35
+ # 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
36
+ # 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
37
+ # 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
38
+ # --ai-precheck --ai-precheck-fail-on error # AI compat scan gate
39
+ # --estimate # pre-flight quota gate
40
+ # --watermark "$COMMIT_SHA" # HMAC marker (needs JSO_WATERMARK_KEY env)
41
+ # --sign-release ci-key.priv.pem # Ed25519 attestation -> .manifest.json.sig
42
+ npm run smoke --if-present
43
+ artifact_paths:
44
+ - "dist-protected/**/*"
45
+ - "dist-protected/jso-report.json"
46
+
47
+ # Configure credentials via a Buildkite agent environment hook:
48
+ # .buildkite/hooks/environment
49
+ # export JSO_API_KEY="$(buildkite-agent secret get jso_api_key)"
50
+ # export JSO_API_PASSWORD="$(buildkite-agent secret get jso_api_password)"
@@ -0,0 +1,60 @@
1
+ # CircleCI 2.1 template for jso-protector.
2
+ #
3
+ # Drop this at .circleci/config.yml in your repo, then add JSO_API_KEY and
4
+ # JSO_API_PASSWORD as project environment variables (or use a context).
5
+ #
6
+ # The job tags every protection run with the current commit SHA and writes
7
+ # the API report alongside the protected dist so a later stack trace can be
8
+ # symbolicated against this exact build.
9
+ version: 2.1
10
+
11
+ jobs:
12
+ protect-release:
13
+ docker:
14
+ - image: cimg/node:22.4
15
+ steps:
16
+ - checkout
17
+ - run:
18
+ name: Install dependencies
19
+ command: npm ci
20
+ - run:
21
+ name: Build application
22
+ command: npm run build
23
+ - run:
24
+ name: Release preflight
25
+ command: npx jso-protector --config jso.config.json --release-check --json
26
+ - run:
27
+ name: Protect JavaScript
28
+ command: |
29
+ npx jso-protector \
30
+ --config jso.config.json \
31
+ --label "$CIRCLE_SHA1" \
32
+ --manifest dist-protected/jso-manifest.json \
33
+ --report dist-protected/jso-report.json
34
+ # Optional: migration and supply-chain checks. Copy into a preflight/protect step as needed.
35
+ # Configure JSO_WATERMARK_KEY as a masked secret; check in ci-key.pub.pem,
36
+ # store ci-key.priv.pem in a CI file secret. See WireFormat.aspx#watermark.
37
+ # npx jso-protector --config jso.config.json --competitor-gap-report --json # competitor migration gap report
38
+ # 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
39
+ # 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
40
+ # 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
41
+ # --ai-precheck --ai-precheck-fail-on error # AI compat scan gate
42
+ # --estimate # pre-flight quota gate
43
+ # --watermark "$COMMIT_SHA" # HMAC marker (needs JSO_WATERMARK_KEY env)
44
+ # --sign-release ci-key.priv.pem # Ed25519 attestation -> .manifest.json.sig
45
+ - run:
46
+ name: Smoke test protected output
47
+ command: npm run smoke --if-present
48
+ - store_artifacts:
49
+ path: dist-protected
50
+ destination: protected-dist
51
+
52
+ workflows:
53
+ release:
54
+ jobs:
55
+ - protect-release:
56
+ # Wire credentials via CircleCI contexts when shared across orgs.
57
+ # Otherwise expose JSO_API_KEY and JSO_API_PASSWORD as project env vars.
58
+ # filters:
59
+ # branches:
60
+ # only: [main]
package/ci/drone.yml ADDED
@@ -0,0 +1,67 @@
1
+ # Drone CI 1.x template for jso-protector.
2
+ #
3
+ # Drop this at .drone.yml in your repo. Add JSO_API_KEY and JSO_API_PASSWORD
4
+ # as Drone organization or repository secrets (jso_api_key / jso_api_password).
5
+ #
6
+ # Every protection run is tagged with DRONE_COMMIT_SHA via --label, and the
7
+ # API report rides alongside the protected dist for later symbolication.
8
+
9
+ kind: pipeline
10
+ type: docker
11
+ name: protected-release
12
+
13
+ trigger:
14
+ branch:
15
+ - main
16
+
17
+ steps:
18
+ - name: install
19
+ image: node:22
20
+ commands:
21
+ - npm ci
22
+
23
+ - name: build
24
+ image: node:22
25
+ commands:
26
+ - npm run build
27
+
28
+ - name: protect
29
+ image: node:22
30
+ environment:
31
+ JSO_API_KEY:
32
+ from_secret: jso_api_key
33
+ JSO_API_PASSWORD:
34
+ from_secret: jso_api_password
35
+ commands:
36
+ - npx jso-protector --config jso.config.json --release-check --json
37
+ - >
38
+ npx jso-protector
39
+ --config jso.config.json
40
+ --label "$DRONE_COMMIT_SHA"
41
+ --manifest dist-protected/jso-manifest.json
42
+ --report dist-protected/jso-report.json
43
+ # Optional: migration and supply-chain checks. Copy into a preflight/protect step as needed.
44
+ # Configure JSO_WATERMARK_KEY as a masked secret; check in ci-key.pub.pem,
45
+ # store ci-key.priv.pem in a CI file secret. See WireFormat.aspx#watermark.
46
+ # npx jso-protector --config jso.config.json --competitor-gap-report --json # competitor migration gap report
47
+ # 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
48
+ # 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
49
+ # 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
50
+ # --ai-precheck --ai-precheck-fail-on error # AI compat scan gate
51
+ # --estimate # pre-flight quota gate
52
+ # --watermark "$COMMIT_SHA" # HMAC marker (needs JSO_WATERMARK_KEY env)
53
+ # --sign-release ci-key.priv.pem # Ed25519 attestation -> .manifest.json.sig
54
+ - npm run smoke --if-present
55
+
56
+ - name: archive
57
+ image: plugins/s3
58
+ settings:
59
+ bucket: your-artifact-bucket
60
+ source: dist-protected/**/*
61
+ target: /builds/$DRONE_COMMIT_SHA
62
+ access_key:
63
+ from_secret: aws_access_key
64
+ secret_key:
65
+ from_secret: aws_secret_key
66
+ when:
67
+ status: [success]