From 9e881d5bebff169735a008a5e24c50279d2ded6a Mon Sep 17 00:00:00 2001 From: Arnis Voitkans Date: Mon, 21 Sep 2026 21:52:46 +0300 Subject: [PATCH 1/3] Own frontend release builds and exact-image qualification in application CI --- .../upstream}/build.yml | 0 .../upstream}/codescan.yml | 0 .../upstream}/docker.yml | 0 .../upstream}/import-weekly.yml | 0 .../upstream}/issue_opened.yml | 0 .../upstream}/label_merge_conflicts.yml | 0 .../upstream}/new_issue_label.yml | 0 .../upstream}/playwright-tests.yml | 0 .../upstream}/port_merged_pull_request.yml | 0 .../upstream}/pull_request_opened.yml | 0 .../upstream}/tag-release.yml | 0 .../upstream}/trigger-builds.yml | 0 .../upstream}/trigger-ui-tests.yml | 0 .github/workflows/clarin-release.yml | 137 +++++++ ci/release/.gitignore | 2 + ci/release/README.md | 91 +++++ .../templates/config.prod.yml.j2 | 20 + .../clarin_dspace/templates/dspace-ui.json.j2 | 14 + .../templates/http-launcher.cjs.j2 | 22 + .../clarin_dspace/templates/nginx.conf.j2 | 209 ++++++++++ .../ansible/vars/public-paths.yml | 4 + ci/release/compatibility/manifest.json | 11 + ci/release/compatibility/tests/render.yml | 33 ++ ci/release/frontend_image.py | 252 ++++++++++++ ci/release/image/.dockerignore | 7 + ci/release/image/Dockerfile | 57 +++ ci/release/image/dspace-ui.json | 13 + ci/release/image/pm2/package.json | 6 + ci/release/image/toolchain.json | 19 + ci/release/publish.sh | 40 ++ ci/release/publish_report.py | 55 +++ ci/release/record.py | 43 ++ ci/release/release_contract.py | 33 ++ ci/release/scan-policy.json | 10 + ci/release/scan.sh | 48 +++ ci/release/test_https_runtime.py | 377 ++++++++++++++++++ ci/release/test_release.py | 182 +++++++++ ci/release/verify_record.py | 27 ++ 38 files changed, 1712 insertions(+) rename .github/{workflows => disabled-workflows/upstream}/build.yml (100%) rename .github/{workflows => disabled-workflows/upstream}/codescan.yml (100%) rename .github/{workflows => disabled-workflows/upstream}/docker.yml (100%) rename .github/{workflows => disabled-workflows/upstream}/import-weekly.yml (100%) rename .github/{workflows => disabled-workflows/upstream}/issue_opened.yml (100%) rename .github/{workflows => disabled-workflows/upstream}/label_merge_conflicts.yml (100%) rename .github/{workflows => disabled-workflows/upstream}/new_issue_label.yml (100%) rename .github/{workflows => disabled-workflows/upstream}/playwright-tests.yml (100%) rename .github/{workflows => disabled-workflows/upstream}/port_merged_pull_request.yml (100%) rename .github/{workflows => disabled-workflows/upstream}/pull_request_opened.yml (100%) rename .github/{workflows => disabled-workflows/upstream}/tag-release.yml (100%) rename .github/{workflows => disabled-workflows/upstream}/trigger-builds.yml (100%) rename .github/{workflows => disabled-workflows/upstream}/trigger-ui-tests.yml (100%) create mode 100644 .github/workflows/clarin-release.yml create mode 100644 ci/release/.gitignore create mode 100644 ci/release/README.md create mode 100644 ci/release/compatibility/ansible/roles/clarin_dspace/templates/config.prod.yml.j2 create mode 100644 ci/release/compatibility/ansible/roles/clarin_dspace/templates/dspace-ui.json.j2 create mode 100644 ci/release/compatibility/ansible/roles/clarin_dspace/templates/http-launcher.cjs.j2 create mode 100644 ci/release/compatibility/ansible/roles/clarin_dspace/templates/nginx.conf.j2 create mode 100644 ci/release/compatibility/ansible/vars/public-paths.yml create mode 100644 ci/release/compatibility/manifest.json create mode 100644 ci/release/compatibility/tests/render.yml create mode 100644 ci/release/frontend_image.py create mode 100644 ci/release/image/.dockerignore create mode 100644 ci/release/image/Dockerfile create mode 100644 ci/release/image/dspace-ui.json create mode 100644 ci/release/image/pm2/package.json create mode 100644 ci/release/image/toolchain.json create mode 100644 ci/release/publish.sh create mode 100644 ci/release/publish_report.py create mode 100644 ci/release/record.py create mode 100644 ci/release/release_contract.py create mode 100644 ci/release/scan-policy.json create mode 100644 ci/release/scan.sh create mode 100644 ci/release/test_https_runtime.py create mode 100644 ci/release/test_release.py create mode 100644 ci/release/verify_record.py diff --git a/.github/workflows/build.yml b/.github/disabled-workflows/upstream/build.yml similarity index 100% rename from .github/workflows/build.yml rename to .github/disabled-workflows/upstream/build.yml diff --git a/.github/workflows/codescan.yml b/.github/disabled-workflows/upstream/codescan.yml similarity index 100% rename from .github/workflows/codescan.yml rename to .github/disabled-workflows/upstream/codescan.yml diff --git a/.github/workflows/docker.yml b/.github/disabled-workflows/upstream/docker.yml similarity index 100% rename from .github/workflows/docker.yml rename to .github/disabled-workflows/upstream/docker.yml diff --git a/.github/workflows/import-weekly.yml b/.github/disabled-workflows/upstream/import-weekly.yml similarity index 100% rename from .github/workflows/import-weekly.yml rename to .github/disabled-workflows/upstream/import-weekly.yml diff --git a/.github/workflows/issue_opened.yml b/.github/disabled-workflows/upstream/issue_opened.yml similarity index 100% rename from .github/workflows/issue_opened.yml rename to .github/disabled-workflows/upstream/issue_opened.yml diff --git a/.github/workflows/label_merge_conflicts.yml b/.github/disabled-workflows/upstream/label_merge_conflicts.yml similarity index 100% rename from .github/workflows/label_merge_conflicts.yml rename to .github/disabled-workflows/upstream/label_merge_conflicts.yml diff --git a/.github/workflows/new_issue_label.yml b/.github/disabled-workflows/upstream/new_issue_label.yml similarity index 100% rename from .github/workflows/new_issue_label.yml rename to .github/disabled-workflows/upstream/new_issue_label.yml diff --git a/.github/workflows/playwright-tests.yml b/.github/disabled-workflows/upstream/playwright-tests.yml similarity index 100% rename from .github/workflows/playwright-tests.yml rename to .github/disabled-workflows/upstream/playwright-tests.yml diff --git a/.github/workflows/port_merged_pull_request.yml b/.github/disabled-workflows/upstream/port_merged_pull_request.yml similarity index 100% rename from .github/workflows/port_merged_pull_request.yml rename to .github/disabled-workflows/upstream/port_merged_pull_request.yml diff --git a/.github/workflows/pull_request_opened.yml b/.github/disabled-workflows/upstream/pull_request_opened.yml similarity index 100% rename from .github/workflows/pull_request_opened.yml rename to .github/disabled-workflows/upstream/pull_request_opened.yml diff --git a/.github/workflows/tag-release.yml b/.github/disabled-workflows/upstream/tag-release.yml similarity index 100% rename from .github/workflows/tag-release.yml rename to .github/disabled-workflows/upstream/tag-release.yml diff --git a/.github/workflows/trigger-builds.yml b/.github/disabled-workflows/upstream/trigger-builds.yml similarity index 100% rename from .github/workflows/trigger-builds.yml rename to .github/disabled-workflows/upstream/trigger-builds.yml diff --git a/.github/workflows/trigger-ui-tests.yml b/.github/disabled-workflows/upstream/trigger-ui-tests.yml similarity index 100% rename from .github/workflows/trigger-ui-tests.yml rename to .github/disabled-workflows/upstream/trigger-ui-tests.yml diff --git a/.github/workflows/clarin-release.yml b/.github/workflows/clarin-release.yml new file mode 100644 index 00000000000..ca498e74d0e --- /dev/null +++ b/.github/workflows/clarin-release.yml @@ -0,0 +1,137 @@ +--- +name: CLARIN frontend release +on: + pull_request: + branches: [clarin-v7] + push: + branches: [clarin-v7] + workflow_dispatch: +permissions: + contents: read +concurrency: + group: clarin-release-${{ github.ref }} + cancel-in-progress: false +jobs: + build: + if: github.repository == 'LUMII-AILab/dspace-angular' + runs-on: ubuntu-24.04 + timeout-minutes: 60 + outputs: + digest: ${{ steps.build.outputs.digest }} + image: ${{ steps.inputs.outputs.image }} + tag: ${{ steps.inputs.outputs.tag }} + steps: + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 + with: + persist-credentials: false + - name: Derive source identity and validate release tooling + id: inputs + run: | + python3 -m unittest discover -s ci/release -p 'test_release.py' + python3 ci/release/frontend_image.py outputs >> "$GITHUB_OUTPUT" + mkdir -p output/evidence + cp ci/release/image/inputs.json output/evidence/inputs.json + - name: Export this commit without submodules + id: source + run: | + python3 ci/release/frontend_image.py prepare-source \ + "$RUNNER_TEMP/source-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" \ + output/evidence >> "$GITHUB_OUTPUT" + - uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3 + with: + version: ${{ steps.inputs.outputs.buildx_version }} + driver-opts: image=${{ steps.inputs.outputs.buildkit_image }} + buildkitd-flags: "" + - name: Build once without registry credentials + id: build + uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6 + with: + context: ci/release/image + file: ci/release/image/Dockerfile + build-contexts: frontend=${{ steps.source.outputs.context }} + platforms: linux/amd64 + push: false + outputs: type=oci,dest=output/frontend.oci.tar + tags: ${{ steps.inputs.outputs.image }}:${{ steps.inputs.outputs.tag }} + cache-from: type=gha,scope=clarin-frontend + cache-to: ${{ github.event_name != 'pull_request' && 'type=gha,scope=clarin-frontend,mode=max' || '' }} + provenance: mode=max + attests: type=sbom,generator=${{ steps.inputs.outputs.sbom_generator }} + build-args: | + NODE_IMAGE=${{ steps.inputs.outputs.node_image }} + NODE_VERSION=${{ steps.inputs.outputs.node_version }} + YARN_VERSION=${{ steps.inputs.outputs.yarn_version }} + APK_PACKAGES=${{ steps.inputs.outputs.apk_packages }} + SOURCE_PACKAGE_SHA256=${{ steps.inputs.outputs.source_package_sha256 }} + SOURCE_LOCK_SHA256=${{ steps.inputs.outputs.source_lock_sha256 }} + UPSTREAM_DOCKERFILE_SHA256=${{ steps.inputs.outputs.upstream_dockerfile_sha256 }} + SOURCE_REVISION=${{ steps.inputs.outputs.source_revision }} + OPS_REVISION=${{ steps.inputs.outputs.compatibility_revision }} + - name: Verify OCI identity, scan and load the exact runtime image + env: + EXPECTED_DIGEST: ${{ steps.build.outputs.digest }} + SKOPEO: ${{ steps.inputs.outputs.skopeo_image }} + run: | + python3 ci/release/frontend_image.py inspect output/frontend.oci.tar \ + "$EXPECTED_DIGEST" output/evidence + bash ci/release/scan.sh output/frontend.oci.tar output/evidence + docker run --rm --user "$(id -u):$(id -g)" -v "$PWD/output:/artifact" \ + "$SKOPEO" copy --override-os linux --override-arch amd64 \ + oci-archive:/artifact/frontend.oci.tar docker-archive:/artifact/runtime.tar:clarin-runtime:test + docker load --input output/runtime.tar + rm output/runtime.tar + - name: Qualify the exact artifact against pinned HTTPS fixtures + env: + CLARIN_COMPAT_ROOT: ${{ github.workspace }}/ci/release/compatibility + SOURCE: ${{ steps.inputs.outputs.source_revision }} + run: | + python3 -m venv "$RUNNER_TEMP/ansible" + "$RUNNER_TEMP/ansible/bin/pip" install ansible-core==2.21.3 + export PATH="$RUNNER_TEMP/ansible/bin:$PATH" + docker pull nginx@sha256:dc5069ad14f19660b141b21236140b91656bf89bbc3e2417c70ae650cd66104c + python3 ci/release/test_https_runtime.py \ + --frontend "$(jq -er .config_digest output/evidence/identity.json)" \ + --source "$SOURCE" --report output/evidence/https.json + python3 ci/release/record.py + - name: Preserve candidate for publication retries + if: always() + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: frontend-candidate-${{ github.run_id }} + path: output/ + overwrite: true + retention-days: 30 + compression-level: 0 + if-no-files-found: error + publish: + needs: build + if: >- + github.event_name != 'pull_request' && github.ref == 'refs/heads/clarin-v7' && + github.repository == 'LUMII-AILab/dspace-angular' && + vars.CLARIN_RELEASE_PUBLISH_ENABLED == 'true' + runs-on: ubuntu-24.04 + timeout-minutes: 20 + permissions: + contents: write + packages: write + steps: + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 + with: + persist-credentials: false + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 + with: + name: frontend-candidate-${{ github.run_id }} + path: output + - name: Publish tested artifact and durable release reports + env: + GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GHCR_USER: ${{ github.actor }} + EXPECTED_DIGEST: ${{ needs.build.outputs.digest }} + IMAGE: ${{ needs.build.outputs.image }} + TAG: ${{ needs.build.outputs.tag }} + run: | + cp output/evidence/inputs.json ci/release/image/inputs.json + python3 ci/release/verify_record.py + bash ci/release/publish.sh + python3 ci/release/publish_report.py diff --git a/ci/release/.gitignore b/ci/release/.gitignore new file mode 100644 index 00000000000..47102321496 --- /dev/null +++ b/ci/release/.gitignore @@ -0,0 +1,2 @@ +__pycache__/ +image/inputs.json diff --git a/ci/release/README.md b/ci/release/README.md new file mode 100644 index 00000000000..1f12f6849cc --- /dev/null +++ b/ci/release/README.md @@ -0,0 +1,91 @@ +# CLARIN frontend releases + +The CLARIN workflow validates PRs to `clarin-v7` without registry/deployment +credentials. A mainline push builds one OCI artifact, verifies source identity, +provenance and SBOM, scans the image and dependency locks, and qualifies that exact +runtime image with disposable HTTPS fixtures. Publication copies that artifact +without rebuilding, verifies the registry digest, then creates a GitHub release +`sha-FULL_COMMIT` with small JSON reports. No server deployment runs in CI. + +`image/toolchain.json` owns pinned Node/Yarn/PM2, APK, Buildx/BuildKit, scanner and +publisher versions. Source revision and package/lock hashes are derived from the +checked-out commit; `image/inputs.json` is generated. The source context is a Git +archive without submodule contents. Frozen dependency installation and persistent +BuildKit `gha` cache retain dependency layers; PRs only read the trusted cache. +A PR build and a mainline build validate different commits. Warm-cache speed is +not established until real runs measure it. + +## Activation and retries + +The existing GHCR package is `ghcr.io/lumii-ailab/dspace-angular`. Before enabling +publication, review its linked repository, private visibility, deployment reader +access and Actions access for `LUMII-AILab/dspace-angular`. Grant the app repository +write access through the package's **Manage Actions access**, preserving the existing +package/reader. Do not delete/recreate the package or change visibility. +Then set repository variable `CLARIN_RELEASE_PUBLISH_ENABLED=true`. The one-time +switch is separate from the automatic per-merge flow. The current CLI cannot inspect +package permissions (missing `read:packages`); this review/activation remains pending. +See [GitHub package access](https://docs.github.com/en/packages/learn-github-packages/configuring-a-packages-access-control-and-visibility). + +Merge/push and workflow execution require their own requested publication scope. +Verify a real PR run and a real mainline release before claiming the automation is +operational. The retired ops publisher must not be used for new releases. The +existing Latvian publication remains preserved and its target rollout paused. + +If publication fails, use **Re-run failed jobs**, retaining the successful build's +`frontend-candidate-RUN_ID` artifact (30 days). The publisher rechecks its digest, +source, reports and runtime identity. Do not rerun all jobs merely to retry a push: +that recompiles and may produce a different digest. An existing image tag cannot +be moved by this publisher. A full rebuild of the same source needs a deliberate +new source commit/version; the stable release tag must keep its original digest. +Manual dispatch is available for an intentional unreleased commit or recovery. + +Report uploads use a draft release and verify every existing asset before publishing. +An interrupted draft can resume; existing different assets are never overwritten. +The GitHub release retains small reports beyond CI archive retention. Ops consumes +`release.json` from the trusted successful mainline workflow, selects the exact +recorded digest, and validates its source/config identity after the target pull. +This is repository/workflow trust, not signature verification. Reports cannot +replace the registry image or a recovery backup. + +## Compatibility and security scope + +Ops is private. `compatibility/manifest.json` identifies the immutable ops revision +and SHA-256 of the four public frontend/proxy templates plus public paths vendored +here. `compatibility/tests/render.yml` renders only these synthetic fixtures; it +contains no target inventory, credential or private configuration. This avoids +private repository credentials in app PR jobs. Update the compatibility revision, +fixture hashes and ops release validator together when the contract changes. + +The HTTPS suite covers mock-backend routing, public configuration sanitization, +forwarding/header rejection, DNS/TLS and restart behavior. It does not establish +integrated DSpace content, authenticated access, browser Anubis behavior or +production acceptance. Ops adds bounded deployment probes and configured synthetic +file fixtures; usability changes still need owner acceptance. + +`scan-policy.json` versions the existing **report-only synthetic** policy. Scanner +errors fail the build; findings remain visible in both retained Trivy reports. +No production security acceptance or vulnerability exception is inferred. An +owner-reviewed baseline and exceptions with owner, scope and expiry must precede +a future "new findings" gate; this change does not invent a baseline decision. + +Local offline checks: + +```sh +python3 -m unittest discover -s ci/release -p test_release.py +bash -n ci/release/scan.sh ci/release/publish.sh +``` + +The complete artifact test runs in CI. To exercise the disposable harness locally, +use an already-loaded exact config digest with `--frontend`, its source label with +`--source`, and `CLARIN_COMPAT_ROOT=$PWD/ci/release/compatibility`. No implicit pull +or rebuild is performed by the harness. CI explicitly pulls only the pinned proxy +and loads the verified runtime from its OCI archive. + +Inherited upstream workflows are preserved byte-for-byte in +`.github/disabled-workflows/upstream/`, including the old customer dispatch, +DockerHub tagging, deployment and triage jobs. They are inactive in this fork. +This also removes obsolete CodeQL actions, an empty workflow and a missing local +reusable deployment workflow from active Actions configuration without upgrading +upstream tooling. CLARIN's focused release workflow is the fork's PR/mainline entry +point; it does not claim to run the upstream full Cypress/backend test matrix. diff --git a/ci/release/compatibility/ansible/roles/clarin_dspace/templates/config.prod.yml.j2 b/ci/release/compatibility/ansible/roles/clarin_dspace/templates/config.prod.yml.j2 new file mode 100644 index 00000000000..9c27d567584 --- /dev/null +++ b/ci/release/compatibility/ansible/roles/clarin_dspace/templates/config.prod.yml.j2 @@ -0,0 +1,20 @@ +# Ansible-managed rehearsal configuration; contains no credentials. +ui: + ssl: true + host: {{ clarin_public_host | default('repository.clarin.test') }} + bindAddress: 0.0.0.0 + useProxies: true + port: {{ clarin_public_port | default(443) }} + nameSpace: {{ clarin_ui_prefix }}/ +rest: + ssl: true + host: {{ clarin_public_host | default('repository.clarin.test') }} + port: {{ clarin_public_port | default(443) }} + nameSpace: {{ clarin_rest_prefix }} + ssrBaseUrl: http://dspace:8080/repository/server +universal: + replaceRestUrl: true + transferState: false +matomo: + hostUrl: '' + siteId: 0 diff --git a/ci/release/compatibility/ansible/roles/clarin_dspace/templates/dspace-ui.json.j2 b/ci/release/compatibility/ansible/roles/clarin_dspace/templates/dspace-ui.json.j2 new file mode 100644 index 00000000000..6c6bbc526cb --- /dev/null +++ b/ci/release/compatibility/ansible/roles/clarin_dspace/templates/dspace-ui.json.j2 @@ -0,0 +1,14 @@ +{ + "apps": [{ + "name": "dspace-ui", + "cwd": "/app", + "script": "/app/config/http-launcher.cjs", + "instances": 1, + "exec_mode": "fork", + "node_args": "--max-old-space-size=1024", + "max_memory_restart": "1500M", + "time": true, + "kill_timeout": 25000, + "env": {"NODE_ENV": "production"} + }] +} diff --git a/ci/release/compatibility/ansible/roles/clarin_dspace/templates/http-launcher.cjs.j2 b/ci/release/compatibility/ansible/roles/clarin_dspace/templates/http-launcher.cjs.j2 new file mode 100644 index 00000000000..4733ad6e861 --- /dev/null +++ b/ci/release/compatibility/ansible/roles/clarin_dspace/templates/http-launcher.cjs.j2 @@ -0,0 +1,22 @@ +// Public HTTPS is terminated by Nginx; this listener stays on the private network. +'use strict'; +const { app } = require('/app/dist/server/main.js'); +const server = app().listen(4000, '0.0.0.0'); +const sockets = new Set(); +server.on('connection', socket => { + sockets.add(socket); + socket.on('close', () => sockets.delete(socket)); +}); +let stopping = false; +function shutdown() { + if (stopping) return; + stopping = true; + server.close(() => process.exit(0)); + if (server.closeIdleConnections) server.closeIdleConnections(); + setTimeout(() => { + for (const socket of sockets) socket.destroy(); + process.exit(0); + }, 20000).unref(); +} +process.on('SIGINT', shutdown); +process.on('SIGTERM', shutdown); diff --git a/ci/release/compatibility/ansible/roles/clarin_dspace/templates/nginx.conf.j2 b/ci/release/compatibility/ansible/roles/clarin_dspace/templates/nginx.conf.j2 new file mode 100644 index 00000000000..6c898c90360 --- /dev/null +++ b/ci/release/compatibility/ansible/roles/clarin_dspace/templates/nginx.conf.j2 @@ -0,0 +1,209 @@ +# Rehearsal HTTPS ingress. No Docker socket, caching, or content mounts. +worker_processes 1; +pid /tmp/nginx.pid; +error_log /dev/stderr warn; + +events { worker_connections 1024; } + +http { + # Omit URLs, query strings, cookies, and authorization from access logs. + log_format minimal '$time_iso8601 $request_method $status $body_bytes_sent $request_time'; + access_log /dev/stdout minimal; + server_tokens off; + resolver 127.0.0.11 valid=5s ipv6=off; + resolver_timeout 5s; + + upstream frontend { + zone frontend 64k; + server dspace-angular:4000 resolve; + keepalive 16; + } + upstream backend { + zone backend 64k; + server dspace:8080 resolve; + keepalive 16; + } + +{% if clarin_dspace_anubis_enabled | default(false) | bool %} + upstream anubis { + zone anubis 64k; + server anubis:8923 resolve; + keepalive 8; + } +{% endif %} + + # Stream transfers; do not spool repository content to the proxy filesystem. + proxy_http_version 1.1; +{% if clarin_development | default(false) | bool %} + map $http_upgrade $connection_upgrade { + default upgrade; + "" close; + } + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; +{% else %} + proxy_set_header Connection ""; +{% endif %} + proxy_set_header Host {{ clarin_public_authority | default('repository.clarin.test') }}; + # Do not propagate client-supplied identity/proxy headers. + proxy_set_header Forwarded ""; + proxy_set_header X-Forwarded-For ""; + proxy_set_header X-Forwarded-Host {{ clarin_public_authority | default('repository.clarin.test') }}; + proxy_set_header X-Forwarded-Prefix ""; + proxy_set_header X-Forwarded-Proto https; + proxy_set_header X-Forwarded-Port {{ clarin_public_port | default(443) }}; + proxy_set_header X-Real-IP ""; + proxy_set_header Remote-User ""; + proxy_set_header Shib-Session-ID ""; + proxy_set_header Eppn ""; + proxy_set_header Mail ""; + proxy_set_header Uid ""; + proxy_request_buffering off; + proxy_buffering off; + proxy_cache off; + proxy_max_temp_file_size 0; + proxy_connect_timeout 5s; + proxy_read_timeout 300s; + proxy_send_timeout 300s; + proxy_next_upstream off; + client_max_body_size 0; + client_body_timeout 300s; + send_timeout 300s; + client_body_temp_path /tmp/client_body; + proxy_temp_path /tmp/proxy; + fastcgi_temp_path /tmp/fastcgi; + uwsgi_temp_path /tmp/uwsgi; + scgi_temp_path /tmp/scgi; + + # Ignore unknown hosts and reject client-supplied identity headers. + map $http_host $known_host { + default 0; + {{ clarin_public_host | default('repository.clarin.test') }} 1; + {{ clarin_public_host | default('repository.clarin.test') }}:80 1; + {{ clarin_public_host | default('repository.clarin.test') }}:{{ clarin_public_port | default(443) }} 1; + } + map "$http_remote_user$http_shib_session_id$http_eppn$http_mail$http_uid" $identity_spoof { + default 1; + "" 0; + } + server { + listen 8080 default_server; + server_name {{ clarin_public_host | default('repository.clarin.test') }}; + if ($known_host = 0) { return 444; } + return 308 {{ clarin_public_origin | default('https://repository.clarin.test') }}$request_uri; + } + server { + listen {{ clarin_public_port | default(443) }} ssl default_server; + server_name {{ clarin_public_host | default('repository.clarin.test') }}; + ssl_certificate /etc/nginx/tls.crt; + ssl_certificate_key /etc/nginx/tls.key; + ssl_protocols TLSv1.2 TLSv1.3; + if ($known_host = 0) { return 444; } + if ($identity_spoof = 1) { return 403; } +{% if clarin_dspace_anubis_enabled | default(false) | bool %} + # Tomcat path parameters must not bypass the normalized discovery match. + if ($uri ~* "^{{ clarin_rest_prefix }}(?:/.*)?;") { return 400; } + location = /_anubis_check { + internal; + proxy_pass http://anubis/.within.website/x/cmd/anubis/api/check; + proxy_pass_request_headers off; + proxy_pass_request_body off; + proxy_set_header Content-Length ""; + proxy_set_header Host {{ clarin_public_authority | default('repository.clarin.test') }}; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Proto https; + proxy_set_header Cookie $http_cookie; + proxy_set_header User-Agent $http_user_agent; + proxy_set_header Accept-Language $http_accept_language; + proxy_set_header Accept-Encoding $http_accept_encoding; + proxy_connect_timeout 2s; + proxy_read_timeout 10s; + } + location ^~ /.within.website/ { + proxy_pass http://anubis; + proxy_pass_request_headers off; + proxy_pass_request_body off; + proxy_set_header Content-Length ""; + proxy_set_header Host {{ clarin_public_authority | default('repository.clarin.test') }}; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Proto https; + proxy_set_header Cookie $http_cookie; + proxy_set_header User-Agent $http_user_agent; + proxy_set_header Accept-Language $http_accept_language; + proxy_set_header Accept-Encoding $http_accept_encoding; + proxy_connect_timeout 2s; + proxy_read_timeout 10s; + } + location @anubis_challenge { + proxy_pass http://anubis; + proxy_pass_request_headers off; + proxy_pass_request_body off; + proxy_set_header Content-Length ""; + proxy_set_header Host {{ clarin_public_authority | default('repository.clarin.test') }}; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Proto https; + proxy_set_header Cookie $http_cookie; + proxy_set_header User-Agent $http_user_agent; + proxy_set_header Accept-Language $http_accept_language; + proxy_set_header Accept-Encoding $http_accept_encoding; + proxy_connect_timeout 2s; + proxy_read_timeout 10s; + } + location @anubis_api_required { + default_type application/json; + add_header Cache-Control no-store always; + return 403 '{"error":"Browser verification required. Reload the repository page and retry."}'; + } + location ~* ^{{ clarin_rest_prefix }}/api/(discover|browse)(/|$) { + auth_request /_anubis_check; + error_page 401 = @anubis_api_required; + proxy_pass http://backend; + } +{% endif %} + # Explicit browser-only compatibility routes; never replay legacy writes. + location = / { + if ($request_method !~ ^(GET|HEAD)$) { return 405; } + return 308 {{ clarin_public_origin | default('https://repository.clarin.test') }}{{ clarin_ui_prefix }}/$is_args$args; + } + location = {{ clarin_ui_prefix }} { + if ($request_method !~ ^(GET|HEAD)$) { return 405; } + return 308 {{ clarin_public_origin | default('https://repository.clarin.test') }}{{ clarin_ui_prefix }}/$is_args$args; + } + location ~ ^{{ clarin_ui_prefix }}/xmlui/?$ { + if ($request_method !~ ^(GET|HEAD)$) { return 405; } + return 308 {{ clarin_public_origin | default('https://repository.clarin.test') }}{{ clarin_ui_prefix }}/$is_args$args; + } + location = {{ clarin_ui_prefix }}/xmlui/login { + if ($request_method !~ ^(GET|HEAD)$) { return 405; } + return 308 {{ clarin_public_origin | default('https://repository.clarin.test') }}{{ clarin_ui_prefix }}/login$is_args$args; + } + location ~ ^{{ clarin_ui_prefix }}/xmlui/handle/(?[A-Za-z0-9._~-]+/[A-Za-z0-9._~/-]+)$ { + if ($request_method !~ ^(GET|HEAD)$) { return 405; } + return 308 {{ clarin_public_origin | default('https://repository.clarin.test') }}{{ clarin_ui_prefix }}/handle/$legacy_handle$is_args$args; + } + location {{ clarin_ui_prefix }}/xmlui/ { return 404; } + location = {{ clarin_rest_prefix }} { + proxy_pass http://backend; + } + location {{ clarin_rest_prefix }}/ { + proxy_pass http://backend; + } + location {{ clarin_ui_prefix }}/ { +{% if clarin_dspace_anubis_enabled | default(false) | bool %} + auth_request /_anubis_check; + error_page 401 = @anubis_challenge; +{% endif %} + proxy_pass http://frontend; + } + location / { return 404; } + } + server { + listen 127.0.0.1:8081; + access_log off; + location = /healthz { return 200 'ok\n'; } + location / { return 404; } + } +} diff --git a/ci/release/compatibility/ansible/vars/public-paths.yml b/ci/release/compatibility/ansible/vars/public-paths.yml new file mode 100644 index 00000000000..f7db2835f3f --- /dev/null +++ b/ci/release/compatibility/ansible/vars/public-paths.yml @@ -0,0 +1,4 @@ +--- +# Shared public paths; REST uses the same context internally and externally. +clarin_ui_prefix: /repository +clarin_rest_prefix: "{{ clarin_ui_prefix }}/server" diff --git a/ci/release/compatibility/manifest.json b/ci/release/compatibility/manifest.json new file mode 100644 index 00000000000..f70fdb4d5ee --- /dev/null +++ b/ci/release/compatibility/manifest.json @@ -0,0 +1,11 @@ +{ + "repository": "LUMII-AILab/clarin-dspace-ops", + "revision": "8a250e4e577d9704eac6e813448b0a0106aae396", + "files": { + "ansible/roles/clarin_dspace/templates/nginx.conf.j2": "1c853ab8e21d2ba388f109fed8b177ebc69b56f9b0827e584bae183eabc92ee7", + "ansible/roles/clarin_dspace/templates/config.prod.yml.j2": "0e9937f2bde94c8c4b5224738ca7c4783b809e7812b68eb778bdc6037ebceb23", + "ansible/roles/clarin_dspace/templates/dspace-ui.json.j2": "7498eb3affd1d5a41785f70acda036a8f44fc83adc17933ba8794f4c0d51f67c", + "ansible/roles/clarin_dspace/templates/http-launcher.cjs.j2": "5c473f3e23fbca32909125405062403b377e7ffe9f2886f092755a653799742a", + "ansible/vars/public-paths.yml": "90adeaf1e3003b1b555dead3c3d7a1d64faf2f1f324c0974d65a4c1cb76d6565" + } +} diff --git a/ci/release/compatibility/tests/render.yml b/ci/release/compatibility/tests/render.yml new file mode 100644 index 00000000000..4fc5cab2e64 --- /dev/null +++ b/ci/release/compatibility/tests/render.yml @@ -0,0 +1,33 @@ +--- +# Synthetic fixture rendering only; no server roles, inventories or private inputs. +- name: Render pinned frontend and proxy compatibility templates + hosts: localhost + connection: local + gather_facts: false + vars: + clarin_dspace_anubis_enabled: false + clarin_public_host: repository.clarin.test + clarin_public_port: 443 + fixture_root: "{{ lookup('env', 'CLARIN_TEST_ROOT') }}" + vars_files: + - ../ansible/vars/public-paths.yml + tasks: + - name: Require disposable test location + ansible.builtin.assert: + that: fixture_root is match('^/tmp/clarin-test-[A-Za-z0-9_-]+$') + - name: Create fixture configuration directories + ansible.builtin.file: + path: '{{ fixture_root }}/config/{{ item }}' + state: directory + mode: '0755' + loop: [frontend, proxy] + - name: Render reviewed templates with synthetic public configuration + ansible.builtin.template: + src: '../ansible/roles/clarin_dspace/templates/{{ item.src }}.j2' + dest: '{{ fixture_root }}/config/{{ item.dest }}' + mode: '0644' + loop: + - {src: nginx.conf, dest: proxy/nginx.conf} + - {src: config.prod.yml, dest: frontend/config.prod.yml} + - {src: dspace-ui.json, dest: frontend/dspace-ui.json} + - {src: http-launcher.cjs, dest: frontend/http-launcher.cjs} diff --git a/ci/release/frontend_image.py b/ci/release/frontend_image.py new file mode 100644 index 00000000000..e30069fa76f --- /dev/null +++ b/ci/release/frontend_image.py @@ -0,0 +1,252 @@ +#!/usr/bin/env python3 +"""Offline recipe checks and OCI evidence validation. Never builds or publishes.""" + +import argparse +import hashlib +import json +import os +from pathlib import Path +import re +import subprocess +import tarfile +import tempfile + +ROOT = Path(__file__).resolve().parents[2] +RECIPE = ROOT / "ci/release/image" +SHA = re.compile(r"[0-9a-f]{64}") +DIGEST = re.compile(r"sha256:[0-9a-f]{64}") + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def inputs(): + data = json.loads((RECIPE / "toolchain.json").read_text()) + data["source_revision"] = subprocess.check_output( + ["git", "rev-parse", "HEAD"], cwd=ROOT, text=True).strip() + for name, key in (("package.json", "source_package_sha256"), + ("yarn.lock", "source_lock_sha256"), + ("Dockerfile.dist", "upstream_dockerfile_sha256")): + data[key] = hashlib.sha256((ROOT / name).read_bytes()).hexdigest() + return data + + +def check_manifest(data): + require(data["source_repository"] == "https://github.com/LUMII-AILab/dspace-angular.git", + "Unexpected source repository") + require(data["image"] == "ghcr.io/lumii-ailab/dspace-angular", "Unexpected image destination") + require(data["platform"] == "linux/amd64", "Only amd64 is qualified") + for key in ("source_revision", "source_baseline"): + require(re.fullmatch(r"[0-9a-f]{40}", data[key]), f"Unpinned {key}") + for key in ("node_image", "buildkit_image", "sbom_generator", "skopeo_image"): + require(re.fullmatch(r"[a-z0-9./-]+@sha256:[0-9a-f]{64}", data[key]), + f"Unpinned {key}") + for key in ("source_package_sha256", "source_lock_sha256", "upstream_dockerfile_sha256", + "trivy_sha256"): + require(SHA.fullmatch(data[key]), f"Invalid {key}") + require(DIGEST.fullmatch(data["node_amd64_manifest"]), "Invalid Node manifest") + require(data["node_version"] == "18.20.8" and data["yarn_version"] == "1.22.22" + and data["pm2_version"] == "7.0.3", "Unreviewed runtime/tool version change") + require(re.fullmatch(r"v\d+\.\d+\.\d+", data["buildx_version"]), "Unpinned Buildx") + require(re.fullmatch(r"https://github.com/aquasecurity/trivy/releases/download/v[0-9.]+/" + r"trivy_[0-9.]+_Linux-64bit.tar.gz", data["trivy_url"]), + "Unexpected scanner download") + packages = data["apk_packages"].split() + require(len(packages) == 3 and all(re.fullmatch(r"[a-z0-9+]+=[0-9.]+-r\d+", p) + for p in packages), "Unpinned APK tools") + require({p.split("=")[0] for p in packages} == {"python3", "make", "g++"}, + "Unexpected APK tools") + require(all(isinstance(v, str) and "\n" not in v and "\r" not in v for v in data.values()), + "Inputs must be single-line strings") + + +def check_pm2(package, lock, version): + require(package["dependencies"] == {"pm2": version}, "Unexpected PM2 dependency") + require(lock["lockfileVersion"] == 3, "Require npm lockfile v3") + require(lock["packages"][""]["dependencies"] == package["dependencies"], + "PM2 package/lock mismatch") + require(lock["packages"]["node_modules/pm2"]["version"] == version, "PM2 lock mismatch") + for name, entry in lock["packages"].items(): + if name: + require(entry.get("resolved", "").startswith("https://registry.npmjs.org/"), + f"Non-registry PM2 dependency: {name}") + require(entry.get("integrity", "").startswith("sha512-"), + f"Missing PM2 integrity: {name}") + + +def check_recipe(): + data = inputs() + check_manifest(data) + check_pm2(json.loads((RECIPE / "pm2/package.json").read_text()), + json.loads((RECIPE / "pm2/package-lock.json").read_text()), data["pm2_version"]) + workflow = (ROOT / ".github/workflows/clarin-release.yml").read_text() + actions = re.findall(r"uses: ([^\s]+)", workflow) + require(all(re.fullmatch(r"[\w-]+/[\w-]+@[0-9a-f]{40}", a) for a in actions), + "Actions must be pinned") + require("cache-from: type=gha" in workflow and "cache-to:" in workflow, + "Persistent cache required") + + +def workflow_outputs(): + check_recipe() + data = inputs() + data["tag"] = "sha-" + data["source_revision"] + (RECIPE / "inputs.json").write_text(json.dumps(data, indent=2) + "\n") + for key, value in data.items(): + print(f"{key}={value}") + + +def export_source(repository, revision, destination, evidence, data): + """Export a verified commit, never a checkout or its submodule contents.""" + require(re.fullmatch(r"[0-9a-f]{40}", revision), "Unpinned source revision") + git = ["git", "-C", str(repository)] + actual = subprocess.check_output(git + ["rev-parse", f"{revision}^{{commit}}"], + text=True).strip() + require(actual == data["source_revision"], "Fetched source revision mismatch") + tree = subprocess.check_output(git + ["rev-parse", f"{revision}^{{tree}}"], + text=True).strip() + entries = subprocess.check_output(git + ["ls-tree", "-rz", revision]).split(b"\0") + submodules = [entry.split(b"\t", 1)[1].decode() for entry in entries + if entry.startswith(b"160000 ")] + require(submodules == [".dspace-skills"], "Unreviewed source submodules") + # No overwrite/reuse of a potentially contaminated existing context. + destination.mkdir(parents=True, exist_ok=False) + with tempfile.TemporaryFile() as archive: + subprocess.run(git + ["archive", "--format=tar", revision], stdout=archive, check=True) + archive.seek(0) + archive_sha = hashlib.file_digest(archive, "sha256").hexdigest() + archive.seek(0) + with tarfile.open(fileobj=archive) as bundle: + bundle.extractall(destination, filter="data") + require(not (destination / ".git").exists(), "Git metadata in source export") + for path in submodules: + entry = destination / path + require(not entry.exists() or (entry.is_dir() and not any(entry.iterdir())), + "Submodule contents in source export") + for name, key in (("package.json", "source_package_sha256"), + ("yarn.lock", "source_lock_sha256"), + ("Dockerfile.dist", "upstream_dockerfile_sha256")): + require(hashlib.sha256((destination / name).read_bytes()).hexdigest() == data[key], + f"Source hash mismatch: {name}") + evidence.mkdir(parents=True, exist_ok=True) + result = {"source_repository": data["source_repository"], "source_revision": actual, + "source_tree": tree, "archive_sha256": archive_sha, + "excluded_submodules": submodules} + (evidence / "source-export.json").write_text(json.dumps(result, indent=2) + "\n") + + +def prepare_source(destination, evidence): + """Fetch only the public superproject; no recursive fetch or private credentials.""" + data = inputs() + check_manifest(data) + export_source(ROOT, data["source_revision"], destination, evidence, data) + print(f"context={destination.resolve()}") + + +def inspect_archive(archive, expected_digest, evidence): + """Verify reachable OCI blobs without extracting filesystem layers or executing code.""" + require(DIGEST.fullmatch(expected_digest), "Invalid expected digest") + statements = [] + runtime = [] + visited = set() + with tarfile.open(archive, "r:*") as bundle: + members = {} + for member in bundle.getmembers(): + name = member.name.removeprefix("./") + require(not member.issym() and not member.islnk(), "Archive links forbidden") + require(member.isfile() or member.isdir(), "Archive special files forbidden") + require(not name.startswith("/") and ".." not in Path(name).parts, + "Unsafe archive member") + if member.isfile(): + require(name in ("index.json", "oci-layout") or + re.fullmatch(r"blobs/sha256/[0-9a-f]{64}", name), + "Unexpected archive file") + require(name not in members, "Duplicate archive member") + members[name] = member + + def read_json(name): + member = members[name] + require(member.size < 20 * 1024 * 1024, "Oversized OCI metadata") + return json.load(bundle.extractfile(member)) + + def visit(descriptor): + digest = descriptor["digest"] + require(DIGEST.fullmatch(digest), "Unsupported blob digest") + if digest in visited: + return + visited.add(digest) + name = "blobs/sha256/" + digest.split(":")[1] + member = members[name] + require(member.size == descriptor["size"], "Blob size mismatch") + with bundle.extractfile(member) as stream: + require(hashlib.file_digest(stream, "sha256").hexdigest() == digest.split(":")[1], + "Blob digest mismatch") + media = descriptor["mediaType"] + if media.endswith("image.index.v1+json"): + for child in read_json(name)["manifests"]: + visit(child) + elif media.endswith("image.manifest.v1+json"): + manifest = read_json(name) + visit(manifest["config"]) + config = read_json("blobs/sha256/" + manifest["config"]["digest"].split(":")[1]) + if config.get("architecture") == "amd64" and config.get("os") == "linux": + runtime.append((digest, manifest["config"]["digest"], config)) + for layer in manifest["layers"]: + visit(layer) + elif media == "application/vnd.in-toto+json": + statements.append(read_json(name)) + + index = read_json("index.json") + require(len(index["manifests"]) == 1, "Expected one exported image/index") + require(index["manifests"][0]["digest"] == expected_digest, "Build/export digest mismatch") + visit(index["manifests"][0]) + require(len(runtime) == 1, "Expected one Linux amd64 runtime image") + runtime_digest, config_digest, config = runtime[0] + require(config["config"]["User"] == "1000:1000", "Wrong runtime user") + require(config["config"]["Labels"]["org.opencontainers.image.revision"] == + inputs()["source_revision"], "Wrong frontend source label") + bound = [s for s in statements if any( + sub.get("digest", {}).get("sha256") == runtime_digest.split(":")[1] + for sub in s.get("subject", []))] + require(any(s.get("predicateType", "").startswith("https://slsa.dev/provenance/") + for s in bound), "Missing image-bound provenance") + require(any(s.get("predicateType") == "https://spdx.dev/Document" for s in bound), + "Missing image-bound SPDX SBOM") + evidence.mkdir(parents=True, exist_ok=True) + for number, statement in enumerate(bound): + (evidence / f"attestation-{number}.json").write_text(json.dumps(statement, indent=2) + "\n") + result = {"index_digest": expected_digest, "amd64_manifest_digest": runtime_digest, + "source_revision": inputs()["source_revision"], "config_digest": config_digest, + "verified_blobs": len(visited)} + (evidence / "identity.json").write_text(json.dumps(result, indent=2) + "\n") + return result + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + sub = parser.add_subparsers(dest="command", required=True) + sub.add_parser("check") + sub.add_parser("outputs") + source = sub.add_parser("prepare-source") + source.add_argument("destination", type=Path) + source.add_argument("evidence", type=Path) + inspect = sub.add_parser("inspect") + inspect.add_argument("archive", type=Path) + inspect.add_argument("digest") + inspect.add_argument("evidence", type=Path) + args = parser.parse_args() + if args.command == "check": + check_recipe() + print("Frontend recipe, locks and workflow policy passed (no build).") + elif args.command == "outputs": + workflow_outputs() + elif args.command == "prepare-source": + prepare_source(args.destination, args.evidence) + else: + print(json.dumps(inspect_archive(args.archive, args.digest, args.evidence))) + + +if __name__ == "__main__": + main() diff --git a/ci/release/image/.dockerignore b/ci/release/image/.dockerignore new file mode 100644 index 00000000000..076f15b707f --- /dev/null +++ b/ci/release/image/.dockerignore @@ -0,0 +1,7 @@ +** +!Dockerfile +!inputs.json +!dspace-ui.json +!pm2/ +!pm2/package.json +!pm2/package-lock.json diff --git a/ci/release/image/Dockerfile b/ci/release/image/Dockerfile new file mode 100644 index 00000000000..8acd1a6693e --- /dev/null +++ b/ci/release/image/Dockerfile @@ -0,0 +1,57 @@ +# Adapted from the pinned frontend Dockerfile.dist; inputs have no moving defaults. +# The frontend named context is a verified Git archive of the full reviewed SHA, +# prepared without submodules by scripts/frontend_image.py prepare-source. +ARG NODE_IMAGE +FROM ${NODE_IMAGE} AS build +ARG APK_PACKAGES +ARG NODE_VERSION +ARG YARN_VERSION +ARG SOURCE_PACKAGE_SHA256 +ARG SOURCE_LOCK_SHA256 +ARG UPSTREAM_DOCKERFILE_SHA256 +ARG BUILDKIT_SBOM_SCAN_STAGE=true +RUN test "$(node --version)" = "v${NODE_VERSION}" \ + && test "$(yarn --version)" = "${YARN_VERSION}" \ + && apk add --no-cache ${APK_PACKAGES} +WORKDIR /app +COPY --from=frontend /package.json /yarn.lock /Dockerfile.dist ./ +RUN printf '%s %s\n' "${SOURCE_PACKAGE_SHA256}" package.json \ + "${SOURCE_LOCK_SHA256}" yarn.lock \ + "${UPSTREAM_DOCKERFILE_SHA256}" Dockerfile.dist | sha256sum -c - \ + && yarn install --frozen-lockfile --non-interactive --network-timeout 300000 +COPY --from=frontend / /app/ +ENV NODE_OPTIONS=--max-old-space-size=4096 +RUN yarn test:server-config && yarn build:prod \ + && printf '%s %s\n' "${SOURCE_LOCK_SHA256}" yarn.lock | sha256sum -c - +RUN mkdir /build-evidence \ + && apk info -v | sort > /build-evidence/apk-packages.txt \ + && node --version > /build-evidence/node-version.txt \ + && yarn --version > /build-evidence/yarn-version.txt + +ARG NODE_IMAGE +FROM ${NODE_IMAGE} AS process-manager +WORKDIR /opt/pm2 +COPY pm2/package.json pm2/package-lock.json ./ +RUN npm ci --omit=dev --ignore-scripts --no-audit --no-fund + +ARG NODE_IMAGE +FROM ${NODE_IMAGE} AS runtime +ARG SOURCE_REVISION +ARG OPS_REVISION +LABEL org.opencontainers.image.source="https://github.com/LUMII-AILab/dspace-angular" \ + org.opencontainers.image.revision="${SOURCE_REVISION}" \ + org.opencontainers.image.title="CLARIN DSpace frontend release" \ + lv.clarin.frontend.source="https://github.com/LUMII-AILab/dspace-angular" \ + lv.clarin.ops.revision="${OPS_REVISION}" +COPY --from=process-manager /opt/pm2 /opt/pm2 +RUN ln -s /opt/pm2/node_modules/.bin/pm2-runtime /usr/local/bin/pm2-runtime +COPY --chown=1000:1000 --from=build /app/dist /app/dist +COPY --chown=1000:1000 --from=frontend /config/config.yml /app/config/config.yml +COPY --chown=1000:1000 dspace-ui.json /app/dspace-ui.json +COPY --from=build /build-evidence /usr/share/clarin-build +COPY inputs.json /usr/share/clarin-build/inputs.json +WORKDIR /app +USER 1000:1000 +ENV NODE_ENV=production +EXPOSE 4000 +CMD ["pm2-runtime", "start", "/app/dspace-ui.json", "--json"] diff --git a/ci/release/image/dspace-ui.json b/ci/release/image/dspace-ui.json new file mode 100644 index 00000000000..fb358014d80 --- /dev/null +++ b/ci/release/image/dspace-ui.json @@ -0,0 +1,13 @@ +{ + "apps": [{ + "name": "dspace-ui", + "cwd": "/app", + "script": "dist/server/main.js", + "instances": 1, + "exec_mode": "fork", + "node_args": "--max-old-space-size=1024", + "max_memory_restart": "1500M", + "time": true, + "env": {"NODE_ENV": "production"} + }] +} diff --git a/ci/release/image/pm2/package.json b/ci/release/image/pm2/package.json new file mode 100644 index 00000000000..161117caa81 --- /dev/null +++ b/ci/release/image/pm2/package.json @@ -0,0 +1,6 @@ +{ + "name": "clarin-frontend-process-manager", + "version": "1.0.0", + "private": true, + "dependencies": {"pm2": "7.0.3"} +} diff --git a/ci/release/image/toolchain.json b/ci/release/image/toolchain.json new file mode 100644 index 00000000000..cdddbc6f53e --- /dev/null +++ b/ci/release/image/toolchain.json @@ -0,0 +1,19 @@ +{ + "source_repository": "https://github.com/LUMII-AILab/dspace-angular.git", + "source_baseline": "d4868c36a89430f68a84a0b8a98fe67b5b9edd36", + "platform": "linux/amd64", + "image": "ghcr.io/lumii-ailab/dspace-angular", + "node_image": "docker.io/library/node@sha256:8d6421d663b4c28fd3ebc498332f249011d118945588d0a35cb9bc4b8ca09d9e", + "node_amd64_manifest": "sha256:929b04d7c782f04f615cf785488fed452b6569f87c73ff666ad553a7554f0006", + "node_version": "18.20.8", + "yarn_version": "1.22.22", + "pm2_version": "7.0.3", + "apk_packages": "python3=3.12.14-r0 make=4.4.1-r2 g++=14.2.0-r4", + "buildx_version": "v0.37.0", + "buildkit_image": "moby/buildkit@sha256:ddd1ca44b21eda906e81ab14a3d467fa6c39cd73b9a39df1196210edcb8db59e", + "sbom_generator": "docker/buildkit-syft-scanner@sha256:ae4f3b554449e7e25548e7d8ccc029d17357348e30c6e3df01b92bc93654d6a9", + "skopeo_image": "quay.io/skopeo/stable@sha256:47853bb9fb24202af9110531ebd6e43c5f97701254ca290596640290d17942f4", + "trivy_url": "https://github.com/aquasecurity/trivy/releases/download/v0.74.0/trivy_0.74.0_Linux-64bit.tar.gz", + "trivy_sha256": "2ae6fe3ee734b7fdf11335663e18c75ea12dccc76062f09f164a3b0f8be4371a", + "compatibility_revision": "8a250e4e577d9704eac6e813448b0a0106aae396" +} diff --git a/ci/release/publish.sh b/ci/release/publish.sh new file mode 100644 index 00000000000..39c6e1e4186 --- /dev/null +++ b/ci/release/publish.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# Publish only the successfully qualified OCI archive; never rebuild here. +set -euo pipefail +: "${GHCR_TOKEN:?}" "${GHCR_USER:?}" "${EXPECTED_DIGEST:?}" "${IMAGE:?}" "${TAG:?}" +test "$IMAGE" = ghcr.io/lumii-ailab/dspace-angular +[[ "$TAG" =~ ^sha-[a-f0-9]{40}$ ]] +[[ "$EXPECTED_DIGEST" =~ ^sha256:[a-f0-9]{64}$ ]] +python3 ci/release/frontend_image.py inspect output/frontend.oci.tar \ + "$EXPECTED_DIGEST" output/evidence +skopeo_image=$(jq -er .skopeo_image ci/release/image/inputs.json) +auth_dir=$(mktemp -d) +trap 'rm -rf -- "$auth_dir"' EXIT +chmod 700 "$auth_dir" +# This helper never mounts the Docker socket or target configuration. +skopeo() { + local -a stdin_flags=() + if [[ "$1" == login ]]; then + stdin_flags=(-i) + fi + docker run "${stdin_flags[@]}" --rm --read-only --cap-drop ALL --security-opt no-new-privileges \ + --user "$(id -u):$(id -g)" --memory 512m --pids-limit 128 --tmpfs /tmp \ + -v "$auth_dir:/auth" -v "$PWD/output:/artifact:ro" \ + "$skopeo_image" --tmpdir /tmp "$@" +} +printf '%s' "$GHCR_TOKEN" | skopeo login --authfile /auth/auth.json \ + --username "$GHCR_USER" --password-stdin ghcr.io +unset GHCR_TOKEN +# A retry may finish an interrupted publication but must never move a release tag. +# Listing first distinguishes a missing tag from denied access/network errors. +tags=$(skopeo list-tags --authfile /auth/auth.json "docker://$IMAGE") +if jq -e --arg tag "$TAG" '.Tags | index($tag) != null' <<< "$tags" >/dev/null; then + existing=$(skopeo inspect --raw --authfile /auth/auth.json "docker://$IMAGE:$TAG" | sha256sum | cut -d ' ' -f 1) + test "sha256:$existing" = "$EXPECTED_DIGEST" +else + skopeo copy --all --preserve-digests --authfile /auth/auth.json \ + oci-archive:/artifact/frontend.oci.tar "docker://$IMAGE:$TAG" +fi +remote_digest=$(skopeo inspect --raw --authfile /auth/auth.json "docker://$IMAGE:$TAG" \ + | sha256sum | cut -d ' ' -f 1) +test "sha256:$remote_digest" = "$EXPECTED_DIGEST" diff --git a/ci/release/publish_report.py b/ci/release/publish_report.py new file mode 100644 index 00000000000..c83fe6bda6d --- /dev/null +++ b/ci/release/publish_report.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +"""Resume draft report uploads; publish only after all verified assets are present.""" +import json +import os +from pathlib import Path +import subprocess +import tempfile +from verify_record import verify + + +def command(*args): + return subprocess.check_output(['gh', *args], text=True).strip() + + +def publish(record, evidence=Path('output/evidence')): + repo, version = record['repository'], record['version'] + + def find_release(): + rows = command('api', '--paginate', f'repos/{repo}/releases', '--jq', + '.[] | [.tag_name, .id] | @tsv') + for row in rows.splitlines(): + tag, identifier = row.split('\t') + if tag == version: + return json.loads(command('api', f'repos/{repo}/releases/{int(identifier)}')) + return None + + release = find_release() + if release is None: + command('release', 'create', version, '-R', repo, '--draft', '--target', record['source'], + '--title', version, '--notes', + 'Exact-image checks passed. Synthetic rehearsal only; scan findings remain report-only.') + release = find_release() + assert release and release['tag_name'] == version + assert release['target_commitish'] == record['source'], 'Release target changed' + names = {asset['name'] for asset in release['assets']} + for path in sorted(evidence.glob('*.json')): + if path.name not in names: + # An interrupted draft is resumable; a published release is immutable here. + assert release['draft'], 'Published release is missing a required report' + command('release', 'upload', version, '-R', repo, str(path)) + with tempfile.TemporaryDirectory() as directory: + command('release', 'download', version, '-R', repo, '--pattern', path.name, '--dir', directory) + assert (Path(directory) / path.name).read_bytes() == path.read_bytes(), 'Existing report differs' + if release['draft']: + command('release', 'edit', version, '-R', repo, '--draft=false') + commit = json.loads(command('api', f'repos/{repo}/commits/{version}')) + assert commit['sha'] == record['source'], 'Published Git tag/source mismatch' + + +if __name__ == '__main__': + record = verify() + publish(record) + with open(os.environ['GITHUB_STEP_SUMMARY'], 'a') as summary: + summary.write(f"Published [{record['version']}](https://github.com/{record['repository']}/releases/tag/{record['version']}) " + f"at `{record['image']}@{record['digest']}`. No target deployment.\n") diff --git a/ci/release/record.py b/ci/release/record.py new file mode 100644 index 00000000000..6e8b327682f --- /dev/null +++ b/ci/release/record.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 +"""Create a compact digest-bound report only after all exact-artifact gates pass.""" +import hashlib +import json +import os +from pathlib import Path +from frontend_image import inputs +from release_contract import validate + +root = Path('output/evidence') +data = inputs() +identity = json.loads((root / 'identity.json').read_text()) +https = json.loads((root / 'https.json').read_text()) +assert identity['source_revision'] == data['source_revision'] +assert https['result'] == 'passed' +assert https['source_revision'] == identity['source_revision'] +assert https['frontend_config_digest'] == identity['config_digest'] +# Preserve the existing report-only synthetic policy; no new security acceptance. +policy = json.loads(Path('ci/release/scan-policy.json').read_text()) +assert policy['id'] == 'synthetic-report-v1' and policy['findings'] == 'report-only' +assert policy['scanner_errors'] == 'fail' and policy['production_accepted'] is False +assert policy['exceptions'] == [] +reports = {} +for name in ('vulnerabilities.json', 'dependency-vulnerabilities.json'): + path = root / name + report = json.loads(path.read_text()) + assert report.get('SchemaVersion') == 2 and 'Results' in report + reports[name] = hashlib.sha256(path.read_bytes()).hexdigest() +record = dict(schema=1, repository='LUMII-AILab/dspace-angular', image=data['image'], + version='sha-' + data['source_revision'], source=data['source_revision'], + digest=identity['index_digest'], config_digest=identity['config_digest'], + compatibility_revision=data['compatibility_revision'], + workflow='.github/workflows/clarin-release.yml', run_id=int(os.environ['GITHUB_RUN_ID']), + checks=dict(oci='passed', https='passed', configuration='passed'), + scan=dict(policy='synthetic-report-v1', disposition='report-only', + production_accepted=False, reports=reports)) +validate(record) +(root / 'release.json').write_text(json.dumps(record, indent=2) + '\n') +with open(os.environ['GITHUB_STEP_SUMMARY'], 'a') as summary: + summary.write(f"Frontend `{record['version']}`\n\n`{record['image']}@{record['digest']}`\n\n" + 'Configuration, OCI provenance/SBOM and exact-image HTTPS checks passed. ' + 'Scan reports retained; report-only synthetic policy, no production acceptance.\n\n' + f"After publication: `make release-select VERSION={record['version']}`.\n") diff --git a/ci/release/release_contract.py b/ci/release/release_contract.py new file mode 100644 index 00000000000..79cb8fa72bf --- /dev/null +++ b/ci/release/release_contract.py @@ -0,0 +1,33 @@ +"""Version 1 frontend release record, validated offline before any target mutation.""" +import re + +REPOSITORY = 'LUMII-AILab/dspace-angular' +IMAGE = 'ghcr.io/lumii-ailab/dspace-angular' +WORKFLOW = '.github/workflows/clarin-release.yml' +COMPATIBILITY = '8a250e4e577d9704eac6e813448b0a0106aae396' + + +def validate(record, reference=None): + def require(test, message): + if not test: + raise ValueError(message) + require(isinstance(record, dict) and record.get('schema') == 1, 'Invalid release schema') + require(record.get('repository') == REPOSITORY and record.get('image') == IMAGE, + 'Unexpected release publisher/image') + for field, pattern in [('source', r'[a-f0-9]{40}'), ('digest', r'sha256:[a-f0-9]{64}'), + ('config_digest', r'sha256:[a-f0-9]{64}')]: + require(isinstance(record.get(field), str) and re.fullmatch(pattern, record[field]), + 'Invalid release ' + field) + require(record.get('version') == 'sha-' + record['source'], 'Version/source mismatch') + require(reference is None or reference == IMAGE + '@' + record['digest'], 'Release digest mismatch') + require(record.get('compatibility_revision') == COMPATIBILITY, 'Unreviewed compatibility fixture') + require(record.get('workflow') == WORKFLOW and type(record.get('run_id')) is int + and record['run_id'] > 0, 'Invalid workflow identity') + require(record.get('checks') == {'oci': 'passed', 'https': 'passed', 'configuration': 'passed'}, + 'Release qualification incomplete') + require(isinstance(record.get('scan'), dict), 'Invalid security disposition') + require(record.get('scan', {}).get('policy') == 'synthetic-report-v1' + and record['scan'].get('disposition') == 'report-only' + and record['scan'].get('production_accepted') is False, + 'Unexpected security disposition') + return record diff --git a/ci/release/scan-policy.json b/ci/release/scan-policy.json new file mode 100644 index 00000000000..16bd3b2a73a --- /dev/null +++ b/ci/release/scan-policy.json @@ -0,0 +1,10 @@ +{ + "schema": 1, + "id": "synthetic-report-v1", + "scope": "synthetic-preparation-only", + "scanner_errors": "fail", + "findings": "report-only", + "production_accepted": false, + "baseline_status": "owner-reviewed baseline and expiring exceptions pending", + "exceptions": [] +} diff --git a/ci/release/scan.sh b/ci/release/scan.sh new file mode 100644 index 00000000000..062b71fa151 --- /dev/null +++ b/ci/release/scan.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# Invoked only by an authorized image build, never by make check. +set -euo pipefail +archive=$(realpath "${1:?OCI archive required}") +evidence=$(realpath "${2:?Evidence directory required}") +recipe=ci/release/image/inputs.json +scanner_url=$(jq -er .trivy_url "$recipe") +scanner_sha=$(jq -er .trivy_sha256 "$recipe") +scanner_dir=$(mktemp -d) +# Only remove the directory created by this invocation. +trap 'rm -rf -- "$scanner_dir"' EXIT +# The inspector rejects links, traversal and blob tampering before extraction. +expected_digest=$(jq -er .index_digest "$evidence/identity.json") +python3 ci/release/frontend_image.py inspect "$archive" "$expected_digest" "$evidence" +mkdir "$scanner_dir/oci" +tar --no-same-owner --no-same-permissions -xf "$archive" -C "$scanner_dir/oci" +# Trivy accepts OCI directories, not OCI tar files. Point the scan-only index at +# the verified runtime manifest rather than relying on attestation/index order. +runtime_digest=$(jq -er .amd64_manifest_digest "$evidence/identity.json") +runtime_size=$(stat -c %s "$scanner_dir/oci/blobs/sha256/${runtime_digest#sha256:}") +jq -n --arg digest "$runtime_digest" --argjson size "$runtime_size" \ + '{schemaVersion: 2, manifests: [{mediaType: "application/vnd.oci.image.manifest.v1+json", + digest: $digest, size: $size}]}' > "$scanner_dir/oci/index.json" +curl --fail --show-error --silent --location --retry 3 \ + --connect-timeout 20 --max-time 300 "$scanner_url" -o "$scanner_dir/trivy.tar.gz" +printf '%s %s\n' "$scanner_sha" "$scanner_dir/trivy.tar.gz" | sha256sum -c - +tar -xzf "$scanner_dir/trivy.tar.gz" -C "$scanner_dir" trivy +"$scanner_dir/trivy" version > "$evidence/trivy-version.txt" +# Fresh DB per run: vulnerability knowledge must not be frozen at recipe creation. +# Vulnerabilities are evidence, not automatic acceptance. Scanner failures still fail the job. +"$scanner_dir/trivy" image --cache-dir "$scanner_dir/cache" --timeout 15m \ + --input "$scanner_dir/oci" --scanners vuln --format json --exit-code 0 \ + --output "$evidence/vulnerabilities.json" +"$scanner_dir/trivy" version --cache-dir "$scanner_dir/cache" \ + --format json > "$evidence/trivy-database.json" +test -s "$evidence/vulnerabilities.json" +# Bundled Angular output can hide package metadata from a runtime-only scan. +# Scan the exact application lockfile and PM2 lock as a second, explicit evidence source. +mkdir "$scanner_dir/locks" +cp yarn.lock package.json "$scanner_dir/locks/" +expected_lock=$(jq -er .source_lock_sha256 "$recipe") +printf '%s %s\n' "$expected_lock" "$scanner_dir/locks/yarn.lock" | sha256sum -c - +cp -r ci/release/image/pm2 "$scanner_dir/locks/pm2" +"$scanner_dir/trivy" fs --cache-dir "$scanner_dir/cache" --timeout 15m \ + --scanners vuln --format json --exit-code 0 \ + --output "$evidence/dependency-vulnerabilities.json" "$scanner_dir/locks" +"$scanner_dir/trivy" fs --cache-dir "$scanner_dir/cache" --timeout 15m \ + --format spdx-json --output "$evidence/dependency-sbom.spdx.json" "$scanner_dir/locks" diff --git a/ci/release/test_https_runtime.py b/ci/release/test_https_runtime.py new file mode 100644 index 00000000000..b28316391c6 --- /dev/null +++ b/ci/release/test_https_runtime.py @@ -0,0 +1,377 @@ +#!/usr/bin/env python3 +"""Disposable local HTTPS/launcher check; pinned images only, no credentials or pulls.""" + +import argparse, json, os, pathlib, re, shutil, subprocess, tempfile, time, uuid + +ROOT = pathlib.Path(os.environ.get("CLARIN_COMPAT_ROOT", pathlib.Path(__file__).resolve().parents[1])) +# Exact linux/amd64 config identity of the accepted M05 frontend. No pull or rebuild. +FRONT = "sha256:db5eaf475dad1e43296b598d2a87b8abbed269b530e808e51a3193dd27016ba0" +PROXY = "nginx@sha256:dc5069ad14f19660b141b21236140b91656bf89bbc3e2417c70ae650cd66104c" + + +def run(*args, **kw): + return subprocess.run( + args, check=True, capture_output=True, text=True, **kw + ).stdout.strip() + + +parser = argparse.ArgumentParser(description=__doc__) +parser.add_argument('--frontend', default=FRONT, help='Already loaded exact Docker config digest') +parser.add_argument('--source', help='Expected full source revision label') +parser.add_argument('--report', type=pathlib.Path) +args = parser.parse_args() +if not re.fullmatch(r'sha256:[a-f0-9]{64}', args.frontend): + raise ValueError('An exact loaded frontend config digest is required') +FRONT = args.frontend +identity = json.loads(run('docker', 'image', 'inspect', FRONT))[0] +assert identity['Id'] == FRONT and identity['Os'] == 'linux' and identity['Architecture'] == 'amd64' +if args.source: + assert re.fullmatch(r'[a-f0-9]{40}', args.source) + assert identity['Config']['Labels']['org.opencontainers.image.revision'] == args.source + + +with tempfile.TemporaryDirectory(prefix="clarin-test-") as d: + p = pathlib.Path(d) + os.chmod(p, 0o755) + env = dict(os.environ, CLARIN_TEST_ROOT=d) + result = subprocess.run( + ["ansible-playbook", "-i", "localhost,", "tests/render.yml", + "-e", "clarin_dspace_anubis_enabled=false"], + cwd=ROOT, + env=env, + capture_output=True, + text=True, + ) + if result.returncode: + raise RuntimeError("Fixture rendering failed; output suppressed") + proxy = p / "nginx.conf" + shutil.copy(p / "config/proxy/nginx.conf", proxy) + os.chmod(proxy, 0o644) + for src in ["config.prod.yml", "dspace-ui.json", "http-launcher.cjs"]: + shutil.copy(p / "config/frontend" / src, p / src) + os.chmod(p / src, 0o644) + run( + "openssl", + "req", + "-x509", + "-newkey", + "rsa:2048", + "-nodes", + "-days", + "1", + "-subj", + "/CN=repository.clarin.test", + "-addext", + "subjectAltName=DNS:repository.clarin.test", + "-keyout", + str(p / "tls.key"), + "-out", + str(p / "tls.crt"), + ) + os.chmod(p / "tls.key", 0o644) # Disposable, self-signed test material only. + name = "clarin-m07-smoke-" + uuid.uuid4().hex[:10] + containers = [] + run("docker", "network", "create", "--internal", name) + run("docker", "network", "create", name + "-ingress") + + def start(suffix, image, args, mounts=(), extra=()): + n = name + "-" + suffix + cmd = [ + "docker", + "run", + "-d", + "--name", + n, + "--network", + name, + "--network-alias", + suffix, + "--cap-drop", + "ALL", + "--security-opt", + "no-new-privileges", + "--memory", + "2g", + ] + for source, target in mounts: + cmd += ["--mount", f"type=bind,source={source},target={target},readonly"] + cmd += list(extra) + [image] + list(args) + run(*cmd) + containers.append(n) + return n + + try: + mock = "require('http').createServer((q,s)=>{if(q.url.startsWith('/repository/server/api/pid/find')){s.writeHead(302,{Location:'https://repository.clarin.test/repository/server/api/core/items/mock?via=pid'});s.end();return;}s.setHeader('content-type','application/json');s.end(JSON.stringify({status:'UP',path:q.url,host:q.headers.host,proto:q.headers['x-forwarded-proto'],prefix:q.headers['x-forwarded-prefix']}));}).listen(8080,'0.0.0.0')" + start("dspace", FRONT, ["-e", mock], extra=["--entrypoint", "node"]) + ui = start( + "dspace-angular", + FRONT, + [], + [ + (p / "config.prod.yml", "/app/config/config.prod.yml"), + (p / "dspace-ui.json", "/app/dspace-ui.json"), + (p / "http-launcher.cjs", "/app/config/http-launcher.cjs"), + (p / "tls.crt", "/app/config/ca.crt"), + ], + [ + "--user", + "1000:1000", + "-e", + "DSPACE_APP_CONFIG_PATH=/app/config/config.prod.yml", + "-e", + "NODE_EXTRA_CA_CERTS=/app/config/ca.crt", + ], + ) + + def start_proxy(): + ng = start( + "nginx", + PROXY, + ["-g", "daemon off;"], + [ + (proxy, "/etc/nginx/nginx.conf"), + (p / "tls.key", "/etc/nginx/tls.key"), + (p / "tls.crt", "/etc/nginx/tls.crt"), + ], + [ + "--user", + "101:101", + "--network-alias", + "repository.clarin.test", + "--sysctl", + "net.ipv4.ip_unprivileged_port_start=443", + "--read-only", + "--tmpfs", + "/tmp:rw,noexec,nosuid,size=16m,mode=1777", + "--entrypoint", + "nginx", + "-p", + "127.0.0.1::8080", + "-p", + "127.0.0.1::443", + ], + ) + run("docker", "network", "connect", name + "-ingress", ng) + return ng + + ng = start_proxy() + + def port(target): + return run("docker", "port", ng, str(target) + "/tcp").rsplit(":", 1)[1] + + hp, tp = port(8080), port(443) + + def request(path, headers=(), tls=True, method="GET"): + targetport = tp if tls else hp + scheme = "https" if tls else "http" + cmd = [ + "curl", + "--noproxy", + "*", + "--silent", + "--show-error", + "--connect-timeout", + "2", + "--max-time", + "8", + "--cacert", + str(p / "tls.crt"), + "--resolve", + f"repository.clarin.test:{targetport}:127.0.0.1", + ] + if not any(h.lower().startswith("host:") for h in headers): + cmd += ["-H", "Host: repository.clarin.test"] + for h in headers: + cmd += ["-H", h] + if method == "HEAD": + cmd += ["--head"] + return subprocess.run( + cmd + ["-X", method, "-i", f"{scheme}://repository.clarin.test:{targetport}{path}"], + capture_output=True, + text=True, + ) + + for i in range(30): + reply = request("/repository/assets/config.json") + if reply.returncode == 0 and "200 OK" in reply.stdout: + break + time.sleep(1) + else: + raise RuntimeError("Frontend/proxy did not become ready") + cfg = json.loads( + reply.stdout.split("\r\n\r\n")[-1] + if "\r\n\r\n" in reply.stdout + else reply.stdout.split("\n\n", 1)[1] + ) + assert cfg["rest"]["baseUrl"] == "https://repository.clarin.test/repository/server" + assert "ssrBaseUrl" not in cfg["rest"] and "bindAddress" not in cfg["ui"] + redir = request("/example?x=1", tls=False).stdout + assert ( + "308 Permanent Redirect" in redir + and "Location: https://repository.clarin.test/example?x=1" in redir + ) + api = request( + "/repository/server/api", + headers=["X-Forwarded-Host: attacker.invalid", "X-Forwarded-Proto: http", "X-Forwarded-Prefix: /attacker"], + ).stdout + assert ( + '"host":"repository.clarin.test"' in api + and '"proto":"https"' in api + and '"prefix"' not in api + and '"path":"/repository/server/api"' in api + ) + for source, destination in [ + ("/", "/repository/"), ("/repository", "/repository/"), + ("/repository/xmlui", "/repository/"), ("/repository/xmlui/", "/repository/"), + ("/repository/xmlui/login", "/repository/login"), + ("/repository/xmlui/handle/20.500.12574/161", "/repository/handle/20.500.12574/161"), + ]: + reply = request(source + "?x=a%26b&y=2").stdout + assert reply.startswith("HTTP/1.1 308"), (source, reply) + assert "Location: https://repository.clarin.test" + destination + "?x=a%26b&y=2" in reply + assert request(source, method="POST").stdout.startswith("HTTP/1.1 405"), source + assert request(source, method="HEAD").stdout.startswith("HTTP/1.1 308"), source + for retired in ["/home", "/login", "/items/example", "/handle/20.500/1", "/server/api", + "/repository/xmlui/discover", "/repository/xmlui/bitstream/1/file.txt"]: + assert request(retired).stdout.startswith("HTTP/1.1 404"), retired + # Public query and URI mapping are preserved; internal and public contexts match. + reply = request("/repository/server/api?x=a%26b&y=2").stdout + assert '\"path\":\"/repository/server/api?x=a%26b&y=2\"' in reply + robots = request("/repository/robots.txt").stdout + assert ( + "https://repository.clarin.test" in robots + and "http://repository.clarin.test" not in robots + ) + assert request( + "/repository/server/api", headers=["Remote-User: administrator"] + ).stdout.startswith("HTTP/1.1 403") + assert ( + request("/repository/server/api", headers=["Host: attacker.invalid"]).returncode != 0 + ) + # Backend redirect leaves the initial internal REST request. It must still + # resolve inside Docker and verify the public hostname with our CA. + probe = "fetch('http://dspace:8080/repository/server/api/pid/find?id=hdl:test',{signal:AbortSignal.timeout(6000)}).then(async r=>{const b=await r.json();if(r.status!==200||b.path!=='/repository/server/api/core/items/mock?via=pid')process.exit(2);console.log('redirect-ok')}).catch(e=>{console.error(e.cause?.code||e.message);process.exit(1)})" + assert run("docker", "exec", ui, "node", "-e", probe) == "redirect-ok" + untrusted = subprocess.run( + ["docker", "exec", "-e", "NODE_EXTRA_CA_CERTS=", ui, "node", "-e", probe], + capture_output=True, + text=True, + ) + assert ( + untrusted.returncode != 0 + and "DEPTH_ZERO_SELF_SIGNED_CERT" in untrusted.stderr + ) + wrong_host = subprocess.run( + [ + "docker", + "exec", + ui, + "node", + "-e", + probe.replace( + "http://dspace:8080/repository/server/api/pid/find?id=hdl:test", + "https://nginx/server/api", + ), + ], + capture_output=True, + text=True, + ) + assert ( + wrong_host.returncode != 0 + and "ERR_TLS_CERT_ALTNAME_INVALID" in wrong_host.stderr + ) + + # Force a different proxy IP while the frontend remains running. + old_ip = run( + "docker", + "inspect", + "--format", + '{{(index .NetworkSettings.Networks "' + name + '").IPAddress}}', + ng, + ) + run("docker", "rm", "-f", ng) + containers.remove(ng) + start( + "old-address-holder", + FRONT, + ["-e", "setInterval(()=>{},1000)"], + extra=["--entrypoint", "node", "--ip", old_ip], + ) + ng = start_proxy() + hp, tp = port(8080), port(443) + new_ip = run( + "docker", + "inspect", + "--format", + '{{(index .NetworkSettings.Networks "' + name + '").IPAddress}}', + ng, + ) + assert old_ip != new_ip + for i in range(15): + reply = subprocess.run( + ["docker", "exec", ui, "node", "-e", probe], + capture_output=True, + text=True, + ) + if reply.returncode == 0: + break + time.sleep(1) + else: + raise RuntimeError("Redirect lookup did not recover after proxy IP change") + before = time.monotonic() + run("docker", "stop", "--time", "30", ui) + elapsed = time.monotonic() - before + assert run("docker", "inspect", "--format", "{{.State.ExitCode}}", ui) == "0" + run("docker", "start", ui) + for i in range(30): + if "200 OK" in request("/repository/assets/config.json").stdout: + break + time.sleep(1) + else: + raise RuntimeError("Frontend restart failed") + report = { + "checks": [ + "public REST HTTPS config", + "private-field sanitization", + "fixed HTTP redirect", + "same-origin REST routing", + "controlled forwarding headers", + "identity spoof rejection", + "unknown host rejection", + "frontend graceful stop and restart", + "internal PID redirect through public DNS alias and trusted HTTPS", + "untrusted CA and wrong certificate hostname rejected", + "proxy recreation with changed IP and running frontend", + ], + "frontend_stop_seconds": round(elapsed, 2), + "scope": "mock backend; not integrated DSpace acceptance", + "frontend_config_digest": FRONT, + "source_revision": args.source, + "result": "passed", + } + if args.report: + args.report.write_text(json.dumps(report, indent=2) + "\n") + print(json.dumps(report)) + except Exception: + for n in containers: + print( + subprocess.run( + ["docker", "logs", "--tail", "15", n], + capture_output=True, + text=True, + ).stdout + ) + print( + subprocess.run( + ["docker", "logs", "--tail", "15", n], + capture_output=True, + text=True, + ).stderr + ) + raise + finally: + for n in reversed(containers): + subprocess.run(["docker", "rm", "-f", n], capture_output=True) + subprocess.run( + ["docker", "network", "rm", name, name + "-ingress"], capture_output=True + ) diff --git a/ci/release/test_release.py b/ci/release/test_release.py new file mode 100644 index 00000000000..276f596e686 --- /dev/null +++ b/ci/release/test_release.py @@ -0,0 +1,182 @@ +"""Offline release gates: OCI tampering, source identity, fixture pins and workflow privileges.""" +import copy +import hashlib +import io +import json +import os +import subprocess +from pathlib import Path +import tarfile +import tempfile +import unittest +from unittest.mock import patch + +import frontend_image as m +from release_contract import validate, COMPATIBILITY + +ROOT=Path(__file__).resolve().parents[2] + + +def archive(path, source=None, corrupt=False): + blobs={} + def blob(data, media): + payload=json.dumps(data).encode() + digest='sha256:'+hashlib.sha256(payload).hexdigest() + blobs['blobs/sha256/'+digest[7:]]=payload + return dict(mediaType=media,digest=digest,size=len(payload)) + config=blob({'architecture':'amd64','os':'linux','config':{'User':'1000:1000', + 'Labels':{'org.opencontainers.image.revision':source or m.inputs()['source_revision']}}}, + 'application/vnd.oci.image.config.v1+json') + runtime=blob({'config':config,'layers':[]},'application/vnd.oci.image.manifest.v1+json') + attest=[] + for predicate in ['https://slsa.dev/provenance/v0.2','https://spdx.dev/Document']: + attest.append(blob({'predicateType':predicate,'subject':[{'digest':{'sha256':runtime['digest'][7:]}}]}, + 'application/vnd.in-toto+json')) + unknown=blob({},'application/vnd.oci.image.config.v1+json') + attestation=blob({'config':unknown,'layers':attest},'application/vnd.oci.image.manifest.v1+json') + index=blob({'manifests':[runtime,attestation]},'application/vnd.oci.image.index.v1+json') + blobs['index.json']=json.dumps({'manifests':[index]}).encode() + if corrupt: blobs['blobs/sha256/'+config['digest'][7:]]=b'bad' + with tarfile.open(path,'w') as tar: + for name,data in blobs.items(): + info=tarfile.TarInfo(name);info.size=len(data);tar.addfile(info,io.BytesIO(data)) + return index['digest'],config['digest'] + + +class ReleaseTests(unittest.TestCase): + def test_recipe_and_derived_source(self): + m.check_recipe() + self.assertNotIn('source_revision',json.loads((m.RECIPE/'toolchain.json').read_text())) + self.assertEqual(m.inputs()['source_lock_sha256'],hashlib.sha256((ROOT/'yarn.lock').read_bytes()).hexdigest()) + + def test_exact_archive_and_source_tampering(self): + with tempfile.TemporaryDirectory() as d: + p=Path(d);candidate=p/'image.tar' + digest,config=archive(candidate) + result=m.inspect_archive(candidate,digest,p/'evidence') + self.assertEqual(result['config_digest'],config) + with self.assertRaises(ValueError):m.inspect_archive(candidate,'sha256:'+'0'*64,p/'evidence') + for kw in ({'source':'0'*40},{'corrupt':True}): + digest,_=archive(candidate,**kw) + with self.assertRaises(ValueError):m.inspect_archive(candidate,digest,p/'evidence') + + def test_pinned_nonprivate_compatibility_files(self): + root=ROOT/'ci/release/compatibility' + manifest=json.loads((root/'manifest.json').read_text()) + self.assertEqual(manifest['revision'],COMPATIBILITY) + for path,digest in manifest['files'].items(): + self.assertEqual(hashlib.sha256((root/path).read_bytes()).hexdigest(),digest,path) + self.assertFalse((root/'ansible/inventories').exists()) + + def test_publisher_verifies_reports_bound_to_exact_loaded_image(self): + from verify_record import verify + with tempfile.TemporaryDirectory() as d: + root=Path(d); evidence=root/'evidence';evidence.mkdir() + digest, config=archive(root/'frontend.oci.tar') + source=m.inputs()['source_revision'] + reports={} + for name in ('vulnerabilities.json','dependency-vulnerabilities.json'): + (evidence/name).write_text('{}') + reports[name]=hashlib.sha256(b'{}').hexdigest() + record=dict(schema=1,repository='LUMII-AILab/dspace-angular',image=m.inputs()['image'], + version='sha-'+source,source=source,digest=digest,config_digest=config, + compatibility_revision=COMPATIBILITY,workflow='.github/workflows/clarin-release.yml', + run_id=123,checks=dict(oci='passed',https='passed',configuration='passed'), + scan=dict(policy='synthetic-report-v1',disposition='report-only',production_accepted=False,reports=reports)) + (evidence/'release.json').write_text(json.dumps(record)) + https=dict(result='passed',frontend_config_digest=config,source_revision=source) + (evidence/'https.json').write_text(json.dumps(https)) + with patch.dict(os.environ,EXPECTED_DIGEST=digest,GITHUB_RUN_ID='123'): + self.assertEqual(verify(root),record) + for bad in (https|{'result':'failed'},https|{'frontend_config_digest':'sha256:'+'0'*64}): + (evidence/'https.json').write_text(json.dumps(bad)) + with self.assertRaises(AssertionError): verify(root) + (evidence/'https.json').write_text(json.dumps(https)) + (evidence/'vulnerabilities.json').write_text('{"changed":true}') + with self.assertRaises(AssertionError): verify(root) + + def test_publication_copies_once_and_refuses_moved_tag_or_denied_registry(self): + # Exercise the real publisher shell; replace external processes, never a live registry. + harness = r""" +python3() { printf 'inspect\n' >> "$TRACE"; } +docker() { + case " $* " in + *" login "*) cat >/dev/null ;; + *" list-tags "*) + if [ "$CASE" = denied ]; then return 1; fi + if [ "$CASE" = new ]; then printf '{"Tags":[]}'; + else printf '{"Tags":["%s"]}' "$TAG"; fi ;; + *" inspect "*) + if [ "$CASE" = moved ]; then printf other; else printf index; fi ;; + *" copy "*) printf 'copy\n' >> "$TRACE" ;; + esac +} +export -f python3 docker +bash "$PUBLISHER" +""" + with tempfile.TemporaryDirectory() as d: + root=Path(d);(root/'ci/release/image').mkdir(parents=True) + (root/'ci/release/image/inputs.json').write_text(json.dumps(m.inputs())) + (root/'output').mkdir() + for case, code, copies in [('new',0,1),('same',0,0),('moved',1,0),('denied',1,0)]: + trace=root/'trace';trace.write_text('') + env=dict(os.environ,CASE=case,TRACE=str(trace),PUBLISHER=str(ROOT/'ci/release/publish.sh'), + GHCR_TOKEN='private-test-sentinel',GHCR_USER='fixture', + EXPECTED_DIGEST='sha256:'+hashlib.sha256(b'index').hexdigest(), + IMAGE=m.inputs()['image'],TAG='sha-'+'a'*40) + result=subprocess.run(['bash','-c',harness],cwd=root,env=env,capture_output=True,text=True) + self.assertEqual(result.returncode,code,result.stderr) + self.assertEqual(trace.read_text().splitlines().count('copy'),copies) + self.assertIn('inspect',trace.read_text()) + self.assertNotIn('private-test-sentinel',result.stdout+result.stderr+trace.read_text()) + + def test_partial_report_upload_resumes_draft_without_overwriting_assets(self): + import publish_report + with tempfile.TemporaryDirectory() as d: + root=Path(d) + (root/'release.json').write_text('{"verified":true}') + (root/'https.json').write_text('{"passed":true}') + record=dict(repository='owner/app',version='sha-'+'a'*40,source='a'*40) + state={'draft':True, 'assets':{'release.json':(root/'release.json').read_bytes()}} + calls=[] + def gh(*args): + calls.append(args) + if args[:2]==('api','--paginate'): return record['version']+'\t1' + if args==('api','repos/owner/app/releases/1'): + return json.dumps(dict(tag_name=record['version'],target_commitish=record['source'], + draft=state['draft'],assets=[{'name':name} for name in state['assets']])) + if args[:2]==('release','upload'): + p=Path(args[-1]); self.assertNotIn(p.name,state['assets']);state['assets'][p.name]=p.read_bytes() + elif args[:2]==('release','download'): + name=args[args.index('--pattern')+1] + (Path(args[-1])/name).write_bytes(state['assets'][name]) + elif args[:2]==('release','edit'): state['draft']=False + elif args[0]=='api' and '/commits/' in args[1]: return json.dumps({'sha':record['source']}) + return '' + with patch.object(publish_report,'command',side_effect=gh): + publish_report.publish(record,root) + self.assertFalse(state['draft']) + self.assertEqual(len([c for c in calls if c[:2]==('release','upload')]),1) + calls.clear() + publish_report.publish(record,root) + self.assertFalse(any(c[:2]==('release','upload') for c in calls)) + state['assets']['release.json']=b'changed' + with self.assertRaises(AssertionError): publish_report.publish(record,root) + + def test_workflow_qualifies_before_publishing_without_private_checkout(self): + workflow=(ROOT/'.github/workflows/clarin-release.yml').read_text() + build,publish=workflow.split('\n publish:\n') + self.assertNotIn('secrets.',build) + self.assertNotIn('packages: write',build) + self.assertNotIn('contents: write',build) + self.assertNotIn('repository: LUMII-AILab/clarin-dspace-ops',build) + self.assertIn('needs: build',publish) + self.assertIn("github.event_name != 'pull_request'",publish) + self.assertIn('CLARIN_RELEASE_PUBLISH_ENABLED',publish) + self.assertIn('test_https_runtime.py',build) + self.assertIn('python3 ci/release/verify_record.py',publish) + self.assertNotIn('build-push-action',publish) + self.assertIn('--preserve-digests',(ROOT/'ci/release/publish.sh').read_text()) + + +if __name__=='__main__': unittest.main() diff --git a/ci/release/verify_record.py b/ci/release/verify_record.py new file mode 100644 index 00000000000..658f4e1ad0f --- /dev/null +++ b/ci/release/verify_record.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +"""Fail closed before publisher receives a candidate as an accepted release.""" +import hashlib +import json +import os +from pathlib import Path +from frontend_image import inputs, inspect_archive +from release_contract import validate + + +def verify(root=Path('output')): + record = validate(json.loads((root / 'evidence/release.json').read_text())) + assert record['source'] == inputs()['source_revision'] + assert record['digest'] == os.environ['EXPECTED_DIGEST'] + assert record['run_id'] == int(os.environ['GITHUB_RUN_ID']) + identity = inspect_archive(root / 'frontend.oci.tar', record['digest'], root / 'evidence') + assert record['config_digest'] == identity['config_digest'] + https = json.loads((root / 'evidence/https.json').read_text()) + assert https['result'] == 'passed' and https['frontend_config_digest'] == record['config_digest'] + assert https['source_revision'] == record['source'] + for name in ('vulnerabilities.json', 'dependency-vulnerabilities.json'): + assert record['scan']['reports'][name] == hashlib.sha256((root / 'evidence' / name).read_bytes()).hexdigest() + return record + + +if __name__ == '__main__': + verify() From 5612573ebe671feb6061a64f2dd78af37b059ac9 Mon Sep 17 00:00:00 2001 From: Arnis Voitkans Date: Mon, 21 Sep 2026 21:55:55 +0300 Subject: [PATCH 2/3] Track the pinned release PM2 lockfile despite inherited ignore rule --- ci/release/.gitignore | 1 + ci/release/image/pm2/package-lock.json | 947 +++++++++++++++++++++++++ 2 files changed, 948 insertions(+) create mode 100644 ci/release/image/pm2/package-lock.json diff --git a/ci/release/.gitignore b/ci/release/.gitignore index 47102321496..523afe79363 100644 --- a/ci/release/.gitignore +++ b/ci/release/.gitignore @@ -1,2 +1,3 @@ __pycache__/ image/inputs.json +!image/pm2/package-lock.json diff --git a/ci/release/image/pm2/package-lock.json b/ci/release/image/pm2/package-lock.json new file mode 100644 index 00000000000..a30042cbe80 --- /dev/null +++ b/ci/release/image/pm2/package-lock.json @@ -0,0 +1,947 @@ +{ + "name": "clarin-frontend-process-manager", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "clarin-frontend-process-manager", + "version": "1.0.0", + "dependencies": { + "pm2": "7.0.3" + } + }, + "node_modules/@pm2/blessed": { + "version": "0.1.81", + "resolved": "https://registry.npmjs.org/@pm2/blessed/-/blessed-0.1.81.tgz", + "integrity": "sha512-ZcNHqQjMuNRcQ7Z1zJbFIQZO/BDKV3KbiTckWdfbUaYhj7uNmUwb+FbdDWSCkvxNr9dBJQwvV17o6QBkAvgO0g==", + "license": "MIT", + "bin": { + "blessed": "bin/tput.js" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/@pm2/js-api": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@pm2/js-api/-/js-api-0.8.1.tgz", + "integrity": "sha512-n9tDOz1ojyDOs05XthEXrLFVQYbbh2oAN19UakLPyEZDrUyEq05h8wIZU8+dNXBQY/KeFlWMLVA76nnX52ofRg==", + "license": "Apache-2", + "dependencies": { + "async": "^2.6.3", + "debug": "~4.3.1", + "eventemitter2": "^6.3.1", + "extrareqp2": "^1.0.0", + "ws": "^8.21.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/@pm2/js-api/node_modules/async": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", + "license": "MIT", + "dependencies": { + "lodash": "^4.17.14" + } + }, + "node_modules/@pm2/js-api/node_modules/debug": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/@pm2/pm2-version-check": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@pm2/pm2-version-check/-/pm2-version-check-1.0.4.tgz", + "integrity": "sha512-SXsM27SGH3yTWKc2fKR4SYNxsmnvuBQ9dd6QHtEWmiZ/VqaOYPAIlS8+vMcn27YLtAEBGvNRSh3TPNvtjZgfqA==", + "license": "MIT", + "dependencies": { + "debug": "^4.3.1" + } + }, + "node_modules/@tootallnate/quickjs-emscripten": { + "version": "0.23.0", + "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", + "integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==", + "license": "MIT" + }, + "node_modules/agent-base": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", + "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, + "node_modules/amp": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/amp/-/amp-0.3.1.tgz", + "integrity": "sha512-OwIuC4yZaRogHKiuU5WlMR5Xk/jAcpPtawWL05Gj8Lvm2F6mwoJt4O/bHI+DHwG79vWd+8OFYM4/BzYqyRd3qw==", + "license": "MIT" + }, + "node_modules/amp-message": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/amp-message/-/amp-message-0.1.2.tgz", + "integrity": "sha512-JqutcFwoU1+jhv7ArgW38bqrE+LQdcRv4NxNw0mp0JHQyB6tXesWRjtYKlDgHRY2o3JE5UTaBGUK8kSWUdxWUg==", + "license": "MIT", + "dependencies": { + "amp": "0.3.1" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/ansis": { + "version": "4.0.0-node10", + "resolved": "https://registry.npmjs.org/ansis/-/ansis-4.0.0-node10.tgz", + "integrity": "sha512-BRrU0Bo1X9dFGw6KgGz6hWrqQuOlVEDOzkb0QSLZY9sXHqA7pNj7yHPVJRz7y/rj4EOJ3d/D5uxH+ee9leYgsg==", + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "license": "Python-2.0" + }, + "node_modules/ast-types": { + "version": "0.13.4", + "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.13.4.tgz", + "integrity": "sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w==", + "license": "MIT", + "dependencies": { + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/async": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", + "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", + "license": "MIT" + }, + "node_modules/basic-ftp": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.3.1.tgz", + "integrity": "sha512-bopVNp6ugyA150DDuZfPFdt1KZ5a94ZDiwX4hMgZDzF+GttD80lEy8kj98kbyhLXnPvhtIo93mdnLIjpCAeeOw==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/chalk": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", + "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/cli-tableau": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/cli-tableau/-/cli-tableau-2.0.1.tgz", + "integrity": "sha512-he+WTicka9cl0Fg/y+YyxcN6/bfQ/1O3QmgxRXDhABKqLzvoOSM4fMzp39uMyLBulAFuywD2N7UaoQE7WaADxQ==", + "dependencies": { + "chalk": "3.0.0" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "license": "MIT" + }, + "node_modules/commander": { + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "license": "MIT" + }, + "node_modules/croner": { + "version": "4.1.97", + "resolved": "https://registry.npmjs.org/croner/-/croner-4.1.97.tgz", + "integrity": "sha512-/f6gpQuxDaqXu+1kwQYSckUglPaOrHdbIlBAu0YuW8/Cdb45XwXYNUBXg3r/9Mo6n540Kn/smKcZWko5x99KrQ==", + "license": "MIT" + }, + "node_modules/data-uri-to-buffer": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz", + "integrity": "sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw==", + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, + "node_modules/dayjs": { + "version": "1.11.15", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.15.tgz", + "integrity": "sha512-MC+DfnSWiM9APs7fpiurHGCoeIx0Gdl6QZBy+5lu8MbYKN5FZEXqOgrundfibdfhGZ15o9hzmZ2xJjZnbvgKXQ==", + "license": "MIT" + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/degenerator": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-5.0.1.tgz", + "integrity": "sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==", + "license": "MIT", + "dependencies": { + "ast-types": "^0.13.4", + "escodegen": "^2.1.0", + "esprima": "^4.0.1" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/escodegen": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.1.0.tgz", + "integrity": "sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==", + "license": "BSD-2-Clause", + "dependencies": { + "esprima": "^4.0.1", + "estraverse": "^5.2.0", + "esutils": "^2.0.2" + }, + "bin": { + "escodegen": "bin/escodegen.js", + "esgenerate": "bin/esgenerate.js" + }, + "engines": { + "node": ">=6.0" + }, + "optionalDependencies": { + "source-map": "~0.6.1" + } + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "license": "BSD-2-Clause", + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/eventemitter2": { + "version": "6.4.9", + "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.9.tgz", + "integrity": "sha512-JEPTiaOt9f04oa6NOkc4aH+nVp5I3wEjpHbIPqfgCdD5v5bUzy7xQqwcVO2aDQgOWhI28da57HksMrzK9HlRxg==", + "license": "MIT" + }, + "node_modules/extrareqp2": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/extrareqp2/-/extrareqp2-1.0.0.tgz", + "integrity": "sha512-Gum0g1QYb6wpPJCVypWP3bbIuaibcFiJcpuPM10YSXp/tzqi84x9PJageob+eN4xVRIOto4wjSGNLyMD54D2xA==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.14.0" + } + }, + "node_modules/fast-json-patch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/fast-json-patch/-/fast-json-patch-3.1.1.tgz", + "integrity": "sha512-vf6IHUX2SBcA+5/+4883dsIjpBTqmfBjmYiWK1savxQmFk4JfBMLa7ynTYOs1Rolp/T1betJxHiGD3g1Mn8lUQ==", + "license": "MIT" + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/follow-redirects": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz", + "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-uri": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-6.0.5.tgz", + "integrity": "sha512-b1O07XYq8eRuVzBNgJLstU6FYc1tS6wnMtF1I1D9lE8LxZSOGZ7LhxN54yPP6mGw5f2CkXY2BQUL9Fx41qvcIg==", + "license": "MIT", + "dependencies": { + "basic-ftp": "^5.0.2", + "data-uri-to-buffer": "^6.0.2", + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/http-proxy-agent": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", + "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==", + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.0", + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/https-proxy-agent": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/ip-address": { + "version": "10.7.0", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.0.tgz", + "integrity": "sha512-BGFsyJd5mpXp3rK6jIdADLNgpJUK1jnjzvYF8lK+VyDab9JAmqN0YOKDdP17HlgKb2+ehPgDc8EtnRLbGCAMhA==", + "license": "MIT", + "engines": { + "node": ">= 12" + } + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "license": "MIT", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/js-yaml": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.0.tgz", + "integrity": "sha512-1td788aAnnZ5qs7V2QIRl1owjtYpbKt749Y3xauqQgwIIGF/xXWz1wMTEBx5O3LK3lXLVuqXPdPxj2BoFHaW9Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", + "license": "ISC" + }, + "node_modules/lodash": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz", + "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==", + "license": "MIT" + }, + "node_modules/lru-cache": { + "version": "7.18.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", + "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/netmask": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/netmask/-/netmask-2.1.1.tgz", + "integrity": "sha512-eonl3sLUha+S1GzTPxychyhnUzKyeQkZ7jLjKrBagJgPla13F+uQ71HgpFefyHgqrjEbCPkDArxYsjY8/+gLKA==", + "license": "MIT", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pac-proxy-agent": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-7.2.0.tgz", + "integrity": "sha512-TEB8ESquiLMc0lV8vcd5Ql/JAKAoyzHFXaStwjkzpOpC5Yv+pIzLfHvjTSdf3vpa2bMiUQrg9i6276yn8666aA==", + "license": "MIT", + "dependencies": { + "@tootallnate/quickjs-emscripten": "^0.23.0", + "agent-base": "^7.1.2", + "debug": "^4.3.4", + "get-uri": "^6.0.1", + "http-proxy-agent": "^7.0.0", + "https-proxy-agent": "^7.0.6", + "pac-resolver": "^7.0.1", + "socks-proxy-agent": "^8.0.5" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/pac-resolver": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-7.0.1.tgz", + "integrity": "sha512-5NPgf87AT2STgwa2ntRMr45jTKrYBGkVU36yT0ig/n/GMAa3oPqhZfIQ2kMEimReg0+t9kZViDVZ83qfVUlckg==", + "license": "MIT", + "dependencies": { + "degenerator": "^5.0.0", + "netmask": "^2.0.2" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/picomatch": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pidusage": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pidusage/-/pidusage-4.0.1.tgz", + "integrity": "sha512-yCH2dtLHfEBnzlHUJymR/Z1nN2ePG3m392Mv8TFlTP1B0xkpMQNHAnfkY0n2tAi6ceKO6YWhxYfZ96V4vVkh/g==", + "license": "MIT", + "dependencies": { + "safe-buffer": "^5.2.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/pm2": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/pm2/-/pm2-7.0.3.tgz", + "integrity": "sha512-zRJOdburpb9OEPB0uqoNT8C1Gp7hPJPVy4Kr67XJNuT9UlMQcOt1WXrYQUmwqKPHk8FyauvP1CPhqoCrCaPw0Q==", + "license": "AGPL-3.0", + "dependencies": { + "@pm2/blessed": "0.1.81", + "@pm2/js-api": "0.8.1", + "@pm2/pm2-version-check": "1.0.4", + "amp": "0.3.1", + "amp-message": "0.1.2", + "ansis": "4.0.0-node10", + "async": "3.2.6", + "chokidar": "3.6.0", + "cli-tableau": "2.0.1", + "commander": "2.15.1", + "croner": "4.1.97", + "dayjs": "1.11.15", + "debug": "4.4.3", + "eventemitter2": "6.4.9", + "fast-json-patch": "3.1.1", + "js-yaml": "4.3.0", + "pidusage": "4.0.1", + "pm2-deploy": "1.0.2", + "proxy-agent": "6.5.0", + "semver": "7.7.2", + "tx2": "1.0.5", + "ws": "8.21.0" + }, + "bin": { + "pm2": "bin/pm2", + "pm2-dev": "bin/pm2-dev", + "pm2-docker": "bin/pm2-docker", + "pm2-runtime": "bin/pm2-runtime" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/pm2-deploy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pm2-deploy/-/pm2-deploy-1.0.2.tgz", + "integrity": "sha512-YJx6RXKrVrWaphEYf++EdOOx9EH18vM8RSZN/P1Y+NokTKqYAca/ejXwVLyiEpNju4HPZEk3Y2uZouwMqUlcgg==", + "license": "MIT", + "dependencies": { + "run-series": "^1.1.8", + "tv4": "^1.3.0" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/proxy-agent": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-6.5.0.tgz", + "integrity": "sha512-TmatMXdr2KlRiA2CyDu8GqR8EjahTG3aY3nXjdzFyoZbmB8hrBsTyMezhULIXKnC0jpfjlmiZ3+EaCzoInSu/A==", + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.2", + "debug": "^4.3.4", + "http-proxy-agent": "^7.0.1", + "https-proxy-agent": "^7.0.6", + "lru-cache": "^7.14.1", + "pac-proxy-agent": "^7.1.0", + "proxy-from-env": "^1.1.0", + "socks-proxy-agent": "^8.0.5" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "license": "MIT" + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/run-series": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/run-series/-/run-series-1.1.9.tgz", + "integrity": "sha512-Arc4hUN896vjkqCYrUXquBFtRZdv1PfLbTYP71efP6butxyQ0kWpiNJyAgsxscmQg1cqvHY32/UCBzXedTpU2g==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/smart-buffer": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", + "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", + "license": "MIT", + "engines": { + "node": ">= 6.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/socks": { + "version": "2.8.10", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.10.tgz", + "integrity": "sha512-e0VyvkVTwVYViNovRkZ9aodhxVlyoMn7eJhVUPxZ+eK9P/7CBkxvvsBOHqFPEH416726W8tLXXXjKwqgTErrCQ==", + "license": "MIT", + "dependencies": { + "ip-address": "^10.1.1", + "smart-buffer": "^4.2.0" + }, + "engines": { + "node": ">= 10.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/socks-proxy-agent": { + "version": "8.0.5", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.5.tgz", + "integrity": "sha512-HehCEsotFqbPW9sJ8WVYB6UbmIMv7kUUORIF2Nncq4VQvBfNBLibW9YZR5dlYCSUhwcD628pRllm7n+E+YTzJw==", + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.2", + "debug": "^4.3.4", + "socks": "^2.8.3" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "license": "BSD-3-Clause", + "optional": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD" + }, + "node_modules/tv4": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/tv4/-/tv4-1.3.0.tgz", + "integrity": "sha512-afizzfpJgvPr+eDkREK4MxJ/+r8nEEHcmitwgnPUqpaP+FpwQyadnxNoSACbgc/b1LsZYtODGoPiFxQrgJgjvw==", + "license": [ + { + "type": "Public Domain", + "url": "http://geraintluff.github.io/tv4/LICENSE.txt" + }, + { + "type": "MIT", + "url": "http://jsonary.com/LICENSE.txt" + } + ], + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/tx2": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/tx2/-/tx2-1.0.5.tgz", + "integrity": "sha512-sJ24w0y03Md/bxzK4FU8J8JveYYUbSs2FViLJ2D/8bytSiyPRbuE3DyL/9UKYXTZlV3yXq0L8GLlhobTnekCVg==", + "license": "MIT", + "dependencies": { + "json-stringify-safe": "^5.0.1" + } + }, + "node_modules/ws": { + "version": "8.21.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz", + "integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + } + } +} From 33bfa74ca766bf4f9fd5c9a996689c245dbedfec Mon Sep 17 00:00:00 2001 From: Arnis Voitkans Date: Mon, 21 Sep 2026 22:10:14 +0300 Subject: [PATCH 3/3] Make HTTPS proxy-IP fixture portable to hosted Docker runners --- ci/release/test_https_runtime.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/ci/release/test_https_runtime.py b/ci/release/test_https_runtime.py index b28316391c6..9920e6552db 100644 --- a/ci/release/test_https_runtime.py +++ b/ci/release/test_https_runtime.py @@ -10,9 +10,10 @@ def run(*args, **kw): - return subprocess.run( - args, check=True, capture_output=True, text=True, **kw - ).stdout.strip() + result = subprocess.run(args, capture_output=True, text=True, **kw) + if result.returncode: + raise RuntimeError(f"Fixture command failed ({args[0]}): {result.stderr[-2000:]}") + return result.stdout.strip() parser = argparse.ArgumentParser(description=__doc__) @@ -71,8 +72,6 @@ def run(*args, **kw): os.chmod(p / "tls.key", 0o644) # Disposable, self-signed test material only. name = "clarin-m07-smoke-" + uuid.uuid4().hex[:10] containers = [] - run("docker", "network", "create", "--internal", name) - run("docker", "network", "create", name + "-ingress") def start(suffix, image, args, mounts=(), extra=()): n = name + "-" + suffix @@ -96,11 +95,19 @@ def start(suffix, image, args, mounts=(), extra=()): for source, target in mounts: cmd += ["--mount", f"type=bind,source={source},target={target},readonly"] cmd += list(extra) + [image] + list(args) + containers.append(n) # Docker may create a stopped container before returning failure. run(*cmd) - containers.append(n) return n try: + # Let Docker choose a free subnet, then make it explicit before attaching + # containers. Engines requiring configured IPAM can then reserve the old + # proxy address during the DNS-recovery check without hardcoded ranges. + run("docker", "network", "create", "--internal", name) + subnet = json.loads(run("docker", "network", "inspect", name))[0]["IPAM"]["Config"][0]["Subnet"] + run("docker", "network", "rm", name) + run("docker", "network", "create", "--internal", "--subnet", subnet, name) + run("docker", "network", "create", name + "-ingress") mock = "require('http').createServer((q,s)=>{if(q.url.startsWith('/repository/server/api/pid/find')){s.writeHead(302,{Location:'https://repository.clarin.test/repository/server/api/core/items/mock?via=pid'});s.end();return;}s.setHeader('content-type','application/json');s.end(JSON.stringify({status:'UP',path:q.url,host:q.headers.host,proto:q.headers['x-forwarded-proto'],prefix:q.headers['x-forwarded-prefix']}));}).listen(8080,'0.0.0.0')" start("dspace", FRONT, ["-e", mock], extra=["--entrypoint", "node"]) ui = start(