diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df4c4ad..2e8eb2b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -123,7 +123,7 @@ jobs: package_json_file: crates/app/ui/package.json - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: - node-version: 24 + node-version-file: crates/app/ui/.node-version cache: pnpm cache-dependency-path: crates/app/ui/pnpm-lock.yaml @@ -202,7 +202,7 @@ jobs: package_json_file: crates/app/ui/package.json - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: - node-version: 24 + node-version-file: crates/app/ui/.node-version cache: pnpm cache-dependency-path: | crates/app/ui/pnpm-lock.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d0e02c2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,473 @@ +name: Release + +# A tag v* on a commit of main builds the installers, signs their checksums with cosign +# (keyless) and creates a draft GitHub Release; publishing the draft is a manual step. +# Every other run is a dry run: same builds, checksums and signature, no release, no OS code +# signing. See docs/RELEASING.md. +on: + push: + tags: ["v*"] + workflow_dispatch: + pull_request: + branches: [main] + paths: + - .github/workflows/release.yml + - scripts/release/** + - crates/app/tauri.conf.json + - crates/app/tauri.release*.json + +permissions: {} + +concurrency: + group: release-${{ github.ref }} + cancel-in-progress: false + +env: + CARGO_TERM_COLOR: always + +jobs: + verify: + name: verify + runs-on: ubuntu-24.04 + permissions: + contents: read + outputs: + release: ${{ steps.verify.outputs.release }} + version: ${{ steps.verify.outputs.version }} + source_date_epoch: ${{ steps.verify.outputs.source_date_epoch }} + cosign: ${{ steps.verify.outputs.cosign }} + windows_signing: ${{ steps.verify.outputs.windows_signing }} + macos_signing: ${{ steps.verify.outputs.macos_signing }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + - id: verify + env: + # The only predicate that selects a real release: a pushed tag. A manual run on a + # tag stays a dry run. + RELEASE: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }} + # Pull requests from forks and Dependabot get no OIDC token, so no cosign signature. + COSIGN: >- + ${{ github.event_name != 'pull_request' || + (github.event.pull_request.head.repo.full_name == github.repository && + github.actor != 'dependabot[bot]') }} + # Only whether the code-signing secrets exist, and only for a release. + WINDOWS_SECRETS: >- + ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && + format('{0}{1}{2}{3}{4}{5}', + secrets.AZURE_CLIENT_ID != '', secrets.AZURE_CLIENT_SECRET != '', + secrets.AZURE_TENANT_ID != '', vars.AZURE_SIGNING_ENDPOINT != '', + vars.AZURE_SIGNING_ACCOUNT != '', vars.AZURE_SIGNING_PROFILE != '') || '' }} + MACOS_SECRETS: >- + ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && + format('{0}{1}{2}{3}{4}{5}', + secrets.APPLE_CERTIFICATE != '', secrets.APPLE_CERTIFICATE_PASSWORD != '', + secrets.APPLE_SIGNING_IDENTITY != '', secrets.APPLE_API_ISSUER != '', + secrets.APPLE_API_KEY != '', secrets.APPLE_API_PRIVATE_KEY != '') || '' }} + run: | + if [[ "$RELEASE" == true ]]; then + version=$(scripts/release/check-version.sh "$GITHUB_REF_NAME") + # A tag outside main publishes nothing. + if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then + echo "::error::$GITHUB_REF_NAME ($GITHUB_SHA) is not a commit of main" + exit 1 + fi + else + version=$(scripts/release/check-version.sh) + fi + + # All the secrets of one OS, or none: a partial set is a configuration mistake. + signing() { + case "$2" in + "" | falsefalsefalsefalsefalsefalse) echo false ;; + truetruetruetruetruetrue) echo true ;; + *) echo "::error::Some $1 code-signing secrets or variables are missing (see docs/RELEASING.md)" >&2 + return 1 ;; + esac + } + windows_signing=$(signing Windows "$WINDOWS_SECRETS") + macos_signing=$(signing macOS "$MACOS_SECRETS") + + { + echo "release=$RELEASE" + echo "version=$version" + echo "source_date_epoch=$(git log -1 --format=%ct)" + echo "cosign=$COSIGN" + echo "windows_signing=$windows_signing" + echo "macos_signing=$macos_signing" + } | tee -a "$GITHUB_OUTPUT" + + build: + name: build (${{ matrix.platform }}) + needs: verify + permissions: + contents: read + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-24.04 + platform: linux + target: x86_64-unknown-linux-gnu + bundles: deb,appimage + - os: windows-latest + platform: windows + target: x86_64-pc-windows-msvc + bundles: nsis,msi + - os: macos-latest + platform: macos + target: universal-apple-darwin + bundles: dmg + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash + env: + SOURCE_DATE_EPOCH: ${{ needs.verify.outputs.source_date_epoch }} + TARGET: ${{ matrix.target }} + BUNDLES: ${{ matrix.bundles }} + # No dependency cache in this workflow: a cache written by another branch must not end up + # in a signed installer. + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Install the Rust toolchain from rust-toolchain.toml + run: rustup toolchain install + - name: Add the macOS targets of the universal build + if: runner.os == 'macOS' + run: rustup target add x86_64-apple-darwin aarch64-apple-darwin + - name: Install Tauri prerequisites (Linux) + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y libwebkit2gtk-4.1-dev libgtk-3-dev librsvg2-dev \ + libayatana-appindicator3-dev libxdo-dev libssl-dev + - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + with: + package_json_file: crates/app/ui/package.json + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version-file: crates/app/ui/.node-version + - name: Install the frontend dependencies + working-directory: crates/app/ui + run: pnpm install --frozen-lockfile + - name: Remap build paths + run: echo "RUSTFLAGS=$(scripts/release/rustflags.sh)" >> "$GITHUB_ENV" + + - name: Build (no OS code signing) + if: >- + (runner.os == 'Windows' && needs.verify.outputs.windows_signing != 'true') || + (runner.os == 'macOS' && needs.verify.outputs.macos_signing != 'true') || + runner.os == 'Linux' + working-directory: crates/app/ui + env: + # linuxdeploy's own strip cannot read the libraries of Ubuntu 24.04 (.relr.dyn); + # the Keyrust binary is already stripped by the release profile. + NO_STRIP: ${{ runner.os == 'Linux' }} + run: | + config=() + if [[ "$RUNNER_OS" == macOS ]]; then + # Ad-hoc signature: without one the app does not start on Apple Silicon. + config=(--config tauri.release.macos-adhoc.json) + echo "Code signing: skipped (ad-hoc signature only, no Developer ID secrets)" >> "$GITHUB_STEP_SUMMARY" + elif [[ "$RUNNER_OS" == Windows ]]; then + echo "Code signing: skipped (no Authenticode secrets)" >> "$GITHUB_STEP_SUMMARY" + else + echo "Code signing: not applicable on Linux (checksums are signed with cosign)" >> "$GITHUB_STEP_SUMMARY" + fi + pnpm tauri build --target "$TARGET" --bundles "$BUNDLES" "${config[@]}" -- --locked + + - name: Build (Authenticode, Azure Trusted Signing) + if: runner.os == 'Windows' && needs.verify.outputs.windows_signing == 'true' + working-directory: crates/app/ui + env: + AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} + AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} + AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} + SIGNING_ENDPOINT: ${{ vars.AZURE_SIGNING_ENDPOINT }} + SIGNING_ACCOUNT: ${{ vars.AZURE_SIGNING_ACCOUNT }} + SIGNING_PROFILE: ${{ vars.AZURE_SIGNING_PROFILE }} + run: | + cargo install trusted-signing-cli --locked --version 0.11.0 + # Tauri runs signCommand on the app binary and on both installers (%1 = the file). + config="$RUNNER_TEMP/tauri.windows-signing.json" + node -e ' + const [file, endpoint, account, profile] = process.argv.slice(1); + const cmd = ["trusted-signing-cli", "-e", endpoint, "-a", account, "-c", profile, "-d", "Keyrust", "%1"]; + require("fs").writeFileSync(file, JSON.stringify({ bundle: { windows: { signCommand: { cmd: cmd[0], args: cmd.slice(1) } } } })); + ' "$config" "$SIGNING_ENDPOINT" "$SIGNING_ACCOUNT" "$SIGNING_PROFILE" + echo "Code signing: Authenticode (Azure Trusted Signing)" >> "$GITHUB_STEP_SUMMARY" + pnpm tauri build --target "$TARGET" --bundles "$BUNDLES" --config "$config" -- --locked + + - name: Build (Developer ID and notarization) + if: runner.os == 'macOS' && needs.verify.outputs.macos_signing == 'true' + working-directory: crates/app/ui + env: + APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} + APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} + APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }} + APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }} + APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }} + APPLE_API_PRIVATE_KEY: ${{ secrets.APPLE_API_PRIVATE_KEY }} + run: | + export APPLE_API_KEY_PATH="$RUNNER_TEMP/AuthKey_$APPLE_API_KEY.p8" + trap 'rm -f "$APPLE_API_KEY_PATH"' EXIT + printf '%s' "$APPLE_API_PRIVATE_KEY" | base64 --decode > "$APPLE_API_KEY_PATH" + unset APPLE_API_PRIVATE_KEY + echo "Code signing: Developer ID and notarization" >> "$GITHUB_STEP_SUMMARY" + pnpm tauri build --target "$TARGET" --bundles "$BUNDLES" -- --locked + + - name: Check the universal binary + if: runner.os == 'macOS' + run: | + lipo -info "target/$TARGET/release/keyrust" | tee "$RUNNER_TEMP/lipo.txt" + grep -q x86_64 "$RUNNER_TEMP/lipo.txt" && grep -q arm64 "$RUNNER_TEMP/lipo.txt" + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: bundle-${{ matrix.platform }} + path: | + target/${{ matrix.target }}/release/bundle/deb/*.deb + target/${{ matrix.target }}/release/bundle/appimage/*.AppImage + target/${{ matrix.target }}/release/bundle/nsis/*-setup.exe + target/${{ matrix.target }}/release/bundle/msi/*.msi + target/${{ matrix.target }}/release/bundle/dmg/*.dmg + retention-days: 7 + if-no-files-found: error + + # The Linux binary built twice, on two runners and in two directories: the same bytes mean + # the build does not depend on the time or the path. Informational, it never blocks a release. + rebuild: + name: rebuild (${{ matrix.copy }}) + needs: verify + permissions: + contents: read + strategy: + fail-fast: false + matrix: + copy: [first, second] + runs-on: ubuntu-24.04 + defaults: + run: + shell: bash + env: + SOURCE_DATE_EPOCH: ${{ needs.verify.outputs.source_date_epoch }} + SRC: ${{ matrix.copy == 'first' && 'keyrust' || 'second-copy/src' }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + path: ${{ env.SRC }} + persist-credentials: false + - name: Install the Rust toolchain from rust-toolchain.toml + working-directory: ${{ env.SRC }} + run: rustup toolchain install + - name: Install Tauri prerequisites + run: | + sudo apt-get update + sudo apt-get install -y libwebkit2gtk-4.1-dev libgtk-3-dev librsvg2-dev \ + libayatana-appindicator3-dev libxdo-dev libssl-dev + - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + with: + package_json_file: ${{ env.SRC }}/crates/app/ui/package.json + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version-file: ${{ env.SRC }}/crates/app/ui/.node-version + - name: Build the binary + working-directory: ${{ env.SRC }} + run: | + RUSTFLAGS="$(scripts/release/rustflags.sh)" + export RUSTFLAGS + cd crates/app/ui + pnpm install --frozen-lockfile + pnpm tauri build --target x86_64-unknown-linux-gnu --no-bundle -- --locked + cd "$GITHUB_WORKSPACE/$SRC" + mkdir -p "$RUNNER_TEMP/rebuild" + cp target/x86_64-unknown-linux-gnu/release/keyrust "$RUNNER_TEMP/rebuild/keyrust" + (cd "$RUNNER_TEMP/rebuild" && sha256sum keyrust > keyrust.sha256 && cat keyrust.sha256) + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: rebuild-${{ matrix.copy }} + path: ${{ runner.temp }}/rebuild/ + retention-days: 7 + if-no-files-found: error + + reproducibility: + name: reproducibility + needs: [verify, build, rebuild] + if: always() && needs.verify.result == 'success' + runs-on: ubuntu-24.04 + permissions: + contents: read + outputs: + status: ${{ steps.compare.outputs.status }} + first: ${{ steps.compare.outputs.first }} + second: ${{ steps.compare.outputs.second }} + steps: + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + continue-on-error: true + with: + pattern: rebuild-* + path: rebuild + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + continue-on-error: true + with: + name: bundle-linux + path: bundle-linux + - id: compare + run: | + hash() { if [[ -f "$1" ]]; then cut -d ' ' -f 1 "$1"; fi; } + first=$(hash rebuild/rebuild-first/keyrust.sha256) + second=$(hash rebuild/rebuild-second/keyrust.sha256) + if [[ -z "$first" || -z "$second" ]]; then + status="not available" + elif [[ "$first" == "$second" ]]; then + status=match + else + status=mismatch + fi + # The binary inside the .deb, for reference: the bundler may patch it, so it can + # differ from the rebuilds without the build being unreproducible. + deb_hash="not available" + deb=$(find bundle-linux -name '*.deb' -print -quit 2>/dev/null || true) + if [[ -n "$deb" ]]; then + dpkg-deb -x "$deb" deb-root + deb_hash=$(sha256sum deb-root/usr/bin/keyrust | cut -d ' ' -f 1) + fi + { + echo "status=$status" + echo "first=$first" + echo "second=$second" + } | tee -a "$GITHUB_OUTPUT" + { + echo "### Reproducibility (Linux binary)" + echo "- Result: **$status**" + echo "- First build: \`${first:-not available}\`" + echo "- Second build: \`${second:-not available}\`" + echo "- Binary inside the .deb: \`$deb_hash\`" + } >> "$GITHUB_STEP_SUMMARY" + + sign: + name: checksums and signature + needs: [verify, build] + runs-on: ubuntu-24.04 + permissions: + contents: read + id-token: write + env: + VERSION: ${{ needs.verify.outputs.version }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + pattern: bundle-* + path: artifacts + - name: Collect the installers + run: | + mkdir dist + find artifacts -type f -exec mv -t dist {} + + scripts/release/check-assets.sh "$VERSION" dist + # Written outside dist first: the glob must not see a half-written SHA256SUMS. + (cd dist && sha256sum -- * | LC_ALL=C sort -k 2 > "$RUNNER_TEMP/SHA256SUMS") + mv "$RUNNER_TEMP/SHA256SUMS" dist/SHA256SUMS + (cd dist && cat SHA256SUMS && sha256sum -c SHA256SUMS) + - uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 + if: needs.verify.outputs.cosign == 'true' + with: + cosign-release: v3.1.4 + - name: Sign the checksums + if: needs.verify.outputs.cosign == 'true' + working-directory: dist + run: | + cosign sign-blob --yes --bundle SHA256SUMS.sigstore.json SHA256SUMS + # The same check as in SECURITY.md, with the identity of this run. + cosign verify-blob --bundle SHA256SUMS.sigstore.json \ + --certificate-identity "https://github.com/$GITHUB_WORKFLOW_REF" \ + --certificate-oidc-issuer https://token.actions.githubusercontent.com \ + SHA256SUMS + echo "Signature: SHA256SUMS signed with cosign (identity https://github.com/$GITHUB_WORKFLOW_REF)" >> "$GITHUB_STEP_SUMMARY" + - name: Signature skipped + if: needs.verify.outputs.cosign != 'true' + run: | + echo "Signature: skipped (no OIDC token on fork/Dependabot PRs)" >> "$GITHUB_STEP_SUMMARY" + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: ${{ needs.verify.outputs.release == 'true' && 'keyrust-release' || 'keyrust-release-dryrun' }} + path: dist/ + retention-days: 7 + if-no-files-found: error + + release: + name: draft release + needs: [verify, sign, reproducibility] + if: always() && needs.sign.result == 'success' && needs.verify.outputs.release == 'true' + runs-on: ubuntu-24.04 + permissions: + contents: write + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ github.ref_name }} + VERSION: ${{ needs.verify.outputs.version }} + REPRO_STATUS: ${{ needs.reproducibility.outputs.status || 'not available' }} + REPRO_FIRST: ${{ needs.reproducibility.outputs.first }} + REPRO_SECOND: ${{ needs.reproducibility.outputs.second }} + WINDOWS_SIGNING: ${{ needs.verify.outputs.windows_signing }} + MACOS_SIGNING: ${{ needs.verify.outputs.macos_signing }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: keyrust-release + path: dist + - name: Check the assets + run: | + count=$(find dist -maxdepth 1 -type f | wc -l) + if [[ "$count" -ne 7 || ! -f dist/SHA256SUMS || ! -f dist/SHA256SUMS.sigstore.json ]]; then + echo "::error::Expected 5 installers, SHA256SUMS and SHA256SUMS.sigstore.json; found:" + ls -l dist + exit 1 + fi + - name: Write the release notes + run: | + { + scripts/release/changelog-section.sh "$VERSION" + echo + echo "### Build" + echo + if [[ "$WINDOWS_SIGNING" == true ]]; then + echo "- Windows: Authenticode-signed." + else + echo "- Windows: not code-signed." + fi + if [[ "$MACOS_SIGNING" == true ]]; then + echo "- macOS: signed with a Developer ID and notarized." + else + echo "- macOS: not signed with a Developer ID (ad-hoc signature only)." + fi + case "$REPRO_STATUS" in + match) echo "- Reproducibility check (Linux binary): match, \`$REPRO_FIRST\`." ;; + mismatch) echo "- Reproducibility check (Linux binary): mismatch, \`$REPRO_FIRST\` and \`$REPRO_SECOND\`." ;; + *) echo "- Reproducibility check (Linux binary): not available." ;; + esac + echo "- Verify your download: https://github.com/${GITHUB_REPOSITORY}/blob/main/SECURITY.md#verifying-releases" + } > "$RUNNER_TEMP/notes.md" + cat "$RUNNER_TEMP/notes.md" + - name: Create or update the draft release + run: | + if draft=$(gh release view "$TAG" --repo "$GITHUB_REPOSITORY" --json isDraft --jq .isDraft 2>/dev/null); then + if [[ "$draft" != true ]]; then + echo "::error::Release $TAG is already published; it is left untouched" + exit 1 + fi + gh release upload "$TAG" dist/* --clobber --repo "$GITHUB_REPOSITORY" + gh release edit "$TAG" --notes-file "$RUNNER_TEMP/notes.md" --repo "$GITHUB_REPOSITORY" + else + gh release create "$TAG" dist/* --draft --verify-tag --title "Keyrust $VERSION" \ + --notes-file "$RUNNER_TEMP/notes.md" --repo "$GITHUB_REPOSITORY" + fi + echo "Draft release: $(gh release view "$TAG" --repo "$GITHUB_REPOSITORY" --json url --jq .url)" >> "$GITHUB_STEP_SUMMARY" diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..fdcb316 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,40 @@ +# Changelog + +All notable changes to Keyrust are documented in this file. The format is based on +[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses +[Semantic Versioning](https://semver.org/). + +## [Unreleased] + +## [0.1.0] + +The first release: a minimal KeePass client for Linux, Windows and macOS. Alpha software, not +audited: keep backups of your database. + +### Added + +- Create, open and save KDBX 4 databases protected by a master password; new databases use + Argon2id calibrated to about one second. +- KDBX 3.1 and 4.0 files open normally and are converted to KDBX 4.1 on the first save, with a + notice when they are opened. +- Nested groups, entries with title, username, password, URL and notes, entry history and a + recycle bin with restore. Custom fields, attachments and history written by other clients are + preserved. +- Instant search over titles, usernames and URLs. +- Password generator with a strength estimate. +- Clipboard copy from the Rust process, cleared after a delay, on lock and on exit. +- Auto-lock on inactivity, screen lock, sleep and (optionally) minimize. +- Atomic saves with detection of changes made by another app (*Reload* or *Keep mine*). +- Database settings: name, cipher, key-derivation parameters, recycle bin, master password. +- Full keyboard use, a command palette and a shortcuts panel; accessibility checked in CI. + +### Distribution + +- Installers for Windows (NSIS and MSI), Linux (`.deb` and AppImage) and macOS (universal + `.dmg`), with SHA-256 checksums signed with Sigstore cosign. See + [Verifying releases](https://github.com/downlevel/keyrust/blob/main/SECURITY.md#verifying-releases). +- The installers are not code-signed for Windows or macOS: SmartScreen and Gatekeeper warn before + the first launch (see the [README](https://github.com/downlevel/keyrust/blob/main/README.md#download)). + +[Unreleased]: https://github.com/downlevel/keyrust/compare/v0.1.0...HEAD +[0.1.0]: https://github.com/downlevel/keyrust/releases/tag/v0.1.0 diff --git a/Cargo.lock b/Cargo.lock index b59202b..cc8c3f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2341,7 +2341,7 @@ dependencies = [ [[package]] name = "keyrust-app" -version = "0.0.1" +version = "0.1.0" dependencies = [ "arboard", "keyrust-core", @@ -2362,7 +2362,7 @@ dependencies = [ [[package]] name = "keyrust-core" -version = "0.0.1" +version = "0.1.0" dependencies = [ "arbitrary", "base64 0.22.1", @@ -2386,7 +2386,7 @@ dependencies = [ [[package]] name = "keyrust-os" -version = "0.0.1" +version = "0.1.0" dependencies = [ "core-foundation", "serde", diff --git a/Cargo.toml b/Cargo.toml index e80084e..3a4767c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ exclude = ["fuzz"] default-members = ["crates/core"] [workspace.package] -version = "0.0.1" +version = "0.1.0" edition = "2024" rust-version = "1.99" license = "GPL-3.0-or-later" diff --git a/README.md b/README.md index efe11a7..b19d983 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,25 @@ reference for compatibility. The comparison below is as of KeePassXC 2.7. If you need any of the features Keyrust lacks, KeePassXC is the right choice, and your database works in both. +## Download + +Installers are on the [Releases page](https://github.com/downlevel/keyrust/releases): + +| System | File | +|---|---| +| Windows 10 and 11 | `Keyrust_X.Y.Z_x64-setup.exe` (or the `.msi`, for managed deployment) | +| macOS, Intel and Apple Silicon | `Keyrust_X.Y.Z_universal.dmg` | +| Debian, Ubuntu and derivatives | `Keyrust_X.Y.Z_amd64.deb` | +| Other Linux distributions (x86-64) | `Keyrust_X.Y.Z_amd64.AppImage` | + +Check your download as described in [Verifying releases](SECURITY.md#verifying-releases). + +The installers are not code-signed for Windows or macOS yet (the release notes say when they are). +Windows SmartScreen shows *Windows protected your PC*: choose *More info* → *Run anyway*. macOS +refuses to open the app the first time: open *System Settings → Privacy & Security* and choose +*Open Anyway*. Some corporate computers do not allow unsigned software at all; there, build from +source (below) or ask your administrator. + ## Building Prerequisites for each OS are in [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md). In short: @@ -151,7 +170,8 @@ on Linux. See [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md). - [Product requirements](docs/PRD.md) · [Architecture](docs/ARCHITECTURE.md) · [Design](docs/DESIGN.md) · [Accessibility](docs/ACCESSIBILITY.md) -- [Roadmap](docs/TASKS.md) · [Development guide](docs/DEVELOPMENT.md) · [Contributing](CONTRIBUTING.md) +- [Roadmap](docs/TASKS.md) · [Development guide](docs/DEVELOPMENT.md) · [Releasing](docs/RELEASING.md) + · [Changelog](CHANGELOG.md) · [Contributing](CONTRIBUTING.md) - [Security policy and threat model](SECURITY.md) ## License diff --git a/SECURITY.md b/SECURITY.md index f2d8bd7..597a788 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -17,8 +17,8 @@ reporters are credited unless they prefer otherwise. | Version | Supported | |---|---| -| `0.1.x` | ✅ once released | -| `main` | ✅ best effort, until `0.1.0` is released | +| `0.1.x` | ✅ | +| `main` | ✅ best effort | | anything else | ❌ | ## Scope @@ -226,6 +226,54 @@ production CSP. ## Verifying releases -Starting with v0.1.0, release artifacts will be published with SHA-256 checksums and signatures, -and this section will explain how to verify them. Until then, build from source -([docs/DEVELOPMENT.md](docs/DEVELOPMENT.md)). +Every release on the [Releases page](https://github.com/downlevel/keyrust/releases) carries, next +to the installers: + +- `SHA256SUMS`: the SHA-256 of every installer; +- `SHA256SUMS.sigstore.json`: a [Sigstore cosign](https://docs.sigstore.dev/cosign/) signature of + `SHA256SUMS`. It is *keyless*: instead of a long-lived key, it binds the file to the GitHub + Actions run of this repository's release workflow for that tag, and is recorded in the public + Rekor transparency log. + +Verifying takes two steps: the signature proves that `SHA256SUMS` was produced by Keyrust's release +workflow, and the checksum proves that your installer is the one listed there. + +**1. Check the signature** (needs [cosign](https://docs.sigstore.dev/cosign/system_config/installation/) 3 +or later; replace `v0.1.0` with the release you downloaded): + +```sh +cosign verify-blob SHA256SUMS \ + --bundle SHA256SUMS.sigstore.json \ + --certificate-identity "https://github.com/downlevel/keyrust/.github/workflows/release.yml@refs/tags/v0.1.0" \ + --certificate-oidc-issuer https://token.actions.githubusercontent.com +``` + +It must print `Verified OK`. Any other identity means the file was not signed by a Keyrust release. + +**2. Check your installer** against its line of `SHA256SUMS` (you need only the installer you +downloaded, not all of them): + +```sh +# Linux +grep ' Keyrust_0.1.0_amd64.deb$' SHA256SUMS | sha256sum -c - +# macOS +grep ' Keyrust_0.1.0_universal.dmg$' SHA256SUMS | shasum -a 256 -c - +``` + +```powershell +# Windows (PowerShell) +$file = "Keyrust_0.1.0_x64-setup.exe" +$expected = (Select-String -Path SHA256SUMS -Pattern " $([regex]::Escape($file))$").Line.Split(" ")[0] +if ((Get-FileHash $file -Algorithm SHA256).Hash -eq $expected) { "OK" } else { "MISMATCH" } +``` + +The check must print `OK`. + +**Code signing.** Installers are signed for Windows (Authenticode) or macOS (Developer ID and +notarization) only when the maintainer has configured a certificate; the *Build* section of each +release's notes says which. Without it, SmartScreen and Gatekeeper warn before the first launch, +and the cosign check above is the way to know the installer is genuine. + +**Reproducibility.** Builds are reproducible on a best-effort basis; the release notes report +whether the Linux binary came out identical when built twice, and +[docs/RELEASING.md](docs/RELEASING.md#reproducing-a-build) explains how to rebuild it yourself. diff --git a/crates/app/tauri.release.macos-adhoc.json b/crates/app/tauri.release.macos-adhoc.json new file mode 100644 index 0000000..419fa2e --- /dev/null +++ b/crates/app/tauri.release.macos-adhoc.json @@ -0,0 +1,8 @@ +{ + "$schema": "https://schema.tauri.app/config/2", + "bundle": { + "macOS": { + "signingIdentity": "-" + } + } +} diff --git a/crates/app/ui/.node-version b/crates/app/ui/.node-version new file mode 100644 index 0000000..a43a5b9 --- /dev/null +++ b/crates/app/ui/.node-version @@ -0,0 +1 @@ +24.22.0 diff --git a/crates/app/ui/package.json b/crates/app/ui/package.json index e1c40e3..470be74 100644 --- a/crates/app/ui/package.json +++ b/crates/app/ui/package.json @@ -1,6 +1,6 @@ { "name": "keyrust-ui", - "version": "0.0.1", + "version": "0.1.0", "description": "Keyrust desktop UI (SvelteKit SPA rendered by Tauri)", "type": "module", "scripts": { diff --git a/crates/app/ui/svelte.config.js b/crates/app/ui/svelte.config.js index c4e5ebb..df8b24d 100644 --- a/crates/app/ui/svelte.config.js +++ b/crates/app/ui/svelte.config.js @@ -15,6 +15,12 @@ const config = { // The app has a single route and keeps its screen in state; hash routing // makes it independent of the page URL (Tauri and the web preview alike). router: { type: "hash" }, + // SvelteKit writes the version name into _app/version.json, which Tauri embeds in + // the binary. Its default is the build time: release builds take the commit time + // instead, so two builds of one commit produce the same bytes. + ...(process.env.SOURCE_DATE_EPOCH && { + version: { name: process.env.SOURCE_DATE_EPOCH }, + }), }, }; diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 214f5ef..089a464 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -180,13 +180,18 @@ per circa 1 s sulla macchina corrente. Cifratura AES-256 o ChaCha20 come previst ## Deploy - **Ambienti**: solo locale (`cargo tauri dev`) + release. -- **Pipeline release** (su tag `v*`): matrice tre OS → `tauri build` → artefatti firmati → bozza GitHub Release - con checksum SHA-256 e firma (minisign/cosign) degli artefatti. -- **Firma codice OS**: Windows (Authenticode) e macOS (Developer ID + notarizzazione) richiedono certificati a pagamento: - vedi Domande aperte. -- **Build riproducibili**: `Cargo.lock` e `pnpm-lock.yaml` committati, toolchain fissata (`rust-toolchain.toml`), - `SOURCE_DATE_EPOCH`; obiettivo "best effort" documentato nel README. -- **Segreti CI**: chiavi di firma come GitHub secrets, usate solo nel job di release. +- **Pipeline release** (`.github/workflows/release.yml`, su tag `v*` di un commit di `main`): matrice tre OS → + `tauri build` (NSIS + MSI, deb + AppImage, dmg universale) → `SHA256SUMS` firmato con **cosign keyless** (identità + OIDC del workflow, log Rekor) → **bozza** di GitHub Release, pubblicata a mano. Ogni altro evento è un dry run + senza release. Procedura in [RELEASING.md](RELEASING.md), verifica per gli utenti in `SECURITY.md`. +- **Firma codice OS**: **opzionale**, si attiva solo se esistono i secret dell'OS (Windows: Azure Trusted Signing + via `signCommand`; macOS: Developer ID + notarizzazione con chiave API). Senza secret gli installer escono non + firmati (macOS con firma ad hoc) e le note di release lo dichiarano. +- **Build riproducibili** ("best effort"): toolchain, Node e pnpm fissati, lockfile con `--locked` / + `--frozen-lockfile`, `SOURCE_DATE_EPOCH` (anche come versione di SvelteKit), percorsi rimappati, nessuna cache; + il job `reproducibility` ricostruisce due volte il binario Linux e riporta l'esito nelle note, senza bloccare. +- **Segreti CI**: solo i secret di firma codice, letti solo su push di tag e solo nello step di build che li usa; + cosign non ne richiede. ## Testing & osservabilità - **Unit test `core`**: generatore (distribuzione, vincoli), ricerca, gestione gruppi/voci, parametri KDF, errori. @@ -210,8 +215,8 @@ per circa 1 s sulla macchina corrente. Cifratura AES-256 o ChaCha20 come previst ## Domande aperte - **Supporto KDBX4 in scrittura di keepass-rs**: verificare maturità del feature flag di salvataggio KDBX4 e la preservazione lossless di campi custom/allegati/cronologia; se insufficiente, contribuire upstream (bonus da portfolio). -- **Firma codice Windows/macOS**: acquistare certificati (Apple Developer, Authenticode) o pubblicare in V1 solo - artefatti firmati con minisign/cosign + checksum? DA DEFINIRE. +- ~~Firma codice Windows/macOS~~: decisa in Milestone 4b. Checksum firmati con cosign keyless sempre; firma codice OS + opzionale, attivata dai secret (nessun certificato acquistato per v0.1.0). - ~~Libreria i18n~~: decisa in Milestone 1, Paraglide JS 2. - ~~Conflitti di sync~~: decisa in Milestone 3, rilevamento e avviso (Reload / Keep mine), niente merge in V1. - ~~Package manager frontend~~: pnpm. diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md index 7ecc88c..32d9afc 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -11,9 +11,9 @@ crates/app/tests/ Tauri security configuration tests crates/app/ keyrust-app: Tauri 2 crate (tauri.conf.json, capabilities/, icons/) crates/app/ui/ SvelteKit (SPA) + Svelte 5 + TypeScript + Tailwind + shadcn-svelte tests/fixtures/ KeePassXC-created test databases (test data only) -scripts/ helper scripts (fixture generation) +scripts/ helper scripts (fixture generation, release checks) fuzz/ cargo-fuzz targets (separate workspace, nightly) -.github/workflows/ CI +.github/workflows/ CI (ci.yml) and releases (release.yml) docs/ PRD, architecture, design, roadmap, plans, spikes ``` @@ -26,7 +26,7 @@ without the Tauri system libraries. Build the app explicitly with `-p keyrust-ap | Tool | Version | Notes | |---|---|---| | Rust (rustup) | pinned by `rust-toolchain.toml` (1.99.1) | rustup installs it on first use | -| Node.js | 22+ | | +| Node.js | 24 (CI and releases use the exact version in `crates/app/ui/.node-version`) | | | pnpm | 12 (via `corepack enable pnpm`) | version pinned in `crates/app/ui/package.json` | | KeePassXC | 2.7+ | provides `keepassxc-cli` for the compatibility tests | | cargo-deny | latest | `cargo install cargo-deny --locked` | @@ -147,6 +147,9 @@ Download it from the run page on GitHub (*Actions* → run → *Artifacts*). The Windows SmartScreen and macOS Gatekeeper will warn because they are not signed (on macOS: right click → Open). +Releases are built by a separate workflow, `.github/workflows/release.yml`: see +[RELEASING.md](RELEASING.md). + ## Web preview The UI runs in a plain browser too: outside Tauri it uses the demo vault and in-memory settings diff --git a/docs/RELEASING.md b/docs/RELEASING.md new file mode 100644 index 0000000..4165d41 --- /dev/null +++ b/docs/RELEASING.md @@ -0,0 +1,163 @@ +# Releasing Keyrust + +Releases are built by [`.github/workflows/release.yml`](../.github/workflows/release.yml). A tag +`vX.Y.Z` on a commit of `main` builds the installers on GitHub's runners, signs their checksums +with [cosign](https://docs.sigstore.dev/cosign/) and creates a **draft** GitHub Release. Nothing +is public until a maintainer publishes the draft. + +## What a release contains + +| File | Platform | +|---|---| +| `Keyrust_X.Y.Z_x64-setup.exe` | Windows installer (NSIS) | +| `Keyrust_X.Y.Z_x64_en-US.msi` | Windows installer (MSI, for managed deployment) | +| `Keyrust_X.Y.Z_amd64.deb` | Debian, Ubuntu and derivatives | +| `Keyrust_X.Y.Z_amd64.AppImage` | Other Linux distributions | +| `Keyrust_X.Y.Z_universal.dmg` | macOS, Intel and Apple Silicon | +| `SHA256SUMS` | SHA-256 of the five installers | +| `SHA256SUMS.sigstore.json` | cosign signature bundle of `SHA256SUMS` | + +How users verify them is in [SECURITY.md](../SECURITY.md#verifying-releases). + +## Making a release + +1. On a branch, set the new version in `Cargo.toml` (`[workspace.package] version`) and in + `crates/app/ui/package.json`, update the `keyrust-*` entries of `Cargo.lock` and + `fuzz/Cargo.lock` (`cargo metadata --offline` in both workspaces does it without touching other + dependencies), and move the `[Unreleased]` notes of `CHANGELOG.md` under a `## [X.Y.Z]` + heading. `scripts/release/check-version.sh vX.Y.Z` must print the version. +2. Open a pull request, wait for CI, merge it. +3. Tag the merge commit on `main` and push the tag: + + ```sh + git switch main && git pull + git tag vX.Y.Z # or `git tag -s vX.Y.Z` to sign the tag with your key + git push origin vX.Y.Z + ``` + +4. Watch the **Release** workflow. When it is green, open the draft on the Releases page, read the + notes (the CHANGELOG section plus a *Build* section: code-signing status and the reproducibility + check) and download one installer to verify it as described in SECURITY.md. +5. Publish the draft. + +### If the workflow fails + +- **verify** fails when the tag does not match the version, the tagged commit is not on `main`, or + only part of the code-signing secrets of an OS exists. Fix the cause; to move a tag that was + never published: `git push --delete origin vX.Y.Z && git tag -d vX.Y.Z`, then tag again. +- A **build**, **checksums and signature** or **draft release** failure can be rerun from the + Actions page (*Re-run failed jobs*). Rerunning a release whose draft already exists replaces its + assets and notes; a published release is never modified, the job fails instead. +- A wrong draft can be deleted from the Releases page; the tag stays and can be reused. + +### Dry runs + +Every run that is not a pushed tag is a dry run: same builds, same checksums, same cosign +signature, no release and no OS code signing. The result is the `keyrust-release-dryrun` artifact +of the run (kept 7 days). Dry runs start: + +- on pull requests to `main` that change the release workflow, `scripts/release/` or the Tauri + configuration. Pull requests from forks and Dependabot get no OIDC token from GitHub, so their + dry run skips the cosign signature; +- by hand from the Actions page (*Release* → *Run workflow*), on any branch or tag. + +## Code signing (optional) + +Without code signing, Windows SmartScreen and macOS Gatekeeper warn before the first launch, and +some corporate machines refuse unsigned installers entirely. The workflow signs automatically as +soon as the secrets of an OS exist; without them it still produces every installer, unsigned +(macOS builds get an ad-hoc signature, without which the app does not start on Apple Silicon). +Secrets are read only for a pushed tag, never for pull requests or manual runs. + +All the secrets and variables of an OS must be set: a partial set makes the **verify** job fail +rather than silently produce unsigned installers. + +Prices and eligibility change: check them when you sign up. + +### Windows + +| Option | Cost | Status in the workflow | +|---|---|---| +| [Azure Trusted Signing](https://learn.microsoft.com/azure/trusted-signing/) | Monthly subscription (about 10 USD/month at the time of writing); identity validation; eligibility for individuals depends on the country | **Wired**: set the secrets below | +| [SignPath Foundation](https://signpath.org/) | Free for open-source projects, after an application | Not wired: SignPath signs files uploaded to its service, so the workflow needs a signing step of its own | +| OV/EV certificate from a certificate authority | Yearly fee; the key lives on a hardware token or a cloud HSM | Not wired: a hardware token cannot be used from GitHub's runners | + +Azure Trusted Signing uses [`trusted-signing-cli`](https://crates.io/crates/trusted-signing-cli) +through Tauri's `bundle.windows.signCommand`, which signs the app binary and both installers. + +| Name | Kind | Value | +|---|---|---| +| `AZURE_CLIENT_ID` | secret | Client ID of the app registration allowed to sign | +| `AZURE_CLIENT_SECRET` | secret | Its client secret | +| `AZURE_TENANT_ID` | secret | The Azure tenant | +| `AZURE_SIGNING_ENDPOINT` | variable | The account's endpoint, e.g. `https://weu.codesigning.azure.net` | +| `AZURE_SIGNING_ACCOUNT` | variable | The Trusted Signing account name | +| `AZURE_SIGNING_PROFILE` | variable | The certificate profile name | + +Secrets and variables are set under *Settings → Secrets and variables → Actions*. + +Even when signed, a new certificate has no SmartScreen reputation yet, and a corporate policy may +still block software that is not on its allow list. + +### macOS + +Signing and notarization need the [Apple Developer Program](https://developer.apple.com/programs/) +(99 USD/year at the time of writing). Tauri signs with the *Developer ID Application* certificate +and notarizes with an App Store Connect API key. + +| Name | Kind | Value | +|---|---|---| +| `APPLE_CERTIFICATE` | secret | The *Developer ID Application* certificate and key, exported as `.p12`, base64-encoded | +| `APPLE_CERTIFICATE_PASSWORD` | secret | The password of the `.p12` | +| `APPLE_SIGNING_IDENTITY` | secret | The identity name, e.g. `Developer ID Application: Name (TEAMID)` | +| `APPLE_API_ISSUER` | secret | Issuer ID of the App Store Connect API key | +| `APPLE_API_KEY` | secret | Key ID of that API key | +| `APPLE_API_PRIVATE_KEY` | secret | The `.p8` private key, base64-encoded | + +> **Not yet exercised.** No certificate has been configured so far, so the signed paths of the +> workflow have not run. The first signed release should be checked by hand: `signtool verify /pa` +> on Windows, `spctl -a -vv` and `stapler validate` on macOS. + +## Reproducing a build + +Releases are reproducible on a best-effort basis: the inputs are pinned and the build is +normalised, and every release run rebuilds the Linux binary twice to check it. The installers +themselves (`.deb`, AppImage, `.dmg`, `.msi`, NSIS) are **not** claimed to be bit-for-bit +reproducible: they contain timestamps and tool output of their own. + +What is pinned or normalised: + +- Rust toolchain (`rust-toolchain.toml`), Node (`crates/app/ui/.node-version`) and pnpm + (`packageManager` in `crates/app/ui/package.json`); dependencies from `Cargo.lock` (`--locked`) + and `pnpm-lock.yaml` (`--frozen-lockfile`); GitHub Actions pinned to commit SHAs. +- `SOURCE_DATE_EPOCH` set to the commit time; SvelteKit uses it as its version name, which would + otherwise be the build time embedded in the binary (`crates/app/ui/svelte.config.js`). +- Absolute paths remapped by `scripts/release/rustflags.sh` (checkout → `/build`, Cargo home → + `/cargo`, rustup home → `/rustup`). +- No build cache. + +Not pinned: the runner images (`ubuntu-24.04` changes with updates, `windows-latest` and +`macos-latest` move between versions) and the system libraries they provide. + +The **reproducibility** job compares the two rebuilds; its result (`match`, `mismatch` or +`not available`) is in the run summary and in the release notes. It never blocks a release. + +To rebuild the Linux binary of a release yourself, on Ubuntu 24.04 (or in an `ubuntu:24.04` +container) with the [Tauri prerequisites](DEVELOPMENT.md#linux-debianubuntu), rustup, Node and +pnpm at the pinned versions: + +```sh +git clone https://github.com/downlevel/keyrust && cd keyrust +git checkout vX.Y.Z +export SOURCE_DATE_EPOCH=$(git log -1 --format=%ct) +export RUSTFLAGS="$(scripts/release/rustflags.sh)" +cd crates/app/ui +pnpm install --frozen-lockfile +pnpm tauri build --target x86_64-unknown-linux-gnu --no-bundle -- --locked +sha256sum ../../../target/x86_64-unknown-linux-gnu/release/keyrust +``` + +Compare the hash with the *Reproducibility check* line of the release notes. The binary inside the +`.deb` (`dpkg-deb -x Keyrust_X.Y.Z_amd64.deb out && sha256sum out/usr/bin/keyrust`) can differ from +it, because the Tauri bundler may patch the binary while packaging it; the run summary of the +**reproducibility** job shows both hashes. diff --git a/docs/TASKS.md b/docs/TASKS.md index 20a9161..2406192 100644 --- a/docs/TASKS.md +++ b/docs/TASKS.md @@ -76,10 +76,11 @@ - [x] `DatabaseInfo.version` segue il file su disco anche dopo un salvataggio rifiutato (4a) ### 4b — rilascio -- [ ] Pipeline di release su tag: build tre OS, checksum SHA-256, firma artefatti (minisign/cosign), bozza GitHub Release -- [ ] Decidere ed eventualmente configurare la firma codice Windows (Authenticode) e macOS (Developer ID + notarizzazione) -- [ ] Build riproducibili "best effort" (`SOURCE_DATE_EPOCH`, lockfile, toolchain fissata) e documentazione per verificarle -- [ ] Release `v0.1.0` +- [x] Pipeline di release su tag: build tre OS, checksum SHA-256, firma artefatti (cosign keyless), bozza GitHub Release (4b) +- [x] Decidere ed eventualmente configurare la firma codice Windows (Authenticode) e macOS (Developer ID + notarizzazione): + opzionale, attivata dai secret; nessun certificato per ora (4b, [RELEASING.md](RELEASING.md#code-signing-optional)) +- [x] Build riproducibili "best effort" (`SOURCE_DATE_EPOCH`, lockfile, toolchain fissata) e documentazione per verificarle (4b) +- [ ] Release `v0.1.0` *(task utente: tag `v0.1.0` su `main` dopo il merge, poi pubblicare la bozza — [RELEASING.md](RELEASING.md#making-a-release))* ## Dopo l'MVP (V2) - [ ] Keyfile diff --git a/docs/plans/milestone-4b-review-log.md b/docs/plans/milestone-4b-review-log.md new file mode 100644 index 0000000..92394a6 --- /dev/null +++ b/docs/plans/milestone-4b-review-log.md @@ -0,0 +1,49 @@ +# Log di revisione — Milestone 4b (pipeline di release, firma, build riproducibili, v0.1.0) + +- Ruoli: host/planner/builder **Claude** (Claude Code, Opus 5.5), reviewer e inspector **Codex** (CLI 0.165.0, modello di default, `--effort high`). +- Piano: `docs/plans/milestone-4b.md`. Base `0325d9a`, branch `milestone-4b`. +- Autorizzazione: preparare il piano con claudex-loop; implementazione solo su conferma dell'utente; push solo sul branch; tag e release all'utente. +- Decisioni utente (2026-10-29): firma codice OS opzionale (attiva con i secret); cosign keyless; pacchetti NSIS+MSI, deb+AppImage, dmg universale; dry run senza release, tag `v0.1.0` creato dall'utente. +- Limiti: MAX_ROUNDS=5, MAX_FIX_ROUNDS=2, MAX_INSPECTION_ROUNDS=2, inspect=on. + +## Round 1 — Codex codex-cli 0.165.0 (gpt-6.1-sol, effort high; sessione 01a18806-07e0-7272-894f-206767415ecd) — REVISE (1 high, 5 medium, 1 low) — plan sha256 73344e41…dfb +- Result: `/tmp/claude-0/-opt-apps-password-manager/396c1774-6943-4819-a44e-4e13330ae930/scratchpad/claudex/r1/claudex-vn6xsixz/result.json` +- M4B-R01 (high) gli installer sono 5, non 6 (asset release 7, non 8) → ACCETTATO. +- M4B-R02 (medium) SvelteKit scrive `Date.now()` in `_app/version.json`, incorporato nel binario → ACCETTATO (verificato): `kit.version.name` da `SOURCE_DATE_EPOCH`. +- M4B-R03 (medium) i permessi valgono per job: `contents: write` e OIDC nello stesso job anche in dry run → ACCETTATO: job `sign` e `release` separati. +- M4B-R04 (medium) PR da fork/Dependabot senza OIDC → ACCETTATO: lì niente firma, dichiarato nel summary. +- M4B-R05 (medium) l'esito della riproducibilità non arrivava alle note → ACCETTATO: `release` attende `reproducibility` senza esserne bloccato. +- M4B-R06 (medium) `sha256sum` assente su macOS e verifica di un solo installer → ACCETTATO. +- M4B-R07 (low) `fuzz/Cargo.lock` registra `keyrust-core` 0.0.1 → ACCETTATO. + +## Round 2 — stessa sessione — REVISE (1 medium) — plan sha256 a85a2750…087 +- Result: `/tmp/claude-0/-opt-apps-password-manager/396c1774-6943-4819-a44e-4e13330ae930/scratchpad/claudex/r2/claudex-qlrhaay8/result.json`. M4B-R01…R07 risolti secondo il reviewer. +- M4B-R08 (medium) un `workflow_dispatch` su un tag avrebbe avviato il job `release` → ACCETTATO: un solo predicato `release` (push di tag) calcolato in `verify` e usato ovunque. + +## Round 3 — stessa sessione — **APPROVED**, 0 findings — plan sha256 3147bcd6…071 +- Result: `/tmp/claude-0/-opt-apps-password-manager/396c1774-6943-4819-a44e-4e13330ae930/scratchpad/claudex/r3/claudex-sem_dyuc/result.json`. Limiti dichiarati: approvazione del piano, non dell'implementazione; revisione statica; impostazioni GitHub, credenziali di firma e installer non verificati. + +## Build — Claude (builder), base `612bc2d` +- Autorizzazione: l'utente ha confermato l'implementazione il 2026-10-29, precisando che la strada senza firma codice + (nessuna spesa) dev'essere pienamente funzionante. Approvazione del piano verificata (`runner.py check`). +- Prove locali: actionlint 1.7.12 (con shellcheck) su `release.yml` e `ci.yml` → 0 errori; shellcheck su + `scripts/release/*.sh` → 0; `check-version.sh` (senza tag, `v0.1.0` → 0; `v0.1.1`, `v0.2.0`, `0.1.0` → 1); + `changelog-section.sh` (0.1.0 → sezione senza link finali; 9.9.9, Unreleased → 1); `check-assets.sh` (5 file → 0; + mancante/extra → 1 con elenco); override Tauri (ad hoc macOS e `signCommand` Windows generato) validi contro + `config.schema.json` di `@tauri-apps/cli` 2.12.4 dopo il merge con `tauri.conf.json`; due `pnpm build` con lo stesso + `SOURCE_DATE_EPOCH` → `diff -r` identico, senza → diversi; `pnpm lint/format:check/check/test` (250 test) verdi; + `cargo metadata --locked --offline` nei due workspace; `cargo test -p keyrust-core` verde. +- Deviazioni dal piano: l'override Windows non è un file committato ma è generato nello step (endpoint, account e + profilo vengono da variabili del repository); la riproducibilità usa due job `rebuild` paralleli (due runner, due + cartelle) più il job `reproducibility` che confronta; `fuzz/Cargo.lock` era già disallineato da 4a (mancava + `roxmltree`), riallineato alla stessa versione del lockfile principale; la verifica di partial secrets fa fallire + `verify` invece di produrre installer non firmati in silenzio. + +## Ispezione 1 — Codex codex-cli 0.165.0 (gpt-6.1-sol, effort high; sessione nuova 01a1881c-7abb-7302-9b16-98696776fe42) — REVISE (1 medium) — base `612bc2d`, snapshot `ad07ef9` +- Un primo avvio (`/tmp/claude-0/-opt-apps-password-manager/396c1774-6943-4819-a44e-4e13330ae930/scratchpad/claudex/i1`) con `--host codex` errato è stato interrotto dall'host prima del risultato (record rimasto `running`); non conta come ispezione. +- Result: `/tmp/claude-0/-opt-apps-password-manager/396c1774-6943-4819-a44e-4e13330ae930/scratchpad/claudex/i1b/claudex-jqwl7p0u/result.json` +- M4B-I01 (medium) `SHA256SUMS` scritto nella cartella espansa da `sha256sum -- *`: una corsa può includerlo con l'hash del file vuoto e far fallire `sha256sum -c` → ACCETTATO: manifesto scritto in `$RUNNER_TEMP` e spostato in `dist` dopo; actionlint e simulazione dello step verdi. + +## Ispezione 2 — Codex, sessione nuova 01a18823-6d4d-79e1-9761-211499970e7e — **APPROVED**, 0 findings — snapshot `7d41d12` +- Result: `/tmp/claude-0/-opt-apps-password-manager/396c1774-6943-4819-a44e-4e13330ae930/scratchpad/claudex/i2/claudex-2xklbt_v/result.json` +- Limiti dichiarati: revisione statica; installer, riproducibilità, firma OIDC e firma con certificati non verificati; impostazioni GitHub e mapping SHA→release delle action non verificati. Il dry run sulla PR resta la prova pendente. diff --git a/docs/plans/milestone-4b.md b/docs/plans/milestone-4b.md new file mode 100644 index 0000000..09c7ea6 --- /dev/null +++ b/docs/plans/milestone-4b.md @@ -0,0 +1,244 @@ +# Piano — Milestone 4b (pipeline di release, firma, build riproducibili, v0.1.0) di Keyrust + +Riferimenti: `docs/TASKS.md` § "4b — rilascio", `docs/ARCHITECTURE.md` § Deploy e Domande aperte, `SECURITY.md` +§ "Verifying releases", `README.md`, `docs/DEVELOPMENT.md`, `.github/workflows/ci.yml`, `crates/app/tauri.conf.json`. +Base: `main` @ `0325d9a`. Branch: `milestone-4b`. + +## Obiettivo +1. Un **workflow di release** (`.github/workflows/release.yml`) che, su tag `v*` di un commit di `main`, costruisce + l'app in release sui tre OS, calcola i checksum SHA-256, li **firma con cosign keyless** e crea una **bozza** di + GitHub Release con installer, `SHA256SUMS` e bundle di firma. La pubblicazione della bozza resta manuale. +2. **Firma codice OS opzionale**: Windows (Authenticode) e macOS (Developer ID + notarizzazione) si attivano solo se + i secret corrispondenti esistono; senza secret la release esce non firmata a livello OS, e il log lo dice. +3. **Build riproducibili "best effort"**: input fissati, timestamp e percorsi normalizzati, un controllo automatico + che ricostruisce il binario Linux due volte e confronta gli hash, e la procedura documentata per verificarlo. +4. Il repository è **pronto per `v0.1.0`**: versione 0.1.0 ovunque, `CHANGELOG.md`, documentazione di download e + verifica. Il tag lo crea e lo pusha l'utente dopo il merge. + +## Contesto e vincoli (confermati) +- **Decisioni dell'utente (2026-10-29)**: + - (a) firma degli artefatti: **cosign keyless** (Sigstore, identità OIDC del workflow GitHub), niente minisign; + - (b) pacchetti: Windows **NSIS + MSI**, Linux **.deb + AppImage**, macOS **un .dmg universale** (x86_64 + arm64); + - (c) firma codice Windows/macOS: **opzionale**, attivata dalla presenza dei secret; nessun certificato acquistato ora; + - (d) prova: un **dry run** che costruisce e firma senza creare release; il tag `v0.1.0` lo crea **l'utente** dopo + il merge, la bozza la pubblica l'utente. +- **Fatti dal repository**: + - toolchain Rust già fissata: `rust-toolchain.toml` → `1.99.1` (profilo minimal, `rustfmt`, `clippy`); + - lockfile committati: `Cargo.lock`, `crates/app/ui/pnpm-lock.yaml` (`@tauri-apps/cli` 2.12.4, crate `tauri` 2.12.5); + `packageManager: pnpm@12.15.0`; Node in CI è `24` (non una versione esatta); + - `[profile.release]` già con `lto = true`, `codegen-units = 1`, `strip = true`, `panic = "abort"`; + - `tauri.conf.json` non ha `version` → Tauri usa la versione del crate (`workspace.package.version = "0.0.1"`); + `ui/package.json` è `0.0.1`; `bundle.targets = "all"`, nessuna configurazione `windows`/`macOS` di firma; + - la CI esistente (`ci.yml`) costruisce già bundle **debug** non firmati su PR e `main` (`nsis`, `deb`, `dmg`); + le action sono fissate a SHA; `permissions: contents: read` a livello di workflow; + - `SECURITY.md` § "Verifying releases" e `ARCHITECTURE.md` § Domande aperte ("Firma codice Windows/macOS … DA + DEFINIRE") vanno chiusi; + - un workflow `workflow_dispatch` si può avviare solo se il file esiste sul branch di default: finché `release.yml` + è solo su `milestone-4b`, il dry run deve partire da un altro evento (§ 1.1). +- **Macchina di sviluppo**: niente WebKitGTK né build Tauri locali, ~3 GB liberi → il workflow si verifica in CI; + localmente solo lint statico (actionlint/YAML) e i test esistenti. +- **Macchina di test dell'utente**: PC Windows aziendale che blocca installer non firmati. Questa milestone non lo + risolve finché non c'è un certificato Authenticode: va detto nella documentazione, senza promettere altro. +- **Autorizzato**: commit e push su `milestone-4b`. **Non autorizzato**: push su `main`, creazione di tag o release + (li fa l'utente). L'implementazione parte solo dopo l'approvazione del piano e la conferma dell'utente. + +## Criteri di accettazione + +### 1. Workflow di release (`.github/workflows/release.yml`) +1. **Eventi**: + - `push` di tag `v*` → release vera (bozza); + - `workflow_dispatch` → dry run (utile dopo il merge, quando il file è su `main`); + - `pull_request` verso `main` con `paths` limitati a `.github/workflows/release.yml`, `scripts/release/**`, + `crates/app/tauri.conf.json`, `crates/app/tauri.release*.json` → dry run, così la pipeline si prova sulla PR di + questa milestone senza creare tag. Nessun secret di firma è esposto agli eventi `pull_request` (§ 2.4). + - Dry run = stesse build, stessi checksum e (dove possibile) stessa firma cosign; gli output vanno in un artifact + del workflow (`keyrust-release-dryrun`, retention 7 giorni) invece che in una release. + - **PR da fork e di Dependabot** (revisione M4B-R04): non hanno token OIDC. Lì il dry run fa build, checksum e + riproducibilità, ma **salta la firma cosign** e lo scrive nel summary (`Signature: skipped (no OIDC token on + fork/Dependabot PRs)`). La firma nel dry run avviene solo per PR dello stesso repository + (`github.event.pull_request.head.repo.full_name == github.repository` e `github.actor != 'dependabot[bot]'`) e + per `workflow_dispatch`. +2. **Permessi**: `permissions: {}` a livello di workflow; ogni job dichiara solo ciò che usa. Poiché i permessi valgono + per l'intero job (revisione M4B-R03), firma e pubblicazione sono **job separati**: `build` e `reproducibility` → + `contents: read`; `sign` → `contents: read` + `id-token: write`; `release` (solo su tag) → `contents: write`, senza + `id-token`. `concurrency` per ref, senza cancellare una release in corso. +3. **Job `verify`** (ubuntu): su tag controlla che + - il tag sia esattamente `v` + `workspace.package.version` di `Cargo.toml` e uguale alla `version` di + `crates/app/ui/package.json` (script `scripts/release/check-version.sh`, testabile in locale); + - il commit del tag sia raggiungibile da `origin/main` (`git merge-base --is-ancestor`), così un tag su un branch + non pubblica nulla. + Calcola e passa agli altri job `SOURCE_DATE_EPOCH` = timestamp del commit (`git log -1 --format=%ct`) e l'output + **`release`** = `true` solo se `github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')` (revisione + M4B-R08). È l'**unico predicato** che seleziona il comportamento da release vera: controlli del tag, nome + dell'artifact (`keyrust-release` vs `keyrust-release-dryrun`), firma codice OS (§ 2.4) e job `release`. Un + `workflow_dispatch` lanciato su un tag esistente resta quindi un dry run. +4. **Job `build`** (matrice): + + | OS runner | target | bundle | + |---|---|---| + | `ubuntu-24.04` | `x86_64-unknown-linux-gnu` | `deb,appimage` | + | `windows-latest` | `x86_64-pc-windows-msvc` | `nsis,msi` | + | `macos-latest` | `universal-apple-darwin` (aggiunge `x86_64-apple-darwin` e `aarch64-apple-darwin` con rustup) | `dmg` | + + Passi: checkout (stesso SHA dell'action di `ci.yml`), toolchain da `rust-toolchain.toml`, prerequisiti Linux + come in `ci.yml` (più quanto serve all'AppImage, se manca), pnpm, Node con versione **esatta** da + `crates/app/ui/.node-version` (nuovo file, usato anche da `ci.yml` per coerenza), `pnpm install --frozen-lockfile`, + poi `pnpm tauri build --target --bundles [--config ] -- --locked`. + **Nessuna cache** (`rust-cache`, cache pnpm) nel workflow di release: una cache avvelenata da un altro branch non + deve poter finire in un artefatto firmato; la build release è più lenta e va bene così. + Ambiente: `SOURCE_DATE_EPOCH` dal job `verify` e `RUSTFLAGS` con `--remap-path-prefix` per la cartella di lavoro, + `$CARGO_HOME` e la home di rustup (§ 3). + Ogni job carica gli installer prodotti (solo i file di bundle, non tutta `target/`) come artifact + `bundle-`, con un nome file che contiene versione e architettura (es. `Keyrust_0.1.0_amd64.deb`, + `Keyrust_0.1.0_x64-setup.exe`, `Keyrust_0.1.0_x64_en-US.msi`, `Keyrust_0.1.0_universal.dmg`): quelli di Tauri se + già univoci, altrimenti rinominati in uno step esplicito. + Ogni job scrive nel `$GITHUB_STEP_SUMMARY` lo stato della firma codice: `Code signing: skipped (no secrets)` o + `Code signing: Authenticode (Azure Trusted Signing)` / `Developer ID + notarization`. +5. **Job `sign`** (ubuntu, dipende da `build`; `contents: read`, `id-token: write`): + - scarica gli artifact, verifica che ci siano **esattamente i 5 installer** attesi (revisione M4B-R01): `.deb` e + `.AppImage` amd64, NSIS `-setup.exe` e `.msi` x64, `.dmg` universale, ciascuno con la versione nel nome; fallisce + altrimenti, elencando quelli mancanti o in più; + - genera `SHA256SUMS` (formato `sha256sum`, nomi senza percorso, ordinati); + - installa cosign con `sigstore/cosign-installer` fissato a SHA (versione cosign esatta) e firma: + `cosign sign-blob --yes --bundle SHA256SUMS.sigstore.json SHA256SUMS` (saltata solo nei casi di § 1.1 senza + OIDC); + - **verifica subito** la propria firma con `cosign verify-blob` e l'identità attesa (stesso comando documentato in + `SECURITY.md`, con il ref effettivo), e `sha256sum -c SHA256SUMS`; + - carica installer, `SHA256SUMS` e (se c'è) `SHA256SUMS.sigstore.json` come artifact `keyrust-release-dryrun` in + dry run, o `keyrust-release` su tag (input del job `release`). +6. **Job `release`** (ubuntu, **solo su push di tag**, `contents: write`; `needs: [verify, sign, reproducibility]` con + `if: always() && needs.sign.result == 'success' && needs.verify.outputs.release == 'true'`, così un mismatch o un + errore di riproducibilità non blocca la release ma la bozza aspetta il suo esito — revisione M4B-R05): + - scarica l'artifact `keyrust-release` e controlla che contenga esattamente **7 asset** (5 installer, + `SHA256SUMS`, `SHA256SUMS.sigstore.json`); + - note = sezione della versione estratta da `CHANGELOG.md` (script `scripts/release/changelog-section.sh`, + fallisce se la sezione manca) + una riga "Reproducibility check" generata dall'esito del job `reproducibility` + (`match` con l'hash, `mismatch` con i due hash, o `not available` se il job è fallito); + - `gh release create --draft --verify-tag --title "Keyrust " --notes-file ` con i 7 asset. + Se la bozza esiste già (rilancio del workflow) gli asset si aggiornano con `gh release upload --clobber` e le note + con `gh release edit`; se la release è già **pubblicata**, il job fallisce senza toccarla. +7. Nessuna action nuova senza SHA fissato; le action nuove (`sigstore/cosign-installer`, eventualmente + `actions/download-artifact`) hanno il SHA del tag di release indicato in commento, come in `ci.yml`. + +### 2. Firma codice OS opzionale +1. **macOS** (supporto nativo di Tauri): se il secret `APPLE_CERTIFICATE` esiste, lo step di build riceve + `APPLE_CERTIFICATE`, `APPLE_CERTIFICATE_PASSWORD`, `APPLE_SIGNING_IDENTITY` e, per la notarizzazione, + `APPLE_API_ISSUER`, `APPLE_API_KEY` e il file della chiave API (`APPLE_API_KEY_PATH`, scritto da un secret base64 + in `$RUNNER_TEMP` e cancellato a fine job). Senza secret: firma **ad hoc** (`signingIdentity: "-"`) tramite + l'override `crates/app/tauri.release.macos-adhoc.json`, così l'app parte su Apple Silicon dopo l'approvazione + manuale di Gatekeeper. +2. **Windows**: se i secret di **Azure Trusted Signing** (`AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`, + `AZURE_TENANT_ID`, più le variabili `AZURE_SIGNING_ENDPOINT`, `AZURE_SIGNING_ACCOUNT`, + `AZURE_SIGNING_PROFILE`) esistono, il job installa `trusted-signing-cli` (versione esatta, `cargo install --locked`) + e passa a Tauri un override con `bundle.windows.signCommand` che lo invoca su `%1`: Tauri firma così l'eseguibile, + l'installer NSIS e l'MSI. Senza secret: nessun override, build non firmata. +3. La presenza dei secret si rileva in uno step che espone solo un booleano (`steps.signing.outputs.macos == 'true'`); + i valori dei secret entrano solo nell'`env` dello step di build che li usa, mai a livello di job o workflow. +4. Quando `needs.verify.outputs.release != 'true'` (`pull_request` e ogni `workflow_dispatch`, anche su un tag) la + firma codice è **sempre disattivata** (i secret non vengono + letti): solo un tag di `main` produce binari firmati. +5. **Documentazione** (`docs/RELEASING.md`, nuovo): come attivare ogni opzione, con costi e vincoli indicati come + "verificare al momento dell'acquisto": + - Windows: **Azure Trusted Signing** (cablato), **SignPath Foundation** (gratuito per OSS, su candidatura; firma + tramite il loro servizio dopo la build: richiede di adattare il workflow, non cablato ora), **certificato OV/EV** + su token hardware (non usabile su runner ospitati senza servizio di firma remoto); + - macOS: **Apple Developer Program** (99 $/anno), certificato "Developer ID Application" esportato in `.p12`, + chiave API App Store Connect per la notarizzazione; + - avvertenza: anche con firma, SmartScreen può avvisare finché il certificato non ha reputazione, e una policy + aziendale può bloccare comunque. +6. **Limite dichiarato**: i percorsi con secret non si possono provare in CI finché i secret non esistono. Il piano + verifica il percorso "senza secret" e la correttezza statica degli override (JSON valido, schema Tauri, comando + `signCommand` con `%1`). + +### 3. Build riproducibili (best effort) +1. **Input fissati**: toolchain Rust (`rust-toolchain.toml`), Node esatto (`.node-version`), pnpm esatto + (`packageManager`), `--frozen-lockfile` e `cargo … --locked`, action fissate a SHA, runner con immagine nominata + (`ubuntu-24.04`; per Windows e macOS l'immagine `-latest` cambia nel tempo: documentato come limite). +2. **Normalizzazione**: `SOURCE_DATE_EPOCH` = data del commit; `--remap-path-prefix` per checkout, `CARGO_HOME` e + rustup, così i percorsi assoluti non entrano nel binario (con `strip = true` restano comunque pochi). + **Versione del frontend** (revisione M4B-R02): SvelteKit, se `kit.version.name` non è impostato, usa + `Date.now()` e lo scrive in `_app/version.json`, che Tauri incorpora nel binario. `crates/app/ui/svelte.config.js` + imposta `kit.version.name` a `process.env.SOURCE_DATE_EPOCH` quando è definita (build di release, entrambe le + ricostruzioni e la procedura documentata), altrimenti lascia il default (sviluppo). Prova locale: due `pnpm build` + con lo stesso `SOURCE_DATE_EPOCH` producono `build/` identiche (`diff -r`). +3. **Controllo automatico** (job `reproducibility`, ubuntu, su tag e in dry run, `contents: read`): costruisce + `keyrust` (solo il binario, `pnpm tauri build --no-bundle -- --locked`, frontend incluso) **due volte in due + cartelle diverse** con lo stesso ambiente e confronta gli SHA-256. Espone come output del job l'esito (`match` / + `mismatch`) e gli hash, letti dal job `release` (§ 1.6), e li scrive nel `$GITHUB_STEP_SUMMARY` insieme all'hash del + binario dentro il `.deb` della build ufficiale. Il job è **informativo**: un mismatch non fallisce il job (esito + `mismatch` nell'output), un errore di build lo fa fallire ma non blocca la release (`not available` nelle note). + Gli installer (deb, AppImage, dmg, msi) **non** sono dichiarati riproducibili bit per bit. +4. **Documentazione** in `docs/RELEASING.md` § "Reproducing a build": comandi per ricostruire il binario Linux da un + tag (stessa toolchain, stesse variabili, container `ubuntu:24.04` o runner equivalente) e confrontarlo con quello + estratto dal `.deb` (`dpkg-deb -x`), con i limiti noti. + +### 4. Preparazione di v0.1.0 +1. Versione `0.1.0` in `Cargo.toml` (`workspace.package.version`), `Cargo.lock` aggiornato di conseguenza (solo le + righe dei crate del workspace: `cargo update --workspace` offline o modifica equivalente, nessun aggiornamento di + dipendenze), `fuzz/Cargo.lock` (riga `keyrust-core`, workspace separato con dipendenza per percorso — revisione + M4B-R07), `crates/app/ui/package.json`. `check-version.sh` passa con `v0.1.0`. +2. `CHANGELOG.md` (formato Keep a Changelog) con la sezione `## [0.1.0]` che riassume le funzionalità dell'MVP e i + limiti noti (nessuna firma codice OS se non configurata, auto-lock, KDBX 3.1/4.0 convertiti a 4.1 al salvataggio). +3. **Documentazione**: + - `SECURITY.md` § "Verifying releases": verifica di `SHA256SUMS` con cosign (comando completo con + `--certificate-identity` del workflow `release.yml` al ref del tag e `--certificate-oidc-issuer + https://token.actions.githubusercontent.com`), poi la verifica **del solo installer scaricato** contro la sua + riga di `SHA256SUMS` (revisione M4B-R06): Linux `grep ' $' SHA256SUMS | sha256sum -c -`, macOS + `grep ' $' SHA256SUMS | shasum -a 256 -c -` (`sha256sum` non c'è di serie), Windows confronto in PowerShell + tra `(Get-FileHash -Algorithm SHA256).Hash` e la riga del file; stato della firma codice OS; righe della + tabella "Supported versions" aggiornate per `0.1.x`. + - `README.md`: sezione "Download" (link alle release, quale file scegliere per OS, avvisi Gatekeeper/SmartScreen + per build non firmate, rimando alla verifica). + - `docs/DEVELOPMENT.md`: rimando a `docs/RELEASING.md`. + - `docs/RELEASING.md`: procedura di release passo per passo (aggiornare versione e CHANGELOG su branch → PR → merge → + `git tag -s`/`git tag v0.1.0` su `main` → `git push origin v0.1.0` → controllare la bozza → pubblicare), firma + codice (§ 2.5), riproducibilità (§ 3.4), cosa fare se il workflow fallisce a metà (rilancio, bozza da cancellare). + - `docs/ARCHITECTURE.md`: § Deploy aggiornato, domanda aperta sulla firma codice **chiusa** con la decisione (c). + - `docs/TASKS.md`: voci 4b spuntate tranne "Release `v0.1.0`", che resta all'utente (tag e pubblicazione). +4. `ci.yml`: unica modifica = Node dalla stessa `.node-version` (nessun altro cambio di comportamento). + +## Non obiettivi +- Aggiornamenti automatici (Tauri updater), pacchetti per store (winget, Homebrew, Flathub, AUR), build ARM per + Linux/Windows. +- Acquisto o configurazione reale di certificati; integrazione cablata di SignPath. +- Attestazioni SLSA/`gh attestation`, SBOM: possibili in seguito. +- Creare il tag, pubblicare la release o modificare `main`. + +## Rischi +- **AppImage e MSI in CI**: richiedono strumenti scaricati da Tauri durante la build (linuxdeploy, WiX). Se falliscono + sul runner, si correggono i prerequisiti; non si rinuncia al formato senza chiedere all'utente. +- **Universal macOS**: build due volte più lunga; accettato. +- **Riproducibilità**: dipendenze native (WebKitGTK linkato dinamicamente, quindi fuori dal binario) e codice generato + da `tauri-build` possono introdurre differenze; il job le rende visibili senza bloccare. +- **cosign keyless**: dipende dalla disponibilità di Fulcio/Rekor al momento della release; se non disponibili il job + `sign` fallisce e si rilancia. La firma registra nel log pubblico di trasparenza repository, workflow e ref + (informazioni già pubbliche). +- **Firma codice non verificata**: i rami con secret restano non provati fino alla configurazione reale (§ 2.6). + +## Verifica +Locale (questa macchina): +1. `actionlint .github/workflows/release.yml .github/workflows/ci.yml` (binario actionlint scaricato con checksum + verificato nello scratchpad, non nel repository) → nessun errore; `shellcheck` sugli script `scripts/release/*.sh`. +2. `scripts/release/check-version.sh v0.1.0` → esce 0; con `v0.1.1` e `0.1.0` → esce ≠ 0 con messaggio chiaro. +3. `scripts/release/changelog-section.sh 0.1.0` stampa la sezione; con una versione assente esce ≠ 0. +4. Override Tauri: `python3 -m json.tool` su ogni `tauri.release*.json`; i campi esistono nello schema + `https://schema.tauri.app/config/2` (validazione con lo schema scaricato, nello scratchpad). +5. `cargo metadata --locked` (versione 0.1.0 coerente nel lockfile), `cargo test -p keyrust-core`, `cargo clippy` come + nella memoria di sviluppo; pulizia di `target/debug/incremental` e degli eseguibili di test. +CI (sulla PR di questa milestone, aperta dall'utente): +6. `ci.yml` resta verde su tutti i job. +7. `release.yml` in dry run (evento `pull_request` dello stesso repository): job `verify` (senza controlli del tag), + `build` ×3, `sign`, `reproducibility` completati, `release` saltato; dopo il merge, un `workflow_dispatch` lanciato + su `main` (e, se il tag esiste già, sul tag) si comporta allo stesso modo: nessuna release, nessuna firma codice; l'artifact `keyrust-release-dryrun` contiene + esattamente 5 installer, `SHA256SUMS`, `SHA256SUMS.sigstore.json`; il summary di ogni build riporta `Code signing: + skipped`; `cosign verify-blob` nel job è passato; il summary di `reproducibility` mostra i due hash (atteso + uguali; se diversi, il limite viene documentato con la causa individuata). +8. Verifica manuale (host, fuori CI): scaricare l'artifact del dry run, `cosign verify-blob` con l'identità del ref + della PR (binario cosign con checksum verificato, nello scratchpad) e `sha256sum -c SHA256SUMS` → OK; il comando + per un singolo installer documentato in `SECURITY.md` → OK. Controllo che `.deb`, `.dmg` universale (`lipo -info` non disponibile + qui: si controlla nel log del job macOS con uno step `lipo -info`), NSIS e MSI abbiano versione 0.1.0 nel nome. +Dopo il merge (utente): +9. `git tag v0.1.0 && git push origin v0.1.0` → bozza di release con 7 asset (5 installer, `SHA256SUMS`, + `SHA256SUMS.sigstore.json`) e note dal CHANGELOG più la riga di riproducibilità; l'utente la controlla e la + pubblica. Facoltativo: provare l'installer NSIS sul PC aziendale (atteso: bloccato finché non c'è + firma Authenticode). diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock index c5dcf91..72e25ac 100644 --- a/fuzz/Cargo.lock +++ b/fuzz/Cargo.lock @@ -664,12 +664,14 @@ dependencies = [ [[package]] name = "keyrust-core" -version = "0.0.1" +version = "0.1.0" dependencies = [ "arbitrary", + "base64 0.22.1", "chrono", "getrandom 0.3.4", "keepass", + "roxmltree", "rust-argon2", "secrecy", "serde", @@ -837,6 +839,12 @@ version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" +[[package]] +name = "roxmltree" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" + [[package]] name = "rust-argon2" version = "3.0.0" diff --git a/scripts/release/changelog-section.sh b/scripts/release/changelog-section.sh new file mode 100755 index 0000000..85b297a --- /dev/null +++ b/scripts/release/changelog-section.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# Prints the CHANGELOG.md section of one version, without its heading. +# Usage: scripts/release/changelog-section.sh 0.1.0 +set -euo pipefail + +version="${1:?usage: changelog-section.sh X.Y.Z}" +root="$(cd "$(dirname "$0")/../.." && pwd)" + +section=$(awk -v heading="## [$version]" ' + index($0, heading) == 1 { found = 1; next } + found && /^## \[/ { exit } + # The link definitions at the end of the file close the last section. + found && /^\[[^]]+\]: / { exit } + found { print } +' "$root/CHANGELOG.md") + +# Drop leading and trailing blank lines. +section=$(printf '%s\n' "$section" | sed -e '/./,$!d' | sed -e ':a' -e '/^\n*$/{$d;N;ba' -e '}') +if [[ -z "$section" ]]; then + echo "error: CHANGELOG.md has no section for $version" >&2 + exit 1 +fi +printf '%s\n' "$section" diff --git a/scripts/release/check-assets.sh b/scripts/release/check-assets.sh new file mode 100755 index 0000000..ee457af --- /dev/null +++ b/scripts/release/check-assets.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# Checks that a directory holds exactly the installers of a release, nothing more. +# Usage: scripts/release/check-assets.sh 0.1.0 dist/ +set -euo pipefail + +version="${1:?usage: check-assets.sh X.Y.Z DIR}" +dir="${2:?usage: check-assets.sh X.Y.Z DIR}" + +expected=( + "Keyrust_${version}_amd64.AppImage" + "Keyrust_${version}_amd64.deb" + "Keyrust_${version}_universal.dmg" + "Keyrust_${version}_x64-setup.exe" + "Keyrust_${version}_x64_en-US.msi" +) + +mapfile -t actual < <(find "$dir" -maxdepth 1 -type f -printf '%f\n' | LC_ALL=C sort) +mapfile -t wanted < <(printf '%s\n' "${expected[@]}" | LC_ALL=C sort) + +missing=$(LC_ALL=C comm -13 <(printf '%s\n' "${actual[@]}") <(printf '%s\n' "${wanted[@]}")) +extra=$(LC_ALL=C comm -23 <(printf '%s\n' "${actual[@]}") <(printf '%s\n' "${wanted[@]}")) +if [[ -n "$missing" || -n "$extra" ]]; then + [[ -n "$missing" ]] && printf 'missing: %s\n' "${missing//$'\n'/ }" >&2 + [[ -n "$extra" ]] && printf 'unexpected: %s\n' "${extra//$'\n'/ }" >&2 + exit 1 +fi +echo "All ${#expected[@]} installers of $version are present" diff --git a/scripts/release/check-version.sh b/scripts/release/check-version.sh new file mode 100755 index 0000000..39d9a7a --- /dev/null +++ b/scripts/release/check-version.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# Checks that Cargo.toml and the UI package.json carry the same version and, given a tag, that +# the tag is that version. Prints the version on success. +# Usage: scripts/release/check-version.sh [vX.Y.Z] +set -euo pipefail + +tag="${1:-}" +root="$(cd "$(dirname "$0")/../.." && pwd)" + +# The first `version = "…"` after [workspace.package] in the root manifest. +cargo_version=$(awk ' + /^\[workspace\.package\]/ { section = 1; next } + /^\[/ { section = 0 } + section && /^version *=/ { gsub(/.*= *"|".*/, ""); print; exit } +' "$root/Cargo.toml") +ui_version=$(jq -r .version "$root/crates/app/ui/package.json") + +if [[ -z "$cargo_version" ]]; then + echo "error: no version in [workspace.package] of Cargo.toml" >&2 + exit 1 +fi +if [[ "$ui_version" != "$cargo_version" ]]; then + echo "error: crates/app/ui/package.json is $ui_version, Cargo.toml is $cargo_version" >&2 + exit 1 +fi +if [[ -n "$tag" && "$tag" != "v$cargo_version" ]]; then + echo "error: tag $tag does not match version $cargo_version (expected v$cargo_version)" >&2 + exit 1 +fi +echo "$cargo_version" diff --git a/scripts/release/rustflags.sh b/scripts/release/rustflags.sh new file mode 100755 index 0000000..f5f0fec --- /dev/null +++ b/scripts/release/rustflags.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# Prints the RUSTFLAGS of a release build: the checkout, Cargo and rustup directories are +# remapped to fixed names, so absolute paths of the build machine do not end up in the binary. +# Usage: RUSTFLAGS="$(scripts/release/rustflags.sh)" +set -euo pipefail + +root="$(cd "$(dirname "$0")/../.." && pwd)" +cargo_home="${CARGO_HOME:-$HOME/.cargo}" +rustup_home="${RUSTUP_HOME:-$HOME/.rustup}" + +# Git Bash on Windows: rustc sees native paths (C:\…), not /c/…. +native() { + if command -v cygpath >/dev/null 2>&1; then cygpath -w "$1"; else printf '%s' "$1"; fi +} + +printf '%s' "--remap-path-prefix=$(native "$root")=/build" +printf ' %s' "--remap-path-prefix=$(native "$cargo_home")=/cargo" +printf ' %s\n' "--remap-path-prefix=$(native "$rustup_home")=/rustup"