diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b0d37ae..8559d7d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -10,6 +10,16 @@ on: description: 'gpgui branch to use for the snapshot release' required: true default: dev + build_bsd: + description: 'Build FreeBSD/OpenBSD packages for the snapshot release' + required: true + default: false + type: boolean + build_bsd_arm64: + description: 'Build optional FreeBSD/OpenBSD arm64 packages for the snapshot release. Slow and disabled by default' + required: true + default: false + type: boolean push: paths-ignore: - LICENSE @@ -29,19 +39,8 @@ concurrency: cancel-in-progress: true jobs: - setup-matrix: - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.set-matrix.outputs.matrix }} - steps: - - name: Set up matrix - id: set-matrix - run: | - echo 'matrix=[{"runner": "ubuntu-latest", "arch": "amd64"}, {"runner": "ubuntu-24.04-arm", "arch": "ubuntu-24.04-arm"}]' >> $GITHUB_OUTPUT - tarball: runs-on: ubuntu-latest - needs: [setup-matrix] steps: - uses: pnpm/action-setup@v5 with: @@ -132,12 +131,15 @@ jobs: build-gp: needs: - - setup-matrix - tarball strategy: fail-fast: false matrix: - os: ${{fromJson(needs.setup-matrix.outputs.matrix)}} + os: + - runner: ubuntu-latest + arch: amd64 + - runner: ubuntu-24.04-arm + arch: ubuntu-24.04-arm package: [deb, rpm, pkg, apk, binary, ubuntu-rolling] runs-on: ${{ matrix.os.runner }} name: build-gp (${{ matrix.package }}, ${{ matrix.os.arch }}) @@ -238,12 +240,14 @@ jobs: retention-days: 1 build-gpgui: - needs: - - setup-matrix strategy: fail-fast: false matrix: - os: ${{fromJson(needs.setup-matrix.outputs.matrix)}} + os: + - runner: ubuntu-latest + arch: amd64 + - runner: ubuntu-24.04-arm + arch: ubuntu-24.04-arm libc: - name: glibc builder: gpgui-builder-tauri2 @@ -302,17 +306,274 @@ jobs: gpgui-source/*.bin.tar.xz gpgui-source/*.bin.tar.xz.sha256 - gh-release: - if: ${{ github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') }} + setup-bsd-matrix: runs-on: ubuntu-latest + outputs: + enabled: ${{ steps.matrix.outputs.enabled }} + matrix: ${{ steps.matrix.outputs.matrix }} + steps: + - name: Build matrix + id: matrix + env: + IS_TAG: ${{ startsWith(github.ref, 'refs/tags/') }} + BUILD_BSD: ${{ github.event_name == 'workflow_dispatch' && inputs.build_bsd }} + BUILD_BSD_ARM64: ${{ github.event_name == 'workflow_dispatch' && inputs.build_bsd_arm64 }} + run: | + python3 - <<'PY' + import json + import os + + build_bsd = os.environ["IS_TAG"] == "true" or os.environ["BUILD_BSD"] == "true" + build_bsd_arm64 = os.environ["BUILD_BSD_ARM64"] == "true" + include = [] + + def add(os_name, arch): + include.append({ + "os": os_name, + "arch": arch, + "workspace": f"{os_name}-{arch}-source", + "artifact": f"artifact-bsd-{os_name}-{arch}", + "package_target": f"package-{os_name}", + "artifact_dir": os_name, + }) + + if build_bsd: + add("freebsd", "x86_64") + add("openbsd", "x86_64") + if build_bsd_arm64: + add("freebsd", "arm64") + add("openbsd", "arm64") + + with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output: + output.write(f"enabled={str(bool(include)).lower()}\n") + output.write(f"matrix={json.dumps({'include': include}, separators=(',', ':'))}\n") + PY + + build-gpgui-frontend: + needs: setup-bsd-matrix + if: ${{ needs.setup-bsd-matrix.outputs.enabled == 'true' }} + runs-on: ubuntu-latest + steps: + - uses: pnpm/action-setup@v5 + with: + version: 9 + - name: Prepare workspace + run: rm -rf gpgui-frontend && mkdir gpgui-frontend + - name: Checkout GlobalProtect-openconnect + uses: actions/checkout@v6 + with: + token: ${{ secrets.GH_PAT }} + repository: yuezk/GlobalProtect-openconnect + ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }} + path: gpgui-frontend/gp + submodules: recursive + - name: Checkout gpgui + uses: actions/checkout@v6 + with: + token: ${{ secrets.GH_PAT }} + repository: yuezk/gpgui + ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gpgui_branch || github.ref_name }} + path: gpgui-frontend/gpgui + - name: Build gpgui frontend + run: | + cd gpgui-frontend/gpgui/app + pnpm install --frozen-lockfile + pnpm build + - name: Upload gpgui frontend + uses: actions/upload-artifact@v7 + with: + name: bsd-gpgui-frontend + if-no-files-found: error + path: gpgui-frontend/gpgui/app/dist/** + + build-bsd: + needs: + - setup-bsd-matrix + - build-gpgui-frontend + if: ${{ needs.setup-bsd-matrix.outputs.enabled == 'true' }} + runs-on: ubuntu-latest + name: build-${{ matrix.os }} (${{ matrix.arch }}) + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.setup-bsd-matrix.outputs.matrix) }} + steps: + - name: Prepare workspace + run: rm -rf "${{ matrix.workspace }}" && mkdir "${{ matrix.workspace }}" + - name: Checkout GlobalProtect-openconnect + uses: actions/checkout@v6 + with: + token: ${{ secrets.GH_PAT }} + repository: yuezk/GlobalProtect-openconnect + ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }} + path: ${{ matrix.workspace }}/gp + submodules: recursive + - name: Checkout gpgui + uses: actions/checkout@v6 + with: + token: ${{ secrets.GH_PAT }} + repository: yuezk/gpgui + ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gpgui_branch || github.ref_name }} + path: ${{ matrix.workspace }}/gpgui + - name: Download gpgui frontend + uses: actions/download-artifact@v8 + with: + name: bsd-gpgui-frontend + path: ${{ matrix.workspace }}/gpgui/app/dist + - name: Build on FreeBSD + if: ${{ matrix.os == 'freebsd' }} + uses: vmactions/freebsd-vm@v1 + with: + release: "14.3" + arch: ${{ matrix.arch }} + usesh: true + prepare: | + pkg install -y \ + git \ + rust \ + libiconv \ + gettext-tools \ + autoconf \ + automake \ + libtool \ + patch \ + gmake \ + pkgconf \ + libxml2 \ + gnutls \ + p11-kit \ + nettle \ + gmp \ + gnome-keyring \ + libayatana-appindicator \ + polkit \ + webkit2-gtk_41 + run: | + set -eu + + cd "${{ matrix.workspace }}/gp" + cargo build --release --workspace + + cd ../gpgui/app/src-tauri + cargo build --release --workspace + + cd ../../../gp + gmake "${{ matrix.package_target }}" GPGUI_BINARY=../gpgui/target/release/gpgui + pkg install -y ".build/${{ matrix.artifact_dir }}"/artifacts/*.pkg + gpclient --version + gpauth --version + gpgui --version + rm -rf target ../gpgui/target + find ".build/${{ matrix.artifact_dir }}" -mindepth 1 -maxdepth 1 ! -name artifacts -exec rm -rf {} + + - name: Build on OpenBSD + if: ${{ matrix.os == 'openbsd' }} + uses: vmactions/openbsd-vm@v1 + with: + release: "7.9" + arch: ${{ matrix.arch }} + usesh: true + prepare: | + pkg_add -z \ + git \ + rust \ + libiconv \ + gettext-tools \ + autoconf-2.72 \ + automake-1.17 \ + libtool \ + patch \ + gmake \ + pkgconf \ + libxml \ + gnutls \ + p11-kit \ + nettle \ + gmp \ + gnome-keyring \ + polkit \ + webkitgtk41 + ln -sf /usr/local/bin/autoreconf-2.72 /usr/local/bin/autoreconf + ln -sf /usr/local/bin/autoconf-2.72 /usr/local/bin/autoconf + ln -sf /usr/local/bin/autoheader-2.72 /usr/local/bin/autoheader + ln -sf /usr/local/bin/autom4te-2.72 /usr/local/bin/autom4te + ln -sf /usr/local/bin/aclocal-1.17 /usr/local/bin/aclocal + ln -sf /usr/local/bin/automake-1.17 /usr/local/bin/automake + run: | + set -eu + export AUTOCONF_VERSION=2.72 + export AUTOMAKE_VERSION=1.17 + + cd "${{ matrix.workspace }}/gp" + cargo build --release --workspace + + cd ../gpgui/app/src-tauri + cargo build --release --workspace + + cd ../../../gp + gmake "${{ matrix.package_target }}" GPGUI_BINARY=../gpgui/target/release/gpgui + pkg_add -D unsigned ".build/${{ matrix.artifact_dir }}"/artifacts/*.tgz + gpclient --version + gpauth --version + gpgui --version + rm -rf target ../gpgui/target + find ".build/${{ matrix.artifact_dir }}" -mindepth 1 -maxdepth 1 ! -name artifacts -exec rm -rf {} + + - name: Upload BSD package + uses: actions/upload-artifact@v7 + with: + name: ${{ matrix.artifact }} + if-no-files-found: error + path: | + ${{ matrix.workspace }}/gp/.build/${{ matrix.artifact_dir }}/artifacts/* + + gh-release: + if: ${{ always() && (github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')) }} + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + id-token: write + attestations: write + artifact-metadata: write needs: - tarball - tarball-offline - build-gp - build-docker-image - build-gpgui + - setup-bsd-matrix + - build-gpgui-frontend + - build-bsd steps: + - name: Check required jobs + env: + NEEDS_JSON: ${{ toJson(needs) }} + BSD_MATRIX_ENABLED: ${{ needs.setup-bsd-matrix.outputs.enabled }} + run: | + python3 - <<'PY' + import json + import os + import sys + + needs = json.loads(os.environ["NEEDS_JSON"]) + bsd_matrix_enabled = os.environ["BSD_MATRIX_ENABLED"] == "true" + failed = [] + + for name, data in needs.items(): + result = data["result"] + if result in {"failure", "cancelled"}: + failed.append(f"{name}: {result}") + elif name in {"build-gpgui-frontend", "build-bsd"} and result == "skipped" and not bsd_matrix_enabled: + continue + elif result == "skipped": + failed.append(f"{name}: {result}") + + if failed: + print("Required jobs did not complete successfully:") + for item in failed: + print(f" - {item}") + sys.exit(1) + PY + - name: Prepare workspace run: rm -rf gh-release && mkdir gh-release @@ -341,6 +602,27 @@ jobs: mv "$file" "${file%.apk}-aarch64.apk" done + - name: Generate release asset checksums + env: + RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && 'snapshot' || github.ref_name }} + run: | + cd gh-release/gp + mkdir -p .build + scripts/release-assets.sh "$RELEASE_TAG" > .build/release-assets.txt + if [ ! -s .build/release-assets.txt ]; then + echo "No release assets found" + exit 1 + fi + while IFS= read -r file; do + digest=$(sha256sum "$file" | cut -d ' ' -f 1) + printf '%s %s\n' "$digest" "$(basename "$file")" + done < .build/release-assets.txt > .build/release-assets.sha256 + + - name: Attest release assets + uses: actions/attest-build-provenance@v4 + with: + subject-checksums: gh-release/gp/.build/release-assets.sha256 + - name: Create GH release env: GH_TOKEN: ${{ secrets.GH_PAT }} diff --git a/.github/workflows/publish-ppa.yaml b/.github/workflows/publish-ppa.yaml index d682a3d..b34526d 100644 --- a/.github/workflows/publish-ppa.yaml +++ b/.github/workflows/publish-ppa.yaml @@ -129,6 +129,7 @@ jobs: cp -v packaging/deb/postrm .build/debian/postrm sed -i "s/@BUILD_GUI_HELPER@/1/g" .build/debian/rules + sed -i "s/@BUILD_WEBVIEW_AUTH@/1/g" .build/debian/rules # Update the control file with the correct Rust version sed -i "s/@RUST_VERSION@/${{ inputs.rust }}/g" .build/debian/control diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3a7d49d..2fe1e42 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -253,9 +253,23 @@ jobs: - build runs-on: ubuntu-latest if: ${{ inputs.gh-release }} + permissions: + actions: read + contents: read + id-token: write + attestations: write + artifact-metadata: write steps: - name: Prepare workspace run: rm -rf gh-release && mkdir gh-release + - name: Checkout GlobalProtect-openconnect + uses: actions/checkout@v6 + with: + token: ${{ secrets.GH_PAT }} + repository: yuezk/GlobalProtect-openconnect + ref: ${{ github.ref }} + path: gh-release/gp + submodules: recursive - name: Download artifact uses: actions/download-artifact@v8 with: @@ -270,6 +284,29 @@ jobs: for file in gh-release/artifact-ubuntu-24.04-arm-apk/*.apk; do mv "$file" "${file%.apk}-aarch64.apk" done + - name: Generate release asset checksums + id: release-assets + run: | + cd gh-release/gp + mkdir -p .build + scripts/release-assets.sh all "$GITHUB_WORKSPACE/gh-release" > .build/release-assets.txt + if [ ! -s .build/release-assets.txt ]; then + echo "No release assets found" + exit 1 + fi + while IFS= read -r file; do + digest=$(sha256sum "$file" | cut -d ' ' -f 1) + printf '%s %s\n' "$digest" "$(basename "$file")" + done < .build/release-assets.txt > .build/release-assets.sha256 + { + echo 'files<> "$GITHUB_OUTPUT" + - name: Attest release assets + uses: actions/attest-build-provenance@v4 + with: + subject-checksums: gh-release/gp/.build/release-assets.sha256 - name: Update release uses: softprops/action-gh-release@v1 with: @@ -277,5 +314,4 @@ jobs: prerelease: ${{ contains(github.ref, 'snapshot') }} fail_on_unmatched_files: true tag_name: ${{ inputs.tag }} - files: | - gh-release/artifact-*/* + files: ${{ steps.release-assets.outputs.files }} diff --git a/.gitignore b/.gitignore index 0ec367a..f64b65f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ .cargo .build SNAPSHOT +SOURCE_COMMIT # Tauri generated files gen diff --git a/Cargo.lock b/Cargo.lock index 48c56c6..6bbd17e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -41,9 +41,9 @@ checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" [[package]] name = "alloc-stdlib" -version = "0.2.2" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" +checksum = "0e76a019e91224d279006ff972f1e984179a6e9feb050adba6ce8274aef23195" dependencies = [ "alloc-no-stdlib", ] @@ -121,11 +121,11 @@ checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" [[package]] name = "askama" -version = "0.14.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f75363874b771be265f4ffe307ca705ef6f3baa19011c149da8674a87f1b75c4" +checksum = "f1bf825125edd887a019d0a3a837dcc5499a68b0d034cc3eb594070c3e18addc" dependencies = [ - "askama_derive", + "askama_macros", "itoa", "percent-encoding", "serde", @@ -134,31 +134,42 @@ dependencies = [ [[package]] name = "askama_derive" -version = "0.14.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "129397200fe83088e8a68407a8e2b1f826cf0086b21ccdb866a722c8bcd3a94f" +checksum = "e1c7065972a130eafa84215f21352ae15b4a7393da48c1f5e103904490736738" dependencies = [ "askama_parser", "basic-toml", + "glob", "memchr", "proc-macro2", "quote", "rustc-hash", "serde", "serde_derive", - "syn 2.0.117", + "syn 2.0.118", +] + +[[package]] +name = "askama_macros" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e23b1d2c4bd39a41971f6124cef4cc6fd0540913ecb90919b69ab3bbe44ae1a" +dependencies = [ + "askama_derive", ] [[package]] name = "askama_parser" -version = "0.14.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6ab5630b3d5eaf232620167977f95eb51f3432fc76852328774afbd242d4358" +checksum = "7db09fde9143e7ac4513358fb32ee32847125b63b18ea715afd487956da715da" dependencies = [ - "memchr", + "rustc-hash", "serde", "serde_derive", - "winnow 0.7.15", + "unicode-ident", + "winnow 1.0.3", ] [[package]] @@ -169,7 +180,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -228,9 +239,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" [[package]] name = "autotools" @@ -241,6 +252,28 @@ dependencies = [ "cc", ] +[[package]] +name = "aws-lc-rs" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ec2f1fc3ec205783a5da9a7e6c1509cc69dedf09a1949e412c1e18469326d00" +dependencies = [ + "aws-lc-sys", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a2f9779ce85b93ab6170dd940ad0169b5766ff848247aff13bb788b832fe3f4" +dependencies = [ + "cc", + "cmake", + "dunce", + "fs_extra", +] + [[package]] name = "axum" version = "0.8.9" @@ -340,9 +373,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.11.1" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" +checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8" dependencies = [ "serde_core", ] @@ -367,9 +400,9 @@ dependencies = [ [[package]] name = "brotli" -version = "8.0.2" +version = "8.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bd8b9603c7aa97359dbd97ecf258968c95f3adddd6db2f7e7a5bef101c84560" +checksum = "5cc91aac060a7a1e25823bdccbfb6af1875b88f17c6daac97894eed8207166b3" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -378,19 +411,28 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "5.0.0" +version = "5.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "874bb8112abecc98cbd6d81ea4fa7e94fb9449648c93cc89aa40c81c24d7de03" +checksum = "3a32acac15fe1967bc3986b2a6347dffc965602354ea6f450ad07e8bfd253583" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", ] [[package]] -name = "bumpalo" -version = "3.20.2" +name = "bs58" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" [[package]] name = "bytemuck" @@ -406,9 +448,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.11.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" +checksum = "8ae3f5d315924270530207e2a68396c3cc547f6dca3fbdca317cfb1a51edb593" dependencies = [ "serde", ] @@ -419,7 +461,7 @@ version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ca26ef0159422fb77631dc9d17b102f253b876fe1586b03b803e63a309b4ee2" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "cairo-sys-rs", "glib", "libc", @@ -440,9 +482,9 @@ dependencies = [ [[package]] name = "camino" -version = "1.2.2" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e629a66d692cb9ff1a1c664e41771b3dcaf961985a9774c0eb0bd1b51cf60a48" +checksum = "b4ce8d3bd5823c7504d3f579f13e7b2f3da252fcb938c594d5680ee508bf846f" dependencies = [ "serde_core", ] @@ -482,11 +524,13 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.61" +version = "1.2.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d16d90359e986641506914ba71350897565610e87ce0ad9e6f28569db3dd5c6d" +checksum = "dad887fd958be91b5098c0248def011f4523ab786cd411be668777e55063501f" dependencies = [ "find-msvc-tools", + "jobserver", + "libc", "shlex", ] @@ -555,9 +599,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.44" +version = "0.4.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0" +checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" dependencies = [ "iana-time-zone", "js-sys", @@ -625,7 +669,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -634,6 +678,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" +[[package]] +name = "cmake" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678" +dependencies = [ + "cc", +] + [[package]] name = "colorchoice" version = "1.0.5" @@ -719,7 +772,7 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "064badf302c3194842cf2c5d61f56cc88e54a759313879cdf03abdd27d0c3b97" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "core-foundation 0.10.1", "core-graphics-types", "foreign-types 0.5.0", @@ -732,7 +785,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "core-foundation 0.10.1", "libc", ] @@ -795,7 +848,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8b9f2e4c67f833b660cdb0a3523065869fb35570177239812ed4c905aeff87b" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "crossterm_winapi", "derive_more", "document-features", @@ -847,7 +900,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" dependencies = [ "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -886,7 +939,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -897,7 +950,7 @@ checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" dependencies = [ "darling_core", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -923,7 +976,6 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" dependencies = [ - "powerfmt", "serde_core", ] @@ -946,7 +998,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -995,7 +1047,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "block2", "libc", "objc2", @@ -1003,13 +1055,13 @@ dependencies = [ [[package]] name = "displaydoc" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +checksum = "1ac70aa55017e108007fbaf5aa0f54b021c98f92ff8af59d42eda9da96e3dd4f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -1043,7 +1095,7 @@ checksum = "0fbbb781877580993a8707ec48672673ec7b81eeba04cfd2310bd28c08e47c8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -1075,7 +1127,7 @@ checksum = "521e380c0c8afb8d9a1e83a1822ee03556fc3e3e7dbc1fd30be14e37f9cb3f89" dependencies = [ "bit-set", "cssparser", - "foldhash 0.2.0", + "foldhash", "html5ever", "precomputed-hash", "selectors", @@ -1135,9 +1187,9 @@ checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" [[package]] name = "either" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" +checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e" [[package]] name = "embed-resource" @@ -1245,13 +1297,12 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.27" +version = "0.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98844151eee8917efc50bd9e8318cb963ae8b297431495d3f758616ea5c57db" +checksum = "5c287a33c7f0a620c38e641e7f60827713987b3c0f26e8ddc9462cc69cf75759" dependencies = [ "cfg-if", "libc", - "libredox", ] [[package]] @@ -1276,12 +1327,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foldhash" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" - [[package]] name = "foldhash" version = "0.2.0" @@ -1315,7 +1360,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -1401,7 +1446,7 @@ checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -1558,8 +1603,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" dependencies = [ "cfg-if", + "js-sys", "libc", - "wasi", + "wasi 0.11.1+wasi-snapshot-preview1", + "wasm-bindgen", ] [[package]] @@ -1569,22 +1616,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" dependencies = [ "cfg-if", + "js-sys", "libc", "r-efi 5.3.0", "wasip2", + "wasm-bindgen", ] [[package]] name = "getrandom" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" dependencies = [ "cfg-if", "libc", "r-efi 6.0.0", - "wasip2", - "wasip3", ] [[package]] @@ -1625,7 +1672,7 @@ version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "233daaf6e83ae6a12a52055f568f9d7cf4671dabb78ff9560ab6da230ce00ee5" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "futures-channel", "futures-core", "futures-executor", @@ -1653,7 +1700,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -1700,14 +1747,15 @@ dependencies = [ "humantime", "log", "log-reload", - "machine-uid", "md5", + "netdev", "openssl", "os_info", "pem", + "proptest", "redact-engine", "regex", - "reqwest 0.12.28", + "reqwest", "serde", "serde_json", "serde_urlencoded", @@ -1763,13 +1811,14 @@ dependencies = [ "log", "netdev", "openconnect", - "reqwest 0.12.28", + "reqwest", "serde", "serde_json", "serde_urlencoded", "sysinfo", "tempfile", "tokio", + "uuid", "whoami", "xmltree", ] @@ -1785,7 +1834,7 @@ dependencies = [ "futures-util", "gpapi", "log", - "reqwest 0.12.28", + "reqwest", "tauri", "tauri-build", "tempfile", @@ -1863,14 +1912,14 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] name = "h2" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "171fefbc92fe4a4de27e0698d6a5b392d6a0e333506bc49133760b3bcf948733" +checksum = "6cb093c84e8bd9b188d4c4a8cb6579fc016968d14c99882163cd3ff402a4f155" dependencies = [ "atomic-waker", "bytes", @@ -1893,18 +1942,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.15.5" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" -dependencies = [ - "foldhash 0.1.5", -] - -[[package]] -name = "hashbrown" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" [[package]] name = "heck" @@ -1954,9 +1994,9 @@ dependencies = [ [[package]] name = "http" -version = "1.4.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +checksum = "6970f50e31d6fc17d3fa27329444bfa74e196cf62e95052a3f6fee181dba6425" dependencies = [ "bytes", "itoa", @@ -2005,9 +2045,9 @@ checksum = "135b12329e5e3ce057a9f972339ea52bc954fe1e9358ef27f95e89716fbc5424" [[package]] name = "hyper" -version = "1.9.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6299f016b246a94207e63da54dbe807655bf9e00044f73ded42c3ac5305fbcca" +checksum = "55281c53a1894c864990125767da440a4e630446785086f52523b20033b74498" dependencies = [ "atomic-waker", "bytes", @@ -2197,12 +2237,6 @@ dependencies = [ "zerovec", ] -[[package]] -name = "id-arena" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" - [[package]] name = "ident_case" version = "1.0.1" @@ -2248,7 +2282,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" dependencies = [ "equivalent", - "hashbrown 0.17.0", + "hashbrown 0.17.1", "serde", "serde_core", ] @@ -2277,7 +2311,7 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6654738b8024300cf062d04a1c13c10c8e2cea598ec1c47dc9b6641159429756" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "crossterm", "dyn-clone", "fuzzy-matcher", @@ -2312,11 +2346,11 @@ dependencies = [ [[package]] name = "is_executable" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baabb8b4867b26294d818bf3f651a454b6901431711abb96e296245888d6e8c4" +checksum = "82cb6a9f675da968c63b6208c641b9dca58fc0133ae53375736b1767b0cab8bd" dependencies = [ - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -2356,9 +2390,9 @@ dependencies = [ [[package]] name = "jiff" -version = "0.2.24" +version = "0.2.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f00b5dbd620d61dfdcb6007c9c1f6054ebd75319f163d886a9055cec1155073d" +checksum = "4603d3033e49e2b0e31229fcab20a5d40089c607d975cd9c80551dc69eed9102" dependencies = [ "jiff-static", "log", @@ -2369,13 +2403,13 @@ dependencies = [ [[package]] name = "jiff-static" -version = "0.2.24" +version = "0.2.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e000de030ff8022ea1da3f466fbb0f3a809f5e51ed31f6dd931c35181ad8e6d7" +checksum = "782d32378dddf207193ac91cefb848ad41abb58195c95168e1291227a0832b47" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -2421,7 +2455,7 @@ dependencies = [ "quote", "rustc_version", "simd_cesu8", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -2449,18 +2483,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" dependencies = [ "quote", - "syn 2.0.117", + "syn 2.0.118", +] + +[[package]] +name = "jobserver" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" +dependencies = [ + "getrandom 0.3.4", + "libc", ] [[package]] name = "js-sys" -version = "0.3.97" +version = "0.3.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1840c94c045fbcf8ba2812c95db44499f7c64910a912551aaaa541decebcacf" +checksum = "03d04c30968dffe80775bd4d7fb676131cd04a1fb46d2686dbffbaec2d9dfd31" dependencies = [ "cfg-if", "futures-util", - "once_cell", "wasm-bindgen", ] @@ -2492,17 +2535,11 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b750dcadc39a09dbadd74e118f6dd6598df77fa01df0cfcdc52c28dece74528a" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "serde", "unicode-segmentation", ] -[[package]] -name = "leb128fmt" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" - [[package]] name = "libappindicator" version = "0.9.0" @@ -2554,14 +2591,11 @@ dependencies = [ [[package]] name = "libredox" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e02f3bb43d335493c96bf3fd3a321600bf6bd07ed34bc64118e9293bdffea46c" +checksum = "f02ab6bace2054fb888a3c16f990117b579d14a3088e472d63c6011fa185c9d3" dependencies = [ - "bitflags 2.11.1", "libc", - "plain", - "redox_syscall 0.7.5", ] [[package]] @@ -2593,9 +2627,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.29" +version = "0.4.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" +checksum = "953f07c43838f8e6f9758cab68bf5bed85465e7587ebe0b823f1bcd81978ad3a" [[package]] name = "log-reload" @@ -2606,6 +2640,12 @@ dependencies = [ "log", ] +[[package]] +name = "lru-slab" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" + [[package]] name = "lzma-sys" version = "0.1.20" @@ -2623,17 +2663,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3d25b0e0b648a86960ac23b7ad4abb9717601dec6f66c165f5b037f3f03065f" -[[package]] -name = "machine-uid" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d7217d573cdb141d6da43113b098172e057d39915d79c4bdedbc3aacd46bd96" -dependencies = [ - "libc", - "windows-registry", - "windows-sys 0.61.2", -] - [[package]] name = "markup5ever" version = "0.38.0" @@ -2659,9 +2688,9 @@ checksum = "ae960838283323069879657ca3de837e9f7bbb4c7bf6ea7f1b290d5e9476d2e0" [[package]] name = "memchr" -version = "2.8.0" +version = "2.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" +checksum = "88904434abc2901f197fe8cc55f0445e7ded921dba5911dad2e2b39b48e663c4" [[package]] name = "memoffset" @@ -2690,21 +2719,21 @@ dependencies = [ [[package]] name = "mio" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50b7e5b27aa02a74bac8c3f23f448f8d87ff11f92d3aac1a6ed369ee08cc56c1" +checksum = "02bd0af71c67b473010cbbc60715ee815645a4dc942899111f494b4b737d6fda" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.1+wasi-snapshot-preview1", "windows-sys 0.61.2", ] [[package]] name = "muda" -version = "0.19.1" +version = "0.19.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ae8844f63b5b118e334e205585b8c5c17b984121dbdb179d44aeb087ffad3cb" +checksum = "1dd04e60bc0b07438a6771710ee1698f98f6ebbc7f89b61264af1563b8aeb878" dependencies = [ "crossbeam-channel", "dpi", @@ -2744,7 +2773,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "jni-sys 0.3.1", "log", "ndk-sys", @@ -2805,7 +2834,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df9854ea6ad14e3f4698a7f03b65bce0833dd2d81d594a0e4a984170537146b6" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "libc", "log", "netlink-packet-core", @@ -2830,11 +2859,11 @@ checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" [[package]] name = "nix" -version = "0.30.1" +version = "0.31.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6" +checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "cfg-if", "cfg_aliases", "libc", @@ -2851,9 +2880,9 @@ dependencies = [ [[package]] name = "num-conv" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6673768db2d862beb9b39a78fdcb1a69439615d5794a1be50caa9bc92c81967" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" [[package]] name = "num-traits" @@ -2883,7 +2912,7 @@ dependencies = [ "proc-macro-crate 3.5.0", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -2902,7 +2931,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "block2", "objc2", "objc2-core-foundation", @@ -2915,7 +2944,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73ad74d880bb43877038da939b7427bba67e9dd42004a18b809ba7d87cee241c" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "objc2", "objc2-foundation", ] @@ -2936,7 +2965,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "block2", "dispatch2", "libc", @@ -2949,7 +2978,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "dispatch2", "objc2", "objc2-core-foundation", @@ -2982,7 +3011,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0cde0dfb48d25d2b4862161a4d5fcc0e3c24367869ad306b0c9ec0073bfed92d" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "objc2", "objc2-core-foundation", "objc2-core-graphics", @@ -3009,7 +3038,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "block2", "libc", "objc2", @@ -3032,7 +3061,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "objc2", "objc2-core-foundation", ] @@ -3053,7 +3082,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "objc2", "objc2-core-foundation", "objc2-foundation", @@ -3065,7 +3094,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "709fe137109bd1e8b5a99390f77a7d8b2961dafc1a1c5db8f2e60329ad6d895a" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "objc2", "objc2-core-foundation", ] @@ -3076,7 +3105,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7216bd11cbda54ccabcab84d523dc93b858ec75ecfb3a7d89513fa22464da396" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "dispatch2", "libc", "objc2", @@ -3090,7 +3119,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d87d638e33c06f577498cbcc50491496a3ed4246998a7fbba7ccb98b1e7eab22" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "block2", "objc2", "objc2-cloud-kit", @@ -3121,7 +3150,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2e5aaab980c433cf470df9d7af96a7b46a9d892d521a2cbbb2f8a4c16751e7f" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "block2", "objc2", "objc2-app-kit", @@ -3151,9 +3180,9 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "open" -version = "5.3.4" +version = "5.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3bab717c29a857abf75fcef718d441ec7cb2725f937343c734740a985d37fd" +checksum = "2fbaa89d2ddc8473c78a3adf69eea8cffa28c483b8e02a971ef31527cd0fc92c" dependencies = [ "is-wsl", "libc", @@ -3174,11 +3203,11 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.79" +version = "0.10.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf0b434746ee2832f4f0baf10137e1cabb18cbe6912c69e2e33263c45250f542" +checksum = "77823a27f0babb03091cb9ed9ef80af3b39dbc82f97e8fa530374b7dafd87a45" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "cfg-if", "foreign-types 0.3.2", "libc", @@ -3194,7 +3223,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -3205,9 +3234,9 @@ checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" [[package]] name = "openssl-sys" -version = "0.9.115" +version = "0.9.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "158fe5b292746440aa6e7a7e690e55aeb72d41505e2804c23c6973ad0e9c9781" +checksum = "b47e7e6bb2c38cd930d25a23b40fa52e068c10e85f3e03a7f5ba5aaca5713695" dependencies = [ "cc", "libc", @@ -3223,9 +3252,9 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "os_info" -version = "3.14.0" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4022a17595a00d6a369236fdae483f0de7f0a339960a53118b818238e132224" +checksum = "9cf20a545b305cf1da722b236b5155c9bb35f1d5ceb28c048bd96ca842f41b5b" dependencies = [ "android_system_properties", "log", @@ -3279,7 +3308,7 @@ checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.18", + "redox_syscall", "smallvec", "windows-link 0.2.1", ] @@ -3353,7 +3382,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -3377,12 +3406,6 @@ version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" -[[package]] -name = "plain" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" - [[package]] name = "plist" version = "1.9.0" @@ -3415,7 +3438,7 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "crc32fast", "fdeflate", "flate2", @@ -3478,16 +3501,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" -[[package]] -name = "prettyplease" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" -dependencies = [ - "proc-macro2", - "syn 2.0.117", -] - [[package]] name = "proc-macro-crate" version = "1.3.1" @@ -3514,7 +3527,7 @@ version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" dependencies = [ - "toml_edit 0.25.11+spec-1.1.0", + "toml_edit 0.25.12+spec-1.1.0", ] [[package]] @@ -3551,14 +3564,95 @@ dependencies = [ ] [[package]] -name = "quick-xml" -version = "0.39.3" +name = "proptest" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721da970c312655cde9b4ffe0547f20a8494866a4af5ff51f18b7c633d0c870b" +checksum = "4b45fcc2344c680f5025fe57779faef368840d0bd1f42f216291f0dc4ace4744" +dependencies = [ + "bit-set", + "bit-vec", + "bitflags 2.13.0", + "num-traits", + "rand", + "rand_chacha", + "rand_xorshift", + "regex-syntax", + "rusty-fork", + "tempfile", + "unarray", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quick-xml" +version = "0.39.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdcc8dd4e2f670d309a5f0e83fe36dfdc05af317008fea29144da1a2ac858e5e" dependencies = [ "memchr", ] +[[package]] +name = "quinn" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e20a958963c291dc322d98411f541009df2ced7b5a4f2bd52337638cfccf20" +dependencies = [ + "bytes", + "cfg_aliases", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2", + "thiserror 2.0.18", + "tokio", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "434b42fec591c96ef50e21e886936e66d3cc3f737104fdb9b737c40ffb94c098" +dependencies = [ + "aws-lc-rs", + "bytes", + "getrandom 0.3.4", + "lru-slab", + "rand", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror 2.0.18", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "addec6a0dcad8a8d96a771f815f0eaf55f9d1805756410b39f5fa81332574cbd" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.52.0", +] + [[package]] name = "quote" version = "1.0.45" @@ -3618,6 +3712,15 @@ dependencies = [ "getrandom 0.3.4", ] +[[package]] +name = "rand_xorshift" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "513962919efc330f829edb2535844d1b912b0fbe2ca165d613e4e8788bb05a5a" +dependencies = [ + "rand_core 0.9.5", +] + [[package]] name = "raw-window-handle" version = "0.6.2" @@ -3664,16 +3767,7 @@ version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags 2.11.1", -] - -[[package]] -name = "redox_syscall" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4666a1a60d8412eab19d94f6d13dcc9cea0a5ef4fdf6a5db306537413c661b1b" -dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", ] [[package]] @@ -3704,14 +3798,14 @@ checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] name = "regex" -version = "1.12.3" +version = "1.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +checksum = "f1292b7759ae1cb9ec195452d1390a074f0cd8541ab7a5a8c31cd6db45d4a6ba" dependencies = [ "aho-corasick", "memchr", @@ -3732,15 +3826,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" [[package]] name = "reqwest" -version = "0.12.28" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" +checksum = "219c5811de6525e5416c7d5d53bb656d3afdbc6c5af816e0802bcfa42dbdc1c3" dependencies = [ "base64 0.22.1", "bytes", @@ -3761,13 +3855,17 @@ dependencies = [ "native-tls", "percent-encoding", "pin-project-lite", + "quinn", + "rustls", "rustls-pki-types", + "rustls-platform-verifier", "serde", "serde_json", "serde_urlencoded", "sync_wrapper", "tokio", "tokio-native-tls", + "tokio-rustls", "tokio-util", "tower", "tower-http", @@ -3775,41 +3873,7 @@ dependencies = [ "url", "wasm-bindgen", "wasm-bindgen-futures", - "wasm-streams 0.4.2", - "web-sys", -] - -[[package]] -name = "reqwest" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62e0021ea2c22aed41653bc7e1419abb2c97e038ff2c33d0e1309e49a97deec0" -dependencies = [ - "base64 0.22.1", - "bytes", - "futures-core", - "futures-util", - "http", - "http-body", - "http-body-util", - "hyper", - "hyper-util", - "js-sys", - "log", - "percent-encoding", - "pin-project-lite", - "serde", - "serde_json", - "sync_wrapper", - "tokio", - "tokio-util", - "tower", - "tower-http", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-streams 0.5.0", + "wasm-streams", "web-sys", ] @@ -3848,7 +3912,7 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "errno", "libc", "linux-raw-sys", @@ -3861,6 +3925,7 @@ version = "0.23.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef86cd5876211988985292b91c96a8f2d298df24e75989a43a3c73f2d4d8168b" dependencies = [ + "aws-lc-rs", "once_cell", "rustls-pki-types", "rustls-webpki", @@ -3868,21 +3933,62 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls-native-certs" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dab5152771c58876a2146916e53e35057e1a4dfa2b9df0f0305b07f611fdea4d" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework", +] + [[package]] name = "rustls-pki-types" version = "1.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30a7197ae7eb376e574fe940d068c30fe0462554a3ddbe4eca7838e049c937a9" dependencies = [ + "web-time", "zeroize", ] +[[package]] +name = "rustls-platform-verifier" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d1e2536ce4f35f4846aa13bff16bd0ff40157cdb14cc056c7b14ba41233ba0" +dependencies = [ + "core-foundation 0.10.1", + "core-foundation-sys", + "jni 0.22.4", + "log", + "once_cell", + "rustls", + "rustls-native-certs", + "rustls-platform-verifier-android", + "rustls-webpki", + "security-framework", + "security-framework-sys", + "webpki-root-certs", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls-platform-verifier-android" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" + [[package]] name = "rustls-webpki" version = "0.103.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" dependencies = [ + "aws-lc-rs", "ring", "rustls-pki-types", "untrusted", @@ -3894,6 +4000,18 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" +[[package]] +name = "rusty-fork" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc6bf79ff24e648f6da1f8d1f011e9cac26491b619e6b9280f2b47f1774e6ee2" +dependencies = [ + "fnv", + "quick-error", + "tempfile", + "wait-timeout", +] + [[package]] name = "ryu" version = "1.0.23" @@ -3966,7 +4084,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -3981,7 +4099,7 @@ version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "core-foundation 0.10.1", "core-foundation-sys", "libc", @@ -4004,7 +4122,7 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c5d9c0c92a92d33f08817311cf3f2c29a3538a8240e94a6a3c622ce652d7e00c" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "cssparser", "derive_more", "log", @@ -4066,7 +4184,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -4077,14 +4195,14 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] name = "serde_json" -version = "1.0.149" +version = "1.0.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" dependencies = [ "itoa", "memchr", @@ -4106,9 +4224,9 @@ dependencies = [ [[package]] name = "serde_regex" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8136f1a4ea815d7eac4101cfd0b16dc0cb5e1fe1b8609dfd728058656b7badf" +checksum = "bafc8d0c5330cecff10f16b459b479fd9acaa5b4acd7167301414e21b0057012" dependencies = [ "regex", "serde", @@ -4122,7 +4240,7 @@ checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -4157,11 +4275,12 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.19.0" +version = "3.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f05839ce67618e14a09b286535c0d9c94e85ef25469b0e13cb4f844e5593eb19" +checksum = "76a5c54c7310e7b8b9577c286d7e399ddd876c3e12b3ed917a8aabc4b96e9e8c" dependencies = [ "base64 0.22.1", + "bs58", "chrono", "hex", "indexmap 1.9.3", @@ -4176,14 +4295,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.19.0" +version = "3.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf2ebbe86054f9b45bc3881e865683ccfaccce97b9b4cb53f3039d67f355a334" +checksum = "84d57bc0c8b9a17920c178daa6bb924850d54a9c97ab45194bb8c17ad66bb660" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -4205,7 +4324,7 @@ checksum = "772ee033c0916d670af7860b6e1ef7d658a4629a6d0b4c8c3e67f09b3765b75d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -4260,9 +4379,9 @@ dependencies = [ [[package]] name = "shlex" -version = "1.3.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" [[package]] name = "signal-hook" @@ -4331,15 +4450,15 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "smallvec" -version = "1.15.1" +version = "1.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" +checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" [[package]] name = "socket2" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" +checksum = "52d1cfed4120b4d927bf7c0f86d2087a4a7d6027c906d9f9d525a80573b9be51" dependencies = [ "libc", "windows-sys 0.61.2", @@ -4360,7 +4479,7 @@ dependencies = [ "objc2-foundation", "objc2-quartz-core", "raw-window-handle", - "redox_syscall 0.5.18", + "redox_syscall", "tracing", "wasm-bindgen", "web-sys", @@ -4412,7 +4531,7 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -4480,9 +4599,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.117" +version = "2.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422" dependencies = [ "proc-macro2", "quote", @@ -4506,7 +4625,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -4529,7 +4648,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "core-foundation 0.9.4", "system-configuration-sys", ] @@ -4559,11 +4678,11 @@ dependencies = [ [[package]] name = "tao" -version = "0.35.2" +version = "0.35.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33f7f9e486ade65fcf1e45c440f9236c904f5c1002cdc7fc6ae582777345ce4" +checksum = "d1c93047acf68669466a34690ac58cca7010bd1b201e1ec86f1fd0a75d3dd4a9" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "block2", "core-foundation 0.10.1", "core-graphics", @@ -4605,14 +4724,14 @@ checksum = "f4e16beb8b2ac17db28eab8bca40e62dbfbb34c0fcdc6d9826b11b7b5d047dfd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] name = "tar" -version = "0.4.45" +version = "0.4.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22692a6476a21fa75fdfc11d452fda482af402c008cdbaf3476414e122040973" +checksum = "3f6221d9a6003c78398e3b239969f352578258df48c8eb051caadae0015bc840" dependencies = [ "filetime", "libc", @@ -4627,9 +4746,9 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tauri" -version = "2.11.1" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b93bd86d231f0a8138f11a02a584769fe4b703dc36ae133d783228dbc4801405" +checksum = "c2616f96cb644bf2c5c456d9de4d5d5100e592d7424c74d8b55c5cb96e359e93" dependencies = [ "anyhow", "bytes", @@ -4655,7 +4774,7 @@ dependencies = [ "percent-encoding", "plist", "raw-window-handle", - "reqwest 0.13.3", + "reqwest", "serde", "serde_json", "serde_repr", @@ -4678,9 +4797,9 @@ dependencies = [ [[package]] name = "tauri-build" -version = "2.6.1" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a318b234cc2dea65f575467bafcfb76286bce228ebc3778e337d61d03213007" +checksum = "bc9ce40b16101cb6ea63d3e221567affd1c3a9205f95d7bc574941a10636b632" dependencies = [ "anyhow", "cargo_toml", @@ -4699,9 +4818,9 @@ dependencies = [ [[package]] name = "tauri-codegen" -version = "2.6.1" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bd11644962add2549a60b7e7c6800f17d7020156e02f516021d8103e80cc528" +checksum = "08279169ff42f8fc45a1dbc9dcae888893ba95288142e5880c59b93a26d2cfc5" dependencies = [ "base64 0.22.1", "brotli", @@ -4715,7 +4834,7 @@ dependencies = [ "serde", "serde_json", "sha2", - "syn 2.0.117", + "syn 2.0.118", "tauri-utils", "thiserror 2.0.18", "time", @@ -4726,23 +4845,23 @@ dependencies = [ [[package]] name = "tauri-macros" -version = "2.6.1" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed9d3742a37a355d2e47c9af924e9fbc112abb76f9835d35d4780e318419502" +checksum = "e8b394794f399a421811d06966343e7933fcae92d59f5180b9388d1174497a45" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", "tauri-codegen", "tauri-utils", ] [[package]] name = "tauri-runtime" -version = "2.11.1" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fef478ba1d2ac21c2d528740b24d0cb315e1e8b1111aae53fafac34804371fc" +checksum = "b0b4bc95aed361b0019067d189a1174a603d460d0f6c72606512d59fc9c12ec8" dependencies = [ "cookie", "dpi", @@ -4765,9 +4884,9 @@ dependencies = [ [[package]] name = "tauri-runtime-wry" -version = "2.11.1" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3989df2ae1c476404fe0a2e8ffc4cfbde97e51efd613c2bb5355fbc9ab52cf0" +checksum = "fe41e015bf8fc4d6477ff4926a0ef769dc64ff34c7b0038b6f7cacae892acb5c" dependencies = [ "gtk", "http", @@ -4791,9 +4910,9 @@ dependencies = [ [[package]] name = "tauri-utils" -version = "2.9.1" +version = "2.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d57200389a2f82b4b0a40ae29ca19b6978116e8f4d4e974c3234ce40c0ffbdec" +checksum = "3e176a18e67764923c4f1ce66f25ae4abe5f688384d5eb1a0fa6c77f3d90f887" dependencies = [ "anyhow", "brotli", @@ -4845,7 +4964,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.4.2", + "getrandom 0.4.3", "once_cell", "rustix", "windows-sys 0.61.2", @@ -4887,7 +5006,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -4898,7 +5017,7 @@ checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -4912,12 +5031,11 @@ dependencies = [ [[package]] name = "time" -version = "0.3.47" +version = "0.3.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" +checksum = "711a53c2d47bbd818258c498c8dbfe186a2526c631495cfe7e078567f86b8469" dependencies = [ "deranged", - "itoa", "num-conv", "powerfmt", "serde_core", @@ -4927,15 +5045,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" [[package]] name = "time-macros" -version = "0.2.27" +version = "0.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" +checksum = "71c652a3727a9cbb9a02f707f530b618ce00d0ccd762009c8c23bd191df3c17d" dependencies = [ "num-conv", "time-core", @@ -4964,10 +5082,25 @@ dependencies = [ ] [[package]] -name = "tokio" -version = "1.52.2" +name = "tinyvec" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "110a78583f19d5cdb2c5ccf321d1290344e71313c6c37d43520d386027d18386" +checksum = "3e61e67053d25a4e82c844e8424039d9745781b3fc4f32b8d55ed50f5f667ef3" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc7f01b389ac15039e4dc9531aa973a135d7a4135281b12d7c1bc79fd57fffe" dependencies = [ "bytes", "libc", @@ -4987,7 +5120,7 @@ checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -5074,7 +5207,7 @@ dependencies = [ "toml_datetime 1.1.1+spec-1.1.0", "toml_parser", "toml_writer", - "winnow 1.0.2", + "winnow 1.0.3", ] [[package]] @@ -5130,14 +5263,14 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.25.11+spec-1.1.0" +version = "0.25.12+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b59c4d22ed448339746c59b905d24568fcbb3ab65a500494f7b8c3e97739f2b" +checksum = "d2153edc6955a6c354fad8f5efd38b6a8769bdccf9fe50f8e1329f81b0baa5d7" dependencies = [ "indexmap 2.14.0", "toml_datetime 1.1.1+spec-1.1.0", "toml_parser", - "winnow 1.0.2", + "winnow 1.0.3", ] [[package]] @@ -5146,7 +5279,7 @@ version = "1.1.2+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2abe9b86193656635d2411dc43050282ca48aa31c2451210f4202550afb7526" dependencies = [ - "winnow 1.0.2", + "winnow 1.0.3", ] [[package]] @@ -5173,11 +5306,11 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.6.9" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28f0d049ccfaa566e14e9663d304d8577427b368cb4710a20528690287a738b" +checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "bytes", "futures-util", "http", @@ -5223,9 +5356,9 @@ dependencies = [ [[package]] name = "tray-icon" -version = "0.23.1" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15edbb0d80583e85ee8df283410038e17314df5cba30da2087a54a85216c0773" +checksum = "65ba1e5f6b9ef9fd87e21b9c6f351554dbd717960089168fcfdef854686961dc" dependencies = [ "crossbeam-channel", "dirs", @@ -5273,9 +5406,15 @@ checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" [[package]] name = "typenum" -version = "1.20.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ce102ab67701b8526c123c1bab5cbe42d7040ccfd0f64af1a385808d2f43de" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "unarray" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] name = "unic-char-property" @@ -5326,9 +5465,9 @@ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] name = "unicode-segmentation" -version = "1.13.2" +version = "1.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9629274872b2bfaf8d66f5f15725007f635594914870f65218920345aa11aa8c" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" [[package]] name = "unicode-width" @@ -5336,12 +5475,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" -[[package]] -name = "unicode-xid" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" - [[package]] name = "universal-hash" version = "0.5.1" @@ -5415,11 +5548,11 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.23.1" +version = "1.23.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddd74a9687298c6858e9b88ec8935ec45d22e8fd5e6394fa1bd4e99a87789c76" +checksum = "144d6b123cef80b301b8f72a9e2ca4370ddec21950d0a103dd22c437006d2db7" dependencies = [ - "getrandom 0.4.2", + "getrandom 0.4.3", "js-sys", "serde_core", "sha1_smol", @@ -5474,6 +5607,15 @@ dependencies = [ "libc", ] +[[package]] +name = "wait-timeout" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11" +dependencies = [ + "libc", +] + [[package]] name = "walkdir" version = "2.5.0" @@ -5500,34 +5642,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] -name = "wasip2" -version = "1.0.3+wasi-0.2.9" +name = "wasi" +version = "0.14.7+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6" +checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c" dependencies = [ - "wit-bindgen 0.57.1", + "wasip2", ] [[package]] -name = "wasip3" -version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +name = "wasip2" +version = "1.0.4+wasi-0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" dependencies = [ - "wit-bindgen 0.51.0", + "wit-bindgen", ] [[package]] name = "wasite" -version = "0.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" +checksum = "66fe902b4a6b8028a753d5424909b764ccf79b7a209eac9bf97e59cda9f71a42" +dependencies = [ + "wasi 0.14.7+wasi-0.2.4", +] [[package]] name = "wasm-bindgen" -version = "0.2.120" +version = "0.2.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df52b6d9b87e0c74c9edfa1eb2d9bf85e5d63515474513aa50fa181b3c4f5db1" +checksum = "8ddb3f79143bced6de84270411622a2699cee572fc0875aeaf1e7867cf9fca1a" dependencies = [ "cfg-if", "once_cell", @@ -5538,9 +5683,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.70" +version = "0.4.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af934872acec734c2d80e6617bbb5ff4f12b052dd8e6332b0817bce889516084" +checksum = "503b14d284f2c8dac03b819967e155ea753f573586193b2b2c95990cb5d69280" dependencies = [ "js-sys", "wasm-bindgen", @@ -5548,9 +5693,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.120" +version = "0.2.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b1041f495fb322e64aca85f5756b2172e35cd459376e67f2a6c9dffcedb103" +checksum = "4e21a184b13fb19e157296e2c46056aec9092264fab83e4ba59e68c61b323c3d" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -5558,61 +5703,26 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.120" +version = "0.2.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dcd0ff20416988a18ac686d4d4d0f6aae9ebf08a389ff5d29012b05af2a1b41" +checksum = "fecefd9c35bd935a20fc3fc344b5f29138961e4f47fb03297d88f2587afb5ebd" dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.120" +version = "0.2.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49757b3c82ebf16c57d69365a142940b384176c24df52a087fb748e2085359ea" +checksum = "23939e44bb9a5d7576fa2b563dc2e136628f1224e88a8deed09e04858b77871f" dependencies = [ "unicode-ident", ] -[[package]] -name = "wasm-encoder" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" -dependencies = [ - "leb128fmt", - "wasmparser", -] - -[[package]] -name = "wasm-metadata" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" -dependencies = [ - "anyhow", - "indexmap 2.14.0", - "wasm-encoder", - "wasmparser", -] - -[[package]] -name = "wasm-streams" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65" -dependencies = [ - "futures-util", - "js-sys", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - [[package]] name = "wasm-streams" version = "0.5.0" @@ -5627,22 +5737,20 @@ dependencies = [ ] [[package]] -name = "wasmparser" -version = "0.244.0" +name = "web-sys" +version = "0.3.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +checksum = "a6430a72df5eb332242960fe84b3002a241163998241eb596d4f739b9757061d" dependencies = [ - "bitflags 2.11.1", - "hashbrown 0.15.5", - "indexmap 2.14.0", - "semver", + "js-sys", + "wasm-bindgen", ] [[package]] -name = "web-sys" -version = "0.3.97" +name = "web-time" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eadbac71025cd7b0834f20d1fe8472e8495821b4e9801eb0a60bd1f19827602" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" dependencies = [ "js-sys", "wasm-bindgen", @@ -5650,9 +5758,9 @@ dependencies = [ [[package]] name = "web_atoms" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7cff6eef815df1834fd250e3a2ff436044d82a9f1bc1980ca1dbdf07effc538" +checksum = "075474b12bcb3d2e3d4546580e9de478eeeead668a1761e2a8860c836b7ef297" dependencies = [ "phf", "phf_codegen", @@ -5720,6 +5828,15 @@ dependencies = [ "system-deps", ] +[[package]] +name = "webpki-root-certs" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d46a5a140e6f7afeccd8eae97eff335163939eac8b929834875168b29b3d267" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "webview2-com" version = "0.38.2" @@ -5742,7 +5859,7 @@ checksum = "67a921c1b6914c367b2b823cd4cde6f96beec77d30a939c8199bb377cf9b9b54" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -5758,20 +5875,22 @@ dependencies = [ [[package]] name = "which" -version = "8.0.2" +version = "8.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81995fafaaaf6ae47a7d0cc83c67caf92aeb7e5331650ae6ff856f7c0c60c459" +checksum = "48d7cd18d4acb58fb3cdfe9ea54e6cd96a4e7d4cc45c56338b236e82dad47248" dependencies = [ "libc", ] [[package]] name = "whoami" -version = "1.6.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d4a4db5077702ca3015d3d02d74974948aba2ad9e12ab7df718ee64ccd7e97d" +checksum = "998767ef88740d1f5b0682a9c53c24431453923962269c2db68ee43788c5a40d" dependencies = [ + "libc", "libredox", + "objc2-system-configuration", "wasite", "web-sys", ] @@ -5889,7 +6008,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -5900,7 +6019,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -6235,15 +6354,12 @@ name = "winnow" version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945" -dependencies = [ - "memchr", -] [[package]] name = "winnow" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ee1708bef14716a11bae175f579062d4554d95be2c6829f518df847b7b3fdd0" +checksum = "0592e1c9d151f854e6fd382574c3a0855250e1d9b2f99d9281c6e6391af352f1" dependencies = [ "memchr", ] @@ -6258,100 +6374,12 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "wit-bindgen" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" -dependencies = [ - "wit-bindgen-rust-macro", -] - [[package]] name = "wit-bindgen" version = "0.57.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" -[[package]] -name = "wit-bindgen-core" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" -dependencies = [ - "anyhow", - "heck 0.5.0", - "wit-parser", -] - -[[package]] -name = "wit-bindgen-rust" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" -dependencies = [ - "anyhow", - "heck 0.5.0", - "indexmap 2.14.0", - "prettyplease", - "syn 2.0.117", - "wasm-metadata", - "wit-bindgen-core", - "wit-component", -] - -[[package]] -name = "wit-bindgen-rust-macro" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" -dependencies = [ - "anyhow", - "prettyplease", - "proc-macro2", - "quote", - "syn 2.0.117", - "wit-bindgen-core", - "wit-bindgen-rust", -] - -[[package]] -name = "wit-component" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" -dependencies = [ - "anyhow", - "bitflags 2.11.1", - "indexmap 2.14.0", - "log", - "serde", - "serde_derive", - "serde_json", - "wasm-encoder", - "wasm-metadata", - "wasmparser", - "wit-parser", -] - -[[package]] -name = "wit-parser" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" -dependencies = [ - "anyhow", - "id-arena", - "indexmap 2.14.0", - "log", - "semver", - "serde", - "serde_derive", - "serde_json", - "unicode-xid", - "wasmparser", -] - [[package]] name = "writeable" version = "0.6.3" @@ -6435,9 +6463,9 @@ dependencies = [ [[package]] name = "xml" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8aa498d22c9bbaf482329839bc5620c46be275a19a812e9a22a2b07529a642a" +checksum = "636f85e5ca6488e96401b61eb7de54f4e44755c988af0f52cf90230c312a1a89" [[package]] name = "xmltree" @@ -6445,6 +6473,7 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbc04313cab124e498ab1724e739720807b6dc405b9ed0edc5860164d2e4ff70" dependencies = [ + "indexmap 2.14.0", "xml", ] @@ -6459,9 +6488,9 @@ dependencies = [ [[package]] name = "yoke" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abe8c5fda708d9ca3df187cae8bfb9ceda00dd96231bed36e445a1a48e66f9ca" +checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5" dependencies = [ "stable_deref_trait", "yoke-derive", @@ -6476,35 +6505,35 @@ checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", "synstructure", ] [[package]] name = "zerocopy" -version = "0.8.48" +version = "0.8.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9" +checksum = "ce1022995ff5ff5d841ad7d994facc23098cd40152f2c1d11cd607c6f530653f" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.48" +version = "0.8.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4" +checksum = "1ae7f38b72ec2a254e2b87ef277cf2cd4fb97cbebf944faa6f33354da0867930" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] name = "zerofrom" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69faa1f2a1ea75661980b013019ed6687ed0e83d069bc1114e2cc74c6c04c4df" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" dependencies = [ "zerofrom-derive", ] @@ -6517,15 +6546,15 @@ checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", "synstructure", ] [[package]] name = "zeroize" -version = "1.8.2" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" +checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" [[package]] name = "zerotrie" @@ -6557,7 +6586,7 @@ checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 40c0e83..92d27d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ license = "GPL-3.0" [workspace.dependencies] anyhow = "1.0" -askama = "0.14" +askama = "0.16" base64 = "0.22" chrono = "0.4" clap = { version = "4", features = ["derive"] } @@ -31,10 +31,10 @@ env_logger = "0.11" is_executable = "1.0" log = "0.4" regex = "1" -reqwest = { version = "0.12", features = ["native-tls", "json"] } +reqwest = { version = "0.13", features = ["native-tls", "json", "form", "query"] } openssl = "0.10" pem = "3" -xmltree = "0.12" +xmltree = { version = "0.12", features = ["attribute-order"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" # Use 0.36 as newer versions requires Rust 1.88+ @@ -48,7 +48,7 @@ axum = "0.8" futures = "0.3" futures-util = "0.3" uzers = "0.12" -whoami = "1" +whoami = "2" thiserror = "2" redact-engine = "0.1" compile-time = "0.2" @@ -58,12 +58,12 @@ sha256 = "1" which = "8" uuid = "1" netdev = "0.40" -machine-uid = "0.5" humantime = "2" # Tauri dependencies tauri = { version = "2" } specta = "=2.0.0-rc.20" +proptest = "1" [profile.release] opt-level = 'z' # Optimize for size diff --git a/Makefile b/Makefile index b816bd6..6bf9ff2 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ -.SHELLFLAGS += -e +SHELL := /bin/sh +.SHELLFLAGS := -ec INCLUDE_GUI ?= 0 CARGO ?= cargo @@ -7,6 +8,16 @@ RUST_VERSION ?= 1.89 IGNORE_RUST_VERSION ?= 0 VERSION = $(shell grep '^version' Cargo.toml | head -1 | sed 's/version *= *"\(.*\)"/\1/') +SOURCE_COMMIT_VALUE := $(shell \ + if [ -n "$$SOURCE_GIT_COMMIT" ]; then \ + printf '%s' "$$SOURCE_GIT_COMMIT" | cut -c1-9; \ + elif [ -n "$$GITHUB_SHA" ]; then \ + printf '%s' "$$GITHUB_SHA" | cut -c1-9; \ + elif [ -f SOURCE_COMMIT ]; then \ + head -n1 SOURCE_COMMIT | tr -d '[:space:]' | cut -c1-9; \ + else \ + git rev-parse --short=9 HEAD 2>/dev/null || printf unknown; \ + fi) GUI_LIBC_SUFFIX ?= $(shell ldd --version 2>&1 | grep -qi musl && echo -musl || true) REVISION ?= 1 RPM_SOURCE ?= %{name}.tar.gz @@ -20,6 +31,12 @@ PUBLISH ?= 0 # Indicates whether to build the GUI components BUILD_GUI_HELPER ?= 1 +# Indicates whether to build embedded webview auth support into gpauth +BUILD_WEBVIEW_AUTH ?= 1 +PREFIX ?= /usr/local +BSD_FLAVOR ?= $(shell uname -s | tr '[:upper:]' '[:lower:]') +GPGUI_BINARY ?= ../gpgui/target/release/gpgui + export DEBEMAIL = k3vinyue@gmail.com export DEBFULLNAME = Kevin Yue export SNAPSHOT = $(shell test -f SNAPSHOT && echo "true" || echo "false") @@ -55,11 +72,13 @@ clean-tarball: rm -rf .vendor rm -rf vendor.tar.xz rm -rf .cargo + rm -f SOURCE_COMMIT # Create a tarball, include the cargo dependencies if OFFLINE is set to 1 tarball: clean-tarball mkdir -p .cargo mkdir -p .build/tarball + printf '%s\n' "$(SOURCE_COMMIT_VALUE)" > SOURCE_COMMIT # If OFFLINE is set to 1, vendor all cargo dependencies # Generate a OFFLINE_BUILD file to indicate offline build @@ -97,11 +116,18 @@ build-rs: rm -vf rust-toolchain.toml; \ fi + $(CARGO) build $(CARGO_BUILD_ARGS) -p gpclient -p gpservice + + # Build gpauth with or without embedded webview auth support + if [ $(BUILD_WEBVIEW_AUTH) -eq 1 ]; then \ + $(CARGO) build $(CARGO_BUILD_ARGS) -p gpauth; \ + else \ + $(CARGO) build $(CARGO_BUILD_ARGS) -p gpauth --no-default-features; \ + fi + # Only build the GUI components if BUILD_GUI_HELPER is set to 1 if [ $(BUILD_GUI_HELPER) -eq 1 ]; then \ - $(CARGO) build $(CARGO_BUILD_ARGS) -p gpclient -p gpservice -p gpauth -p gpgui-helper; \ - else \ - $(CARGO) build $(CARGO_BUILD_ARGS) -p gpclient -p gpservice -p gpauth --no-default-features; \ + $(CARGO) build $(CARGO_BUILD_ARGS) -p gpgui-helper; \ fi clean: @@ -140,6 +166,98 @@ install: install -Dm644 packaging/files/usr/share/icons/hicolor/256x256@2/apps/gpgui.png $(DESTDIR)/usr/share/icons/hicolor/256x256@2/apps/gpgui.png install -Dm644 packaging/files/usr/share/polkit-1/actions/com.yuezk.gpgui.policy $(DESTDIR)/usr/share/polkit-1/actions/com.yuezk.gpgui.policy +install-bsd: + @echo "Installing $(PKG_NAME) for BSD under $(PREFIX)..." + + install -d $(DESTDIR)$(PREFIX)/bin + install -m 755 target/release/gpclient $(DESTDIR)$(PREFIX)/bin/gpclient + install -m 755 target/release/gpauth $(DESTDIR)$(PREFIX)/bin/gpauth + install -m 755 target/release/gpservice $(DESTDIR)$(PREFIX)/bin/gpservice + + if [ "$(BUILD_GUI_HELPER)" = "1" ]; then \ + install -m 755 target/release/gpgui-helper $(DESTDIR)$(PREFIX)/bin/gpgui-helper; \ + fi + + if [ -x "$(GPGUI_BINARY)" ]; then \ + install -m 755 "$(GPGUI_BINARY)" $(DESTDIR)$(PREFIX)/bin/gpgui; \ + fi + + install -d $(DESTDIR)$(PREFIX)/libexec/gpclient + install -m 755 packaging/files/usr/libexec/gpclient/vpnc-script $(DESTDIR)$(PREFIX)/libexec/gpclient/vpnc-script + install -m 755 packaging/files/usr/libexec/gpclient/hipreport.sh $(DESTDIR)$(PREFIX)/libexec/gpclient/hipreport.sh + + install -d $(DESTDIR)$(PREFIX)/share/applications + install -m 644 packaging/bsd/gpgui.desktop $(DESTDIR)$(PREFIX)/share/applications/gpgui.desktop + install -d $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps + install -d $(DESTDIR)$(PREFIX)/share/icons/hicolor/32x32/apps + install -d $(DESTDIR)$(PREFIX)/share/icons/hicolor/128x128/apps + install -d $(DESTDIR)$(PREFIX)/share/icons/hicolor/256x256@2/apps + install -m 644 packaging/files/usr/share/icons/hicolor/scalable/apps/gpgui.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps/gpgui.svg + install -m 644 packaging/files/usr/share/icons/hicolor/32x32/apps/gpgui.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/32x32/apps/gpgui.png + install -m 644 packaging/files/usr/share/icons/hicolor/128x128/apps/gpgui.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/128x128/apps/gpgui.png + install -m 644 packaging/files/usr/share/icons/hicolor/256x256@2/apps/gpgui.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/256x256@2/apps/gpgui.png + install -d $(DESTDIR)$(PREFIX)/share/polkit-1/actions + install -m 644 packaging/bsd/com.yuezk.gpgui.policy $(DESTDIR)$(PREFIX)/share/polkit-1/actions/com.yuezk.gpgui.policy + +clean-bsd-package: + rm -rf .build/$(BSD_FLAVOR) + +bsd-gpgui-tarball: + test -x "$(GPGUI_BINARY)" + rm -rf .build/$(BSD_FLAVOR)/gpgui + mkdir -p .build/$(BSD_FLAVOR)/artifacts .build/$(BSD_FLAVOR)/gpgui/gpgui_$(VERSION) + cp "$(GPGUI_BINARY)" .build/$(BSD_FLAVOR)/gpgui/gpgui_$(VERSION)/ + tar -cf - -C .build/$(BSD_FLAVOR)/gpgui gpgui_$(VERSION) | xz -c > .build/$(BSD_FLAVOR)/artifacts/gpgui_$(BSD_FLAVOR)_$(shell uname -m).bin.tar.xz + file=.build/$(BSD_FLAVOR)/artifacts/gpgui_$(BSD_FLAVOR)_$(shell uname -m).bin.tar.xz; \ + if command -v sha256sum >/dev/null 2>&1; then sha256sum "$$file" | cut -d ' ' -f 1; \ + elif command -v sha256 >/dev/null 2>&1; then sha256 -q "$$file"; \ + else cksum -a sha256 "$$file" | awk '{print $$1}'; fi > "$$file.sha256" + +package-freebsd: BSD_FLAVOR=freebsd +package-freebsd: clean-bsd-package + test -x "$(GPGUI_BINARY)" + mkdir -p .build/freebsd/pkgroot .build/freebsd/artifacts + $(MAKE) install-bsd DESTDIR=$(CURDIR)/.build/freebsd/pkgroot PREFIX=$(PREFIX) GPGUI_BINARY="$(GPGUI_BINARY)" + find .build/freebsd/pkgroot$(PREFIX) -type f -print | sed 's|^.build/freebsd/pkgroot$(PREFIX)/||' | sort > .build/freebsd/PLIST + freebsd_major=$$(freebsd-version -u | sed 's/\..*//'); \ + freebsd_arch=$$(uname -m | sed -e 's/x86_64/amd64/' -e 's/arm64/aarch64/'); \ + sed \ + -e 's/@PKG_NAME@/$(PKG_NAME)/g' \ + -e 's/@VERSION@/$(VERSION)/g' \ + -e "s/@ABI@/FreeBSD:$$freebsd_major:$$freebsd_arch/g" \ + -e "s/@ARCH@/freebsd:$$freebsd_major:$$freebsd_arch/g" \ + -e 's|@PREFIX@|$(PREFIX)|g' \ + packaging/bsd/freebsd/MANIFEST.in > .build/freebsd/+MANIFEST + pkg create -r .build/freebsd/pkgroot -M .build/freebsd/+MANIFEST -p .build/freebsd/PLIST -o .build/freebsd/artifacts + freebsd_arch=$$(uname -m | sed -e 's/x86_64/amd64/' -e 's/arm64/aarch64/'); \ + mv .build/freebsd/artifacts/$(PKG_NAME)-$(VERSION).pkg .build/freebsd/artifacts/$(PKG_NAME)-$(VERSION)-freebsd-$$freebsd_arch.pkg + $(MAKE) bsd-gpgui-tarball BSD_FLAVOR=freebsd GPGUI_BINARY="$(GPGUI_BINARY)" + +package-openbsd: BSD_FLAVOR=openbsd +package-openbsd: clean-bsd-package + test -x "$(GPGUI_BINARY)" + mkdir -p .build/openbsd/pkgroot .build/openbsd/artifacts + $(MAKE) install-bsd DESTDIR=$(CURDIR)/.build/openbsd/pkgroot PREFIX=$(PREFIX) GPGUI_BINARY="$(GPGUI_BINARY)" + cp packaging/bsd/openbsd/COMMENT .build/openbsd/+COMMENT + cp packaging/bsd/openbsd/DESC .build/openbsd/+DESC + find .build/openbsd/pkgroot$(PREFIX) -type f -print | sed 's|^.build/openbsd/pkgroot$(PREFIX)/||' | sort > .build/openbsd/PLIST + comment=$$(cat .build/openbsd/+COMMENT); \ + openbsd_arch=$$(uname -m | sed 's/x86_64/amd64/'); \ + gnome_keyring_pkg=$$(pkg_info -e 'gnome-keyring-*' | sed 's/^inst://' | head -n 1); \ + polkit_pkg=$$(pkg_info -e 'polkit-*' | sed 's/^inst://' | head -n 1); \ + webkitgtk_pkg=$$(pkg_info -e 'webkitgtk41-*' | sed 's/^inst://' | head -n 1); \ + pkg_create \ + -B .build/openbsd/pkgroot \ + -D COMMENT="$$comment" \ + -d .build/openbsd/+DESC \ + -f .build/openbsd/PLIST \ + -p $(PREFIX) \ + -P x11/gnome/keyring:gnome-keyring-*:$$gnome_keyring_pkg \ + -P sysutils/polkit:polkit-*:$$polkit_pkg \ + -P www/webkitgtk4,webkitgtk41:webkitgtk41-*:$$webkitgtk_pkg \ + .build/openbsd/artifacts/$(PKG_NAME)-$(VERSION)-openbsd-$$openbsd_arch.tgz + $(MAKE) bsd-gpgui-tarball BSD_FLAVOR=openbsd GPGUI_BINARY="$(GPGUI_BINARY)" + uninstall: @echo "Uninstalling $(PKG_NAME)..." @@ -185,10 +303,15 @@ init-debian: clean-debian tarball sed -i "/libsecret-1-0/d" .build/deb/$(PKG)/debian/control; \ sed -i "/libayatana-appindicator3-1/d" .build/deb/$(PKG)/debian/control; \ sed -i "/gnome-keyring/d" .build/deb/$(PKG)/debian/control; \ + fi + + # Remove the WebKitGTK build dependency only if neither gpauth webview auth nor gpgui-helper needs it + if [ $(BUILD_GUI_HELPER) -eq 0 ] && [ $(BUILD_WEBVIEW_AUTH) -eq 0 ]; then \ sed -i "/libwebkit2gtk-4.1-dev/d" .build/deb/$(PKG)/debian/control; \ fi sed -i "s/@BUILD_GUI_HELPER@/$(BUILD_GUI_HELPER)/g" .build/deb/$(PKG)/debian/rules + sed -i "s/@BUILD_WEBVIEW_AUTH@/$(BUILD_WEBVIEW_AUTH)/g" .build/deb/$(PKG)/debian/rules sed -i "s/@RUST_VERSION@/$(RUST_VERSION)/g" .build/deb/$(PKG)/debian/rules rm -f .build/deb/$(PKG)/debian/changelog diff --git a/README.md b/README.md index 9edc828..8d18ab8 100644 --- a/README.md +++ b/README.md @@ -212,14 +212,6 @@ sudo emerge --ask --verbose net-vpn/GlobalProtect-openconnect This repository includes a flake for NixOS integration. -If you want a quick user-level install, you can install it directly from the flake: - -```bash -nix profile add github:yuezk/GlobalProtect-openconnect -``` - -If you want it managed as part of your NixOS system configuration, use the steps below. - #### Installation Steps 1. Add the flake to your `flake.nix`: @@ -245,13 +237,12 @@ If you want it managed as part of your NixOS system configuration, use the steps 2. Add the package to your `configuration.nix`: ```nix - { config, pkgs, inputs, ... }: + { pkgs, inputs, ... }: { # ... other configurations environment.systemPackages = with pkgs; [ # ... other packages - ] ++ [ inputs.globalprotect-openconnect.packages.${pkgs.stdenv.hostPlatform.system}.default ]; } diff --git a/apps/gpauth/build.rs b/apps/gpauth/build.rs index 280edd3..6b1dc12 100644 --- a/apps/gpauth/build.rs +++ b/apps/gpauth/build.rs @@ -1,4 +1,63 @@ +use std::{env, fs, path::PathBuf, process::Command}; + +const UNKNOWN_COMMIT: &str = "unknown"; +const DISPLAY_COMMIT_LEN: usize = 9; + fn main() { + println!("cargo:rerun-if-env-changed=GPAUTH_GIT_COMMIT"); + println!("cargo:rerun-if-env-changed=SOURCE_GIT_COMMIT"); + println!("cargo:rerun-if-env-changed=GITHUB_SHA"); + + let repo_root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is set")).join("../.."); + let source_commit = repo_root.join("SOURCE_COMMIT"); + println!("cargo:rerun-if-changed={}", source_commit.display()); + println!( + "cargo:rustc-env=GPAUTH_GIT_COMMIT={}", + resolve_commit(&repo_root, &source_commit) + ); + #[cfg(feature = "webview-auth")] tauri_build::build() } + +fn resolve_commit(repo_root: &PathBuf, source_commit: &PathBuf) -> String { + env_commit("GPAUTH_GIT_COMMIT") + .or_else(|| env_commit("SOURCE_GIT_COMMIT")) + .or_else(|| env_commit("GITHUB_SHA")) + .or_else(|| file_commit(source_commit)) + .or_else(|| git_commit(repo_root)) + .unwrap_or_else(|| UNKNOWN_COMMIT.to_string()) +} + +fn env_commit(key: &str) -> Option { + env::var(key).ok().and_then(|value| normalize_commit(&value)) +} + +fn file_commit(path: &PathBuf) -> Option { + fs::read_to_string(path).ok().and_then(|value| normalize_commit(&value)) +} + +fn git_commit(repo_root: &PathBuf) -> Option { + let output = Command::new("git") + .args(["rev-parse", "--short=9", "HEAD"]) + .current_dir(repo_root) + .output() + .ok()?; + + if !output.status.success() { + return None; + } + + String::from_utf8(output.stdout) + .ok() + .and_then(|value| normalize_commit(&value)) +} + +fn normalize_commit(value: &str) -> Option { + let value = value.trim(); + if value.is_empty() { + return None; + } + + Some(value.chars().take(DISPLAY_COMMIT_LEN).collect()) +} diff --git a/apps/gpauth/src/cli.rs b/apps/gpauth/src/cli.rs index d63dd02..b5d11ac 100644 --- a/apps/gpauth/src/cli.rs +++ b/apps/gpauth/src/cli.rs @@ -1,17 +1,24 @@ use auth::{BrowserAuthenticator, auth_prelogin}; use clap::Parser; -use common::constants::GP_USER_AGENT; use gpapi::{ auth::{SamlAuthData, SamlAuthResult}, clap::{Args, InfoLevelVerbosity, args::Os, handle_error}, - gp_params::{ClientOs, GpParams}, + gp_params::GpParams, + os_profile::{ClientOs, OsProfile}, utils::{normalize_server, openssl}, }; use log::info; use serde_json::json; use tempfile::NamedTempFile; -const VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), " (", compile_time::date_str!(), ")"); +const VERSION: &str = concat!( + env!("CARGO_PKG_VERSION"), + " (", + env!("GPAUTH_GIT_COMMIT"), + " ", + compile_time::date_str!(), + ")" +); #[derive(Parser)] #[command( @@ -41,14 +48,14 @@ struct Cli { #[arg(long, help = "The SAML authentication request")] saml_request: Option, - #[arg(long, default_value = GP_USER_AGENT, help = "The user agent to use")] - user_agent: String, - - #[arg(long, default_value = "Linux")] + #[arg(long, value_enum, default_value_t = Os::default())] os: Os, - #[arg(long)] - os_version: Option, + #[arg(long, help = "Use this runtime host ID when building the OS profile")] + host_id: Option, + + #[arg(long, help = "Override the GlobalProtect client version reported to the server")] + client_version: Option, #[arg(long, help = "Get around the OpenSSL `unsafe legacy renegotiation` error")] fix_openssl: bool, @@ -114,10 +121,14 @@ impl Cli { let server = normalize_server(&self.server)?; let gp_params = self.build_gp_params(); + info!( + "gpauth auth host-id: {}", + gp_params.os_profile().host_identity().host_id() + ); let auth_request = match self.saml_request.as_deref() { Some(auth_request) => auth_request.to_string(), - None => auth_prelogin(&server, &gp_params).await?, + None => auth_prelogin(&server, &gp_params, self.external_browser_requested()).await?, }; #[cfg(feature = "webview-auth")] @@ -130,10 +141,11 @@ impl Cli { let browser = self.browser.as_deref().or(Some("default")); if let Some(browser) = browser { + let auth_host_id = gp_params.os_profile().host_identity().host_id().to_string(); let authenticator = BrowserAuthenticator::new(&auth_request, browser); let auth_result = authenticator.authenticate().await; - print_auth_result(auth_result); + print_auth_result(auth_result, Some(&auth_host_id)); // explicitly drop openssl_conf to avoid the unused variable warning drop(openssl_conf); @@ -147,15 +159,33 @@ impl Cli { } fn build_gp_params(&self) -> GpParams { - let gp_params = GpParams::builder() - .user_agent(&self.user_agent) - .client_os(ClientOs::from(&self.os)) - .os_version(self.os_version.clone()) + GpParams::builder(self.build_os_profile()) .ignore_tls_errors(self.ignore_tls_errors) .is_gateway(self.gateway) - .build(); + .build() + } - gp_params + fn build_os_profile(&self) -> OsProfile { + let mut builder = OsProfile::builder(ClientOs::from(self.os)); + if let Some(host_id) = self.host_id.as_deref() { + builder = builder.host_id_override(host_id); + } + if let Some(client_version) = self.client_version.as_deref() { + builder = builder.client_version(client_version); + } + builder.build() + } + + fn external_browser_requested(&self) -> bool { + #[cfg(feature = "webview-auth")] + { + self.default_browser || self.browser.is_some() + } + + #[cfg(not(feature = "webview-auth"))] + { + true + } } } @@ -177,11 +207,56 @@ pub async fn run() { } } -pub fn print_auth_result(auth_result: anyhow::Result) { +pub fn print_auth_result(auth_result: anyhow::Result, host_id: Option<&str>) { let auth_result = match auth_result { - Ok(auth_data) => SamlAuthResult::Success(auth_data), + Ok(auth_data) => { + let auth_data = match host_id { + Some(host_id) => auth_data.with_host_id(host_id), + None => auth_data, + }; + SamlAuthResult::Success(auth_data) + } Err(err) => SamlAuthResult::Failure(format!("{}", err)), }; println!("{}", json!(auth_result)); } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn os_defaults_to_runtime_os() { + let cli = Cli::try_parse_from(["gpauth", "portal.example.com"]).expect("gpauth args should parse"); + + assert_eq!(cli.os, Os::default()); + } + + #[test] + fn host_id_arg_sets_profile_host_id_seed() { + let cli = Cli::try_parse_from(["gpauth", "portal.example.com", "--host-id", "host-seed"]) + .expect("gpauth args should parse"); + let profile = cli.build_os_profile(); + + assert_eq!(profile.host_identity().host_id(), "host-seed"); + } + + #[test] + fn browser_arg_requests_external_browser() { + let cli = + Cli::try_parse_from(["gpauth", "portal.example.com", "--browser", "firefox"]).expect("gpauth args should parse"); + + assert!(cli.external_browser_requested()); + } + + #[test] + fn client_version_arg_sets_profile_client_version() { + let cli = Cli::try_parse_from(["gpauth", "portal.example.com", "--client-version", "legacy-client"]) + .expect("gpauth args should parse"); + let profile = cli.build_os_profile(); + + assert_eq!(profile.client_version(), "legacy-client"); + assert!(profile.user_agent().contains("legacy-client")); + } +} diff --git a/apps/gpauth/src/webview_auth.rs b/apps/gpauth/src/webview_auth.rs index 8325622..abdf48b 100644 --- a/apps/gpauth/src/webview_auth.rs +++ b/apps/gpauth/src/webview_auth.rs @@ -13,6 +13,8 @@ pub async fn authenticate( clean: bool, mut openssl_conf: Option, ) -> anyhow::Result<()> { + let auth_host_id = gp_params.os_profile().host_identity().host_id().to_string(); + tauri::Builder::default() .setup(move |app| { let app_handle = app.handle().clone(); @@ -20,10 +22,11 @@ pub async fn authenticate( tauri::async_runtime::spawn(async move { let authenticator = WebviewAuthenticator::new(&server, &gp_params) .with_auth_request(&auth_request) + .with_webview_user_agent(gp_params.os_profile().webview_user_agent()) .with_clean(clean); let auth_result = authenticator.authenticate(&app_handle).await; - print_auth_result(auth_result); + print_auth_result(auth_result, Some(&auth_host_id)); // Ensure the app exits after the authentication process app_handle.exit(0); diff --git a/apps/gpclient/Cargo.toml b/apps/gpclient/Cargo.toml index 99d0f00..6ff57a8 100644 --- a/apps/gpclient/Cargo.toml +++ b/apps/gpclient/Cargo.toml @@ -30,6 +30,7 @@ directories.workspace = true compile-time.workspace = true netdev.workspace = true xmltree.workspace = true +uuid = { workspace = true, features = ["v5"] } [features] default = ["webview-auth"] diff --git a/apps/gpclient/build.rs b/apps/gpclient/build.rs new file mode 100644 index 0000000..d66ac42 --- /dev/null +++ b/apps/gpclient/build.rs @@ -0,0 +1,56 @@ +use std::{env, fs, path::PathBuf, process::Command}; + +const UNKNOWN_COMMIT: &str = "unknown"; +const DISPLAY_COMMIT_LEN: usize = 9; + +fn main() { + println!("cargo:rerun-if-env-changed=SOURCE_GIT_COMMIT"); + println!("cargo:rerun-if-env-changed=GPCLIENT_GIT_COMMIT"); + println!("cargo:rerun-if-env-changed=GITHUB_SHA"); + + let repo_root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is set")).join("../.."); + let source_commit = repo_root.join("SOURCE_COMMIT"); + println!("cargo:rerun-if-changed={}", source_commit.display()); + + let commit = env_commit("GPCLIENT_GIT_COMMIT") + .or_else(|| env_commit("SOURCE_GIT_COMMIT")) + .or_else(|| env_commit("GITHUB_SHA")) + .or_else(|| file_commit(&source_commit)) + .or_else(|| git_commit(&repo_root)) + .unwrap_or_else(|| UNKNOWN_COMMIT.to_string()); + + println!("cargo:rustc-env=GPCLIENT_GIT_COMMIT={commit}"); +} + +fn env_commit(key: &str) -> Option { + env::var(key).ok().and_then(|value| normalize_commit(&value)) +} + +fn file_commit(path: &PathBuf) -> Option { + fs::read_to_string(path).ok().and_then(|value| normalize_commit(&value)) +} + +fn git_commit(repo_root: &PathBuf) -> Option { + let output = Command::new("git") + .args(["rev-parse", "--short=12", "HEAD"]) + .current_dir(repo_root) + .output() + .ok()?; + + if !output.status.success() { + return None; + } + + String::from_utf8(output.stdout) + .ok() + .and_then(|value| normalize_commit(&value)) +} + +fn normalize_commit(value: &str) -> Option { + let value = value.trim(); + if value.is_empty() { + return None; + } + + Some(value.chars().take(DISPLAY_COMMIT_LEN).collect()) +} diff --git a/apps/gpclient/src/cli.rs b/apps/gpclient/src/cli.rs index cff6aa1..ad44c09 100644 --- a/apps/gpclient/src/cli.rs +++ b/apps/gpclient/src/cli.rs @@ -19,7 +19,14 @@ use crate::{ launch_gui::{LaunchGuiArgs, LaunchGuiHandler}, }; -const VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), " (", compile_time::date_str!(), ")"); +const VERSION: &str = concat!( + env!("CARGO_PKG_VERSION"), + " (", + env!("GPCLIENT_GIT_COMMIT"), + " ", + compile_time::date_str!(), + ")" +); pub(crate) struct SharedArgs<'a> { pub(crate) fix_openssl: bool, @@ -147,11 +154,11 @@ fn init_logger(cli: &Cli) { // Output the log messages to a file if the command is the auth callback if let CliCommand::LaunchGui(args) = &cli.command { let auth_data = args.auth_data.as_deref().unwrap_or_default(); - if !auth_data.is_empty() { - if let Ok(log_file) = File::create(temp_dir().join("gpcallback.log")) { - let target = Box::new(log_file); - builder.target(env_logger::Target::Pipe(target)); - } + if !auth_data.is_empty() + && let Ok(log_file) = File::create(temp_dir().join("gpcallback.log")) + { + let target = Box::new(log_file); + builder.target(env_logger::Target::Pipe(target)); } } diff --git a/apps/gpclient/src/connect.rs b/apps/gpclient/src/connect.rs deleted file mode 100644 index 71eb168..0000000 --- a/apps/gpclient/src/connect.rs +++ /dev/null @@ -1,753 +0,0 @@ -use std::{ - borrow::Cow, - cell::RefCell, - fs, - sync::{Arc, Mutex}, -}; - -use anyhow::{Context, bail}; -use clap::Args; -use common::constants::{GP_CLIENT_VERSION, GP_USER_AGENT}; -use gpapi::{ - auth::SamlAuthResult, - clap::{ToVerboseArg, args::Os}, - cookie_store, - credential::{Credential, PasswordCredential}, - error::PortalError, - gateway::{GatewayLogin, SessionExtensionAuth, gateway_login}, - gp_params::{ClientOs, GpParams}, - portal::{Prelogin, StandardPrelogin, prelogin, retrieve_config}, - process::{ - auth_launcher::SamlAuthLauncher, - users::{get_non_root_user, get_user_by_name}, - }, - utils::{host_utils, request::RequestIdentityError, shutdown_signal}, -}; -use inquire::{Password, PasswordDisplayMode, Select, Text}; -use log::{info, warn}; -use openconnect::Vpn; -use tokio::{runtime::Handle, task::JoinHandle}; - -use crate::{ - GP_CLIENT_LOCK_FILE, - cli::SharedArgs, - session::{SessionContextInput, build_session_context, session_info_from_vpn, spawn_session_runtime_with_info}, -}; - -struct GatewayLoginSession { - cookie: String, - extension_auth: SessionExtensionAuth, -} - -#[derive(Args)] -pub(crate) struct ConnectArgs { - #[arg(help = "The portal server to connect to")] - server: String, - - #[arg(short, long, help = "The gateway to connect to, it will prompt if not specified")] - gateway: Option, - - #[arg(short, long, help = "The username to use, it will prompt if not specified")] - user: Option, - - #[arg(long, help = "Read the password from standard input")] - passwd_on_stdin: bool, - - #[arg(long, help = "Read the cookie from standard input")] - cookie_on_stdin: bool, - - #[arg( - long, - help = "Path to the portal-cookie cache file. Defaults to $HOME/.config/gpclient/cookie.json" - )] - cookie_file: Option, - - #[arg(long, help = "Do not read or write the portal-cookie cache")] - no_cookie_cache: bool, - - #[arg(long, short, help = "The VPNC script to use", required_if_eq("script_tun", "true"))] - script: Option, - - #[arg(long, short, help = "The IFNAME for tunnel interface")] - interface: Option, - - #[arg(long, short = 'S', help = "Pass traffic to '--script' program, not tun")] - script_tun: bool, - - #[arg(long, help = "Connect the server as a gateway, instead of a portal")] - as_gateway: bool, - - #[arg( - long, - help = "Use HIP (Host Integrity Protection) extension, optionally specify the HIP script path", - default_missing_value = "", - num_args=0..=1 - )] - hip: Option, - - #[arg(long, help = "The user used to run the HIP script")] - hip_user: Option, - - #[arg( - short, - long, - help = "Use SSL client certificate file in pkcs#8 (.pem) or pkcs#12 (.p12, .pfx) format" - )] - certificate: Option, - - #[arg(short = 'k', long, help = "Use SSL private key file in pkcs#8 (.pem) format")] - sslkey: Option, - - #[arg(short = 'p', long, help = "The key passphrase of the private key")] - key_password: Option, - - #[arg(long, help = "Deprecated: Use the '--hip-user' option instead")] - csd_user: Option, - - #[arg(long, help = "Deprecated: Use the '--hip' option instead")] - csd_wrapper: Option, - - #[arg(long, default_value = "300", help = "Reconnection retry timeout in seconds")] - reconnect_timeout: u32, - - #[arg(short, long, help = "Request MTU from server (legacy servers only)")] - mtu: Option, - - #[arg(long, help = "Do not ask for IPv6 connectivity")] - disable_ipv6: bool, - - #[arg( - long, - help = "The user agent to use, if not specified, it will be generated based on the OS and client version" - )] - user_agent: Option, - - #[arg(long, value_enum, default_value_t = ConnectArgs::default_os())] - os: Os, - - #[arg(long, help = "If not specified, it will be computed based on the --os option")] - os_version: Option, - - #[arg(long, help = "The GP client version to emulate, e.g., '6.2.4-49'")] - client_version: Option, - - #[arg(long, help = "Disable DTLS and ESP")] - no_dtls: bool, - - #[arg( - long = "local-hostname", - help = "Same as the '--local-hostname' option in the openconnect command" - )] - local_hostname: Option, - - #[arg( - long = "force-dpd", - help = "Same as the '--force-dpd' option in the openconnect command" - )] - dpd_interval: Option, - - #[arg( - long = "no-xmlpost", - help = "Same as the '--no-xmlpost' option in the openconnect command" - )] - no_xmlpost: bool, - - #[cfg(feature = "webview-auth")] - #[arg(long, help = "The HiDPI mode, useful for high-resolution screens")] - hidpi: bool, - - #[cfg(feature = "webview-auth")] - #[arg(long, help = "Do not reuse the remembered authentication cookie")] - clean: bool, - - #[cfg(feature = "webview-auth")] - #[arg(long, help = "Deprecated: Use the `--browser` option instead")] - default_browser: bool, - - #[arg( - long, - help = "Use the specified browser to authenticate, e.g., `default`, `firefox`, `chrome`, `chromium`, `remote`.\nOr the path to the browser executable.\nUse 'remote' for headless servers.", - default_missing_value = "default", - num_args=0..=1 - )] - browser: Option, -} - -impl ConnectArgs { - fn default_os() -> Os { - #[cfg(target_os = "macos")] - return Os::Mac; - #[cfg(target_os = "windows")] - return Os::Windows; - #[cfg(not(any(target_os = "macos", target_os = "windows")))] - return Os::Linux; - } - - fn os_version(&self) -> &str { - if let Some(os_version) = self.os_version.as_deref() { - return os_version; - } - - match self.os { - Os::Linux => host_utils::get_linux_os_string(), - Os::Windows => host_utils::get_windows_os_string(), - Os::Mac => host_utils::get_macos_os_string(), - } - } -} - -pub(crate) struct ConnectHandler<'a> { - args: &'a ConnectArgs, - shared_args: &'a SharedArgs<'a>, - latest_key_password: RefCell>, - password_from_stdin: RefCell>, - cookie_from_stdin: RefCell>, -} - -impl<'a> ConnectHandler<'a> { - pub(crate) fn new(args: &'a ConnectArgs, shared_args: &'a SharedArgs) -> Self { - Self { - args, - shared_args, - latest_key_password: Default::default(), - password_from_stdin: Default::default(), - cookie_from_stdin: Default::default(), - } - } - - fn user_agent(&self) -> Cow<'_, str> { - if let Some(user_agent) = self.args.user_agent.as_deref() { - Cow::Borrowed(user_agent) - } else { - let client_version = self.args.client_version.as_deref().unwrap_or(GP_CLIENT_VERSION); - Cow::Owned(format!( - "{}/{} ({})", - GP_USER_AGENT, - client_version, - self.args.os_version() - )) - } - } - - fn build_gp_params(&self) -> GpParams { - let mut builder = GpParams::builder(); - builder - .user_agent(&self.user_agent()) - .client_os(ClientOs::from(&self.args.os)) - .os_version(self.args.os_version().to_owned()) - .ignore_tls_errors(self.shared_args.ignore_tls_errors) - .certificate(self.args.certificate.clone()) - .sslkey(self.args.sslkey.clone()) - .key_password(self.latest_key_password.borrow().clone()); - - if let Some(local_hostname) = self.args.local_hostname.as_deref() { - builder.computer(local_hostname); - } - - builder.build() - } - - pub(crate) async fn handle(&self) -> anyhow::Result<()> { - #[cfg(feature = "webview-auth")] - if self.args.default_browser && self.args.browser.is_some() { - bail!("Cannot use `--default-browser` and `--browser` options at the same time"); - } - - // Warn if deprecated options are used and will be removed in the future - if self.args.csd_user.is_some() { - warn!( - "The '--csd-user' option is deprecated and will be removed in future releases, please use the '--hip-user' option instead" - ); - } - - if self.args.csd_wrapper.is_some() { - warn!( - "The '--csd-wrapper' option is deprecated and will be removed in future releases, please use the '--hip' option instead" - ); - } - - self.latest_key_password.replace(self.args.key_password.clone()); - - loop { - let Err(err) = self.handle_impl().await else { - return Ok(()); - }; - - let Some(root_cause) = err.root_cause().downcast_ref::() else { - return Err(err); - }; - - match root_cause { - RequestIdentityError::NoKey => { - eprintln!("ERROR: No private key found in the certificate file"); - eprintln!("ERROR: Please provide the private key file using the `-k` option"); - return Ok(()); - } - RequestIdentityError::NoPassphrase(cert_type) | RequestIdentityError::DecryptError(cert_type) => { - // Decrypt the private key error, ask for the key password - let message = format!("Enter the {} passphrase:", cert_type); - let password = Password::new(&message) - .without_confirmation() - .with_display_mode(PasswordDisplayMode::Masked) - .prompt()?; - - self.latest_key_password.replace(Some(password)); - } - } - } - } - - pub(crate) async fn handle_impl(&self) -> anyhow::Result<()> { - let server = self.args.server.as_str(); - let as_gateway = self.args.as_gateway; - - if as_gateway { - info!("Treating the server as a gateway"); - return self - .connect_gateway_with_prelogin(server, server, self.args.client_version.as_deref(), false) - .await; - } - - if !self.args.no_cookie_cache && !self.args.cookie_on_stdin { - if let Some(()) = self.try_cached_cookie(server).await { - return Ok(()); - } - } - - let Err(err) = self.connect_portal_with_prelogin(server).await else { - return Ok(()); - }; - - warn!("Failed to connect portal with prelogin: {}", err); - if err.root_cause().downcast_ref::().is_some() { - info!("Trying the gateway authentication workflow..."); - self - .connect_gateway_with_prelogin(server, server, self.args.client_version.as_deref(), false) - .await?; - - eprintln!("\nNOTE: the server may be a gateway, not a portal."); - eprintln!("NOTE: try to use the `--as-gateway` option if you were authenticated twice."); - - Ok(()) - } else { - Err(err) - } - } - - async fn try_cached_cookie(&self, server: &str) -> Option<()> { - let path = cookie_store::cookie_path(self.args.cookie_file.as_deref()); - let stored = cookie_store::load(&path, server)?; - info!( - "Using cached portal cookie for {} (saved_at={}, gateway={})", - stored.server, stored.saved_at, stored.last_gateway - ); - - let cred: Credential = (&stored.auth_cookie).into(); - let mut gp_params = self.build_gp_params(); - gp_params.set_is_gateway(true); - - let login_session = match self.login_gateway(&stored.last_gateway, &cred, &gp_params).await { - Ok(s) => s, - Err(err) => { - warn!( - "Cached cookie rejected by gateway {}: {}. Clearing cache and falling back to SAML.", - stored.last_gateway, err - ); - cookie_store::clear(&path); - return None; - } - }; - - let result = self - .connect_gateway( - server, - &stored.last_gateway, - &login_session.cookie, - self.args.client_version.as_deref(), - false, - login_session.extension_auth, - ) - .await; - - match result { - Ok(()) => Some(()), - Err(err) => { - warn!("Gateway connect failed after cached-cookie login: {}", err); - None - } - } - } - - async fn connect_portal_with_prelogin(&self, portal: &str) -> anyhow::Result<()> { - let gp_params = self.build_gp_params(); - - let prelogin = prelogin(portal, &gp_params).await?; - - let cred = self.obtain_credential(&prelogin, portal).await?; - let mut portal_config = retrieve_config(portal, &cred, &gp_params).await?; - - let selected_gateway = match &self.args.gateway { - Some(gateway) => portal_config - .find_gateway(gateway) - .ok_or_else(|| anyhow::anyhow!("Cannot find gateway specified: {}", gateway))?, - None => { - portal_config.sort_gateways(prelogin.region()); - let gateways = portal_config.gateways(); - - if gateways.len() > 1 { - let gateway = Select::new("Which gateway do you want to connect to?", gateways) - .with_vim_mode(true) - .prompt()?; - info!("Connecting to the selected gateway: {}", gateway); - gateway - } else { - info!("Connecting to the only available gateway: {}", gateways[0]); - gateways[0] - } - } - }; - - let gateway = selected_gateway.server(); - let cred: Credential = portal_config.auth_cookie().into(); - - if !self.args.no_cookie_cache { - let path = cookie_store::cookie_path(self.args.cookie_file.as_deref()); - let stored = cookie_store::StoredCookie::new( - portal.to_string(), - cred.username().to_string(), - gateway.to_string(), - portal_config.auth_cookie().clone(), - ); - match cookie_store::save(&path, &stored) { - Ok(()) => info!("Saved portal cookie cache to {}", path.display()), - Err(e) => warn!("Failed to save cookie cache to {}: {}", path.display(), e), - } - } - - let login_session = match self.login_gateway(gateway, &cred, &gp_params).await { - Ok(login_session) => login_session, - Err(err) => { - info!("Gateway login failed: {}", err); - let client_version = self.args.client_version.as_deref().or_else(|| portal_config.version()); - let allow_extend_session = portal_config.allow_extend_session().unwrap_or(false); - return self - .connect_gateway_with_prelogin(portal, gateway, client_version, allow_extend_session) - .await; - } - }; - - // Use the client version from the command line argument if specified, otherwise - // use the version from the portal config if available - let client_version = self.args.client_version.as_deref().or_else(|| portal_config.version()); - let allow_extend_session = portal_config.allow_extend_session().unwrap_or(false); - - self - .connect_gateway( - portal, - gateway, - &login_session.cookie, - client_version, - allow_extend_session, - login_session.extension_auth, - ) - .await - } - - async fn connect_gateway_with_prelogin( - &self, - portal: &str, - gateway: &str, - client_version: Option<&str>, - allow_extend_session: bool, - ) -> anyhow::Result<()> { - info!("Performing the gateway authentication..."); - - let mut gp_params = self.build_gp_params(); - gp_params.set_is_gateway(true); - - let prelogin = prelogin(gateway, &gp_params).await?; - let cred = self.obtain_credential(&prelogin, gateway).await?; - - let login_session = self.login_gateway(gateway, &cred, &gp_params).await?; - - self - .connect_gateway( - portal, - gateway, - &login_session.cookie, - client_version, - allow_extend_session, - login_session.extension_auth, - ) - .await - } - - async fn login_gateway( - &self, - gateway: &str, - cred: &Credential, - gp_params: &GpParams, - ) -> anyhow::Result { - let mut gp_params = gp_params.clone(); - - loop { - match gateway_login(gateway, cred, &gp_params).await? { - GatewayLogin::Cookie(cookie) => { - return Ok(GatewayLoginSession { - cookie, - extension_auth: SessionExtensionAuth::new(cred.clone(), gp_params), - }); - } - GatewayLogin::Mfa(message, input_str) => { - let otp = Text::new(&message).prompt()?; - gp_params.set_input_str(&input_str); - gp_params.set_otp(&otp); - - info!("Retrying gateway login with MFA..."); - } - } - } - } - - async fn connect_gateway( - &self, - portal: &str, - gateway: &str, - cookie: &str, - client_version: Option<&str>, - allow_extend_session: bool, - extension_auth: SessionExtensionAuth, - ) -> anyhow::Result<()> { - let mtu = self.args.mtu.unwrap_or(0); - let (hip, csd_wrapper) = self.determine_hip_script(); - let hip_user = self.determine_hip_user(); - let csd_uid = get_uid(&hip_user)?; - - let os = ClientOs::from(&self.args.os).to_openconnect_os().to_owned(); - let os_version = self.args.os_version().to_owned(); - let client_version = client_version.map(|s| s.to_owned()); - let session_ctx = build_session_context(SessionContextInput { - portal: portal.to_string(), - gateway: gateway.to_string(), - cookie: cookie.to_string(), - user_agent: self.user_agent().into_owned(), - os: ClientOs::from(&self.args.os), - os_version: os_version.clone(), - client_version: client_version.clone(), - certificate: self.args.certificate.clone(), - sslkey: self.args.sslkey.clone(), - key_password: self.latest_key_password.borrow().clone(), - disable_ipv6: self.args.disable_ipv6, - extension_auth: Some(extension_auth), - }); - let vpn = Vpn::builder(gateway, cookie) - .script(self.args.script.clone()) - .interface(self.args.interface.clone()) - .script_tun(self.args.script_tun) - .user_agent(self.user_agent().into_owned()) - .os(Some(os)) - .os_version(Some(os_version)) - .client_version(client_version) - .certificate(self.args.certificate.clone()) - .sslkey(self.args.sslkey.clone()) - .key_password(self.latest_key_password.borrow().clone()) - .hip(hip) - .csd_uid(csd_uid) - .csd_wrapper(csd_wrapper) - .reconnect_timeout(self.args.reconnect_timeout) - .mtu(mtu) - .disable_ipv6(self.args.disable_ipv6) - .no_dtls(self.args.no_dtls) - .local_hostname(self.args.local_hostname.clone()) - .dpd_interval(self.args.dpd_interval.unwrap_or(0)) - .no_xmlpost(self.args.no_xmlpost) - .build()?; - - let vpn = Arc::new(vpn); - let vpn_clone = vpn.clone(); - let runtime_handle = Handle::current(); - let session_ctx = Arc::new(Mutex::new(Some(session_ctx))); - let session_task: Arc>>> = Arc::new(Mutex::new(None)); - let session_task_on_connect = Arc::clone(&session_task); - let session_ctx_on_connect = Arc::clone(&session_ctx); - - // Listen for the interrupt signal in the background - tokio::spawn(async move { - shutdown_signal().await; - info!("Received the interrupt signal, disconnecting..."); - vpn_clone.disconnect(); - }); - - vpn.connect(move |vpn_session_info| { - write_pid_file(); - - let Some(session_ctx) = session_ctx_on_connect.lock().unwrap().take() else { - return; - }; - let session_info = session_info_from_vpn(vpn_session_info, allow_extend_session); - info!("VPN session info: {}", session_info.log_summary()); - - let task = spawn_session_runtime_with_info(&runtime_handle, session_ctx, session_info); - session_task_on_connect.lock().unwrap().replace(task); - }); - - if let Some(task) = session_task.lock().unwrap().take() { - task.abort(); - } - - if fs::metadata(GP_CLIENT_LOCK_FILE).is_ok() { - info!("Removing PID file"); - fs::remove_file(GP_CLIENT_LOCK_FILE)?; - } - - Ok(()) - } - - async fn obtain_credential(&self, prelogin: &Prelogin, server: &str) -> anyhow::Result { - if self.args.cookie_on_stdin { - return self.read_cookie_from_stdin(); - } - - let is_gateway = prelogin.is_gateway(); - - match prelogin { - Prelogin::Saml(prelogin) => { - let browser = if prelogin.support_default_browser() { - self.args.browser.as_deref() - } else if !cfg!(feature = "webview-auth") { - bail!( - "The server does not support authentication via the default browser and the gpclient is not built with the `webview-auth` feature" - ); - } else { - None - }; - let os_version = self.args.os_version(); - let verbose = self.shared_args.verbose.to_verbose_arg(); - let user_agent = self.user_agent(); - let auth_launcher = SamlAuthLauncher::new(&self.args.server) - .gateway(is_gateway) - .saml_request(prelogin.saml_request()) - .user_agent(&user_agent) - .os(self.args.os.as_str()) - .os_version(Some(&os_version)) - .fix_openssl(self.shared_args.fix_openssl) - .ignore_tls_errors(self.shared_args.ignore_tls_errors) - .browser(browser) - .verbose(verbose); - - #[cfg(feature = "webview-auth")] - let use_default_browser = prelogin.support_default_browser() && self.args.default_browser; - #[cfg(feature = "webview-auth")] - let auth_launcher = auth_launcher - .hidpi(self.args.hidpi) - .clean(self.args.clean) - .default_browser(use_default_browser); - - let cred = auth_launcher.launch().await?; - Ok(cred) - } - - Prelogin::Standard(prelogin) => { - let prefix = if is_gateway { "Gateway" } else { "Portal" }; - println!("{} ({}: {})", prelogin.auth_message(), prefix, server); - - let user = self.args.user.as_ref().map_or_else( - || Text::new(&format!("{}:", prelogin.label_username())).prompt(), - |user| Ok(user.to_owned()), - )?; - - let password = self.obtain_password(prelogin)?; - let password_cred = PasswordCredential::new(&user, &password); - - Ok(password_cred.into()) - } - } - } - - fn read_cookie_from_stdin(&self) -> anyhow::Result { - // If the cookie has been read from stdin, use it directly - if let Some(cookie) = self.cookie_from_stdin.borrow().as_ref() { - info!("Reusing the cookie read from standard input"); - return Credential::try_from(serde_json::from_str::(cookie)?); - } - - info!("Reading cookie from standard input"); - - let mut cookie = String::new(); - std::io::stdin().read_line(&mut cookie)?; - - // Considering that the gateway connection may fail even though the cookie read - // from stdin is correct. It may retry the gateway connection, so we need to - // save the cookie read from stdin to avoid reading stdin again. - self.cookie_from_stdin.replace(Some(cookie.trim_end().to_owned())); - - let auth_result = serde_json::from_str::(cookie.trim_end()).context("Failed to parse auth data")?; - Credential::try_from(auth_result) - } - - fn obtain_password(&self, prelogin: &StandardPrelogin) -> anyhow::Result { - let password = if self.args.passwd_on_stdin { - // If the password has been read from stdin, use it directly - if let Some(password) = self.password_from_stdin.borrow().as_ref() { - info!("Reusing the password read from standard input"); - return Ok(password.clone()); - } - - info!("Reading password from standard input"); - let mut input = String::new(); - std::io::stdin().read_line(&mut input)?; - let password = input.trim_end().to_owned(); - // Considering that the gateway connection may fail even though the password read - // from stdin is correct. It may retry the gateway connection, so we need to - // save the password read from stdin to avoid reading stdin again. - self.password_from_stdin.replace(Some(password.clone())); - - password - } else { - Password::new(&format!("{}:", prelogin.label_password())) - .without_confirmation() - .with_display_mode(PasswordDisplayMode::Masked) - .prompt()? - }; - - Ok(password) - } - - fn determine_hip_script(&self) -> (bool, Option) { - if let Some(hip) = &self.args.hip { - return if hip.is_empty() { - (true, None) - } else { - (true, Some(hip.clone())) - }; - } - - (self.args.csd_wrapper.is_some(), self.args.csd_wrapper.clone()) - } - - fn determine_hip_user(&self) -> Option { - if let Some(hip_user) = &self.args.hip_user { - return Some(hip_user.clone()); - } - - self.args.csd_user.clone() - } -} - -fn write_pid_file() { - let pid = std::process::id(); - - if let Err(err) = fs::write(GP_CLIENT_LOCK_FILE, pid.to_string()) { - warn!("Failed to write PID file: {}", err); - } else { - info!("Wrote PID {} to {}", pid, GP_CLIENT_LOCK_FILE); - } -} - -fn get_uid(user: &Option) -> anyhow::Result { - if let Some(user) = user { - get_user_by_name(user).map(|user| user.uid()) - } else { - get_non_root_user().map_or_else(|_| Ok(0), |user| Ok(user.uid())) - } -} diff --git a/apps/gpclient/src/connect/args.rs b/apps/gpclient/src/connect/args.rs new file mode 100644 index 0000000..3c33d82 --- /dev/null +++ b/apps/gpclient/src/connect/args.rs @@ -0,0 +1,381 @@ +use clap::Args; +use gpapi::{ + clap::args::Os, + cookie_store, + gp_params::CscMode, + os_profile::{ClientOs, OsProfile}, +}; +use log::warn; +use std::path::PathBuf; + +#[derive(Args)] +pub(crate) struct ConnectArgs { + #[arg(help = "The portal server to connect to")] + pub(super) server: String, + + #[arg(short, long, help = "The gateway to connect to, it will prompt if not specified")] + pub(super) gateway: Option, + + #[arg( + long, + conflicts_with = "gateway", + help = "Automatically try gateways in priority order until gateway auth/config succeeds, without prompting" + )] + pub(super) auto_gateway: bool, + + #[arg(short, long, help = "The username to use, it will prompt if not specified")] + pub(super) user: Option, + + #[arg(long, help = "Read the password from standard input")] + pub(super) passwd_on_stdin: bool, + + #[arg(long, help = "Read the gpauth authentication result from standard input")] + pub(super) cookie_on_stdin: bool, + + #[arg( + long, + help = "Read and write the portal cookie cache, optionally specify the cache file path", + default_missing_value = "", + num_args=0..=1 + )] + pub(super) cookie_cache: Option, + + #[arg(long, short, help = "The VPNC script to use", required_if_eq("script_tun", "true"))] + pub(super) script: Option, + + #[arg(long, short, help = "The IFNAME for tunnel interface")] + pub(super) interface: Option, + + #[arg(long, short = 'S', help = "Pass traffic to '--script' program, not tun")] + pub(super) script_tun: bool, + + #[arg(long, help = "Connect the server as a gateway, instead of a portal")] + pub(super) as_gateway: bool, + + #[arg( + long, + help = "Use HIP (Host Integrity Protection) extension, optionally specify the HIP script path", + default_missing_value = "", + num_args=0..=1 + )] + pub(super) hip: Option, + + #[arg(long, help = "The user used to run the HIP script")] + pub(super) hip_user: Option, + + #[arg( + short, + long, + help = "Use SSL client certificate file in pkcs#8 (.pem) or pkcs#12 (.p12, .pfx) format" + )] + pub(super) certificate: Option, + + #[arg(short = 'k', long, help = "Use SSL private key file in pkcs#8 (.pem) format")] + pub(super) sslkey: Option, + + #[arg(short = 'p', long, help = "The key passphrase of the private key")] + pub(super) key_password: Option, + + #[arg(long, hide = true)] + pub(super) csd_user: Option, + + #[arg(long, hide = true)] + pub(super) csd_wrapper: Option, + + #[arg(long, default_value = "300", help = "Reconnection retry timeout in seconds")] + pub(super) reconnect_timeout: u32, + + #[arg(short, long, help = "Request MTU from server (legacy servers only)")] + pub(super) mtu: Option, + + #[arg(long, help = "Do not ask for IPv6 connectivity")] + pub(super) disable_ipv6: bool, + + #[arg(long = "user-agent", hide = true)] + pub(super) deprecated_user_agent: Option, + + #[arg(long = "os-version", hide = true)] + pub(super) deprecated_os_version: Option, + + #[arg(long, help = "Override the client version reported to the server, e.g., '6.2.4-49'")] + pub(super) client_version: Option, + + #[arg(long, value_enum, default_value_t = Os::default())] + pub(super) os: Os, + + #[arg(long, value_enum, default_value_t = CscMode::Auto, help = "CSC support mode: auto, yes, or no")] + pub(super) csc: CscMode, + + #[arg(long, help = "Disable DTLS and ESP")] + pub(super) no_dtls: bool, + + #[arg( + long = "local-hostname", + help = "Same as the '--local-hostname' option in the openconnect command" + )] + pub(super) local_hostname: Option, + + #[arg( + long = "force-dpd", + help = "Same as the '--force-dpd' option in the openconnect command" + )] + pub(super) dpd_interval: Option, + + #[arg( + long = "no-xmlpost", + help = "Same as the '--no-xmlpost' option in the openconnect command" + )] + pub(super) no_xmlpost: bool, + + #[cfg(feature = "webview-auth")] + #[arg(long, help = "The HiDPI mode, useful for high-resolution screens")] + pub(super) hidpi: bool, + + #[cfg(feature = "webview-auth")] + #[arg(long, help = "Do not reuse the remembered authentication cookie")] + pub(super) clean: bool, + + #[cfg(feature = "webview-auth")] + #[arg(long, help = "Deprecated: Use the `--browser` option instead")] + pub(super) default_browser: bool, + + #[arg( + long, + help = "Use the specified browser to authenticate, e.g., `default`, `firefox`, `chrome`, `chromium`, `remote`.\nOr the path to the browser executable.\nUse 'remote' for headless servers.", + default_missing_value = "default", + num_args=0..=1 + )] + pub(super) browser: Option, +} + +pub(super) fn build_os_profile(args: &ConnectArgs) -> OsProfile { + build_os_profile_with_host_id(args, None) +} + +pub(super) fn build_os_profile_with_host_id(args: &ConnectArgs, host_id: Option<&str>) -> OsProfile { + let mut builder = OsProfile::builder(ClientOs::from(args.os)); + if let Some(client_version) = args.client_version.as_deref() { + builder = builder.client_version(client_version.to_string()); + } + if let Some(local_hostname) = args.local_hostname.as_deref() { + builder = builder.computer_name_override(local_hostname.to_string()); + } + if let Some(host_id) = host_id { + builder = builder.host_id_override(host_id); + } + builder.build() +} + +pub(super) fn cookie_cache_path(args: &ConnectArgs) -> Option { + args.cookie_cache.as_deref().map(|path| { + let custom = (!path.is_empty()).then_some(path); + cookie_store::cookie_path(custom) + }) +} + +pub(super) fn warn_deprecated_connect_args(args: &ConnectArgs) { + if args.csd_user.is_some() { + warn!("Deprecated option --csd-user will be removed; use --hip-user instead"); + } + + if args.csd_wrapper.is_some() { + warn!("Deprecated option --csd-wrapper will be removed; use --hip instead"); + } + + if args.deprecated_user_agent.is_some() { + warn!("Deprecated option --user-agent is ignored; user agent is derived from --os"); + } + + if args.deprecated_os_version.is_some() { + warn!("Deprecated option --os-version is ignored; OS version is derived from --os"); + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[derive(clap::Parser)] + struct ConnectArgsTestCli { + #[command(flatten)] + args: ConnectArgs, + } + + #[test] + fn parses_csc_mode_values() { + use clap::ValueEnum; + + assert_eq!(CscMode::from_str("auto", false), Ok(CscMode::Auto)); + assert_eq!(CscMode::from_str("yes", false), Ok(CscMode::Yes)); + assert_eq!(CscMode::from_str("no", false), Ok(CscMode::No)); + assert!(CscMode::from_str("maybe", false).is_err()); + } + + #[test] + fn auto_gateway_flag_parses() { + use clap::Parser; + + let cli = ConnectArgsTestCli::try_parse_from(["test", "portal.example.com", "--auto-gateway"]) + .expect("--auto-gateway alone should parse"); + + assert!(cli.args.auto_gateway); + assert!(cli.args.gateway.is_none()); + } + + #[test] + fn auto_gateway_help_describes_auth_config_retry() { + use clap::CommandFactory; + + let help = ConnectArgsTestCli::command().render_long_help().to_string(); + + assert!(help.contains("--auto-gateway")); + assert!(help.contains("Automatically try gateways in priority order until gateway auth/config succeeds")); + } + + #[test] + fn gateway_flag_alone_parses() { + use clap::Parser; + + let cli = ConnectArgsTestCli::try_parse_from(["test", "portal.example.com", "--gateway", "gw1"]) + .expect("--gateway alone should parse"); + + assert!(!cli.args.auto_gateway); + assert_eq!(cli.args.gateway.as_deref(), Some("gw1")); + } + + #[test] + fn os_defaults_to_runtime_os() { + use clap::Parser; + + let cli = ConnectArgsTestCli::try_parse_from(["test", "portal.example.com"]).expect("connect args should parse"); + + assert_eq!(cli.args.os, Os::default()); + } + + #[test] + fn deprecated_profile_override_flags_still_parse() { + use clap::Parser; + + let cli = ConnectArgsTestCli::try_parse_from([ + "test", + "portal.example.com", + "--user-agent", + "legacy-agent", + "--os-version", + "legacy-os", + "--client-version", + "legacy-client", + ]) + .expect("deprecated profile override flags should remain parse-compatible"); + + assert_eq!(cli.args.deprecated_user_agent.as_deref(), Some("legacy-agent")); + assert_eq!(cli.args.deprecated_os_version.as_deref(), Some("legacy-os")); + assert_eq!(cli.args.client_version.as_deref(), Some("legacy-client")); + } + + #[test] + fn deprecated_profile_override_flags_do_not_affect_os_profile() { + use clap::Parser; + + let cli = ConnectArgsTestCli::try_parse_from([ + "test", + "portal.example.com", + "--os", + "Linux", + "--user-agent", + "legacy-agent", + "--os-version", + "legacy-os", + "--client-version", + "legacy-client", + ]) + .expect("deprecated profile override flags should remain parse-compatible"); + + let profile = build_os_profile(&cli.args); + + assert_ne!(profile.user_agent(), "legacy-agent"); + assert_ne!(profile.os_version(), "legacy-os"); + assert_eq!(profile.client_version(), "legacy-client"); + assert!(profile.user_agent().contains("legacy-client")); + } + + #[test] + fn stdin_host_id_sets_profile_runtime_identity_seed() { + use clap::Parser; + + let cli = ConnectArgsTestCli::try_parse_from(["test", "portal.example.com", "--os", "Linux"]) + .expect("connect args should parse"); + + let profile = build_os_profile_with_host_id(&cli.args, Some("auth-host-id")); + + assert_eq!(profile.host_identity().host_id(), "auth-host-id"); + } + + #[test] + fn cookie_cache_is_disabled_by_default() { + use clap::Parser; + + let cli = ConnectArgsTestCli::try_parse_from(["test", "portal.example.com"]).expect("connect args should parse"); + + assert!(cli.args.cookie_cache.is_none()); + assert!(cookie_cache_path(&cli.args).is_none()); + } + + #[test] + fn cookie_cache_accepts_default_path_without_value() { + use clap::Parser; + + let cli = ConnectArgsTestCli::try_parse_from(["test", "portal.example.com", "--cookie-cache"]) + .expect("--cookie-cache without value should parse"); + + assert_eq!(cli.args.cookie_cache.as_deref(), Some("")); + assert!(cookie_cache_path(&cli.args).is_some()); + } + + #[test] + fn cookie_cache_accepts_custom_path() { + use clap::Parser; + + let cli = + ConnectArgsTestCli::try_parse_from(["test", "portal.example.com", "--cookie-cache", "/tmp/gp-cookie.json"]) + .expect("--cookie-cache with value should parse"); + + assert_eq!( + cookie_cache_path(&cli.args).as_deref(), + Some(std::path::Path::new("/tmp/gp-cookie.json")) + ); + } + + #[test] + fn deprecated_hip_alias_flags_still_parse() { + use clap::Parser; + + let cli = ConnectArgsTestCli::try_parse_from([ + "test", + "portal.example.com", + "--csd-user", + "legacy-user", + "--csd-wrapper", + "/tmp/legacy-hip.sh", + ]) + .expect("deprecated HIP alias flags should remain parse-compatible"); + + assert_eq!(cli.args.csd_user.as_deref(), Some("legacy-user")); + assert_eq!(cli.args.csd_wrapper.as_deref(), Some("/tmp/legacy-hip.sh")); + } + + #[test] + fn auto_gateway_and_gateway_are_mutually_exclusive() { + use clap::Parser; + use clap::error::ErrorKind; + + let result = + ConnectArgsTestCli::try_parse_from(["test", "portal.example.com", "--gateway", "gw1", "--auto-gateway"]); + + let err = match result { + Ok(_) => panic!("--gateway and --auto-gateway must conflict"), + Err(err) => err, + }; + assert_eq!(err.kind(), ErrorKind::ArgumentConflict); + } +} diff --git a/apps/gpclient/src/connect/credential.rs b/apps/gpclient/src/connect/credential.rs new file mode 100644 index 0000000..34d37d3 --- /dev/null +++ b/apps/gpclient/src/connect/credential.rs @@ -0,0 +1,232 @@ +use anyhow::{Context, bail}; +use gpapi::{ + auth::SamlAuthResult, + clap::ToVerboseArg, + credential::{Credential, PasswordCredential}, + portal::{Prelogin, StandardPrelogin}, + process::auth_launcher::SamlAuthLauncher, +}; +use inquire::{Password, PasswordDisplayMode, Text}; +use log::info; + +use super::ConnectHandler; + +#[derive(Default)] +pub(super) struct CleanAuthState { + requested: bool, +} + +impl CleanAuthState { + pub(super) fn new(requested: bool) -> Self { + Self { requested } + } + + fn consume_for_webview(&mut self, webview_auth: bool) -> bool { + if !webview_auth || !self.requested { + return false; + } + + self.requested = false; + true + } +} + +impl ConnectHandler<'_> { + pub(super) fn prepare_cookie_from_stdin(&self) -> anyhow::Result<()> { + if !self.args.cookie_on_stdin || self.cookie_from_stdin.borrow().is_some() { + return Ok(()); + } + + let auth_result = self.read_auth_result_from_stdin()?; + log_stdin_host_id(auth_result.host_id()); + self.apply_stdin_host_id(auth_result.host_id()); + + Ok(()) + } + + pub(super) async fn obtain_credential(&self, prelogin: &Prelogin, server: &str) -> anyhow::Result { + if should_read_stdin_credential(self.args.cookie_on_stdin, self.args.as_gateway, prelogin.is_gateway()) { + return self.read_cookie_from_stdin(); + } + + let is_gateway = prelogin.is_gateway(); + + match prelogin { + Prelogin::Saml(prelogin) => { + let browser = if prelogin.support_default_browser() { + self.args.browser.as_deref() + } else if !cfg!(feature = "webview-auth") { + bail!( + "The server does not support authentication via the default browser and the gpclient is not built with the `webview-auth` feature" + ); + } else { + None + }; + let verbose = self.shared_args.verbose.to_verbose_arg(); + let os_profile = self.os_profile.borrow().clone(); + let auth_launcher = SamlAuthLauncher::new(server) + .gateway(is_gateway) + .saml_request(prelogin.saml_request()) + .os_profile(&os_profile) + .fix_openssl(self.shared_args.fix_openssl) + .ignore_tls_errors(self.shared_args.ignore_tls_errors) + .browser(browser) + .verbose(verbose); + + #[cfg(feature = "webview-auth")] + let use_default_browser = prelogin.support_default_browser() && self.args.default_browser; + #[cfg(feature = "webview-auth")] + let browser_kind = if browser.is_some() || use_default_browser { + "external" + } else { + "embedded" + }; + #[cfg(not(feature = "webview-auth"))] + let browser_kind = "external"; + + let clean_auth = self + .clean_auth_state + .borrow_mut() + .consume_for_webview(browser_kind == "embedded"); + + info!( + "SAML auth launch: gateway={}, clean={}, browser={}", + is_gateway, clean_auth, browser_kind + ); + + #[cfg(feature = "webview-auth")] + let auth_launcher = auth_launcher + .hidpi(self.args.hidpi) + .clean(clean_auth) + .default_browser(use_default_browser); + + let cred = auth_launcher.launch().await?; + Ok(cred) + } + + Prelogin::Standard(prelogin) => { + let prefix = if is_gateway { "Gateway" } else { "Portal" }; + println!("{} ({}: {})", prelogin.auth_message(), prefix, server); + + let user = self.args.user.as_ref().map_or_else( + || Text::new(&format!("{}:", prelogin.label_username())).prompt(), + |user| Ok(user.to_owned()), + )?; + + let password = self.obtain_password(prelogin)?; + let password_cred = PasswordCredential::new(&user, &password); + + Ok(password_cred.into()) + } + } + } + + fn read_cookie_from_stdin(&self) -> anyhow::Result { + if let Some(cookie) = self.cookie_from_stdin.borrow().as_ref() { + info!("Reusing the cookie read from standard input"); + return Credential::try_from(serde_json::from_str::(cookie)?); + } + + let auth_result = self.read_auth_result_from_stdin()?; + log_stdin_host_id(auth_result.host_id()); + self.apply_stdin_host_id(auth_result.host_id()); + Credential::try_from(auth_result) + } + + fn read_auth_result_from_stdin(&self) -> anyhow::Result { + info!("Reading cookie from standard input"); + + let mut cookie = String::new(); + std::io::stdin().read_line(&mut cookie)?; + + self.cookie_from_stdin.replace(Some(cookie.trim_end().to_owned())); + + let auth_result = serde_json::from_str::(cookie.trim_end()).context("Failed to parse auth data")?; + Ok(auth_result) + } + + fn obtain_password(&self, prelogin: &StandardPrelogin) -> anyhow::Result { + let password = if self.args.passwd_on_stdin { + if let Some(password) = self.password_from_stdin.borrow().as_ref() { + info!("Reusing the password read from standard input"); + return Ok(password.clone()); + } + + info!("Reading password from standard input"); + let mut input = String::new(); + std::io::stdin().read_line(&mut input)?; + let password = input.trim_end().to_owned(); + self.password_from_stdin.replace(Some(password.clone())); + + password + } else { + Password::new(&format!("{}:", prelogin.label_password())) + .without_confirmation() + .with_display_mode(PasswordDisplayMode::Masked) + .prompt()? + }; + + Ok(password) + } +} + +fn should_read_stdin_credential(cookie_on_stdin: bool, as_gateway: bool, prelogin_is_gateway: bool) -> bool { + cookie_on_stdin && (!prelogin_is_gateway || as_gateway) +} + +fn log_stdin_host_id(host_id: Option<&str>) { + match host_id { + Some(host_id) => info!("stdin auth result host-id: {}", host_id), + None => info!("stdin auth result host-id: "), + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn clean_auth_state_is_consumed_once_for_webview() { + let mut state = CleanAuthState::new(true); + + assert!(state.consume_for_webview(true)); + assert!(!state.consume_for_webview(true)); + } + + #[test] + fn clean_auth_state_is_not_consumed_by_external_browser() { + let mut state = CleanAuthState::new(true); + + assert!(!state.consume_for_webview(false)); + assert!(state.consume_for_webview(true)); + } + + #[test] + fn clean_auth_state_remains_false_when_not_requested() { + let mut state = CleanAuthState::new(false); + + assert!(!state.consume_for_webview(true)); + assert!(!state.consume_for_webview(false)); + } + + #[test] + fn stdin_credential_is_allowed_for_portal_auth() { + assert!(should_read_stdin_credential(true, false, false)); + } + + #[test] + fn stdin_credential_is_allowed_for_direct_gateway_auth() { + assert!(should_read_stdin_credential(true, true, true)); + } + + #[test] + fn stdin_credential_is_not_reused_for_gateway_fallback_auth() { + assert!(!should_read_stdin_credential(true, false, true)); + } + + #[test] + fn stdin_credential_is_not_used_when_flag_is_disabled() { + assert!(!should_read_stdin_credential(false, false, false)); + assert!(!should_read_stdin_credential(false, true, true)); + } +} diff --git a/apps/gpclient/src/connect/gateway.rs b/apps/gpclient/src/connect/gateway.rs new file mode 100644 index 0000000..d13acd3 --- /dev/null +++ b/apps/gpclient/src/connect/gateway.rs @@ -0,0 +1,502 @@ +use std::{ + fs, + sync::{ + Arc, Mutex, + atomic::{AtomicBool, Ordering}, + }, +}; + +use gpapi::{ + cookie_store, + credential::{AuthCookieCredential, Credential}, + gateway::{GatewayLogin, GatewayLoginContext, SessionExtensionAuth, gateway_login, gateway_login_with_context}, + gp_params::GpParams, + os_profile::OsProfile, + portal::prelogin, + process::users::{get_non_root_user, get_user_by_name}, + utils::shutdown_signal, +}; +use inquire::Text; +use log::{info, warn}; +use openconnect::{Vpn, VpnBuilder}; +use tokio::{runtime::Handle, task::JoinHandle}; + +use crate::{ + GP_CLIENT_LOCK_FILE, + session::{SessionContextInput, build_session_context, session_info_from_vpn, spawn_session_runtime_with_info}, +}; + +use super::{ConnectHandler, args::cookie_cache_path}; + +struct GatewayLoginSession { + cookie: String, + extension_auth: SessionExtensionAuth, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +enum GatewayConnectFailureStage { + BeforeTunnel, + AfterTunnel, +} + +#[derive(Debug)] +pub(super) struct GatewayConnectError { + stage: GatewayConnectFailureStage, + error: anyhow::Error, +} + +impl GatewayConnectError { + fn before_tunnel(error: anyhow::Error) -> Self { + Self { + stage: GatewayConnectFailureStage::BeforeTunnel, + error, + } + } + + fn after_tunnel(error: anyhow::Error) -> Self { + Self { + stage: GatewayConnectFailureStage::AfterTunnel, + error, + } + } + + pub(super) fn is_before_tunnel(&self) -> bool { + self.stage == GatewayConnectFailureStage::BeforeTunnel + } + + pub(super) fn as_error(&self) -> &anyhow::Error { + &self.error + } + + pub(super) fn into_error(self) -> anyhow::Error { + self.error + } +} + +impl ConnectHandler<'_> { + pub(super) async fn try_cached_cookie(&self, server: &str) -> Option<()> { + let path = cookie_cache_path(self.args)?; + let host_id = self.os_profile.borrow().host_identity().host_id().to_string(); + let stored = cookie_store::load(&path, server, &host_id)?; + + if !stored.auth_cookie.can_authenticate_gateway() { + warn!( + "Cached portal cookie for {} is not usable for gateway authentication. Clearing cache.", + stored.server + ); + cookie_store::clear(&path); + return None; + } + + info!( + "Using cached portal cookie for {} (saved_at={}, gateway={})", + stored.server, stored.saved_at, stored.last_gateway + ); + + let cred: Credential = (&stored.auth_cookie).into(); + let mut gp_params = self.build_gp_params(); + gp_params.set_is_gateway(true); + + let login_session = match self.login_gateway(&stored.last_gateway, &cred, &gp_params, None).await { + Ok(session) => session, + Err(err) => { + warn!( + "Cached portal cookie rejected by gateway {}: {}. Clearing cache and falling back to portal auth.", + stored.last_gateway, err + ); + cookie_store::clear(&path); + return None; + } + }; + + match self + .connect_gateway( + server, + &stored.last_gateway, + &login_session.cookie, + false, + login_session.extension_auth, + ) + .await + { + Ok(()) => Some(()), + Err(err) => { + warn!("Gateway connect failed after cached-cookie login: {}", err.as_error()); + None + } + } + } + + pub(super) async fn connect_gateway_with_prelogin( + &self, + portal: &str, + gateway: &str, + allow_extend_session: bool, + gateway_context: Option, + ) -> anyhow::Result<()> { + info!("Performing the gateway authentication..."); + + let mut gp_params = self.build_gp_params(); + gp_params.set_is_gateway(true); + + let prelogin = prelogin(gateway, &gp_params, self.prelogin_options(false)).await?; + let cred = self.obtain_credential(&prelogin, gateway).await?; + + let login_session = self + .login_gateway(gateway, &cred, &gp_params, gateway_context.as_ref()) + .await?; + + self + .connect_gateway( + portal, + gateway, + &login_session.cookie, + allow_extend_session, + login_session.extension_auth, + ) + .await + .map_err(GatewayConnectError::into_error) + } + + /// Connect to a gateway using the official client's auth flow: + /// + /// 1. Call gateway prelogin and retain the response (SAML data is held as a fallback). + /// 2. If the portal provided auth cookies, attempt gateway login using them. + /// 3. If that login succeeds, proceed directly to the VPN connection. + /// 4. If no portal auth cookies exist or portal-cookie login fails, use the retained gateway prelogin response to authenticate + /// against the gateway (SAML or username/password) and obtain a gateway-issued + /// credential. + /// 5. Retry gateway login with the gateway credential (now carrying the gateway's + /// `prelogin-cookie`) and connect on success. + pub(super) async fn connect_gateway_with_fallback( + &self, + portal: &str, + gateway: &str, + portal_cred: &AuthCookieCredential, + allow_extend_session: bool, + portal_default_browser_enabled: bool, + gateway_context: GatewayLoginContext, + ) -> Result<(), GatewayConnectError> { + info!("Connecting to gateway with portal-cookie first, gateway prelogin fallback..."); + + let mut gp_params = self.build_gp_params(); + gp_params.set_is_gateway(true); + + let gateway_prelogin = prelogin( + gateway, + &gp_params, + self.prelogin_options(portal_default_browser_enabled), + ) + .await + .map_err(GatewayConnectError::before_tunnel)?; + + if portal_cred.can_authenticate_gateway() { + let portal_cred_for_login: Credential = portal_cred.into(); + match self + .login_gateway(gateway, &portal_cred_for_login, &gp_params, Some(&gateway_context)) + .await + { + Ok(login_session) => { + info!("Gateway login with portal auth cookies succeeded"); + self.save_cookie_cache(portal, gateway, portal_cred); + return self + .connect_gateway( + portal, + gateway, + &login_session.cookie, + allow_extend_session, + login_session.extension_auth, + ) + .await; + } + Err(err) => { + info!("Gateway login with portal auth cookies failed: {}", err); + info!("Falling back to gateway prelogin authentication..."); + } + } + } else { + info!("Portal config did not provide gateway auth cookies; using gateway prelogin flow"); + } + + let gateway_cred = match self.obtain_credential(&gateway_prelogin, gateway).await { + Ok(cred) => cred, + Err(err) => { + self.print_direct_gateway_recommendation(gateway); + return Err(GatewayConnectError::before_tunnel(err)); + } + }; + + let login_session = match self + .login_gateway(gateway, &gateway_cred, &gp_params, Some(&gateway_context)) + .await + { + Ok(login_session) => login_session, + Err(err) => { + self.print_direct_gateway_recommendation(gateway); + return Err(GatewayConnectError::before_tunnel(err)); + } + }; + + self + .connect_gateway( + portal, + gateway, + &login_session.cookie, + allow_extend_session, + login_session.extension_auth, + ) + .await + } + + fn save_cookie_cache(&self, portal: &str, gateway: &str, auth_cookie: &AuthCookieCredential) { + let Some(path) = cookie_cache_path(self.args) else { + return; + }; + + if !auth_cookie.can_authenticate_gateway() { + return; + } + + let stored = cookie_store::StoredCookie::new( + portal.to_string(), + auth_cookie.username().to_string(), + self.os_profile.borrow().host_identity().host_id().to_string(), + gateway.to_string(), + auth_cookie.clone(), + ); + + match cookie_store::save(&path, &stored) { + Ok(()) => info!("Saved portal cookie cache to {}", path.display()), + Err(err) => warn!("Failed to save portal cookie cache to {}: {}", path.display(), err), + } + } + + fn print_direct_gateway_recommendation(&self, gateway: &str) { + if !self.args.cookie_on_stdin { + return; + } + + eprintln!("\nNOTE: Gateway authentication failed after portal login."); + eprintln!("NOTE: If this server also accepts direct gateway login, try:"); + eprintln!("NOTE: {}", direct_gateway_command(gateway)); + } + + async fn login_gateway( + &self, + gateway: &str, + cred: &Credential, + gp_params: &GpParams, + gateway_context: Option<&GatewayLoginContext>, + ) -> anyhow::Result { + let mut gp_params = gp_params.clone(); + + loop { + let login = match gateway_context { + Some(context) => gateway_login_with_context(gateway, cred, &gp_params, context).await?, + None => gateway_login(gateway, cred, &gp_params).await?, + }; + + match login { + GatewayLogin::Cookie(cookie) => { + return Ok(GatewayLoginSession { + cookie, + extension_auth: SessionExtensionAuth::new(cred.clone(), gp_params), + }); + } + GatewayLogin::Mfa(message, input_str) => { + let otp = Text::new(&message).prompt()?; + gp_params.set_input_str(&input_str); + gp_params.set_otp(&otp); + + info!("Retrying gateway login with MFA..."); + } + } + } + } + + async fn connect_gateway( + &self, + portal: &str, + gateway: &str, + cookie: &str, + allow_extend_session: bool, + extension_auth: SessionExtensionAuth, + ) -> Result<(), GatewayConnectError> { + let mtu = self.args.mtu.unwrap_or(0); + let (hip, csd_wrapper) = self.determine_hip_script(); + let hip_user = self.determine_hip_user(); + let csd_uid = get_uid(&hip_user).map_err(GatewayConnectError::before_tunnel)?; + let os_profile = self.os_profile.borrow().clone(); + + let session_ctx = build_session_context(SessionContextInput { + portal: portal.to_string(), + gateway: gateway.to_string(), + cookie: cookie.to_string(), + os_profile: os_profile.clone(), + certificate: self.args.certificate.clone(), + sslkey: self.args.sslkey.clone(), + key_password: self.latest_key_password.borrow().clone(), + disable_ipv6: self.args.disable_ipv6, + extension_auth: Some(extension_auth), + }); + let vpn_builder = Vpn::builder(gateway, cookie) + .script(self.args.script.clone()) + .interface(self.args.interface.clone()) + .script_tun(self.args.script_tun) + .certificate(self.args.certificate.clone()) + .sslkey(self.args.sslkey.clone()) + .key_password(self.latest_key_password.borrow().clone()) + .hip(hip) + .csd_uid(csd_uid) + .csd_wrapper(csd_wrapper) + .reconnect_timeout(self.args.reconnect_timeout) + .mtu(mtu) + .disable_ipv6(self.args.disable_ipv6) + .no_dtls(self.args.no_dtls) + .local_hostname(self.args.local_hostname.clone()) + .dpd_interval(self.args.dpd_interval.unwrap_or(0)) + .no_xmlpost(self.args.no_xmlpost); + let vpn = apply_os_profile(vpn_builder, &os_profile) + .build() + .map_err(|err| GatewayConnectError::before_tunnel(err.into()))?; + + let vpn = Arc::new(vpn); + let vpn_clone = vpn.clone(); + let runtime_handle = Handle::current(); + let session_ctx = Arc::new(Mutex::new(Some(session_ctx))); + let session_task: Arc>>> = Arc::new(Mutex::new(None)); + let session_task_on_connect = Arc::clone(&session_task); + let session_ctx_on_connect = Arc::clone(&session_ctx); + let tunnel_established = Arc::new(AtomicBool::new(false)); + let tunnel_established_on_connect = Arc::clone(&tunnel_established); + + tokio::spawn(async move { + shutdown_signal().await; + info!("Received the interrupt signal, disconnecting..."); + vpn_clone.disconnect(); + }); + + let connect_result = vpn.connect(move |vpn_session_info| { + tunnel_established_on_connect.store(true, Ordering::SeqCst); + write_pid_file(); + + let Some(session_ctx) = session_ctx_on_connect.lock().unwrap().take() else { + return; + }; + let session_info = session_info_from_vpn(vpn_session_info, allow_extend_session); + info!("VPN session info: {}", session_info.log_summary()); + + let task = spawn_session_runtime_with_info(&runtime_handle, session_ctx, session_info); + session_task_on_connect.lock().unwrap().replace(task); + }); + let tunnel_established = tunnel_established.load(Ordering::SeqCst); + + if let Some(task) = session_task.lock().unwrap().take() { + task.abort(); + } + + if fs::metadata(GP_CLIENT_LOCK_FILE).is_ok() { + info!("Removing PID file"); + fs::remove_file(GP_CLIENT_LOCK_FILE).map_err(|err| GatewayConnectError::after_tunnel(err.into()))?; + } + + classify_openconnect_result(connect_result, tunnel_established) + } + + fn determine_hip_script(&self) -> (bool, Option) { + if let Some(hip) = &self.args.hip { + return if hip.is_empty() { + (true, None) + } else { + (true, Some(hip.clone())) + }; + } + + (self.args.csd_wrapper.is_some(), self.args.csd_wrapper.clone()) + } + + fn determine_hip_user(&self) -> Option { + if let Some(hip_user) = &self.args.hip_user { + return Some(hip_user.clone()); + } + + self.args.csd_user.clone() + } +} + +fn classify_openconnect_result(exit_code: i32, tunnel_established: bool) -> Result<(), GatewayConnectError> { + if exit_code == 0 { + return Ok(()); + } + + let error = anyhow::anyhow!("OpenConnect exited with status {}", exit_code); + if tunnel_established { + Err(GatewayConnectError::after_tunnel(error)) + } else { + Err(GatewayConnectError::before_tunnel(error)) + } +} + +fn direct_gateway_command(gateway: &str) -> String { + format!("gpauth --gateway {gateway} | sudo gpclient connect {gateway} --as-gateway --cookie-on-stdin") +} + +fn write_pid_file() { + let pid = std::process::id(); + + if let Err(err) = fs::write(GP_CLIENT_LOCK_FILE, pid.to_string()) { + warn!("Failed to write PID file: {}", err); + } else { + info!("Wrote PID {} to {}", pid, GP_CLIENT_LOCK_FILE); + } +} + +fn get_uid(user: &Option) -> anyhow::Result { + if let Some(user) = user { + get_user_by_name(user).map(|user| user.uid()) + } else { + get_non_root_user().map_or_else(|_| Ok(0), |user| Ok(user.uid())) + } +} + +fn apply_os_profile(builder: VpnBuilder, profile: &OsProfile) -> VpnBuilder { + builder + .os(Some(profile.client_os().to_openconnect_os().to_string())) + .os_version(Some(profile.os_version().to_string())) + .client_version(Some(profile.client_version().to_string())) + .host_id(Some(profile.host_identity().host_id().to_string())) + .user_agent(Some(profile.user_agent().to_string())) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn openconnect_success_is_not_a_gateway_failure() { + assert!(classify_openconnect_result(0, false).is_ok()); + assert!(classify_openconnect_result(0, true).is_ok()); + } + + #[test] + fn openconnect_failure_before_callback_is_retryable_gateway_failure() { + let err = classify_openconnect_result(1, false).expect_err("nonzero exit should fail"); + + assert!(err.is_before_tunnel()); + } + + #[test] + fn openconnect_failure_after_callback_is_terminal_gateway_failure() { + let err = classify_openconnect_result(1, true).expect_err("nonzero exit should fail"); + + assert!(!err.is_before_tunnel()); + } + + #[test] + fn direct_gateway_recommendation_uses_gateway_server() { + assert_eq!( + direct_gateway_command("gateway.example.test"), + "gpauth --gateway gateway.example.test | sudo gpclient connect gateway.example.test --as-gateway --cookie-on-stdin" + ); + } +} diff --git a/apps/gpclient/src/connect/mod.rs b/apps/gpclient/src/connect/mod.rs new file mode 100644 index 0000000..0d701d1 --- /dev/null +++ b/apps/gpclient/src/connect/mod.rs @@ -0,0 +1,281 @@ +mod args; +mod credential; +mod gateway; + +use std::cell::RefCell; + +use anyhow::bail; +use gpapi::{ + error::PortalError, + gateway::{GatewayLoginContext, GatewaySelection}, + gp_params::GpParams, + os_profile::OsProfile, + portal::{PreloginOptions, prelogin, retrieve_config}, + utils::request::RequestIdentityError, +}; +use inquire::{Password, PasswordDisplayMode, Select}; +use log::{info, warn}; + +use crate::cli::SharedArgs; + +pub(crate) use args::ConnectArgs; +use args::{build_os_profile, build_os_profile_with_host_id, warn_deprecated_connect_args}; +use credential::CleanAuthState; +use gateway::GatewayConnectError; + +pub(crate) struct ConnectHandler<'a> { + args: &'a ConnectArgs, + shared_args: &'a SharedArgs<'a>, + os_profile: RefCell, + latest_key_password: RefCell>, + password_from_stdin: RefCell>, + cookie_from_stdin: RefCell>, + clean_auth_state: RefCell, +} + +impl<'a> ConnectHandler<'a> { + pub(crate) fn new(args: &'a ConnectArgs, shared_args: &'a SharedArgs) -> Self { + warn_deprecated_connect_args(args); + + #[cfg(feature = "webview-auth")] + let clean_auth = args.clean; + #[cfg(not(feature = "webview-auth"))] + let clean_auth = false; + + Self { + args, + shared_args, + os_profile: RefCell::new(build_os_profile(args)), + latest_key_password: Default::default(), + password_from_stdin: Default::default(), + cookie_from_stdin: Default::default(), + clean_auth_state: RefCell::new(CleanAuthState::new(clean_auth)), + } + } + + fn build_gp_params(&self) -> GpParams { + let mut builder = GpParams::builder(self.os_profile.borrow().clone()); + builder + .csc_mode(self.args.csc) + .ignore_tls_errors(self.shared_args.ignore_tls_errors) + .certificate(self.args.certificate.clone()) + .sslkey(self.args.sslkey.clone()) + .key_password(self.latest_key_password.borrow().clone()); + + builder.build() + } + + pub(super) fn prelogin_options(&self, portal_default_browser_enabled: bool) -> PreloginOptions { + PreloginOptions::default() + .external_browser_requested(self.external_browser_requested()) + .portal_default_browser_enabled(portal_default_browser_enabled) + } + + fn external_browser_requested(&self) -> bool { + #[cfg(feature = "webview-auth")] + { + self.args.default_browser || self.args.browser.is_some() + } + + #[cfg(not(feature = "webview-auth"))] + { + self.args.browser.is_some() + } + } + + pub(crate) async fn handle(&self) -> anyhow::Result<()> { + #[cfg(feature = "webview-auth")] + if self.args.default_browser && self.args.browser.is_some() { + bail!("Cannot use `--default-browser` and `--browser` options at the same time"); + } + + self.latest_key_password.replace(self.args.key_password.clone()); + + loop { + let Err(err) = self.handle_impl().await else { + return Ok(()); + }; + + let Some(root_cause) = err.root_cause().downcast_ref::() else { + return Err(err); + }; + + match root_cause { + RequestIdentityError::NoKey => { + eprintln!("ERROR: No private key found in the certificate file"); + eprintln!("ERROR: Please provide the private key file using the `-k` option"); + return Ok(()); + } + RequestIdentityError::NoPassphrase(cert_type) | RequestIdentityError::DecryptError(cert_type) => { + let message = format!("Enter the {} passphrase:", cert_type); + let password = Password::new(&message) + .without_confirmation() + .with_display_mode(PasswordDisplayMode::Masked) + .prompt()?; + + self.latest_key_password.replace(Some(password)); + } + } + } + } + + pub(crate) async fn handle_impl(&self) -> anyhow::Result<()> { + let server = self.args.server.as_str(); + let as_gateway = self.args.as_gateway; + + self.prepare_cookie_from_stdin()?; + + if as_gateway { + info!("Treating the server as a gateway"); + return self.connect_gateway_with_prelogin(server, server, false, None).await; + } + + if !self.args.cookie_on_stdin { + if let Some(()) = self.try_cached_cookie(server).await { + return Ok(()); + } + } + + let Err(err) = self.connect_portal_with_prelogin(server).await else { + return Ok(()); + }; + + warn!("Failed to connect portal with prelogin: {}", err); + if err.root_cause().downcast_ref::().is_some() { + info!("Trying the gateway authentication workflow..."); + self.connect_gateway_with_prelogin(server, server, false, None).await?; + + eprintln!("\nNOTE: the server may be a gateway, not a portal."); + eprintln!("NOTE: try to use the `--as-gateway` option if you were authenticated twice."); + + Ok(()) + } else { + Err(err) + } + } + + async fn connect_portal_with_prelogin(&self, portal: &str) -> anyhow::Result<()> { + let gp_params = self.build_gp_params(); + + let prelogin = prelogin(portal, &gp_params, self.prelogin_options(false)).await?; + + let cred = self.obtain_credential(&prelogin, portal).await?; + let mut portal_config = retrieve_config(portal, &cred, &gp_params).await?; + + portal_config.sort_gateways(prelogin.region()); + + let auth_cookie = match cred.password() { + Some(password) => portal_config.auth_cookie().clone().with_password(password), + None => portal_config.auth_cookie().clone(), + }; + let allow_extend_session = portal_config.allow_extend_session().unwrap_or(false); + let portal_default_browser_enabled = portal_config.default_browser().unwrap_or(false); + + if self.args.auto_gateway { + let gateways = portal_config.gateways(); + if gateways.is_empty() { + bail!("No gateways available in portal config for auto-gateway selection"); + } + + info!( + "Auto-gateway mode: trying {} gateway(s) in priority order", + gateways.len() + ); + + let mut last_err: Option = None; + for gateway in &gateways { + info!("Auto-gateway: attempting gateway {}", gateway); + let gateway_context = + GatewayLoginContext::new(gateway, GatewaySelection::Auto).with_connect_method(portal_config.connect_method()); + + match self + .connect_gateway_with_fallback( + portal, + gateway.server(), + &auth_cookie, + allow_extend_session, + portal_default_browser_enabled, + gateway_context, + ) + .await + { + Ok(()) => return Ok(()), + Err(err) => { + if !err.is_before_tunnel() { + return Err(err.into_error()); + } + warn!( + "Auto-gateway: gateway {} failed before tunnel setup: {}", + gateway, + err.as_error() + ); + last_err = Some(err.into_error()); + } + } + } + + let detail = last_err + .map(|e| e.to_string()) + .unwrap_or_else(|| "unknown error".to_string()); + bail!( + "Auto-gateway: all {} gateway(s) failed to connect; last error: {}", + gateways.len(), + detail + ); + } + + let gateway_selection = if self.args.gateway.is_some() { + GatewaySelection::Manual + } else { + GatewaySelection::Auto + }; + let selected_gateway = match &self.args.gateway { + Some(gateway) => portal_config + .find_gateway(gateway) + .ok_or_else(|| anyhow::anyhow!("Cannot find gateway specified: {}", gateway))?, + None => { + let gateways = portal_config.gateways(); + + if gateways.len() > 1 { + let gateway = Select::new("Which gateway do you want to connect to?", gateways) + .with_vim_mode(true) + .prompt()?; + info!("Connecting to the selected gateway: {}", gateway); + gateway + } else { + info!("Connecting to the only available gateway: {}", gateways[0]); + gateways[0] + } + } + }; + + let gateway = selected_gateway.server(); + let gateway_context = + GatewayLoginContext::new(selected_gateway, gateway_selection).with_connect_method(portal_config.connect_method()); + + self + .connect_gateway_with_fallback( + portal, + gateway, + &auth_cookie, + allow_extend_session, + portal_default_browser_enabled, + gateway_context, + ) + .await + .map_err(GatewayConnectError::into_error) + } + + fn apply_stdin_host_id(&self, host_id: Option<&str>) { + let Some(host_id) = host_id else { + return; + }; + self + .os_profile + .replace(build_os_profile_with_host_id(self.args, Some(host_id))); + info!( + "connect profile host-id: {}", + self.os_profile.borrow().host_identity().host_id() + ); + } +} diff --git a/apps/gpclient/src/hip.rs b/apps/gpclient/src/hip.rs index 8706eac..08b9f8f 100644 --- a/apps/gpclient/src/hip.rs +++ b/apps/gpclient/src/hip.rs @@ -1,8 +1,11 @@ use askama::Template; use clap::Args; -use gpapi::{clap::args::Os, utils::host_utils}; +use gpapi::{ + clap::args::Os, + os_profile::{ClientOs, OsProfile, OsProfileBuilder}, +}; use log::debug; -use serde::{Deserialize, Serialize}; +use serde::Deserialize; use std::collections::HashMap; use std::process::Command; use xmltree::Element; @@ -16,12 +19,11 @@ struct HipReportTemplate<'a> { month: String, year: String, user_name: &'a str, - host_info: HostInfo<'a>, + host_info: HostInfo, md5: &'a str, } -/// Information about Microsoft Defender (mdatp) installation and status -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Deserialize)] struct DefenderInfo { #[serde(rename = "appVersion")] app_version: String, @@ -33,31 +35,29 @@ struct DefenderInfo { real_time_protection_enabled: RealTimeProtection, } -/// Wrapper for realTimeProtectionEnabled field which has a nested structure -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Deserialize)] struct RealTimeProtection { value: bool, } /// Host information for HIP reporting -struct HostInfo<'a> { +struct HostInfo { /// Common for all OSes, e.g., "Apple", "Microsoft", "Linux" - os_vendor: &'a str, + os_vendor: String, /// Common for all OSes, e.g., "Linux Ubuntu 20.04", "Apple Mac OS X 10.15.7", etc. - os_version: &'a str, - /// Only for macOS and Windows + os_version: String, + /// Per-OS machine identifier (UUID for Linux/Windows, MAC for macOS) host_id: String, /// Common for all OSes host_name: String, /// Only for macOS and Windows, e.g., "10.15.7", "10.0.19044.2130" - software_version: &'a str, + software_version: String, domain: String, network_interfaces: Vec, - /// Linux only: Microsoft Defender (mdatp) information if available defender: Option, } -impl<'a> HostInfo<'a> { +impl HostInfo { /// Get the first available IPv4 address from network interfaces pub fn default_ipv4(&self) -> &str { self @@ -126,8 +126,11 @@ pub(crate) struct HipArgs { #[arg(long, value_enum, help = "The client OS")] client_os: Os, - #[arg(long, help = "The OS version string, e.g., Apple Mac OS X 10.15.7")] - os_version: String, + #[arg(long, hide = true)] + os_version: Option, + + #[arg(long, help = "Use this runtime host ID when building the OS profile")] + host_id: Option, #[arg(long, help = "The authentication cookie")] cookie: String, @@ -144,11 +147,13 @@ pub(crate) struct HipArgs { pub(crate) struct HipHandler<'a> { args: &'a HipArgs, + profile: OsProfile, } impl<'a> HipHandler<'a> { pub(crate) fn new(args: &'a HipArgs) -> Self { - Self { args } + let profile = build_os_profile(args); + Self { args, profile } } pub(crate) async fn handle(&self) -> anyhow::Result<()> { @@ -187,34 +192,57 @@ impl<'a> HipHandler<'a> { format_xml(&report) } - /// Collect host information based on the client OS - fn collect_host_info(&self, cookie_params: &'a HashMap) -> HostInfo<'a> { - let collector = HostInfoCollector::new(self.args, cookie_params); - - match self.args.client_os { - Os::Linux => collector.collect_linux(), - Os::Mac => collector.collect_macos(), - Os::Windows => collector.collect_windows(), - } + /// Collect host information using the configured OsProfile. + fn collect_host_info(&self, cookie_params: &'a HashMap) -> HostInfo { + HostInfoCollector::new(&self.profile, self.args, cookie_params).collect() } } +/// Construct an `OsProfile` from CLI args, falling back to per-OS defaults +/// for any value not supplied on the command line. +fn build_os_profile(args: &HipArgs) -> OsProfile { + let client_os = ClientOs::from(args.client_os); + let mut builder = OsProfileBuilder::new(client_os).client_version(args.client_version.clone()); + if let Some(host_id) = args.host_id.as_deref() { + debug!("HIP host-id override supplied: {}", host_id); + builder = builder.host_id_override(host_id); + } + let profile = builder.build(); + debug!( + "HIP OS profile host-id: runtime={}, projected={}, client_os={}", + profile.host_identity().host_id(), + profile.host_id(), + client_os.as_str() + ); + profile +} + // ============================================================================ // Host Information Collector // ============================================================================ -/// Helper struct for collecting host information -struct HostInfoCollector<'a> { +/// Helper struct for collecting host information. +/// +/// Identity values (vendor, host_id, computer name, software version) come +/// from the configured `OsProfile`, while runtime state (network interfaces, +/// IP addresses) is enumerated here from the underlying machine. +struct HostInfoCollector<'p, 'a> { + profile: &'p OsProfile, args: &'a HipArgs, cookie_params: &'a HashMap, } -impl<'a> HostInfoCollector<'a> { - fn new(args: &'a HipArgs, cookie_params: &'a HashMap) -> Self { - Self { args, cookie_params } +impl<'p, 'a> HostInfoCollector<'p, 'a> { + fn new(profile: &'p OsProfile, args: &'a HipArgs, cookie_params: &'a HashMap) -> Self { + Self { + profile, + args, + cookie_params, + } } - /// Get domain from cookie parameters + /// Domain belongs to the runtime user/session, not the simulated OS, so + /// it is sourced from the auth cookie when available. fn get_domain(&self) -> String { self .cookie_params @@ -240,141 +268,80 @@ impl<'a> HostInfoCollector<'a> { } } - /// Collect Linux-specific host information - fn collect_linux(&self) -> HostInfo<'a> { - let iface = self.collect_network_interface(); + /// Single entry point for collecting host info — dispatches per-OS + /// behavior via `OsProfile` methods rather than `#[cfg(target_os)]`. + fn collect(&self) -> HostInfo { + let runtime_iface = self.collect_network_interface(); + let primary = self.adapt_primary_interface(&runtime_iface); - // Use the fixed interface name enp1s0f0 for Linux if it is not on Linux - let iface = NetworkInterface { - #[cfg(target_os = "linux")] - name: iface.name, - #[cfg(target_os = "linux")] - description: iface.description, - - #[cfg(not(target_os = "linux"))] - name: "enp1s0f0".to_string(), - #[cfg(not(target_os = "linux"))] - description: "enp1s0f0".to_string(), - - mac_address: iface.mac_address, - ipv4: iface.ipv4, - ipv6: iface.ipv6, - }; - - // Try to detect Microsoft Defender on Linux - let defender = detect_microsoft_defender_blocking(); + let mut interfaces = vec![primary.clone()]; + interfaces.extend(self.extra_interfaces(&primary)); HostInfo { - os_vendor: "Linux", - os_version: &self.args.os_version, - host_id: host_utils::derive_uuid(&[]), - host_name: whoami::devicename(), - software_version: "", - domain: String::new(), - network_interfaces: vec![iface], - defender, + os_vendor: self.profile.os_vendor().to_string(), + os_version: self.profile.os_version().to_string(), + host_id: self.profile.host_id().to_string(), + host_name: self.profile.computer().to_string(), + software_version: self.profile.software_version().to_string(), + domain: self.domain_for_profile(), + network_interfaces: interfaces, + defender: self.defender_for_profile(), } } - /// Collect macOS-specific host information - fn collect_macos(&self) -> HostInfo<'a> { - let iface = self.collect_network_interface(); - // macOS use the mac address as host ID - let host_id = iface - .mac_address - .as_ref() - .map(|s| s.to_string()) - .unwrap_or_else(|| "00:00:00:00:00:00".to_string()); - - // Use the fixed interface name en0 for macOS if it is not on macOS - let iface = NetworkInterface { - #[cfg(target_os = "macos")] - name: iface.name, - #[cfg(target_os = "macos")] - description: iface.description, - - #[cfg(not(target_os = "macos"))] - name: "en0".to_string(), - #[cfg(not(target_os = "macos"))] - description: "en0".to_string(), - - mac_address: iface.mac_address, - ipv4: iface.ipv4, - ipv6: iface.ipv6, + /// Build the primary network interface with OS-appropriate naming and + /// MAC formatting. When emulating a different OS, the runtime interface + /// name/description are replaced with the canonical placeholder for the + /// target OS. + fn adapt_primary_interface(&self, runtime: &NetworkInterface) -> NetworkInterface { + let (name, description) = if self.profile.is_native() { + (runtime.name.clone(), runtime.description.clone()) + } else { + placeholder_interface_for(self.profile, runtime) }; - HostInfo { - os_vendor: "Apple", - os_version: &self.args.os_version, - host_id, - host_name: whoami::devicename(), - software_version: host_utils::get_macos_version(), - domain: self.get_domain(), - network_interfaces: vec![iface], - defender: None, + NetworkInterface { + name, + description, + mac_address: format_mac_for(self.profile, runtime.mac_address.clone()), + ipv4: runtime.ipv4.clone(), + ipv6: runtime.ipv6.clone(), } } - /// Collect Windows-specific host information - fn collect_windows(&self) -> HostInfo<'a> { - // Use the actual machine ID on Windows - #[cfg(target_os = "windows")] - let host_id = host_utils::get_machine_id().to_string(); - #[cfg(not(target_os = "windows"))] - let host_id = host_utils::derive_uuid(&[]); + /// Additional interfaces appended after the primary. Only Windows + /// emits the software loopback interface in HIP reports. + fn extra_interfaces(&self, primary: &NetworkInterface) -> Vec { + match self.profile.client_os() { + ClientOs::Windows => vec![NetworkInterface { + name: derive_windows_network_name(self.profile.host_id(), primary), + description: "Software Loopback Interface 1".to_string(), + mac_address: Some(String::new()), + ipv4: Some("127.0.0.1".to_string()), + ipv6: Some("::1".to_string()), + }], + ClientOs::Linux | ClientOs::Mac => vec![], + } + } - let iface = self.collect_network_interface(); + /// Linux HIP reports omit the domain field; macOS/Windows include it + /// from the auth cookie. + fn domain_for_profile(&self) -> String { + match self.profile.client_os() { + ClientOs::Linux => String::new(), + ClientOs::Mac | ClientOs::Windows => self.get_domain(), + } + } - // Use the fixed interface name if it is not on Windows - let iface = NetworkInterface { - #[cfg(target_os = "windows")] - name: iface.name, - #[cfg(target_os = "windows")] - description: iface.description, - - #[cfg(not(target_os = "windows"))] - name: derive_windows_network_name(&iface), - #[cfg(not(target_os = "windows"))] - description: "PANGP Virtual Ethernet Adapter Secure".to_string(), - - // mac address on windows should replace ':' with '-' - mac_address: iface.mac_address.map(|mac| mac.replace(':', "-")), - ipv4: iface.ipv4, - ipv6: iface.ipv6, - }; - - // Add the local loopback interface - let loopback_iface = NetworkInterface { - name: derive_windows_network_name(&iface), - description: "Software Loopback Interface 1".to_string(), - mac_address: Some(String::new()), - ipv4: Some("127.0.0.1".to_string()), - ipv6: Some("::1".to_string()), - }; - - let ifaces = vec![iface, loopback_iface]; - - HostInfo { - os_vendor: "Microsoft", - os_version: &self.args.os_version, - host_id, - host_name: whoami::devicename(), - software_version: host_utils::get_windows_version(), - domain: self.get_domain(), - network_interfaces: ifaces, - defender: None, + fn defender_for_profile(&self) -> Option { + match self.profile.client_os() { + ClientOs::Linux => detect_microsoft_defender_blocking(), + ClientOs::Mac | ClientOs::Windows => None, } } } -// ============================================================================ -// Microsoft Defender Detection -// ============================================================================ - -/// Detect Microsoft Defender (mdatp) on Linux systems -/// Executes 'mdatp health --output json' and parses the result fn detect_microsoft_defender_blocking() -> Option { - // Try to execute 'mdatp health --output json' let output = Command::new("mdatp") .arg("health") .arg("--output") @@ -382,18 +349,47 @@ fn detect_microsoft_defender_blocking() -> Option { .output() .ok()?; - // Check if command executed successfully if !output.status.success() { debug!("mdatp health command failed"); return None; } - // Parse JSON output - let json_str = String::from_utf8(output.stdout).ok()?; - let defender_info: DefenderInfo = serde_json::from_str(&json_str).ok()?; + let json = String::from_utf8(output.stdout).ok()?; + let defender = parse_defender_info(&json)?; - debug!("Detected Microsoft Defender: {:?}", defender_info); - Some(defender_info) + debug!("Detected Microsoft Defender: {:?}", defender); + Some(defender) +} + +fn parse_defender_info(json: &str) -> Option { + serde_json::from_str(json).ok() +} + +// ============================================================================ +// Per-OS interface helpers (selected via OsProfile, not cfg) +// ============================================================================ + +/// Canonical interface name/description for the target OS when the runtime +/// is a different OS (i.e. emulation). +fn placeholder_interface_for(profile: &OsProfile, runtime: &NetworkInterface) -> (String, String) { + match profile.client_os() { + ClientOs::Linux => ("enp1s0f0".to_string(), "enp1s0f0".to_string()), + ClientOs::Mac => ("en0".to_string(), "en0".to_string()), + ClientOs::Windows => ( + derive_windows_network_name(profile.host_id(), runtime), + "PANGP Virtual Ethernet Adapter Secure".to_string(), + ), + } +} + +/// MAC address formatting per target OS. Windows uses hyphen separators; +/// Linux and macOS preserve the colon-separated form returned by the +/// platform. +fn format_mac_for(profile: &OsProfile, mac: Option) -> Option { + match profile.client_os() { + ClientOs::Windows => mac.map(|m| m.replace(':', "-")), + ClientOs::Linux | ClientOs::Mac => mac, + } } // ============================================================================ @@ -422,11 +418,163 @@ fn format_xml(xml_str: &str) -> anyhow::Result { Ok(String::from_utf8(xml_buf)?) } -fn derive_windows_network_name(iface: &NetworkInterface) -> String { - let seeds = [ +fn derive_windows_network_name(host_id: &str, iface: &NetworkInterface) -> String { + let seed = format!( + "{}-{}-{}", + host_id, iface.mac_address.as_deref().unwrap_or("00:00:00:00:00:00"), - iface.name.as_str(), - ]; + iface.name + ); - format!("{{{}}}", host_utils::derive_uuid(&seeds).to_uppercase()) + format!( + "{{{}}}", + uuid::Uuid::new_v5(&uuid::Uuid::NAMESPACE_DNS, seed.as_bytes()) + .to_string() + .to_uppercase() + ) +} + +#[cfg(test)] +mod tests { + use super::*; + use gpapi::os_profile::runtime_client_os; + + fn make_hip_args(client_os: Os) -> HipArgs { + HipArgs { + client_version: "6.2.4-49".to_string(), + client_os, + os_version: Some("test-os-version".to_string()), + host_id: None, + cookie: String::new(), + client_ip: None, + client_ipv6: None, + md5: "deadbeef".to_string(), + } + } + + fn make_profile(client_os: ClientOs) -> OsProfile { + OsProfileBuilder::new(client_os).build() + } + + #[test] + fn host_info_os_vendor_is_linux_for_linux_profile() { + let args = make_hip_args(Os::Linux); + let profile = make_profile(ClientOs::Linux); + let cookie_params: HashMap = HashMap::new(); + + let info = HostInfoCollector::new(&profile, &args, &cookie_params).collect(); + + assert_eq!(info.os_vendor, "Linux"); + } + + #[test] + fn host_info_os_vendor_is_apple_for_mac_profile() { + let args = make_hip_args(Os::Mac); + let profile = make_profile(ClientOs::Mac); + let cookie_params: HashMap = HashMap::new(); + + let info = HostInfoCollector::new(&profile, &args, &cookie_params).collect(); + + assert_eq!(info.os_vendor, "Apple"); + } + + #[test] + fn host_info_os_vendor_is_microsoft_for_windows_profile() { + let args = make_hip_args(Os::Windows); + let profile = make_profile(ClientOs::Windows); + let cookie_params: HashMap = HashMap::new(); + + let info = HostInfoCollector::new(&profile, &args, &cookie_params).collect(); + + assert_eq!(info.os_vendor, "Microsoft"); + } + + #[test] + fn host_info_host_id_comes_from_os_profile() { + let args = make_hip_args(Os::Linux); + let profile = make_profile(ClientOs::Linux); + let cookie_params: HashMap = HashMap::new(); + + let info = HostInfoCollector::new(&profile, &args, &cookie_params).collect(); + + assert_eq!(info.host_id, profile.host_id()); + } + + #[test] + fn host_info_host_id_independent_of_runtime_for_each_os() { + // host_id should reflect the OsProfile's machine identity for every + // simulated OS, regardless of the runtime platform. + for (client_os, os_arg) in [ + (ClientOs::Linux, Os::Linux), + (ClientOs::Mac, Os::Mac), + (ClientOs::Windows, Os::Windows), + ] { + let args = make_hip_args(os_arg); + let profile = make_profile(client_os); + let cookie_params: HashMap = HashMap::new(); + + let info = HostInfoCollector::new(&profile, &args, &cookie_params).collect(); + + assert_eq!(info.host_id, profile.host_id()); + } + } + + #[test] + fn hip_os_version_argument_is_ignored() { + let args = make_hip_args(Os::Linux); + let profile = build_os_profile(&args); + let cookie_params: HashMap = HashMap::new(); + + let info = HostInfoCollector::new(&profile, &args, &cookie_params).collect(); + + assert_eq!(info.os_version, profile.os_version()); + assert_ne!(info.os_version, "test-os-version"); + } + + #[test] + fn host_id_argument_sets_profile_runtime_identity() { + let mut args = make_hip_args(Os::default()); + args.host_id = Some("auth-host-id".to_string()); + + let profile = build_os_profile(&args); + + assert_eq!(profile.client_os(), runtime_client_os()); + assert_eq!(profile.host_identity().host_id(), "auth-host-id"); + } + + #[test] + fn host_info_uses_host_id_argument_for_native_profile() { + let mut args = make_hip_args(Os::default()); + args.host_id = Some("auth-host-id".to_string()); + let profile = build_os_profile(&args); + let cookie_params: HashMap = HashMap::new(); + + let info = HostInfoCollector::new(&profile, &args, &cookie_params).collect(); + + assert_eq!(profile.host_identity().host_id(), "auth-host-id"); + assert_eq!(info.host_id, profile.host_id()); + } + + #[test] + fn parses_microsoft_defender_health_json() { + let defender = parse_defender_info( + r#"{ + "appVersion": "101.25042.0000", + "engineVersion": "1.1.25040.2", + "definitionsVersion": "1.429.201.0", + "realTimeProtectionEnabled": { "value": true } + }"#, + ) + .expect("defender health json should parse"); + + assert_eq!(defender.app_version, "101.25042.0000"); + assert_eq!(defender.engine_version, "1.1.25040.2"); + assert_eq!(defender.definitions_version, "1.429.201.0"); + assert!(defender.real_time_protection_enabled.value); + } + + #[test] + fn rejects_invalid_microsoft_defender_health_json() { + assert!(parse_defender_info("{}").is_none()); + } } diff --git a/apps/gpclient/src/launch_gui.rs b/apps/gpclient/src/launch_gui.rs index 6acae4f..958270f 100644 --- a/apps/gpclient/src/launch_gui.rs +++ b/apps/gpclient/src/launch_gui.rs @@ -32,7 +32,7 @@ impl<'a> LaunchGuiHandler<'a> { pub(crate) async fn handle(&self) -> anyhow::Result<()> { // `launch-gui`cannot be run as root - let user = whoami::username(); + let user = whoami::username().map_err(|err| anyhow::anyhow!("Failed to resolve current user: {err}"))?; if user == "root" { anyhow::bail!("`launch-gui` cannot be run as root"); } diff --git a/apps/gpclient/src/session.rs b/apps/gpclient/src/session.rs index aabf3bb..d0ed18e 100644 --- a/apps/gpclient/src/session.rs +++ b/apps/gpclient/src/session.rs @@ -1,9 +1,8 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH}; -use common::constants::GP_CLIENT_VERSION; use gpapi::{ gateway::{SessionContext, SessionExtensionAuth, extend_session}, - gp_params::ClientOs, + os_profile::OsProfile, session::{SessionInfo, SessionRequestArgs, SessionWarning}, }; use log::{info, warn}; @@ -21,10 +20,7 @@ pub(crate) struct SessionContextInput { pub(crate) portal: String, pub(crate) gateway: String, pub(crate) cookie: String, - pub(crate) user_agent: String, - pub(crate) os: ClientOs, - pub(crate) os_version: String, - pub(crate) client_version: Option, + pub(crate) os_profile: OsProfile, pub(crate) certificate: Option, pub(crate) sslkey: Option, pub(crate) key_password: Option, @@ -34,12 +30,7 @@ pub(crate) struct SessionContextInput { pub(crate) fn build_session_context(input: SessionContextInput) -> SessionContext { let session_args = SessionRequestArgs::new(input.cookie) - .with_user_agent(Some(input.user_agent)) - .with_os(Some(input.os)) - .with_os_version(Some(input.os_version)) - .with_client_version(Some( - input.client_version.unwrap_or_else(|| GP_CLIENT_VERSION.to_string()), - )) + .with_user_agent(input.os_profile.user_agent().to_string()) .with_certificate(input.certificate) .with_sslkey(input.sslkey) .with_key_password(input.key_password) @@ -181,15 +172,17 @@ mod tests { } #[test] - fn builds_session_context_from_cli_runtime_values() { + fn builds_session_context_from_os_profile() { + let profile = OsProfile::builder(gpapi::os_profile::ClientOs::Mac) + .client_version("6.3.1-12".to_string()) + .build(); + let expected_user_agent = profile.user_agent().to_string(); + let ctx = build_session_context(SessionContextInput { portal: "portal.example.com".to_string(), gateway: "vpn.example.com".to_string(), cookie: "authcookie=AUTH".to_string(), - user_agent: "UA".to_string(), - os: ClientOs::Mac, - os_version: "macOS 15.0".to_string(), - client_version: Some("6.3.1-12".to_string()), + os_profile: profile, certificate: Some("/tmp/client.pem".to_string()), sslkey: Some("/tmp/client.key".to_string()), key_password: Some("secret".to_string()), @@ -200,10 +193,10 @@ mod tests { assert_eq!(ctx.portal(), "portal.example.com"); assert_eq!(ctx.server(), "vpn.example.com"); assert_eq!(ctx.session_args().cookie(), "authcookie=AUTH"); - assert_eq!(ctx.session_args().user_agent().as_deref(), Some("UA")); - assert!(matches!(ctx.session_args().os(), Some(ClientOs::Mac))); - assert_eq!(ctx.session_args().os_version().as_deref(), Some("macOS 15.0")); - assert_eq!(ctx.session_args().client_version().as_deref(), Some("6.3.1-12")); + assert_eq!( + ctx.session_args().user_agent().as_deref(), + Some(expected_user_agent.as_str()) + ); assert_eq!(ctx.session_args().certificate().as_deref(), Some("/tmp/client.pem")); assert_eq!(ctx.session_args().sslkey().as_deref(), Some("/tmp/client.key")); assert_eq!(ctx.session_args().key_password().as_deref(), Some("secret")); diff --git a/apps/gpgui-helper/package.json b/apps/gpgui-helper/package.json index da96db5..4a2bdbb 100644 --- a/apps/gpgui-helper/package.json +++ b/apps/gpgui-helper/package.json @@ -11,27 +11,27 @@ "dependencies": { "@emotion/react": "^11.14.0", "@emotion/styled": "^11.14.1", - "@mui/icons-material": "^7.3.10", - "@mui/material": "^7.3.10", - "@tauri-apps/api": "^2.11.0", - "react": "^19.2.5", - "react-dom": "^19.2.5" + "@mui/icons-material": "^7.3.11", + "@mui/material": "^7.3.11", + "@tauri-apps/api": "^2.11.1", + "react": "^19.2.7", + "react-dom": "^19.2.7" }, "devDependencies": { - "@tauri-apps/cli": "^2.11.1", - "@types/node": "^25.6.0", - "@types/react": "^19.2.14", + "@tauri-apps/cli": "^2.11.2", + "@types/node": "^25.9.4", + "@types/react": "^19.2.17", "@types/react-dom": "^19.2.3", - "@typescript-eslint/eslint-plugin": "^8.59.2", - "@typescript-eslint/parser": "^8.59.2", - "@vitejs/plugin-react": "^6.0.1", + "@typescript-eslint/eslint-plugin": "^8.61.1", + "@typescript-eslint/parser": "^8.61.1", + "@vitejs/plugin-react": "^6.0.2", "eslint": "^9.39.4", "eslint-config-prettier": "^10.1.8", "eslint-plugin-react": "^7.37.5", "eslint-plugin-react-hooks": "^7.1.1", "prettier": "3.8.3", "typescript": "^6.0.3", - "vite": "^8.0.10" + "vite": "^8.0.16" }, "packageManager": "pnpm@9.15.1" } diff --git a/apps/gpgui-helper/pnpm-lock.yaml b/apps/gpgui-helper/pnpm-lock.yaml index d494e79..2c53707 100644 --- a/apps/gpgui-helper/pnpm-lock.yaml +++ b/apps/gpgui-helper/pnpm-lock.yaml @@ -10,47 +10,47 @@ importers: dependencies: '@emotion/react': specifier: ^11.14.0 - version: 11.14.0(@types/react@19.2.14)(react@19.2.5) + version: 11.14.0(@types/react@19.2.17)(react@19.2.7) '@emotion/styled': specifier: ^11.14.1 - version: 11.14.1(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@types/react@19.2.14)(react@19.2.5) + version: 11.14.1(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@types/react@19.2.17)(react@19.2.7) '@mui/icons-material': - specifier: ^7.3.10 - version: 7.3.10(@mui/material@7.3.10(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@types/react@19.2.14)(react@19.2.5))(@types/react@19.2.14)(react-dom@19.2.5(react@19.2.5))(react@19.2.5))(@types/react@19.2.14)(react@19.2.5) + specifier: ^7.3.11 + version: 7.3.11(@mui/material@7.3.11(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@types/react@19.2.17)(react@19.2.7))(@types/react@19.2.17)(react-dom@19.2.7(react@19.2.7))(react@19.2.7))(@types/react@19.2.17)(react@19.2.7) '@mui/material': - specifier: ^7.3.10 - version: 7.3.10(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@types/react@19.2.14)(react@19.2.5))(@types/react@19.2.14)(react-dom@19.2.5(react@19.2.5))(react@19.2.5) + specifier: ^7.3.11 + version: 7.3.11(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@types/react@19.2.17)(react@19.2.7))(@types/react@19.2.17)(react-dom@19.2.7(react@19.2.7))(react@19.2.7) '@tauri-apps/api': - specifier: ^2.11.0 - version: 2.11.0 - react: - specifier: ^19.2.5 - version: 19.2.5 - react-dom: - specifier: ^19.2.5 - version: 19.2.5(react@19.2.5) - devDependencies: - '@tauri-apps/cli': specifier: ^2.11.1 version: 2.11.1 + react: + specifier: ^19.2.7 + version: 19.2.7 + react-dom: + specifier: ^19.2.7 + version: 19.2.7(react@19.2.7) + devDependencies: + '@tauri-apps/cli': + specifier: ^2.11.2 + version: 2.11.2 '@types/node': - specifier: ^25.6.0 - version: 25.6.0 + specifier: ^25.9.4 + version: 25.9.4 '@types/react': - specifier: ^19.2.14 - version: 19.2.14 + specifier: ^19.2.17 + version: 19.2.17 '@types/react-dom': specifier: ^19.2.3 - version: 19.2.3(@types/react@19.2.14) + version: 19.2.3(@types/react@19.2.17) '@typescript-eslint/eslint-plugin': - specifier: ^8.59.2 - version: 8.59.2(@typescript-eslint/parser@8.59.2(eslint@9.39.4)(typescript@6.0.3))(eslint@9.39.4)(typescript@6.0.3) + specifier: ^8.61.1 + version: 8.61.1(@typescript-eslint/parser@8.61.1(eslint@9.39.4)(typescript@6.0.3))(eslint@9.39.4)(typescript@6.0.3) '@typescript-eslint/parser': - specifier: ^8.59.2 - version: 8.59.2(eslint@9.39.4)(typescript@6.0.3) + specifier: ^8.61.1 + version: 8.61.1(eslint@9.39.4)(typescript@6.0.3) '@vitejs/plugin-react': - specifier: ^6.0.1 - version: 6.0.1(vite@8.0.10(@types/node@25.6.0)(esbuild@0.27.2)) + specifier: ^6.0.2 + version: 6.0.2(vite@8.0.16(@types/node@25.9.4)(esbuild@0.27.2)) eslint: specifier: ^9.39.4 version: 9.39.4 @@ -70,80 +70,80 @@ importers: specifier: ^6.0.3 version: 6.0.3 vite: - specifier: ^8.0.10 - version: 8.0.10(@types/node@25.6.0)(esbuild@0.27.2) + specifier: ^8.0.16 + version: 8.0.16(@types/node@25.9.4)(esbuild@0.27.2) packages: - '@babel/code-frame@7.29.0': - resolution: {integrity: sha512-9NhCeYjq9+3uxgdtp20LSiJXJvN0FeCtNGpJxuMFZ1Kv3cWUNb6DOhJwUvcVCzKGR66cw4njwM6hrJLqgOwbcw==} + '@babel/code-frame@7.29.7': + resolution: {integrity: sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==} engines: {node: '>=6.9.0'} - '@babel/compat-data@7.29.3': - resolution: {integrity: sha512-LIVqM46zQWZhj17qA8wb4nW/ixr2y1Nw+r1etiAWgRM6U1IqP+LNhL1yg440jYZR72jCWcWbLWzIosH+uP1fqg==} + '@babel/compat-data@7.29.7': + resolution: {integrity: sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==} engines: {node: '>=6.9.0'} - '@babel/core@7.29.0': - resolution: {integrity: sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==} + '@babel/core@7.29.7': + resolution: {integrity: sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==} engines: {node: '>=6.9.0'} - '@babel/generator@7.29.1': - resolution: {integrity: sha512-qsaF+9Qcm2Qv8SRIMMscAvG4O3lJ0F1GuMo5HR/Bp02LopNgnZBC/EkbevHFeGs4ls/oPz9v+Bsmzbkbe+0dUw==} + '@babel/generator@7.29.7': + resolution: {integrity: sha512-DkXD5OJQaAQIdZ1bt3UZdEnHAn9Imd3IVBdX03UFe+ony9Ojw5pzr9YVKGDY1jt+Gcn/FnGkNf8r+Vj5NOJWtQ==} engines: {node: '>=6.9.0'} - '@babel/helper-compilation-targets@7.28.6': - resolution: {integrity: sha512-JYtls3hqi15fcx5GaSNL7SCTJ2MNmjrkHXg4FSpOA/grxK8KwyZ5bubHsCq8FXCkua6xhuaaBit+3b7+VZRfcA==} + '@babel/helper-compilation-targets@7.29.7': + resolution: {integrity: sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g==} engines: {node: '>=6.9.0'} - '@babel/helper-globals@7.28.0': - resolution: {integrity: sha512-+W6cISkXFa1jXsDEdYA8HeevQT/FULhxzR99pxphltZcVaugps53THCeiWA8SguxxpSp3gKPiuYfSWopkLQ4hw==} + '@babel/helper-globals@7.29.7': + resolution: {integrity: sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==} engines: {node: '>=6.9.0'} - '@babel/helper-module-imports@7.28.6': - resolution: {integrity: sha512-l5XkZK7r7wa9LucGw9LwZyyCUscb4x37JWTPz7swwFE/0FMQAGpiWUZn8u9DzkSBWEcK25jmvubfpw2dnAMdbw==} + '@babel/helper-module-imports@7.29.7': + resolution: {integrity: sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==} engines: {node: '>=6.9.0'} - '@babel/helper-module-transforms@7.28.6': - resolution: {integrity: sha512-67oXFAYr2cDLDVGLXTEABjdBJZ6drElUSI7WKp70NrpyISso3plG9SAGEF6y7zbha/wOzUByWWTJvEDVNIUGcA==} + '@babel/helper-module-transforms@7.29.7': + resolution: {integrity: sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0 - '@babel/helper-string-parser@7.27.1': - resolution: {integrity: sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==} + '@babel/helper-string-parser@7.29.7': + resolution: {integrity: sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==} engines: {node: '>=6.9.0'} - '@babel/helper-validator-identifier@7.28.5': - resolution: {integrity: sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==} + '@babel/helper-validator-identifier@7.29.7': + resolution: {integrity: sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==} engines: {node: '>=6.9.0'} - '@babel/helper-validator-option@7.27.1': - resolution: {integrity: sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==} + '@babel/helper-validator-option@7.29.7': + resolution: {integrity: sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==} engines: {node: '>=6.9.0'} - '@babel/helpers@7.29.2': - resolution: {integrity: sha512-HoGuUs4sCZNezVEKdVcwqmZN8GoHirLUcLaYVNBK2J0DadGtdcqgr3BCbvH8+XUo4NGjNl3VOtSjEKNzqfFgKw==} + '@babel/helpers@7.29.7': + resolution: {integrity: sha512-1k2lAGRMfHTcwuNYcCNUmaUffmQv8KWMfh2iJUUeRlwlwH4FdNG7mfPI10NPfLHJFThE4Tyr4mv7kTNZOiPuBg==} engines: {node: '>=6.9.0'} - '@babel/parser@7.29.3': - resolution: {integrity: sha512-b3ctpQwp+PROvU/cttc4OYl4MzfJUWy6FZg+PMXfzmt/+39iHVF0sDfqay8TQM3JA2EUOyKcFZt75jWriQijsA==} + '@babel/parser@7.29.7': + resolution: {integrity: sha512-hnORnjP/1P/zFEndoeX+n+t1RwWRJiJpM/jO7FW32Kn9r5+sJB2JWOdYo4L6k78j15eCwY3Gm/7364B1EMwtNg==} engines: {node: '>=6.0.0'} hasBin: true - '@babel/runtime@7.29.2': - resolution: {integrity: sha512-JiDShH45zKHWyGe4ZNVRrCjBz8Nh9TMmZG1kh4QTK8hCBTWBi8Da+i7s1fJw7/lYpM4ccepSNfqzZ/QvABBi5g==} + '@babel/runtime@7.29.7': + resolution: {integrity: sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==} engines: {node: '>=6.9.0'} - '@babel/template@7.28.6': - resolution: {integrity: sha512-YA6Ma2KsCdGb+WC6UpBVFJGXL58MDA6oyONbjyF/+5sBgxY/dwkhLogbMT2GXXyU84/IhRw/2D1Os1B/giz+BQ==} + '@babel/template@7.29.7': + resolution: {integrity: sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==} engines: {node: '>=6.9.0'} - '@babel/traverse@7.29.0': - resolution: {integrity: sha512-4HPiQr0X7+waHfyXPZpWPfWL/J7dcN1mx9gL6WdQVMbPnF3+ZhSMs8tCxN7oHddJE9fhNE7+lxdnlyemKfJRuA==} + '@babel/traverse@7.29.7': + resolution: {integrity: sha512-EhlfNQtZ+NK22w5BM61ciuiq1m58ed33Wr1Xan//ZRTy6hgjnwyCffRYwzsGXdASJSUJ1guZILsErh1eQcl+zw==} engines: {node: '>=6.9.0'} - '@babel/types@7.29.0': - resolution: {integrity: sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==} + '@babel/types@7.29.7': + resolution: {integrity: sha512-4zBIxpPzowiZpusoFkyGVwakdRJUyuH5PxQ/PrqghfdFWWasvnCdPfQXHrenDai+gyLARulZjZowCOj6fjT4pA==} engines: {node: '>=6.9.0'} '@emnapi/core@1.10.0': @@ -439,27 +439,27 @@ packages: '@jridgewell/trace-mapping@0.3.31': resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==} - '@mui/core-downloads-tracker@7.3.10': - resolution: {integrity: sha512-vrOpWRmPJSuwLo23J62wggEm/jvGdzqctej+UOCtgDUz6nZJQuj3ByPccVyaa7eQmwAzUwKN56FQPMKkqbj1GA==} + '@mui/core-downloads-tracker@7.3.11': + resolution: {integrity: sha512-a7I/b/nBTdXYz2cOSlEmkQ9WWE1x8FHpqMhFPp+Y1VPFxcOw91G5ELOHARQAGSPy5V+UCgJua6K/1x70bAtQPw==} - '@mui/icons-material@7.3.10': - resolution: {integrity: sha512-Au0ma4NSKGKNiimukj8UT/W1x2Qx6Qwn2RvFGykiSqVLYBNlIOPbjnIMvrwLGLu89EEpTVdu/ys/OduZR+tWqw==} + '@mui/icons-material@7.3.11': + resolution: {integrity: sha512-+hz5ilwHZ3djd5es3sCErLioqe/NhZcYTsV/TNXZAMdJdb23F4xzJjqnnZdnurc3S1+ietcssRNqieOhPQLZ7Q==} engines: {node: '>=14.0.0'} peerDependencies: - '@mui/material': ^7.3.10 + '@mui/material': ^7.3.11 '@types/react': ^17.0.0 || ^18.0.0 || ^19.0.0 react: ^17.0.0 || ^18.0.0 || ^19.0.0 peerDependenciesMeta: '@types/react': optional: true - '@mui/material@7.3.10': - resolution: {integrity: sha512-cHvGOk2ZEfbQt3LnGe0ZKd/ETs9gsUpkW66DCO+GSjMZhpdKU4XsuIr7zJ/B/2XaN8ihxuzHfYAR4zPtCN4RYg==} + '@mui/material@7.3.11': + resolution: {integrity: sha512-yq8bPc3LxOwKRWpcjRgDkYFmpM6aKlARfESTmOQcvLYFeJwtHte2tw6hJDrb8sk8wcvpDprHEHVaoUU0MslIkw==} engines: {node: '>=14.0.0'} peerDependencies: '@emotion/react': ^11.5.0 '@emotion/styled': ^11.3.0 - '@mui/material-pigment-css': ^7.3.10 + '@mui/material-pigment-css': ^7.3.11 '@types/react': ^17.0.0 || ^18.0.0 || ^19.0.0 react: ^17.0.0 || ^18.0.0 || ^19.0.0 react-dom: ^17.0.0 || ^18.0.0 || ^19.0.0 @@ -473,8 +473,8 @@ packages: '@types/react': optional: true - '@mui/private-theming@7.3.10': - resolution: {integrity: sha512-j3EZN+zOctxUISvJSmsEPo5o2F8zse4l5vRkBY+ps6UtnL6J7o14kUaI4w7gwo73id9e3cDNMVQK/9BVaMHVBw==} + '@mui/private-theming@7.3.11': + resolution: {integrity: sha512-9B+YKms0fRHbNrqp9tOT/DNbNnU5gyvJ1o3qAGXfq8GmZcbJnE3At9x07Zr/o0pkhzg4aDdwXVqe4+AcgtOCPA==} engines: {node: '>=14.0.0'} peerDependencies: '@types/react': ^17.0.0 || ^18.0.0 || ^19.0.0 @@ -496,8 +496,8 @@ packages: '@emotion/styled': optional: true - '@mui/system@7.3.10': - resolution: {integrity: sha512-/sfPpdpJaQn7BSF+avjIdHSYmxHp0UOBYNxSG9QGKfMOD6sLANCpRPCnanq1Pe0lFf0NHkO2iUk0TNzdWC1USQ==} + '@mui/system@7.3.11': + resolution: {integrity: sha512-7izwGWdNawAKpBKcRlx7f2gFnAAjmASBWvMcyX4YYEeLOFsbfGRbUYGInvnAcUeql3rPxI7F9Ft4oY2OLRz44g==} engines: {node: '>=14.0.0'} peerDependencies: '@emotion/react': ^11.5.0 @@ -520,8 +520,8 @@ packages: '@types/react': optional: true - '@mui/utils@7.3.10': - resolution: {integrity: sha512-7y2eIfy0h7JPz+Yy4pS+wgV68d46PuuxDqKBN4Q8VlPQSsCAGwroMCV6xWyc7g9dvEp8ZNFsknc59GHWO+r6Ow==} + '@mui/utils@7.3.11': + resolution: {integrity: sha512-XTjGnifwteg71/ij+0e7Y7d+hwyntMYP5wPoA/g2drdGH+Flkvjwy0OfrVpKBbaOvofq4zU/LIyUZyKgmWu18g==} engines: {node: '>=14.0.0'} peerDependencies: '@types/react': ^17.0.0 || ^18.0.0 || ^19.0.0 @@ -530,198 +530,195 @@ packages: '@types/react': optional: true - '@napi-rs/wasm-runtime@1.1.4': - resolution: {integrity: sha512-3NQNNgA1YSlJb/kMH1ildASP9HW7/7kYnRI2szWJaofaS1hWmbGI4H+d3+22aGzXXN9IJ+n+GiFVcGipJP18ow==} + '@napi-rs/wasm-runtime@1.1.5': + resolution: {integrity: sha512-AWPoBRJ9tsnVhor4sjO7rkni+7p+2IAEFj6cx06UgP10jkQHqay/36uRV/bFkgrh18D9vb4cr8Q0Pthskgzy+Q==} peerDependencies: '@emnapi/core': ^1.7.1 '@emnapi/runtime': ^1.7.1 - '@oxc-project/types@0.127.0': - resolution: {integrity: sha512-aIYXQBo4lCbO4z0R3FHeucQHpF46l2LbMdxRvqvuRuW2OxdnSkcng5B8+K12spgLDj93rtN3+J2Vac/TIO+ciQ==} + '@oxc-project/types@0.133.0': + resolution: {integrity: sha512-KzkdCd6Uxqnf6l3HOw1xfatAlUURA0g14cvBYFyJ5SaNOQbOUvBr9PKArcPcrNIeRsBdgcUzOGrhKveVpvOIGA==} '@popperjs/core@2.11.8': resolution: {integrity: sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==} - '@rolldown/binding-android-arm64@1.0.0-rc.17': - resolution: {integrity: sha512-s70pVGhw4zqGeFnXWvAzJDlvxhlRollagdCCKRgOsgUOH3N1l0LIxf83AtGzmb5SiVM4Hjl5HyarMRfdfj3DaQ==} + '@rolldown/binding-android-arm64@1.0.3': + resolution: {integrity: sha512-454rs7jHngixp/NMxd5srYD57OnzSlZ/eFTETjORQHLwJG1lRtmNOJcBerZlfu4GjKqeq8aCCIQrMdHyhI51Hw==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [android] - '@rolldown/binding-darwin-arm64@1.0.0-rc.17': - resolution: {integrity: sha512-4ksWc9n0mhlZpZ9PMZgTGjeOPRu8MB1Z3Tz0Mo02eWfWCHMW1zN82Qz/pL/rC+yQa+8ZnutMF0JjJe7PjwasYw==} + '@rolldown/binding-darwin-arm64@1.0.3': + resolution: {integrity: sha512-PcAhP+ynjURNyy8SKGl5DQP94aGuB/7JrXJb/t7P+hanXvQVMWzUvRRhBAcg/lNRadBhoUPqSoP4xw5tR/KBEA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [darwin] - '@rolldown/binding-darwin-x64@1.0.0-rc.17': - resolution: {integrity: sha512-SUSDOI6WwUVNcWxd02QEBjLdY1VPHvlEkw6T/8nYG322iYWCTxRb1vzk4E+mWWYehTp7ERibq54LSJGjmouOsw==} + '@rolldown/binding-darwin-x64@1.0.3': + resolution: {integrity: sha512-9YpfeUvSE2RS7wysJ81uOZkXJz7f7Q55H2Gvp3VEw/EsahqDtrphrZ0EwDLK5vvKOzaCrBsjF8JmnMLcUt78Gg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [darwin] - '@rolldown/binding-freebsd-x64@1.0.0-rc.17': - resolution: {integrity: sha512-hwnz3nw9dbJ05EDO/PvcjaaewqqDy7Y1rn1UO81l8iIK1GjenME75dl16ajbvSSMfv66WXSRCYKIqfgq2KCfxw==} + '@rolldown/binding-freebsd-x64@1.0.3': + resolution: {integrity: sha512-yB1IlAsSNHncV6SCTL27/MVGR5htvQsoGxIv5KMGXALp+Ll1wYsn+x98M9MW7qa+NdSbvrrY7ANI4wLJ0n1e6g==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [freebsd] - '@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.17': - resolution: {integrity: sha512-IS+W7epTcwANmFSQFrS1SivEXHtl1JtuQA9wlxrZTcNi6mx+FDOYrakGevvvTwgj2JvWiK8B29/qD9BELZPyXQ==} + '@rolldown/binding-linux-arm-gnueabihf@1.0.3': + resolution: {integrity: sha512-Yi30IVAAfLUCy2MseFjbB1jAMDl1VMCAas5StnYp8da9+CKvMd2H2cbEjWcw5NPaPqzvYkVIaF1nNUG+b7u/sw==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm] os: [linux] - '@rolldown/binding-linux-arm64-gnu@1.0.0-rc.17': - resolution: {integrity: sha512-e6usGaHKW5BMNZOymS1UcEYGowQMWcgZ71Z17Sl/h2+ZziNJ1a9n3Zvcz6LdRyIW5572wBCTH/Z+bKuZouGk9Q==} + '@rolldown/binding-linux-arm64-gnu@1.0.3': + resolution: {integrity: sha512-jsO7R8To+AdlYgUmN5sHSCZbfhtMBkO0WUx8iORQnPcMMdgr7qM2DQmMwgabs3GhNztdmoKkMKQFHD6DTMCIQw==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [linux] - '@rolldown/binding-linux-arm64-musl@1.0.0-rc.17': - resolution: {integrity: sha512-b/CgbwAJpmrRLp02RPfhbudf5tZnN9nsPWK82znefso832etkem8H7FSZwxrOI9djcdTP7U6YfNhbRnh7djErg==} + '@rolldown/binding-linux-arm64-musl@1.0.3': + resolution: {integrity: sha512-VWkUHwWriDciit80wleYwKILoR/KMvxh/IdwS/paX+ZgpuRpCrKLUdadJbc0NpBEiyhpYawsJ73j9aCvOH+f7Q==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [linux] - '@rolldown/binding-linux-ppc64-gnu@1.0.0-rc.17': - resolution: {integrity: sha512-4EII1iNGRUN5WwGbF/kOh/EIkoDN9HsupgLQoXfY+D1oyJm7/F4t5PYU5n8SWZgG0FEwakyM8pGgwcBYruGTlA==} + '@rolldown/binding-linux-ppc64-gnu@1.0.3': + resolution: {integrity: sha512-5f1laC0SlIR0yDbFCd8acUhvJIag6N3zC5P7oUPN6wX0aOma+uKJ0wBDH5aq7I1PVI2ttTlhJwzwRIBnLiSGEg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [ppc64] os: [linux] - '@rolldown/binding-linux-s390x-gnu@1.0.0-rc.17': - resolution: {integrity: sha512-AH8oq3XqQo4IibpVXvPeLDI5pzkpYn0WiZAfT05kFzoJ6tQNzwRdDYQ45M8I/gslbodRZwW8uxLhbSBbkv96rA==} + '@rolldown/binding-linux-s390x-gnu@1.0.3': + resolution: {integrity: sha512-Iq4ko0r4XsgbrF/LunNgHtAGLRRVE2kXonAXQ/MV0mC6jQpMOhW1SvtZja2EhC/kd05++bP78dsqBeIQyYJ6Yg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [s390x] os: [linux] - '@rolldown/binding-linux-x64-gnu@1.0.0-rc.17': - resolution: {integrity: sha512-cLnjV3xfo7KslbU41Z7z8BH/E1y5mzUYzAqih1d1MDaIGZRCMqTijqLv76/P7fyHuvUcfGsIpqCdddbxLLK9rA==} + '@rolldown/binding-linux-x64-gnu@1.0.3': + resolution: {integrity: sha512-B8m6tD5+/N5FeNQFbKlLA/2yVq9ycQP1SeedyEYYKWBNR3ZQbkvIUcNnDNM03lO1l5F2roiiFJGgvoLLyZXtSg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [linux] - '@rolldown/binding-linux-x64-musl@1.0.0-rc.17': - resolution: {integrity: sha512-0phclDw1spsL7dUB37sIARuis2tAgomCJXAHZlpt8PXZ4Ba0dRP1e+66lsRqrfhISeN9bEGNjQs+T/Fbd7oYGw==} + '@rolldown/binding-linux-x64-musl@1.0.3': + resolution: {integrity: sha512-pSdpdUJHkuCxun9LE7jvgUB9qsRgaiyNNCX7m/AvHTcq67AiT/Yhoxvw5zPfhrM8k/BfP8ce/hMOpthKDpEUow==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [linux] - '@rolldown/binding-openharmony-arm64@1.0.0-rc.17': - resolution: {integrity: sha512-0ag/hEgXOwgw4t8QyQvUCxvEg+V0KBcA6YuOx9g0r02MprutRF5dyljgm3EmR02O292UX7UeS6HzWHAl6KgyhA==} + '@rolldown/binding-openharmony-arm64@1.0.3': + resolution: {integrity: sha512-OXXS3RKJgX2uLwM+gYyuH5omcH8fL1LJs96pZGgtetVCahON57+d4SJHzTgZiOjxgGkSnpXpOsWuPDGAKAigEg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [openharmony] - '@rolldown/binding-wasm32-wasi@1.0.0-rc.17': - resolution: {integrity: sha512-LEXei6vo0E5wTGwpkJ4KoT3OZJRnglwldt5ziLzOlc6qqb55z4tWNq2A+PFqCJuvWWdP53CVhG1Z9NtToDPJrA==} + '@rolldown/binding-wasm32-wasi@1.0.3': + resolution: {integrity: sha512-JTtb8BWFynicNSoPrehsCzBtOKjZ6jhMiPFEmOiuXg1Fl8dn2KHQob+GuPSGR0dryQa1PQJbzjF3dqO/whhjLg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [wasm32] - '@rolldown/binding-win32-arm64-msvc@1.0.0-rc.17': - resolution: {integrity: sha512-gUmyzBl3SPMa6hrqFUth9sVfcLBlYsbMzBx5PlexMroZStgzGqlZ26pYG89rBb45Mnia+oil6YAIFeEWGWhoZA==} + '@rolldown/binding-win32-arm64-msvc@1.0.3': + resolution: {integrity: sha512-gEdFFEN70A/jxb2svrWsN3aDL7OUtmvlOy+6fa2jxG8K0wQ1ZbdeLGnidov6Yu5/733dI5ySfzFlQ/cb0bSz1g==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [win32] - '@rolldown/binding-win32-x64-msvc@1.0.0-rc.17': - resolution: {integrity: sha512-3hkiolcUAvPB9FLb3UZdfjVVNWherN1f/skkGWJP/fgSQhYUZpSIRr0/I8ZK9TkF3F7kxvJAk0+IcKvPHk9qQg==} + '@rolldown/binding-win32-x64-msvc@1.0.3': + resolution: {integrity: sha512-eXB7CHuaQdqmJcc3koCNtNPmT/bj2gc999kUFgBxG8Ac0NdgXc4rkCHhqrgrhN3zddvvvrgzj1e90SuSfmyIXA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [win32] - '@rolldown/pluginutils@1.0.0-rc.17': - resolution: {integrity: sha512-n8iosDOt6Ig1UhJ2AYqoIhHWh/isz0xpicHTzpKBeotdVsTEcxsSA/i3EVM7gQAj0rU27OLAxCjzlj15IWY7bg==} + '@rolldown/pluginutils@1.0.1': + resolution: {integrity: sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==} - '@rolldown/pluginutils@1.0.0-rc.7': - resolution: {integrity: sha512-qujRfC8sFVInYSPPMLQByRh7zhwkGFS4+tyMQ83srV1qrxL4g8E2tyxVVyxd0+8QeBM1mIk9KbWxkegRr76XzA==} + '@tauri-apps/api@2.11.1': + resolution: {integrity: sha512-M2FPuYND2m+wh5hfW9ZpSdxMPdEJovPBWwoHJmwUpysTYNHaOkVFN419m/K0LIgjb/7KU2vBgsUepJWugQCvAA==} - '@tauri-apps/api@2.11.0': - resolution: {integrity: sha512-7CinYODhky9lmO23xHnUFv0Xt43fbtWMyxZcLcRBlFkcgXKuEirBvHpmtJ89YMhyeGcq20Wuc47Fa4XjyniywA==} - - '@tauri-apps/cli-darwin-arm64@2.11.1': - resolution: {integrity: sha512-6eEKMBXsQPCuM1EmvrjT2+aBuxWQuFdKdW8pzNuNQtpq45nEEpBlD5gr8pUeAyOU1DQKlkFaEc/MPBxb/Pfjtg==} + '@tauri-apps/cli-darwin-arm64@2.11.2': + resolution: {integrity: sha512-+4UZzLt+eOAEQCwgd+TqKgyUJMrvx+BgdXLLaqJYmPqzP+nE6YZr/hY6CWLYGQb8jFn99jEkmC6uA3tNvamA1w==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] - '@tauri-apps/cli-darwin-x64@2.11.1': - resolution: {integrity: sha512-LQUO7exfRWjWALNhetph5guWpMeHphRpokOLk0OIbTTExaNwJNFu3I4vb+CCM/4G/QGoZe/5XikZOJdNEFP1ig==} + '@tauri-apps/cli-darwin-x64@2.11.2': + resolution: {integrity: sha512-VjYYtZUPqDMLutSfJEyxFE3Bz+DPi7c8wC3imckgvciLDZLq4qwKJxBicg0BXGhXjJsl8vKWgWRFNMPELQ+Xyg==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] - '@tauri-apps/cli-linux-arm-gnueabihf@2.11.1': - resolution: {integrity: sha512-5i/awiBCRRhOUG8yjn0fMHXIWD5Ez8eEk5LtvOxyQrKuJkRaZDvnbIjZbE183blAwkoA4xN3aO/prJiqscl02Q==} + '@tauri-apps/cli-linux-arm-gnueabihf@2.11.2': + resolution: {integrity: sha512-yMemD6f4i95AQriS8EazyOFzbE34yjnP16i3IOzpHGQvBoy2DjypFMFBq0NtPuITURv/cOGguRtHR5d79/9CSA==} engines: {node: '>= 10'} cpu: [arm] os: [linux] - '@tauri-apps/cli-linux-arm64-gnu@2.11.1': - resolution: {integrity: sha512-9LrwDw3S9Fygtw/Q6WDhOP+3svJRGAsejeE+GKrc0eO1ThMVhwi2LL6hw4dlKw93IfS7VY1G19sWGxJ/NcU4nA==} + '@tauri-apps/cli-linux-arm64-gnu@2.11.2': + resolution: {integrity: sha512-cgI91D2wL8GSgoWwZXDqt+DwnuZCP2/bz03QAE4TrhgAKIsrB4hX26W/H1EONPUUNkqrsgeCD0wU6pcNjV/5kw==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] - '@tauri-apps/cli-linux-arm64-musl@2.11.1': - resolution: {integrity: sha512-mNA5dbbqPqDUdTIwdUYYuhO2GvIe9UnB2r0VU2njxBOS3Opbx4gKNC5yP0Iu4rYmEmqdlwry9VzGZQ3wq9dyFg==} + '@tauri-apps/cli-linux-arm64-musl@2.11.2': + resolution: {integrity: sha512-X1rm0BERqAAggtYTESSgXrS3sz4Sb/OiPiz54UqISlXW+GkR3vNIGnsy/lejNmoXGVqri3Q53BCfQiclOIyRPw==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] - '@tauri-apps/cli-linux-riscv64-gnu@2.11.1': - resolution: {integrity: sha512-fZj3Gwq+6fUs305T5WQiD5iSGJw+j/4w/HGmk4sHDAcy+rp9zU5eaxB7nOyz5/I/nkNAuKPqfp6uIbiUBXkBCw==} + '@tauri-apps/cli-linux-riscv64-gnu@2.11.2': + resolution: {integrity: sha512-usbMLJbT3KtkOrBMDVeGYNM35aTHXx38SJSzTMSqqjeUIOQ+iVPjb2yAGNAE+KqmBbAx4FOFIyMeKXx2M/JKGQ==} engines: {node: '>= 10'} cpu: [riscv64] os: [linux] - '@tauri-apps/cli-linux-x64-gnu@2.11.1': - resolution: {integrity: sha512-XFxGxOvHM7jjeD6ozCKdGfhzJ7lERYDGZl1/Kb4fsvchaJsfLJ981TlyTG8Qy/gFq+f5GitH3bfrX9JAkjPEyw==} + '@tauri-apps/cli-linux-x64-gnu@2.11.2': + resolution: {integrity: sha512-Ru4gwJKPG0ctVGchRGpRup4Y4lW2SSfFnrbQcyHhCliKy4g8Qz97TrUgCur4CbWyAgKxvGh3SjrkA0LDYzDGiw==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - '@tauri-apps/cli-linux-x64-musl@2.11.1': - resolution: {integrity: sha512-d5C2/Zm+68v7R9wTuTCjRQEVrWjcdMkJBZ1+rXse+QdMMlTB9+u9PDNDLw9PQflWxYLaYZ7tjxxL9Nb9II6PbA==} + '@tauri-apps/cli-linux-x64-musl@2.11.2': + resolution: {integrity: sha512-eUm7T6clN1MMmNSRQ9gaWsQdyehQx2Gmn5hht/QUlqZQI/qcP2OJK5dnaxqwFzCr2HdsEo9ydxaqcS1oJzMvUw==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - '@tauri-apps/cli-win32-arm64-msvc@2.11.1': - resolution: {integrity: sha512-YdeVWFAR1pTXzUU6NLstPq4G6OLxuDrXCXEBdmBH+5EZIDXUx0D2kJlz3+YjpazkKvAzYpgziTsyRagls0OfRQ==} + '@tauri-apps/cli-win32-arm64-msvc@2.11.2': + resolution: {integrity: sha512-HeeZW80jU+gVTOEX4X/hC6NVSAdDVXajwP5fxIZ/3z9WvUC7qrudX2GMTilYq6Dg0e0sk0XgsAJD1hZ5wPBXUA==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] - '@tauri-apps/cli-win32-ia32-msvc@2.11.1': - resolution: {integrity: sha512-VBGkuH0eB9K9LLSMv361Gzr5Ou72sCS4+ztpmkWEQ+wd/amhcYOsf3X6qn1RJZDzIhiOYHJEOysZUC3baD01rA==} + '@tauri-apps/cli-win32-ia32-msvc@2.11.2': + resolution: {integrity: sha512-YhjQNZcXfbkCLyazSv1nPnJ9iRFE1wm6kc51FDbU10/Dk09io+6PAGMLjkxnX2GdM0qMnDmTjstY8mTDVvtKeA==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] - '@tauri-apps/cli-win32-x64-msvc@2.11.1': - resolution: {integrity: sha512-b3ORhIAKgp9ZYY+zBt7b7r0kLU2kjvyGF0+MS2SBym3emsweGPybEqocJcmtMuxyBhkOKHP4CiuEJEDuAlTx6A==} + '@tauri-apps/cli-win32-x64-msvc@2.11.2': + resolution: {integrity: sha512-d2JchlFIpZevZVReyqhQOekJmb1UH3rhZ5VX6sH3ty9ETE0TKQavpihvoScUXfKKpW6HZC0MrFGRU0ZtD+w3gA==} engines: {node: '>= 10'} cpu: [x64] os: [win32] - '@tauri-apps/cli@2.11.1': - resolution: {integrity: sha512-rpEbaJ/HzNb6fwsquwoAbq29/Vt4gADhS423A8fdkwL4edJ0wZmoB8ar7O6JPDL834MUKOCm/rrJ7c9oAaEaYQ==} + '@tauri-apps/cli@2.11.2': + resolution: {integrity: sha512-bk3HemqvGRoy+5D/dVMUQHKMYLglD0jVnMm/0iGMH6ufZ+p8r14m6BpIixwij3PBvZdvORUp1YifTD8QxVZ1Nw==} engines: {node: '>= 10'} hasBin: true '@tybys/wasm-util@0.10.2': resolution: {integrity: sha512-RoBvJ2X0wuKlWFIjrwffGw1IqZHKQqzIchKaadZZfnNpsAYp2mM0h36JtPCjNDAHGgYez/15uMBpfGwchhiMgg==} - '@types/estree@1.0.8': - resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==} + '@types/estree@1.0.9': + resolution: {integrity: sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==} '@types/json-schema@7.0.15': resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} - '@types/node@25.6.0': - resolution: {integrity: sha512-+qIYRKdNYJwY3vRCZMdJbPLJAtGjQBudzZzdzwQYkEPQd+PJGixUL5QfvCLDaULoLv+RhT3LDkwEfKaAkgSmNQ==} + '@types/node@25.9.4': + resolution: {integrity: sha512-dszCsrKb5U7ZsVZBWiHFklTloVl0mSEnWH/iZXfZUlI4rzCUnsvGmgqfuVRHL54ugE7/wRuxEIXRa2iMZ+BG6g==} '@types/parse-json@4.0.2': resolution: {integrity: sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==} @@ -739,70 +736,70 @@ packages: peerDependencies: '@types/react': '*' - '@types/react@19.2.14': - resolution: {integrity: sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==} + '@types/react@19.2.17': + resolution: {integrity: sha512-MXfmqaVPEVgkBT/aY0aGCkRWWtByiYQXo3xdQ8r5RzuFrPiRn8Gar2tQdXSUQ2GKV3bkXckek89V8wQBY2Q/Aw==} - '@typescript-eslint/eslint-plugin@8.59.2': - resolution: {integrity: sha512-j/bwmkBvHUtPNxzuWe5z6BEk3q54YRyGlBXkSsmfoih7zNrBvl5A9A98anlp/7JbyZcWIJ8KXo/3Tq/DjFLtuQ==} + '@typescript-eslint/eslint-plugin@8.61.1': + resolution: {integrity: sha512-ZPlVl3PB3et/59Ne0fv/sci6ZXz4T4Hp4nTJ56i/Y0gR89ARb+KphojTq6j+56E5PIezmOIOOWyY+aWQFd+IkQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - '@typescript-eslint/parser': ^8.59.2 + '@typescript-eslint/parser': ^8.61.1 eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 typescript: '>=4.8.4 <6.1.0' - '@typescript-eslint/parser@8.59.2': - resolution: {integrity: sha512-plR3pp6D+SSUn1HM7xvSkx12/DhoHInI2YF35KAcVFNZvlC0gtrWqx7Qq1oH2Ssgi0vlFRCTbP+DZc7B9+TtsQ==} + '@typescript-eslint/parser@8.61.1': + resolution: {integrity: sha512-PJ5vePq5/ognBbrIcoC5+SHO5dfpeLPzP9FpLkzWrguoYQEeeSjlJpVwOpo1JRSTEi7dRcwNy4h4dzV70PqHcg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 typescript: '>=4.8.4 <6.1.0' - '@typescript-eslint/project-service@8.59.2': - resolution: {integrity: sha512-+2hqvEkeyf/0FBor67duF0Ll7Ot8jyKzDQOSrxazF/danillRq2DwR9dLptsXpoZQqxE1UisSmoZewrlPas9Vw==} + '@typescript-eslint/project-service@8.61.1': + resolution: {integrity: sha512-PrC4JYGmR241lYnfhmKGTXkFqv8+ymbTFgSAY0fVXpY82/QkMw5TZPl+vGzuDDU2QYJk9fIDOBTntF+yDv9LEA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '>=4.8.4 <6.1.0' - '@typescript-eslint/scope-manager@8.59.2': - resolution: {integrity: sha512-JzfyEpEtOU89CcFSwyNS3mu4MLvLSXqnmX05+aKBDM+TdR5jzcGOEBwxwGNxrEQ7p/z6kK2WyioCGBf2zZBnvg==} + '@typescript-eslint/scope-manager@8.61.1': + resolution: {integrity: sha512-L2bdIeoQS8FlKAvONAr20w6OcLXeB+qiDKbAooS9A0Ben+iSIkBef0FxqwKWYqt5sa0i4KJtxVyVmhMylKzF5w==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/tsconfig-utils@8.59.2': - resolution: {integrity: sha512-BKK4alN7oi4C/zv4VqHQ+uRU+lTa6JGIZ7s1juw7b3RHo9OfKB+bKX3u0iVZetdsUCBBkSbdWbarJbmN0fTeSw==} + '@typescript-eslint/tsconfig-utils@8.61.1': + resolution: {integrity: sha512-UN/H4di+OO7EWx2ovME+8t31YO+KVnK0RRKEHR3kOt21/Ay8BOq3M1OMvWs5vNiqcFCYGYoxK3MXPZzmMUE+yg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '>=4.8.4 <6.1.0' - '@typescript-eslint/type-utils@8.59.2': - resolution: {integrity: sha512-nhqaj1nmTdVVl/BP5omXNRGO38jn5iosis2vbdmupF2txCf8ylWT8lx+JlvMYYVqzGVKtjojUFoQ3JRWK+mfzQ==} + '@typescript-eslint/type-utils@8.61.1': + resolution: {integrity: sha512-GYRicKmVK0C4fsKgaACaknOUAq9Oa2kwsjnpFhFcS/5p4Ht5IP9OVLbgIgcK4SRk92nVHFluurg1lumD9dBcLw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 typescript: '>=4.8.4 <6.1.0' - '@typescript-eslint/types@8.59.2': - resolution: {integrity: sha512-e82GVOE8Ps3E++Egvb6Y3Dw0S10u8NkQ9KXmtRhCWJJ8kDhOJTvtMAWnFL16kB1583goCWXsr0NieKCZMs2/0Q==} + '@typescript-eslint/types@8.61.1': + resolution: {integrity: sha512-G+CRlPqLv7Bz1IZVs03x5K59F1veqL0EJUROAdGhKsEq8qOiRiZbI+HUojPq5l0fEGOKModD9br6lObhB8zkoA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/typescript-estree@8.59.2': - resolution: {integrity: sha512-o0XPGNwcWw+FIwStOWn+BwBuEmL6QXP0rsvAFg7ET1dey1Nr6Wb1ac8p5HEsK0ygO/6mUxlk+YWQD9xcb/nnXg==} + '@typescript-eslint/typescript-estree@8.61.1': + resolution: {integrity: sha512-u+oQD3BqYWPc8YV9Zab4vaJElJuwOLPRc10Jm1o/qS+6Qwen14HCWwx0Seo4LnSn2wxea2Ik8DxPt2/FHmuhrg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '>=4.8.4 <6.1.0' - '@typescript-eslint/utils@8.59.2': - resolution: {integrity: sha512-Juw3EinkXqjaffxz6roowvV7GZT/kET5vSKKZT6upl5TXdWkLkYmNPXwDDL2Vkt2DPn0nODIS4egC/0AGxKo/Q==} + '@typescript-eslint/utils@8.61.1': + resolution: {integrity: sha512-1+P/3Dj6jvtybE1q0HQ6yBt/gq+oKJyLdEv4HdnqasaEXRSYCAsD59mXEVQnM/ULNdQxbX77tdG4jPRjIS6knA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 typescript: '>=4.8.4 <6.1.0' - '@typescript-eslint/visitor-keys@8.59.2': - resolution: {integrity: sha512-NwjLUnGy8/Zfx23fl50tRC8rYaYnM52xNRYFAXvmiil9yh1+K6aRVQMnzW6gQB/1DLgWt977lYQn7C+wtgXZiA==} + '@typescript-eslint/visitor-keys@8.61.1': + resolution: {integrity: sha512-6fJ9MHWtK14C1DSkiMlHUSOmrVebL7150xZJBlJiL62jjhIA4JmOq6flwBgDxIdBKKdoiZRel+dfPD5MLfny3w==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@vitejs/plugin-react@6.0.1': - resolution: {integrity: sha512-l9X/E3cDb+xY3SWzlG1MOGt2usfEHGMNIaegaUGFsLkb3RCn/k8/TOXBcab+OndDI4TBtktT8/9BwwW8Vi9KUQ==} + '@vitejs/plugin-react@6.0.2': + resolution: {integrity: sha512-DlSMqo4WhThw4vB8Mpn0Woe9J+Jfq1geJ61AKW0QEgLzGMNwtIMdxbDUzLxcun8W7NbJO0e2Jg/Nxm3cCSVzzg==} engines: {node: ^20.19.0 || >=22.12.0} peerDependencies: '@rolldown/plugin-babel': ^0.1.7 || ^0.2.0 @@ -819,8 +816,8 @@ packages: peerDependencies: acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 - acorn@8.16.0: - resolution: {integrity: sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==} + acorn@8.17.0: + resolution: {integrity: sha512-xRQbDb9BnwDafYNn6Vwl839DYVjqXYb1XVGtWAZ1kcDc6iwAL4hg3B1dZlRiuENFeO2H53gFG3in621AdERVAg==} engines: {node: '>=0.4.0'} hasBin: true @@ -881,16 +878,16 @@ packages: resolution: {integrity: sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==} engines: {node: 18 || 20 || >=22} - baseline-browser-mapping@2.10.27: - resolution: {integrity: sha512-zEs/ufmZoUd7WftKpKyXaT6RFxpQ5Qm9xytKRHvJfxFV9DFJkZph9RvJ1LcOUi0Z1ZVijMte65JbILeV+8QQEA==} + baseline-browser-mapping@2.10.38: + resolution: {integrity: sha512-31/02mVB4yuQU6adKk5SlY6m+mxDwUq5KZkyYgnLrrKl7TEm1+3PyDtDBz2kOv/wxZz41GHsvV1A/u6RmiyBvw==} engines: {node: '>=6.0.0'} hasBin: true - brace-expansion@1.1.14: - resolution: {integrity: sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==} + brace-expansion@1.1.15: + resolution: {integrity: sha512-EwOCDEex4quD37XhqM3omwtMoJjr//isUZz1JopUNWms+4Z2ViyM/k1YIRePpoVNnQhENnxtFjLaxNHrT7xIUg==} - brace-expansion@5.0.5: - resolution: {integrity: sha512-VZznLgtwhn+Mact9tfiwx64fA9erHH/MCXEUfB/0bX/6Fz6ny5EGTXYltMocqg4xFAQZtnO3DHWWXi8RiuN7cQ==} + brace-expansion@5.0.6: + resolution: {integrity: sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==} engines: {node: 18 || 20 || >=22} browserslist@4.28.2: @@ -914,8 +911,8 @@ packages: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} - caniuse-lite@1.0.30001792: - resolution: {integrity: sha512-hVLMUZFgR4JJ6ACt1uEESvQN1/dBVqPAKY0hgrV70eN3391K6juAfTjKZLKvOMsx8PxA7gsY1/tLMMTcfFLLpw==} + caniuse-lite@1.0.30001799: + resolution: {integrity: sha512-hG1bReV+OUU+MOqK4t/ZWI0tZOyz3rqS9XuhOUz1cIcbwBKjOyJEJuw9ER5JuNyqxNk8u/JUVbGibBOL1yrjFw==} chalk@4.1.2: resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} @@ -999,12 +996,16 @@ packages: resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==} engines: {node: '>= 0.4'} - electron-to-chromium@1.5.351: - resolution: {integrity: sha512-9D7Iqx8RImSvCnOsj86rCH6eQjZFQoM04Jn6HnZVM0Nu/G58/gmKYQ1d12MZTbjQbQSTGI8nwEy07ErsA2slLA==} + electron-to-chromium@1.5.376: + resolution: {integrity: sha512-cUVA7/RvbFTEuw/i3obUwDTRIXojaxkResf+ibByPFxjc6XK3VNtcQXV0NSbAlJ0FMjcJGgftVVB4Qo184EXvA==} error-ex@1.3.4: resolution: {integrity: sha512-sqQamAnR14VgCr1A618A3sGrygcpK+HEbenA/HiEAkkUwcZIIB/tgWqHFxWgOyDh4nB4JCRimh79dR5Ywc9MDQ==} + es-abstract-get@1.0.0: + resolution: {integrity: sha512-6PMWXpdhshVvFp+FoWYs1EvG1Nj0tvk0dZM+XcK0xMEM1czRVcP6ohqPWHy6qPagSpC8j4+p89WXlT+xXJs/fg==} + engines: {node: '>= 0.4'} + es-abstract@1.24.2: resolution: {integrity: sha512-2FpH9Q5i2RRwyEP1AylXe6nYLR5OhaJTZwmlcP0dL/+JCbgg7yyEo/sEK6HeGZRf3dFpWwThaRHVApXSkW3xeg==} engines: {node: '>= 0.4'} @@ -1017,12 +1018,12 @@ packages: resolution: {integrity: sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==} engines: {node: '>= 0.4'} - es-iterator-helpers@1.3.2: - resolution: {integrity: sha512-HVLACW1TppGYjJ8H6/jqH/pqOtKRw6wMlrB23xfExmFWxFquAIWCmwoLsOyN96K4a5KbmOf5At9ZUO3GZbetAw==} + es-iterator-helpers@1.3.3: + resolution: {integrity: sha512-0PuBxFi+4uPanB97iDxCLWuHeYud2FALrw5HFZGtAF38UpJDbDC8frwp2cnDyae692CQ0dou60UwWfhgsa4U/g==} engines: {node: '>= 0.4'} - es-object-atoms@1.1.1: - resolution: {integrity: sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==} + es-object-atoms@1.1.2: + resolution: {integrity: sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==} engines: {node: '>= 0.4'} es-set-tostringtag@2.1.0: @@ -1033,8 +1034,8 @@ packages: resolution: {integrity: sha512-d9T8ucsEhh8Bi1woXCf+TIKDIROLG5WCkxg8geBCbvk22kzwC5G2OnXVMO6FUsvQlgUUXQ2itephWDLqDzbeCw==} engines: {node: '>= 0.4'} - es-to-primitive@1.3.0: - resolution: {integrity: sha512-w+5mJ3GuFL+NjVtJlvydShqE1eN3h3PbI7/5LAsYJP/2qtuMXjfL2LpHSRqo4b4eSF5K/DH1JXKUAHSB2UW50g==} + es-to-primitive@1.3.1: + resolution: {integrity: sha512-CxN9N56HYfd2m/acc/NOFrZQsN9kU4eh+2kk6A707Kz1krH8tKmfrs5RnftB8WNX80T0NS7vSQsDOlg23diR2g==} engines: {node: '>= 0.4'} esbuild@0.27.2: @@ -1162,8 +1163,8 @@ packages: function-bind@1.1.2: resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} - function.prototype.name@1.1.8: - resolution: {integrity: sha512-e5iwyodOHhbMr/yNrc7fDYG4qlbIvI5gajyzPnb5TCwyhjApznQh1BMFou9b30SevY43gCJKXycoCBjMbsuW0Q==} + function.prototype.name@1.2.0: + resolution: {integrity: sha512-jObKIik1P2QjPHP5nz5BaOtUlfgS0fWo8IUByNXkM+o+02sJOi94em77GwJKQSJ3gfPHdgzLNrHc1uokV4P/ew==} engines: {node: '>= 0.4'} functions-have-names@1.2.3: @@ -1228,8 +1229,8 @@ packages: resolution: {integrity: sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==} engines: {node: '>= 0.4'} - hasown@2.0.3: - resolution: {integrity: sha512-ej4AhfhfL2Q2zpMmLo7U1Uv9+PyhIZpgQLGT1F9miIGmiCJIoCgSmczFdrc97mWT4kVY72KA+WnnhJ5pghSvSg==} + hasown@2.0.4: + resolution: {integrity: sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==} engines: {node: '>= 0.4'} hermes-estree@0.25.1: @@ -1296,6 +1297,10 @@ packages: resolution: {integrity: sha512-PwwhEakHVKTdRNVOw+/Gyh0+MzlCl4R6qKvkhuvLtPMggI1WAHt9sOwZxQLSGpUaDnrdyDsomoRgNnCfKNSXXg==} engines: {node: '>= 0.4'} + is-document.all@1.0.0: + resolution: {integrity: sha512-+XSoyS05OdBbhFuELhgTCpFNHkpBOJqtsZfUFFpe5QTw+9Sjbh8zitxhQkYAo6wV7e1Vb8cAPvpCk9jGam/82g==} + engines: {node: '>= 0.4'} + is-extglob@2.1.1: resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} engines: {node: '>=0.10.0'} @@ -1373,8 +1378,8 @@ packages: js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} - js-yaml@4.1.1: - resolution: {integrity: sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==} + js-yaml@4.2.0: + resolution: {integrity: sha512-ePWsvanv0DWuDRsW8dnt+R4jQ31SCRCQ7hhNcPXZPsoBZiemuZNYGf7adZdqX2D86j6rvKp3RpCxVTSb8WQlOw==} hasBin: true jsesc@3.1.0: @@ -1511,8 +1516,8 @@ packages: ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} - nanoid@3.3.12: - resolution: {integrity: sha512-ZB9RH/39qpq5Vu6Y+NmUaFhQR6pp+M2Xt76XBnEwDaGcVAqhlvxrl3B2bKS5D3NH3QR76v3aSrKaF/Kiy7lEtQ==} + nanoid@3.3.13: + resolution: {integrity: sha512-sPdqC6ByMVVGvF1ynvvMo0/o+oD1VX7DaHhijt1bFgjvBkHBib4t49GoNDhf2NDta4oeUNlaGbSt5K7qjZ955Q==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true @@ -1523,8 +1528,9 @@ packages: resolution: {integrity: sha512-pyFS63ptit/P5WqUkt+UUfe+4oevH+bFeIiPPdfb0pFeYEu/1ELnJu5l+5EcTKYL5M7zaAa7S8ddywgXypqKCw==} engines: {node: '>= 0.4'} - node-releases@2.0.38: - resolution: {integrity: sha512-3qT/88Y3FbH/Kx4szpQQ4HzUbVrHPKTLVpVocKiLfoYvw9XSGOX2FmD2d6DrXbVYyAQTF2HeF6My8jmzx7/CRw==} + node-releases@2.0.48: + resolution: {integrity: sha512-1uz8041X6LoI6ZSdZacM9lVY28vuzDlSKitnpbSNK0RfKoIJkX29NBPVEFXhnuSuEOA9Ww0xnPJ+ILWbGAv8DA==} + engines: {node: '>=18'} object-assign@4.1.1: resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} @@ -1604,8 +1610,8 @@ packages: resolution: {integrity: sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==} engines: {node: '>= 0.4'} - postcss@8.5.14: - resolution: {integrity: sha512-SoSL4+OSEtR99LHFZQiJLkT59C5B1amGO1NzTwj7TT1qCUgUO6hxOvzkOYxD+vMrXBM3XJIKzokoERdqQq/Zmg==} + postcss@8.5.15: + resolution: {integrity: sha512-FfR8sjd4em2T6fb3I2MwAJU7HWVMr9zba+enmQeeWFfCbm+UOC/0X4DS8XtpUTMwWMGbjKYP7xjfNekzyGmB3A==} engines: {node: ^10 || ^12 || >=14} prelude-ls@1.2.1: @@ -1624,16 +1630,16 @@ packages: resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} engines: {node: '>=6'} - react-dom@19.2.5: - resolution: {integrity: sha512-J5bAZz+DXMMwW/wV3xzKke59Af6CHY7G4uYLN1OvBcKEsWOs4pQExj86BBKamxl/Ik5bx9whOrvBlSDfWzgSag==} + react-dom@19.2.7: + resolution: {integrity: sha512-t0BRVXvbiE/o20Hfw669rLbMCDWtYZLvmJigy2f0MxsXF+71pxhR3xOkspmsO8h3ZlNzyibAmtCa3l4lYKk6gQ==} peerDependencies: - react: ^19.2.5 + react: ^19.2.7 react-is@16.13.1: resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==} - react-is@19.2.5: - resolution: {integrity: sha512-Dn0t8IQhCmeIT3wu+Apm1/YVsJXsGWi6k4sPdnBIdqMVtHtv0IGi6dcpNpNkNac0zB2uUAqNX3MHzN8c+z2rwQ==} + react-is@19.2.7: + resolution: {integrity: sha512-kZFnouyVv7eP/Phmrlo9FK+zcAdriZJvzxXHF1Sl1P377WSGe2G/JxVolhTrB/jeV47lKImhNUsijjHAAbcl/A==} react-transition-group@4.4.5: resolution: {integrity: sha512-pZcd1MCJoiKiBR2NRxeCRg13uCXbydPnmB4EOeRrY7480qNWO8IIgQG6zlDkm6uRMsURXPuKq0GWtiM59a5Q6g==} @@ -1641,8 +1647,8 @@ packages: react: '>=16.6.0' react-dom: '>=16.6.0' - react@19.2.5: - resolution: {integrity: sha512-llUJLzz1zTUBrskt2pwZgLq59AemifIftw4aB7JxOqf1HY2FDaGDxgwpAPVzHU1kdWabH7FauP4i1oEeer2WCA==} + react@19.2.7: + resolution: {integrity: sha512-HNe9WslTbXmFK8o8cmwgAeJFSBvt1bPdHCVKtaaV+WlAN36mpT4hcRpwbf3fY56ar2oIXzsBpOAiIRHAdY0OlQ==} engines: {node: '>=0.10.0'} reflect.getprototypeof@1.0.10: @@ -1662,13 +1668,13 @@ packages: engines: {node: '>= 0.4'} hasBin: true - resolve@2.0.0-next.6: - resolution: {integrity: sha512-3JmVl5hMGtJ3kMmB3zi3DL25KfkCEyy3Tw7Gmw7z5w8M9WlwoPFnIvwChzu1+cF3iaK3sp18hhPz8ANeimdJfA==} + resolve@2.0.0-next.7: + resolution: {integrity: sha512-tqt+NBWwyaMgw3zDsnygx4CByWjQEJHOPMdslYhppaQSJUtL/D4JO9CcBBlhPoI8lz9oJIDXkwXfhF4aWqP8xQ==} engines: {node: '>= 0.4'} hasBin: true - rolldown@1.0.0-rc.17: - resolution: {integrity: sha512-ZrT53oAKrtA4+YtBWPQbtPOxIbVDbxT0orcYERKd63VJTF13zPcgXTvD4843L8pcsI7M6MErt8QtON6lrB9tyA==} + rolldown@1.0.3: + resolution: {integrity: sha512-i00lAJ2ks1BYr7rjNjKC7BcqAS7nVfiT3QX1SI5aY+AFHblCmaUf9OE9dbdzDvW6dJxbi2ZCZiy9v3CcwOiX3g==} engines: {node: ^20.19.0 || >=22.12.0} hasBin: true @@ -1691,8 +1697,8 @@ packages: resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} hasBin: true - semver@7.7.4: - resolution: {integrity: sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==} + semver@7.8.4: + resolution: {integrity: sha512-rUCObTnP32Q08R2uuIrt7r9PlEonuTmtuXYcW6s5kjdlj3xbnwe+21yXptAUYcMAABLkYYTtnmzb3w3EDZfueA==} engines: {node: '>=10'} hasBin: true @@ -1728,8 +1734,8 @@ packages: resolution: {integrity: sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==} engines: {node: '>= 0.4'} - side-channel@1.1.0: - resolution: {integrity: sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==} + side-channel@1.1.1: + resolution: {integrity: sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==} engines: {node: '>= 0.4'} source-map-js@1.2.1: @@ -1751,12 +1757,12 @@ packages: string.prototype.repeat@1.0.0: resolution: {integrity: sha512-0u/TldDbKD8bFCQ/4f5+mNRrXwZ8hg2w7ZR8wa16e8z9XpePWl3eGEcUD0OXpEH/VJH/2G3gjUtR3ZOiBe2S/w==} - string.prototype.trim@1.2.10: - resolution: {integrity: sha512-Rs66F0P/1kedk5lyYyH9uBzuiI/kNRmwJAR9quK6VOtIpZ2G+hMZd+HQbbv25MgCA6gEffoMZYxlTod4WcdrKA==} + string.prototype.trim@1.2.11: + resolution: {integrity: sha512-PwvK7BU+CMTJGYQCTZb5RWXIML92lftJLhQz1tBzgKiqGxJaMlBAa48POXaNAC2s4y8jr3EFqrkF9+44neS46w==} engines: {node: '>= 0.4'} - string.prototype.trimend@1.0.9: - resolution: {integrity: sha512-G7Ok5C6E/j4SGfyLCloXTrngQIQU3PWtXGst3yM7Bea9FRURf1S42ZHlZZtsNque2FN2PoUhfZXYLNWwEr4dLQ==} + string.prototype.trimend@1.0.10: + resolution: {integrity: sha512-2+3aDAOmPTmuFwjDnmJG2ctEkQKVki7vOSqaxkv42Mowj1V6PnvuwFCRrR5lChUux1TBskPjfkeTOhqczDMxTw==} engines: {node: '>= 0.4'} string.prototype.trimstart@1.0.8: @@ -1778,8 +1784,8 @@ packages: resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} engines: {node: '>= 0.4'} - tinyglobby@0.2.16: - resolution: {integrity: sha512-pn99VhoACYR8nFHhxqix+uvsbXineAasWm5ojXoN8xEwK5Kd3/TrhNn1wByuD52UxWRLy8pu+kRMniEi6Eq9Zg==} + tinyglobby@0.2.17: + resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==} engines: {node: '>=12.0.0'} ts-api-utils@2.5.0: @@ -1807,8 +1813,8 @@ packages: resolution: {integrity: sha512-bTlAFB/FBYMcuX81gbL4OcpH5PmlFHqlCCpAl8AlEzMz5k53oNDvN8p1PNOWLEmI2x4orp3raOFB51tv9X+MFQ==} engines: {node: '>= 0.4'} - typed-array-length@1.0.7: - resolution: {integrity: sha512-3KS2b+kL7fsuk/eJZ7EQdnEmQoaho/r6KUef7hxvltNA5DR8NAUM+8wJMbJyZ4G9/7i3v5zPBIMN5aybAh2/Jg==} + typed-array-length@1.0.8: + resolution: {integrity: sha512-phPGCwqr2+Qo0fwniCE8e4pKnGu/yFb5nD5Y8bf0EEeiI5GklnACYA9GFy/DrAeRrKHXvHn+1SUsOWgJp6RO+g==} engines: {node: '>= 0.4'} typescript@6.0.3: @@ -1820,8 +1826,8 @@ packages: resolution: {integrity: sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw==} engines: {node: '>= 0.4'} - undici-types@7.19.2: - resolution: {integrity: sha512-qYVnV5OEm2AW8cJMCpdV20CDyaN3g0AjDlOGf1OW4iaDEx8MwdtChUp4zu4H0VP3nDRF/8RKWH+IPp9uW0YGZg==} + undici-types@7.24.6: + resolution: {integrity: sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==} update-browserslist-db@1.2.3: resolution: {integrity: sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==} @@ -1832,13 +1838,13 @@ packages: uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} - vite@8.0.10: - resolution: {integrity: sha512-rZuUu9j6J5uotLDs+cAA4O5H4K1SfPliUlQwqa6YEwSrWDZzP4rhm00oJR5snMewjxF5V/K3D4kctsUTsIU9Mw==} + vite@8.0.16: + resolution: {integrity: sha512-h9bXPmJichP5fLmVQo3PyaGSDE2n3aPuomeAlVRm0JLmt4rY6zmPKd59HYI4LNW8oTK7tlTsuC7l/m7awx9Jcw==} engines: {node: ^20.19.0 || >=22.12.0} hasBin: true peerDependencies: '@types/node': ^20.19.0 || >=22.12.0 - '@vitejs/devtools': ^0.1.0 + '@vitejs/devtools': ^0.1.18 esbuild: ^0.27.0 || ^0.28.0 jiti: '>=1.21.0' less: ^4.0.0 @@ -1887,8 +1893,8 @@ packages: resolution: {integrity: sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==} engines: {node: '>= 0.4'} - which-typed-array@1.1.20: - resolution: {integrity: sha512-LYfpUkmqwl0h9A2HL09Mms427Q1RZWuOHsukfVcKRq9q95iQxdw0ix1JQrqbcDR9PH1QDwf5Qo8OZb5lksZ8Xg==} + which-typed-array@1.1.22: + resolution: {integrity: sha512-fvO4ExWMFsqyhG3AiPAObMuY1lxaqgYcxbc49CNdWDDECOJNgQyvsOWVwbZc+qf3rzRtxojBK+CMEv0Ld5CYpw==} engines: {node: '>= 0.4'} which@2.0.2: @@ -1922,25 +1928,25 @@ packages: snapshots: - '@babel/code-frame@7.29.0': + '@babel/code-frame@7.29.7': dependencies: - '@babel/helper-validator-identifier': 7.28.5 + '@babel/helper-validator-identifier': 7.29.7 js-tokens: 4.0.0 picocolors: 1.1.1 - '@babel/compat-data@7.29.3': {} + '@babel/compat-data@7.29.7': {} - '@babel/core@7.29.0': + '@babel/core@7.29.7': dependencies: - '@babel/code-frame': 7.29.0 - '@babel/generator': 7.29.1 - '@babel/helper-compilation-targets': 7.28.6 - '@babel/helper-module-transforms': 7.28.6(@babel/core@7.29.0) - '@babel/helpers': 7.29.2 - '@babel/parser': 7.29.3 - '@babel/template': 7.28.6 - '@babel/traverse': 7.29.0 - '@babel/types': 7.29.0 + '@babel/code-frame': 7.29.7 + '@babel/generator': 7.29.7 + '@babel/helper-compilation-targets': 7.29.7 + '@babel/helper-module-transforms': 7.29.7(@babel/core@7.29.7) + '@babel/helpers': 7.29.7 + '@babel/parser': 7.29.7 + '@babel/template': 7.29.7 + '@babel/traverse': 7.29.7 + '@babel/types': 7.29.7 '@jridgewell/remapping': 2.3.5 convert-source-map: 2.0.0 debug: 4.4.3 @@ -1950,79 +1956,79 @@ snapshots: transitivePeerDependencies: - supports-color - '@babel/generator@7.29.1': + '@babel/generator@7.29.7': dependencies: - '@babel/parser': 7.29.3 - '@babel/types': 7.29.0 + '@babel/parser': 7.29.7 + '@babel/types': 7.29.7 '@jridgewell/gen-mapping': 0.3.13 '@jridgewell/trace-mapping': 0.3.31 jsesc: 3.1.0 - '@babel/helper-compilation-targets@7.28.6': + '@babel/helper-compilation-targets@7.29.7': dependencies: - '@babel/compat-data': 7.29.3 - '@babel/helper-validator-option': 7.27.1 + '@babel/compat-data': 7.29.7 + '@babel/helper-validator-option': 7.29.7 browserslist: 4.28.2 lru-cache: 5.1.1 semver: 6.3.1 - '@babel/helper-globals@7.28.0': {} + '@babel/helper-globals@7.29.7': {} - '@babel/helper-module-imports@7.28.6': + '@babel/helper-module-imports@7.29.7': dependencies: - '@babel/traverse': 7.29.0 - '@babel/types': 7.29.0 + '@babel/traverse': 7.29.7 + '@babel/types': 7.29.7 transitivePeerDependencies: - supports-color - '@babel/helper-module-transforms@7.28.6(@babel/core@7.29.0)': + '@babel/helper-module-transforms@7.29.7(@babel/core@7.29.7)': dependencies: - '@babel/core': 7.29.0 - '@babel/helper-module-imports': 7.28.6 - '@babel/helper-validator-identifier': 7.28.5 - '@babel/traverse': 7.29.0 + '@babel/core': 7.29.7 + '@babel/helper-module-imports': 7.29.7 + '@babel/helper-validator-identifier': 7.29.7 + '@babel/traverse': 7.29.7 transitivePeerDependencies: - supports-color - '@babel/helper-string-parser@7.27.1': {} + '@babel/helper-string-parser@7.29.7': {} - '@babel/helper-validator-identifier@7.28.5': {} + '@babel/helper-validator-identifier@7.29.7': {} - '@babel/helper-validator-option@7.27.1': {} + '@babel/helper-validator-option@7.29.7': {} - '@babel/helpers@7.29.2': + '@babel/helpers@7.29.7': dependencies: - '@babel/template': 7.28.6 - '@babel/types': 7.29.0 + '@babel/template': 7.29.7 + '@babel/types': 7.29.7 - '@babel/parser@7.29.3': + '@babel/parser@7.29.7': dependencies: - '@babel/types': 7.29.0 + '@babel/types': 7.29.7 - '@babel/runtime@7.29.2': {} + '@babel/runtime@7.29.7': {} - '@babel/template@7.28.6': + '@babel/template@7.29.7': dependencies: - '@babel/code-frame': 7.29.0 - '@babel/parser': 7.29.3 - '@babel/types': 7.29.0 + '@babel/code-frame': 7.29.7 + '@babel/parser': 7.29.7 + '@babel/types': 7.29.7 - '@babel/traverse@7.29.0': + '@babel/traverse@7.29.7': dependencies: - '@babel/code-frame': 7.29.0 - '@babel/generator': 7.29.1 - '@babel/helper-globals': 7.28.0 - '@babel/parser': 7.29.3 - '@babel/template': 7.28.6 - '@babel/types': 7.29.0 + '@babel/code-frame': 7.29.7 + '@babel/generator': 7.29.7 + '@babel/helper-globals': 7.29.7 + '@babel/parser': 7.29.7 + '@babel/template': 7.29.7 + '@babel/types': 7.29.7 debug: 4.4.3 transitivePeerDependencies: - supports-color - '@babel/types@7.29.0': + '@babel/types@7.29.7': dependencies: - '@babel/helper-string-parser': 7.27.1 - '@babel/helper-validator-identifier': 7.28.5 + '@babel/helper-string-parser': 7.29.7 + '@babel/helper-validator-identifier': 7.29.7 '@emnapi/core@1.10.0': dependencies: @@ -2042,8 +2048,8 @@ snapshots: '@emotion/babel-plugin@11.13.5': dependencies: - '@babel/helper-module-imports': 7.28.6 - '@babel/runtime': 7.29.2 + '@babel/helper-module-imports': 7.29.7 + '@babel/runtime': 7.29.7 '@emotion/hash': 0.9.2 '@emotion/memoize': 0.9.0 '@emotion/serialize': 1.3.3 @@ -2072,19 +2078,19 @@ snapshots: '@emotion/memoize@0.9.0': {} - '@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5)': + '@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7)': dependencies: - '@babel/runtime': 7.29.2 + '@babel/runtime': 7.29.7 '@emotion/babel-plugin': 11.13.5 '@emotion/cache': 11.14.0 '@emotion/serialize': 1.3.3 - '@emotion/use-insertion-effect-with-fallbacks': 1.2.0(react@19.2.5) + '@emotion/use-insertion-effect-with-fallbacks': 1.2.0(react@19.2.7) '@emotion/utils': 1.4.2 '@emotion/weak-memoize': 0.4.0 hoist-non-react-statics: 3.3.2 - react: 19.2.5 + react: 19.2.7 optionalDependencies: - '@types/react': 19.2.14 + '@types/react': 19.2.17 transitivePeerDependencies: - supports-color @@ -2098,26 +2104,26 @@ snapshots: '@emotion/sheet@1.4.0': {} - '@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@types/react@19.2.14)(react@19.2.5)': + '@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@types/react@19.2.17)(react@19.2.7)': dependencies: - '@babel/runtime': 7.29.2 + '@babel/runtime': 7.29.7 '@emotion/babel-plugin': 11.13.5 '@emotion/is-prop-valid': 1.4.0 - '@emotion/react': 11.14.0(@types/react@19.2.14)(react@19.2.5) + '@emotion/react': 11.14.0(@types/react@19.2.17)(react@19.2.7) '@emotion/serialize': 1.3.3 - '@emotion/use-insertion-effect-with-fallbacks': 1.2.0(react@19.2.5) + '@emotion/use-insertion-effect-with-fallbacks': 1.2.0(react@19.2.7) '@emotion/utils': 1.4.2 - react: 19.2.5 + react: 19.2.7 optionalDependencies: - '@types/react': 19.2.14 + '@types/react': 19.2.17 transitivePeerDependencies: - supports-color '@emotion/unitless@0.10.0': {} - '@emotion/use-insertion-effect-with-fallbacks@1.2.0(react@19.2.5)': + '@emotion/use-insertion-effect-with-fallbacks@1.2.0(react@19.2.7)': dependencies: - react: 19.2.5 + react: 19.2.7 '@emotion/utils@1.4.2': {} @@ -2232,7 +2238,7 @@ snapshots: globals: 14.0.0 ignore: 5.3.2 import-fresh: 3.3.1 - js-yaml: 4.1.1 + js-yaml: 4.2.0 minimatch: 3.1.5 strip-json-comments: 3.1.1 transitivePeerDependencies: @@ -2282,243 +2288,241 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.5 - '@mui/core-downloads-tracker@7.3.10': {} + '@mui/core-downloads-tracker@7.3.11': {} - '@mui/icons-material@7.3.10(@mui/material@7.3.10(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@types/react@19.2.14)(react@19.2.5))(@types/react@19.2.14)(react-dom@19.2.5(react@19.2.5))(react@19.2.5))(@types/react@19.2.14)(react@19.2.5)': + '@mui/icons-material@7.3.11(@mui/material@7.3.11(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@types/react@19.2.17)(react@19.2.7))(@types/react@19.2.17)(react-dom@19.2.7(react@19.2.7))(react@19.2.7))(@types/react@19.2.17)(react@19.2.7)': dependencies: - '@babel/runtime': 7.29.2 - '@mui/material': 7.3.10(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@types/react@19.2.14)(react@19.2.5))(@types/react@19.2.14)(react-dom@19.2.5(react@19.2.5))(react@19.2.5) - react: 19.2.5 + '@babel/runtime': 7.29.7 + '@mui/material': 7.3.11(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@types/react@19.2.17)(react@19.2.7))(@types/react@19.2.17)(react-dom@19.2.7(react@19.2.7))(react@19.2.7) + react: 19.2.7 optionalDependencies: - '@types/react': 19.2.14 + '@types/react': 19.2.17 - '@mui/material@7.3.10(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@types/react@19.2.14)(react@19.2.5))(@types/react@19.2.14)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)': + '@mui/material@7.3.11(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@types/react@19.2.17)(react@19.2.7))(@types/react@19.2.17)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)': dependencies: - '@babel/runtime': 7.29.2 - '@mui/core-downloads-tracker': 7.3.10 - '@mui/system': 7.3.10(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@types/react@19.2.14)(react@19.2.5))(@types/react@19.2.14)(react@19.2.5) - '@mui/types': 7.4.12(@types/react@19.2.14) - '@mui/utils': 7.3.10(@types/react@19.2.14)(react@19.2.5) + '@babel/runtime': 7.29.7 + '@mui/core-downloads-tracker': 7.3.11 + '@mui/system': 7.3.11(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@types/react@19.2.17)(react@19.2.7))(@types/react@19.2.17)(react@19.2.7) + '@mui/types': 7.4.12(@types/react@19.2.17) + '@mui/utils': 7.3.11(@types/react@19.2.17)(react@19.2.7) '@popperjs/core': 2.11.8 - '@types/react-transition-group': 4.4.12(@types/react@19.2.14) + '@types/react-transition-group': 4.4.12(@types/react@19.2.17) clsx: 2.1.1 csstype: 3.2.3 prop-types: 15.8.1 - react: 19.2.5 - react-dom: 19.2.5(react@19.2.5) - react-is: 19.2.5 - react-transition-group: 4.4.5(react-dom@19.2.5(react@19.2.5))(react@19.2.5) + react: 19.2.7 + react-dom: 19.2.7(react@19.2.7) + react-is: 19.2.7 + react-transition-group: 4.4.5(react-dom@19.2.7(react@19.2.7))(react@19.2.7) optionalDependencies: - '@emotion/react': 11.14.0(@types/react@19.2.14)(react@19.2.5) - '@emotion/styled': 11.14.1(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@types/react@19.2.14)(react@19.2.5) - '@types/react': 19.2.14 + '@emotion/react': 11.14.0(@types/react@19.2.17)(react@19.2.7) + '@emotion/styled': 11.14.1(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@types/react@19.2.17)(react@19.2.7) + '@types/react': 19.2.17 - '@mui/private-theming@7.3.10(@types/react@19.2.14)(react@19.2.5)': + '@mui/private-theming@7.3.11(@types/react@19.2.17)(react@19.2.7)': dependencies: - '@babel/runtime': 7.29.2 - '@mui/utils': 7.3.10(@types/react@19.2.14)(react@19.2.5) + '@babel/runtime': 7.29.7 + '@mui/utils': 7.3.11(@types/react@19.2.17)(react@19.2.7) prop-types: 15.8.1 - react: 19.2.5 + react: 19.2.7 optionalDependencies: - '@types/react': 19.2.14 + '@types/react': 19.2.17 - '@mui/styled-engine@7.3.10(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@types/react@19.2.14)(react@19.2.5))(react@19.2.5)': + '@mui/styled-engine@7.3.10(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@types/react@19.2.17)(react@19.2.7))(react@19.2.7)': dependencies: - '@babel/runtime': 7.29.2 + '@babel/runtime': 7.29.7 '@emotion/cache': 11.14.0 '@emotion/serialize': 1.3.3 '@emotion/sheet': 1.4.0 csstype: 3.2.3 prop-types: 15.8.1 - react: 19.2.5 + react: 19.2.7 optionalDependencies: - '@emotion/react': 11.14.0(@types/react@19.2.14)(react@19.2.5) - '@emotion/styled': 11.14.1(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@types/react@19.2.14)(react@19.2.5) + '@emotion/react': 11.14.0(@types/react@19.2.17)(react@19.2.7) + '@emotion/styled': 11.14.1(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@types/react@19.2.17)(react@19.2.7) - '@mui/system@7.3.10(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@types/react@19.2.14)(react@19.2.5))(@types/react@19.2.14)(react@19.2.5)': + '@mui/system@7.3.11(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@types/react@19.2.17)(react@19.2.7))(@types/react@19.2.17)(react@19.2.7)': dependencies: - '@babel/runtime': 7.29.2 - '@mui/private-theming': 7.3.10(@types/react@19.2.14)(react@19.2.5) - '@mui/styled-engine': 7.3.10(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@types/react@19.2.14)(react@19.2.5))(react@19.2.5) - '@mui/types': 7.4.12(@types/react@19.2.14) - '@mui/utils': 7.3.10(@types/react@19.2.14)(react@19.2.5) + '@babel/runtime': 7.29.7 + '@mui/private-theming': 7.3.11(@types/react@19.2.17)(react@19.2.7) + '@mui/styled-engine': 7.3.10(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@emotion/styled@11.14.1(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@types/react@19.2.17)(react@19.2.7))(react@19.2.7) + '@mui/types': 7.4.12(@types/react@19.2.17) + '@mui/utils': 7.3.11(@types/react@19.2.17)(react@19.2.7) clsx: 2.1.1 csstype: 3.2.3 prop-types: 15.8.1 - react: 19.2.5 + react: 19.2.7 optionalDependencies: - '@emotion/react': 11.14.0(@types/react@19.2.14)(react@19.2.5) - '@emotion/styled': 11.14.1(@emotion/react@11.14.0(@types/react@19.2.14)(react@19.2.5))(@types/react@19.2.14)(react@19.2.5) - '@types/react': 19.2.14 + '@emotion/react': 11.14.0(@types/react@19.2.17)(react@19.2.7) + '@emotion/styled': 11.14.1(@emotion/react@11.14.0(@types/react@19.2.17)(react@19.2.7))(@types/react@19.2.17)(react@19.2.7) + '@types/react': 19.2.17 - '@mui/types@7.4.12(@types/react@19.2.14)': + '@mui/types@7.4.12(@types/react@19.2.17)': dependencies: - '@babel/runtime': 7.29.2 + '@babel/runtime': 7.29.7 optionalDependencies: - '@types/react': 19.2.14 + '@types/react': 19.2.17 - '@mui/utils@7.3.10(@types/react@19.2.14)(react@19.2.5)': + '@mui/utils@7.3.11(@types/react@19.2.17)(react@19.2.7)': dependencies: - '@babel/runtime': 7.29.2 - '@mui/types': 7.4.12(@types/react@19.2.14) + '@babel/runtime': 7.29.7 + '@mui/types': 7.4.12(@types/react@19.2.17) '@types/prop-types': 15.7.15 clsx: 2.1.1 prop-types: 15.8.1 - react: 19.2.5 - react-is: 19.2.5 + react: 19.2.7 + react-is: 19.2.7 optionalDependencies: - '@types/react': 19.2.14 + '@types/react': 19.2.17 - '@napi-rs/wasm-runtime@1.1.4(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)': + '@napi-rs/wasm-runtime@1.1.5(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)': dependencies: '@emnapi/core': 1.10.0 '@emnapi/runtime': 1.10.0 '@tybys/wasm-util': 0.10.2 optional: true - '@oxc-project/types@0.127.0': {} + '@oxc-project/types@0.133.0': {} '@popperjs/core@2.11.8': {} - '@rolldown/binding-android-arm64@1.0.0-rc.17': + '@rolldown/binding-android-arm64@1.0.3': optional: true - '@rolldown/binding-darwin-arm64@1.0.0-rc.17': + '@rolldown/binding-darwin-arm64@1.0.3': optional: true - '@rolldown/binding-darwin-x64@1.0.0-rc.17': + '@rolldown/binding-darwin-x64@1.0.3': optional: true - '@rolldown/binding-freebsd-x64@1.0.0-rc.17': + '@rolldown/binding-freebsd-x64@1.0.3': optional: true - '@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.17': + '@rolldown/binding-linux-arm-gnueabihf@1.0.3': optional: true - '@rolldown/binding-linux-arm64-gnu@1.0.0-rc.17': + '@rolldown/binding-linux-arm64-gnu@1.0.3': optional: true - '@rolldown/binding-linux-arm64-musl@1.0.0-rc.17': + '@rolldown/binding-linux-arm64-musl@1.0.3': optional: true - '@rolldown/binding-linux-ppc64-gnu@1.0.0-rc.17': + '@rolldown/binding-linux-ppc64-gnu@1.0.3': optional: true - '@rolldown/binding-linux-s390x-gnu@1.0.0-rc.17': + '@rolldown/binding-linux-s390x-gnu@1.0.3': optional: true - '@rolldown/binding-linux-x64-gnu@1.0.0-rc.17': + '@rolldown/binding-linux-x64-gnu@1.0.3': optional: true - '@rolldown/binding-linux-x64-musl@1.0.0-rc.17': + '@rolldown/binding-linux-x64-musl@1.0.3': optional: true - '@rolldown/binding-openharmony-arm64@1.0.0-rc.17': + '@rolldown/binding-openharmony-arm64@1.0.3': optional: true - '@rolldown/binding-wasm32-wasi@1.0.0-rc.17': + '@rolldown/binding-wasm32-wasi@1.0.3': dependencies: '@emnapi/core': 1.10.0 '@emnapi/runtime': 1.10.0 - '@napi-rs/wasm-runtime': 1.1.4(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0) + '@napi-rs/wasm-runtime': 1.1.5(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0) optional: true - '@rolldown/binding-win32-arm64-msvc@1.0.0-rc.17': + '@rolldown/binding-win32-arm64-msvc@1.0.3': optional: true - '@rolldown/binding-win32-x64-msvc@1.0.0-rc.17': + '@rolldown/binding-win32-x64-msvc@1.0.3': optional: true - '@rolldown/pluginutils@1.0.0-rc.17': {} + '@rolldown/pluginutils@1.0.1': {} - '@rolldown/pluginutils@1.0.0-rc.7': {} + '@tauri-apps/api@2.11.1': {} - '@tauri-apps/api@2.11.0': {} - - '@tauri-apps/cli-darwin-arm64@2.11.1': + '@tauri-apps/cli-darwin-arm64@2.11.2': optional: true - '@tauri-apps/cli-darwin-x64@2.11.1': + '@tauri-apps/cli-darwin-x64@2.11.2': optional: true - '@tauri-apps/cli-linux-arm-gnueabihf@2.11.1': + '@tauri-apps/cli-linux-arm-gnueabihf@2.11.2': optional: true - '@tauri-apps/cli-linux-arm64-gnu@2.11.1': + '@tauri-apps/cli-linux-arm64-gnu@2.11.2': optional: true - '@tauri-apps/cli-linux-arm64-musl@2.11.1': + '@tauri-apps/cli-linux-arm64-musl@2.11.2': optional: true - '@tauri-apps/cli-linux-riscv64-gnu@2.11.1': + '@tauri-apps/cli-linux-riscv64-gnu@2.11.2': optional: true - '@tauri-apps/cli-linux-x64-gnu@2.11.1': + '@tauri-apps/cli-linux-x64-gnu@2.11.2': optional: true - '@tauri-apps/cli-linux-x64-musl@2.11.1': + '@tauri-apps/cli-linux-x64-musl@2.11.2': optional: true - '@tauri-apps/cli-win32-arm64-msvc@2.11.1': + '@tauri-apps/cli-win32-arm64-msvc@2.11.2': optional: true - '@tauri-apps/cli-win32-ia32-msvc@2.11.1': + '@tauri-apps/cli-win32-ia32-msvc@2.11.2': optional: true - '@tauri-apps/cli-win32-x64-msvc@2.11.1': + '@tauri-apps/cli-win32-x64-msvc@2.11.2': optional: true - '@tauri-apps/cli@2.11.1': + '@tauri-apps/cli@2.11.2': optionalDependencies: - '@tauri-apps/cli-darwin-arm64': 2.11.1 - '@tauri-apps/cli-darwin-x64': 2.11.1 - '@tauri-apps/cli-linux-arm-gnueabihf': 2.11.1 - '@tauri-apps/cli-linux-arm64-gnu': 2.11.1 - '@tauri-apps/cli-linux-arm64-musl': 2.11.1 - '@tauri-apps/cli-linux-riscv64-gnu': 2.11.1 - '@tauri-apps/cli-linux-x64-gnu': 2.11.1 - '@tauri-apps/cli-linux-x64-musl': 2.11.1 - '@tauri-apps/cli-win32-arm64-msvc': 2.11.1 - '@tauri-apps/cli-win32-ia32-msvc': 2.11.1 - '@tauri-apps/cli-win32-x64-msvc': 2.11.1 + '@tauri-apps/cli-darwin-arm64': 2.11.2 + '@tauri-apps/cli-darwin-x64': 2.11.2 + '@tauri-apps/cli-linux-arm-gnueabihf': 2.11.2 + '@tauri-apps/cli-linux-arm64-gnu': 2.11.2 + '@tauri-apps/cli-linux-arm64-musl': 2.11.2 + '@tauri-apps/cli-linux-riscv64-gnu': 2.11.2 + '@tauri-apps/cli-linux-x64-gnu': 2.11.2 + '@tauri-apps/cli-linux-x64-musl': 2.11.2 + '@tauri-apps/cli-win32-arm64-msvc': 2.11.2 + '@tauri-apps/cli-win32-ia32-msvc': 2.11.2 + '@tauri-apps/cli-win32-x64-msvc': 2.11.2 '@tybys/wasm-util@0.10.2': dependencies: tslib: 2.8.1 optional: true - '@types/estree@1.0.8': {} + '@types/estree@1.0.9': {} '@types/json-schema@7.0.15': {} - '@types/node@25.6.0': + '@types/node@25.9.4': dependencies: - undici-types: 7.19.2 + undici-types: 7.24.6 '@types/parse-json@4.0.2': {} '@types/prop-types@15.7.15': {} - '@types/react-dom@19.2.3(@types/react@19.2.14)': + '@types/react-dom@19.2.3(@types/react@19.2.17)': dependencies: - '@types/react': 19.2.14 + '@types/react': 19.2.17 - '@types/react-transition-group@4.4.12(@types/react@19.2.14)': + '@types/react-transition-group@4.4.12(@types/react@19.2.17)': dependencies: - '@types/react': 19.2.14 + '@types/react': 19.2.17 - '@types/react@19.2.14': + '@types/react@19.2.17': dependencies: csstype: 3.2.3 - '@typescript-eslint/eslint-plugin@8.59.2(@typescript-eslint/parser@8.59.2(eslint@9.39.4)(typescript@6.0.3))(eslint@9.39.4)(typescript@6.0.3)': + '@typescript-eslint/eslint-plugin@8.61.1(@typescript-eslint/parser@8.61.1(eslint@9.39.4)(typescript@6.0.3))(eslint@9.39.4)(typescript@6.0.3)': dependencies: '@eslint-community/regexpp': 4.12.2 - '@typescript-eslint/parser': 8.59.2(eslint@9.39.4)(typescript@6.0.3) - '@typescript-eslint/scope-manager': 8.59.2 - '@typescript-eslint/type-utils': 8.59.2(eslint@9.39.4)(typescript@6.0.3) - '@typescript-eslint/utils': 8.59.2(eslint@9.39.4)(typescript@6.0.3) - '@typescript-eslint/visitor-keys': 8.59.2 + '@typescript-eslint/parser': 8.61.1(eslint@9.39.4)(typescript@6.0.3) + '@typescript-eslint/scope-manager': 8.61.1 + '@typescript-eslint/type-utils': 8.61.1(eslint@9.39.4)(typescript@6.0.3) + '@typescript-eslint/utils': 8.61.1(eslint@9.39.4)(typescript@6.0.3) + '@typescript-eslint/visitor-keys': 8.61.1 eslint: 9.39.4 ignore: 7.0.5 natural-compare: 1.4.0 @@ -2527,41 +2531,41 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.59.2(eslint@9.39.4)(typescript@6.0.3)': + '@typescript-eslint/parser@8.61.1(eslint@9.39.4)(typescript@6.0.3)': dependencies: - '@typescript-eslint/scope-manager': 8.59.2 - '@typescript-eslint/types': 8.59.2 - '@typescript-eslint/typescript-estree': 8.59.2(typescript@6.0.3) - '@typescript-eslint/visitor-keys': 8.59.2 + '@typescript-eslint/scope-manager': 8.61.1 + '@typescript-eslint/types': 8.61.1 + '@typescript-eslint/typescript-estree': 8.61.1(typescript@6.0.3) + '@typescript-eslint/visitor-keys': 8.61.1 debug: 4.4.3 eslint: 9.39.4 typescript: 6.0.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/project-service@8.59.2(typescript@6.0.3)': + '@typescript-eslint/project-service@8.61.1(typescript@6.0.3)': dependencies: - '@typescript-eslint/tsconfig-utils': 8.59.2(typescript@6.0.3) - '@typescript-eslint/types': 8.59.2 + '@typescript-eslint/tsconfig-utils': 8.61.1(typescript@6.0.3) + '@typescript-eslint/types': 8.61.1 debug: 4.4.3 typescript: 6.0.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/scope-manager@8.59.2': + '@typescript-eslint/scope-manager@8.61.1': dependencies: - '@typescript-eslint/types': 8.59.2 - '@typescript-eslint/visitor-keys': 8.59.2 + '@typescript-eslint/types': 8.61.1 + '@typescript-eslint/visitor-keys': 8.61.1 - '@typescript-eslint/tsconfig-utils@8.59.2(typescript@6.0.3)': + '@typescript-eslint/tsconfig-utils@8.61.1(typescript@6.0.3)': dependencies: typescript: 6.0.3 - '@typescript-eslint/type-utils@8.59.2(eslint@9.39.4)(typescript@6.0.3)': + '@typescript-eslint/type-utils@8.61.1(eslint@9.39.4)(typescript@6.0.3)': dependencies: - '@typescript-eslint/types': 8.59.2 - '@typescript-eslint/typescript-estree': 8.59.2(typescript@6.0.3) - '@typescript-eslint/utils': 8.59.2(eslint@9.39.4)(typescript@6.0.3) + '@typescript-eslint/types': 8.61.1 + '@typescript-eslint/typescript-estree': 8.61.1(typescript@6.0.3) + '@typescript-eslint/utils': 8.61.1(eslint@9.39.4)(typescript@6.0.3) debug: 4.4.3 eslint: 9.39.4 ts-api-utils: 2.5.0(typescript@6.0.3) @@ -2569,49 +2573,49 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/types@8.59.2': {} + '@typescript-eslint/types@8.61.1': {} - '@typescript-eslint/typescript-estree@8.59.2(typescript@6.0.3)': + '@typescript-eslint/typescript-estree@8.61.1(typescript@6.0.3)': dependencies: - '@typescript-eslint/project-service': 8.59.2(typescript@6.0.3) - '@typescript-eslint/tsconfig-utils': 8.59.2(typescript@6.0.3) - '@typescript-eslint/types': 8.59.2 - '@typescript-eslint/visitor-keys': 8.59.2 + '@typescript-eslint/project-service': 8.61.1(typescript@6.0.3) + '@typescript-eslint/tsconfig-utils': 8.61.1(typescript@6.0.3) + '@typescript-eslint/types': 8.61.1 + '@typescript-eslint/visitor-keys': 8.61.1 debug: 4.4.3 minimatch: 10.2.5 - semver: 7.7.4 - tinyglobby: 0.2.16 + semver: 7.8.4 + tinyglobby: 0.2.17 ts-api-utils: 2.5.0(typescript@6.0.3) typescript: 6.0.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.59.2(eslint@9.39.4)(typescript@6.0.3)': + '@typescript-eslint/utils@8.61.1(eslint@9.39.4)(typescript@6.0.3)': dependencies: '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.4) - '@typescript-eslint/scope-manager': 8.59.2 - '@typescript-eslint/types': 8.59.2 - '@typescript-eslint/typescript-estree': 8.59.2(typescript@6.0.3) + '@typescript-eslint/scope-manager': 8.61.1 + '@typescript-eslint/types': 8.61.1 + '@typescript-eslint/typescript-estree': 8.61.1(typescript@6.0.3) eslint: 9.39.4 typescript: 6.0.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/visitor-keys@8.59.2': + '@typescript-eslint/visitor-keys@8.61.1': dependencies: - '@typescript-eslint/types': 8.59.2 + '@typescript-eslint/types': 8.61.1 eslint-visitor-keys: 5.0.1 - '@vitejs/plugin-react@6.0.1(vite@8.0.10(@types/node@25.6.0)(esbuild@0.27.2))': + '@vitejs/plugin-react@6.0.2(vite@8.0.16(@types/node@25.9.4)(esbuild@0.27.2))': dependencies: - '@rolldown/pluginutils': 1.0.0-rc.7 - vite: 8.0.10(@types/node@25.6.0)(esbuild@0.27.2) + '@rolldown/pluginutils': 1.0.1 + vite: 8.0.16(@types/node@25.9.4)(esbuild@0.27.2) - acorn-jsx@5.3.2(acorn@8.16.0): + acorn-jsx@5.3.2(acorn@8.17.0): dependencies: - acorn: 8.16.0 + acorn: 8.17.0 - acorn@8.16.0: {} + acorn@8.17.0: {} ajv@6.15.0: dependencies: @@ -2637,7 +2641,7 @@ snapshots: call-bound: 1.0.4 define-properties: 1.2.1 es-abstract: 1.24.2 - es-object-atoms: 1.1.1 + es-object-atoms: 1.1.2 get-intrinsic: 1.3.0 is-string: 1.1.1 math-intrinsics: 1.1.0 @@ -2648,7 +2652,7 @@ snapshots: define-properties: 1.2.1 es-abstract: 1.24.2 es-errors: 1.3.0 - es-object-atoms: 1.1.1 + es-object-atoms: 1.1.2 es-shim-unscopables: 1.1.0 array.prototype.flat@1.3.3: @@ -2691,7 +2695,7 @@ snapshots: babel-plugin-macros@3.1.0: dependencies: - '@babel/runtime': 7.29.2 + '@babel/runtime': 7.29.7 cosmiconfig: 7.1.0 resolve: 1.22.12 @@ -2699,23 +2703,23 @@ snapshots: balanced-match@4.0.4: {} - baseline-browser-mapping@2.10.27: {} + baseline-browser-mapping@2.10.38: {} - brace-expansion@1.1.14: + brace-expansion@1.1.15: dependencies: balanced-match: 1.0.2 concat-map: 0.0.1 - brace-expansion@5.0.5: + brace-expansion@5.0.6: dependencies: balanced-match: 4.0.4 browserslist@4.28.2: dependencies: - baseline-browser-mapping: 2.10.27 - caniuse-lite: 1.0.30001792 - electron-to-chromium: 1.5.351 - node-releases: 2.0.38 + baseline-browser-mapping: 2.10.38 + caniuse-lite: 1.0.30001799 + electron-to-chromium: 1.5.376 + node-releases: 2.0.48 update-browserslist-db: 1.2.3(browserslist@4.28.2) call-bind-apply-helpers@1.0.2: @@ -2737,7 +2741,7 @@ snapshots: callsites@3.1.0: {} - caniuse-lite@1.0.30001792: {} + caniuse-lite@1.0.30001799: {} chalk@4.1.2: dependencies: @@ -2818,7 +2822,7 @@ snapshots: dom-helpers@5.2.1: dependencies: - '@babel/runtime': 7.29.2 + '@babel/runtime': 7.29.7 csstype: 3.2.3 dunder-proto@1.0.1: @@ -2827,12 +2831,19 @@ snapshots: es-errors: 1.3.0 gopd: 1.2.0 - electron-to-chromium@1.5.351: {} + electron-to-chromium@1.5.376: {} error-ex@1.3.4: dependencies: is-arrayish: 0.2.1 + es-abstract-get@1.0.0: + dependencies: + es-errors: 1.3.0 + es-object-atoms: 1.1.2 + is-callable: 1.2.7 + object-inspect: 1.13.4 + es-abstract@1.24.2: dependencies: array-buffer-byte-length: 1.0.2 @@ -2845,10 +2856,10 @@ snapshots: data-view-byte-offset: 1.0.1 es-define-property: 1.0.1 es-errors: 1.3.0 - es-object-atoms: 1.1.1 + es-object-atoms: 1.1.2 es-set-tostringtag: 2.1.0 - es-to-primitive: 1.3.0 - function.prototype.name: 1.1.8 + es-to-primitive: 1.3.1 + function.prototype.name: 1.2.0 get-intrinsic: 1.3.0 get-proto: 1.0.1 get-symbol-description: 1.1.0 @@ -2857,7 +2868,7 @@ snapshots: has-property-descriptors: 1.0.2 has-proto: 1.2.0 has-symbols: 1.1.0 - hasown: 2.0.3 + hasown: 2.0.4 internal-slot: 1.1.0 is-array-buffer: 3.0.5 is-callable: 1.2.7 @@ -2880,21 +2891,21 @@ snapshots: safe-regex-test: 1.1.0 set-proto: 1.0.0 stop-iteration-iterator: 1.1.0 - string.prototype.trim: 1.2.10 - string.prototype.trimend: 1.0.9 + string.prototype.trim: 1.2.11 + string.prototype.trimend: 1.0.10 string.prototype.trimstart: 1.0.8 typed-array-buffer: 1.0.3 typed-array-byte-length: 1.0.3 typed-array-byte-offset: 1.0.4 - typed-array-length: 1.0.7 + typed-array-length: 1.0.8 unbox-primitive: 1.1.0 - which-typed-array: 1.1.20 + which-typed-array: 1.1.22 es-define-property@1.0.1: {} es-errors@1.3.0: {} - es-iterator-helpers@1.3.2: + es-iterator-helpers@1.3.3: dependencies: call-bind: 1.0.9 call-bound: 1.0.4 @@ -2913,7 +2924,7 @@ snapshots: iterator.prototype: 1.1.5 math-intrinsics: 1.1.0 - es-object-atoms@1.1.1: + es-object-atoms@1.1.2: dependencies: es-errors: 1.3.0 @@ -2922,14 +2933,16 @@ snapshots: es-errors: 1.3.0 get-intrinsic: 1.3.0 has-tostringtag: 1.0.2 - hasown: 2.0.3 + hasown: 2.0.4 es-shim-unscopables@1.1.0: dependencies: - hasown: 2.0.3 + hasown: 2.0.4 - es-to-primitive@1.3.0: + es-to-primitive@1.3.1: dependencies: + es-abstract-get: 1.0.0 + es-errors: 1.3.0 is-callable: 1.2.7 is-date-object: 1.1.0 is-symbol: 1.1.1 @@ -2974,8 +2987,8 @@ snapshots: eslint-plugin-react-hooks@7.1.1(eslint@9.39.4): dependencies: - '@babel/core': 7.29.0 - '@babel/parser': 7.29.3 + '@babel/core': 7.29.7 + '@babel/parser': 7.29.7 eslint: 9.39.4 hermes-parser: 0.25.1 zod: 4.4.3 @@ -2990,17 +3003,17 @@ snapshots: array.prototype.flatmap: 1.3.3 array.prototype.tosorted: 1.1.4 doctrine: 2.1.0 - es-iterator-helpers: 1.3.2 + es-iterator-helpers: 1.3.3 eslint: 9.39.4 estraverse: 5.3.0 - hasown: 2.0.3 + hasown: 2.0.4 jsx-ast-utils: 3.3.5 minimatch: 3.1.5 object.entries: 1.1.9 object.fromentries: 2.0.8 object.values: 1.2.1 prop-types: 15.8.1 - resolve: 2.0.0-next.6 + resolve: 2.0.0-next.7 semver: 6.3.1 string.prototype.matchall: 4.0.12 string.prototype.repeat: 1.0.0 @@ -3029,7 +3042,7 @@ snapshots: '@humanfs/node': 0.16.8 '@humanwhocodes/module-importer': 1.0.1 '@humanwhocodes/retry': 0.4.3 - '@types/estree': 1.0.8 + '@types/estree': 1.0.9 ajv: 6.15.0 chalk: 4.1.2 cross-spawn: 7.0.6 @@ -3057,8 +3070,8 @@ snapshots: espree@10.4.0: dependencies: - acorn: 8.16.0 - acorn-jsx: 5.3.2(acorn@8.16.0) + acorn: 8.17.0 + acorn-jsx: 5.3.2(acorn@8.17.0) eslint-visitor-keys: 4.2.1 esquery@1.7.0: @@ -3110,14 +3123,17 @@ snapshots: function-bind@1.1.2: {} - function.prototype.name@1.1.8: + function.prototype.name@1.2.0: dependencies: call-bind: 1.0.9 call-bound: 1.0.4 - define-properties: 1.2.1 + es-define-property: 1.0.1 + es-errors: 1.3.0 functions-have-names: 1.2.3 - hasown: 2.0.3 + has-property-descriptors: 1.0.2 + hasown: 2.0.4 is-callable: 1.2.7 + is-document.all: 1.0.0 functions-have-names@1.2.3: {} @@ -3130,18 +3146,18 @@ snapshots: call-bind-apply-helpers: 1.0.2 es-define-property: 1.0.1 es-errors: 1.3.0 - es-object-atoms: 1.1.1 + es-object-atoms: 1.1.2 function-bind: 1.1.2 get-proto: 1.0.1 gopd: 1.2.0 has-symbols: 1.1.0 - hasown: 2.0.3 + hasown: 2.0.4 math-intrinsics: 1.1.0 get-proto@1.0.1: dependencies: dunder-proto: 1.0.1 - es-object-atoms: 1.1.1 + es-object-atoms: 1.1.2 get-symbol-description@1.1.0: dependencies: @@ -3180,7 +3196,7 @@ snapshots: dependencies: has-symbols: 1.1.0 - hasown@2.0.3: + hasown@2.0.4: dependencies: function-bind: 1.1.2 @@ -3208,8 +3224,8 @@ snapshots: internal-slot@1.1.0: dependencies: es-errors: 1.3.0 - hasown: 2.0.3 - side-channel: 1.1.0 + hasown: 2.0.4 + side-channel: 1.1.1 is-array-buffer@3.0.5: dependencies: @@ -3240,7 +3256,7 @@ snapshots: is-core-module@2.16.2: dependencies: - hasown: 2.0.3 + hasown: 2.0.4 is-data-view@1.0.2: dependencies: @@ -3253,6 +3269,10 @@ snapshots: call-bound: 1.0.4 has-tostringtag: 1.0.2 + is-document.all@1.0.0: + dependencies: + call-bound: 1.0.4 + is-extglob@2.1.1: {} is-finalizationregistry@1.1.1: @@ -3285,7 +3305,7 @@ snapshots: call-bound: 1.0.4 gopd: 1.2.0 has-tostringtag: 1.0.2 - hasown: 2.0.3 + hasown: 2.0.4 is-set@2.0.3: {} @@ -3306,7 +3326,7 @@ snapshots: is-typed-array@1.1.15: dependencies: - which-typed-array: 1.1.20 + which-typed-array: 1.1.22 is-weakmap@2.0.2: {} @@ -3326,7 +3346,7 @@ snapshots: iterator.prototype@1.1.5: dependencies: define-data-property: 1.1.4 - es-object-atoms: 1.1.1 + es-object-atoms: 1.1.2 get-intrinsic: 1.3.0 get-proto: 1.0.1 has-symbols: 1.1.0 @@ -3334,7 +3354,7 @@ snapshots: js-tokens@4.0.0: {} - js-yaml@4.1.1: + js-yaml@4.2.0: dependencies: argparse: 2.0.1 @@ -3435,15 +3455,15 @@ snapshots: minimatch@10.2.5: dependencies: - brace-expansion: 5.0.5 + brace-expansion: 5.0.6 minimatch@3.1.5: dependencies: - brace-expansion: 1.1.14 + brace-expansion: 1.1.15 ms@2.1.3: {} - nanoid@3.3.12: {} + nanoid@3.3.13: {} natural-compare@1.4.0: {} @@ -3454,7 +3474,7 @@ snapshots: object.entries: 1.1.9 semver: 6.3.1 - node-releases@2.0.38: {} + node-releases@2.0.48: {} object-assign@4.1.1: {} @@ -3467,7 +3487,7 @@ snapshots: call-bind: 1.0.9 call-bound: 1.0.4 define-properties: 1.2.1 - es-object-atoms: 1.1.1 + es-object-atoms: 1.1.2 has-symbols: 1.1.0 object-keys: 1.1.1 @@ -3476,21 +3496,21 @@ snapshots: call-bind: 1.0.9 call-bound: 1.0.4 define-properties: 1.2.1 - es-object-atoms: 1.1.1 + es-object-atoms: 1.1.2 object.fromentries@2.0.8: dependencies: call-bind: 1.0.9 define-properties: 1.2.1 es-abstract: 1.24.2 - es-object-atoms: 1.1.1 + es-object-atoms: 1.1.2 object.values@1.2.1: dependencies: call-bind: 1.0.9 call-bound: 1.0.4 define-properties: 1.2.1 - es-object-atoms: 1.1.1 + es-object-atoms: 1.1.2 optionator@0.9.4: dependencies: @@ -3521,7 +3541,7 @@ snapshots: parse-json@5.2.0: dependencies: - '@babel/code-frame': 7.29.0 + '@babel/code-frame': 7.29.7 error-ex: 1.3.4 json-parse-even-better-errors: 2.3.1 lines-and-columns: 1.2.4 @@ -3540,9 +3560,9 @@ snapshots: possible-typed-array-names@1.1.0: {} - postcss@8.5.14: + postcss@8.5.15: dependencies: - nanoid: 3.3.12 + nanoid: 3.3.13 picocolors: 1.1.1 source-map-js: 1.2.1 @@ -3558,25 +3578,25 @@ snapshots: punycode@2.3.1: {} - react-dom@19.2.5(react@19.2.5): + react-dom@19.2.7(react@19.2.7): dependencies: - react: 19.2.5 + react: 19.2.7 scheduler: 0.27.0 react-is@16.13.1: {} - react-is@19.2.5: {} + react-is@19.2.7: {} - react-transition-group@4.4.5(react-dom@19.2.5(react@19.2.5))(react@19.2.5): + react-transition-group@4.4.5(react-dom@19.2.7(react@19.2.7))(react@19.2.7): dependencies: - '@babel/runtime': 7.29.2 + '@babel/runtime': 7.29.7 dom-helpers: 5.2.1 loose-envify: 1.4.0 prop-types: 15.8.1 - react: 19.2.5 - react-dom: 19.2.5(react@19.2.5) + react: 19.2.7 + react-dom: 19.2.7(react@19.2.7) - react@19.2.5: {} + react@19.2.7: {} reflect.getprototypeof@1.0.10: dependencies: @@ -3584,7 +3604,7 @@ snapshots: define-properties: 1.2.1 es-abstract: 1.24.2 es-errors: 1.3.0 - es-object-atoms: 1.1.1 + es-object-atoms: 1.1.2 get-intrinsic: 1.3.0 get-proto: 1.0.1 which-builtin-type: 1.2.1 @@ -3607,7 +3627,7 @@ snapshots: path-parse: 1.0.7 supports-preserve-symlinks-flag: 1.0.0 - resolve@2.0.0-next.6: + resolve@2.0.0-next.7: dependencies: es-errors: 1.3.0 is-core-module: 2.16.2 @@ -3616,26 +3636,26 @@ snapshots: path-parse: 1.0.7 supports-preserve-symlinks-flag: 1.0.0 - rolldown@1.0.0-rc.17: + rolldown@1.0.3: dependencies: - '@oxc-project/types': 0.127.0 - '@rolldown/pluginutils': 1.0.0-rc.17 + '@oxc-project/types': 0.133.0 + '@rolldown/pluginutils': 1.0.1 optionalDependencies: - '@rolldown/binding-android-arm64': 1.0.0-rc.17 - '@rolldown/binding-darwin-arm64': 1.0.0-rc.17 - '@rolldown/binding-darwin-x64': 1.0.0-rc.17 - '@rolldown/binding-freebsd-x64': 1.0.0-rc.17 - '@rolldown/binding-linux-arm-gnueabihf': 1.0.0-rc.17 - '@rolldown/binding-linux-arm64-gnu': 1.0.0-rc.17 - '@rolldown/binding-linux-arm64-musl': 1.0.0-rc.17 - '@rolldown/binding-linux-ppc64-gnu': 1.0.0-rc.17 - '@rolldown/binding-linux-s390x-gnu': 1.0.0-rc.17 - '@rolldown/binding-linux-x64-gnu': 1.0.0-rc.17 - '@rolldown/binding-linux-x64-musl': 1.0.0-rc.17 - '@rolldown/binding-openharmony-arm64': 1.0.0-rc.17 - '@rolldown/binding-wasm32-wasi': 1.0.0-rc.17 - '@rolldown/binding-win32-arm64-msvc': 1.0.0-rc.17 - '@rolldown/binding-win32-x64-msvc': 1.0.0-rc.17 + '@rolldown/binding-android-arm64': 1.0.3 + '@rolldown/binding-darwin-arm64': 1.0.3 + '@rolldown/binding-darwin-x64': 1.0.3 + '@rolldown/binding-freebsd-x64': 1.0.3 + '@rolldown/binding-linux-arm-gnueabihf': 1.0.3 + '@rolldown/binding-linux-arm64-gnu': 1.0.3 + '@rolldown/binding-linux-arm64-musl': 1.0.3 + '@rolldown/binding-linux-ppc64-gnu': 1.0.3 + '@rolldown/binding-linux-s390x-gnu': 1.0.3 + '@rolldown/binding-linux-x64-gnu': 1.0.3 + '@rolldown/binding-linux-x64-musl': 1.0.3 + '@rolldown/binding-openharmony-arm64': 1.0.3 + '@rolldown/binding-wasm32-wasi': 1.0.3 + '@rolldown/binding-win32-arm64-msvc': 1.0.3 + '@rolldown/binding-win32-x64-msvc': 1.0.3 safe-array-concat@1.1.4: dependencies: @@ -3660,7 +3680,7 @@ snapshots: semver@6.3.1: {} - semver@7.7.4: {} + semver@7.8.4: {} set-function-length@1.2.2: dependencies: @@ -3682,7 +3702,7 @@ snapshots: dependencies: dunder-proto: 1.0.1 es-errors: 1.3.0 - es-object-atoms: 1.1.1 + es-object-atoms: 1.1.2 shebang-command@2.0.0: dependencies: @@ -3710,7 +3730,7 @@ snapshots: object-inspect: 1.13.4 side-channel-map: 1.0.1 - side-channel@1.1.0: + side-channel@1.1.1: dependencies: es-errors: 1.3.0 object-inspect: 1.13.4 @@ -3734,42 +3754,43 @@ snapshots: define-properties: 1.2.1 es-abstract: 1.24.2 es-errors: 1.3.0 - es-object-atoms: 1.1.1 + es-object-atoms: 1.1.2 get-intrinsic: 1.3.0 gopd: 1.2.0 has-symbols: 1.1.0 internal-slot: 1.1.0 regexp.prototype.flags: 1.5.4 set-function-name: 2.0.2 - side-channel: 1.1.0 + side-channel: 1.1.1 string.prototype.repeat@1.0.0: dependencies: define-properties: 1.2.1 es-abstract: 1.24.2 - string.prototype.trim@1.2.10: + string.prototype.trim@1.2.11: dependencies: call-bind: 1.0.9 call-bound: 1.0.4 define-data-property: 1.1.4 define-properties: 1.2.1 es-abstract: 1.24.2 - es-object-atoms: 1.1.1 + es-object-atoms: 1.1.2 has-property-descriptors: 1.0.2 + safe-regex-test: 1.1.0 - string.prototype.trimend@1.0.9: + string.prototype.trimend@1.0.10: dependencies: call-bind: 1.0.9 call-bound: 1.0.4 define-properties: 1.2.1 - es-object-atoms: 1.1.1 + es-object-atoms: 1.1.2 string.prototype.trimstart@1.0.8: dependencies: call-bind: 1.0.9 define-properties: 1.2.1 - es-object-atoms: 1.1.1 + es-object-atoms: 1.1.2 strip-json-comments@3.1.1: {} @@ -3781,7 +3802,7 @@ snapshots: supports-preserve-symlinks-flag@1.0.0: {} - tinyglobby@0.2.16: + tinyglobby@0.2.17: dependencies: fdir: 6.5.0(picomatch@4.0.4) picomatch: 4.0.4 @@ -3821,7 +3842,7 @@ snapshots: is-typed-array: 1.1.15 reflect.getprototypeof: 1.0.10 - typed-array-length@1.0.7: + typed-array-length@1.0.8: dependencies: call-bind: 1.0.9 for-each: 0.3.5 @@ -3839,7 +3860,7 @@ snapshots: has-symbols: 1.1.0 which-boxed-primitive: 1.1.1 - undici-types@7.19.2: {} + undici-types@7.24.6: {} update-browserslist-db@1.2.3(browserslist@4.28.2): dependencies: @@ -3851,15 +3872,15 @@ snapshots: dependencies: punycode: 2.3.1 - vite@8.0.10(@types/node@25.6.0)(esbuild@0.27.2): + vite@8.0.16(@types/node@25.9.4)(esbuild@0.27.2): dependencies: lightningcss: 1.32.0 picomatch: 4.0.4 - postcss: 8.5.14 - rolldown: 1.0.0-rc.17 - tinyglobby: 0.2.16 + postcss: 8.5.15 + rolldown: 1.0.3 + tinyglobby: 0.2.17 optionalDependencies: - '@types/node': 25.6.0 + '@types/node': 25.9.4 esbuild: 0.27.2 fsevents: 2.3.3 @@ -3874,7 +3895,7 @@ snapshots: which-builtin-type@1.2.1: dependencies: call-bound: 1.0.4 - function.prototype.name: 1.1.8 + function.prototype.name: 1.2.0 has-tostringtag: 1.0.2 is-async-function: 2.1.1 is-date-object: 1.1.0 @@ -3885,7 +3906,7 @@ snapshots: isarray: 2.0.5 which-boxed-primitive: 1.1.1 which-collection: 1.0.2 - which-typed-array: 1.1.20 + which-typed-array: 1.1.22 which-collection@1.0.2: dependencies: @@ -3894,7 +3915,7 @@ snapshots: is-weakmap: 2.0.2 is-weakset: 2.0.4 - which-typed-array@1.1.20: + which-typed-array@1.1.22: dependencies: available-typed-arrays: 1.0.7 call-bind: 1.0.9 diff --git a/apps/gpgui-helper/src-tauri/build.rs b/apps/gpgui-helper/src-tauri/build.rs index 795b9b7..3978591 100644 --- a/apps/gpgui-helper/src-tauri/build.rs +++ b/apps/gpgui-helper/src-tauri/build.rs @@ -1,3 +1,62 @@ +use std::{env, fs, path::PathBuf, process::Command}; + +const UNKNOWN_COMMIT: &str = "unknown"; +const DISPLAY_COMMIT_LEN: usize = 9; + fn main() { + println!("cargo:rerun-if-env-changed=GPGUI_HELPER_GIT_COMMIT"); + println!("cargo:rerun-if-env-changed=SOURCE_GIT_COMMIT"); + println!("cargo:rerun-if-env-changed=GITHUB_SHA"); + + let repo_root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is set")).join("../../.."); + let source_commit = repo_root.join("SOURCE_COMMIT"); + println!("cargo:rerun-if-changed={}", source_commit.display()); + println!( + "cargo:rustc-env=GPGUI_HELPER_GIT_COMMIT={}", + resolve_commit(&repo_root, &source_commit) + ); + tauri_build::build() } + +fn resolve_commit(repo_root: &PathBuf, source_commit: &PathBuf) -> String { + env_commit("GPGUI_HELPER_GIT_COMMIT") + .or_else(|| env_commit("SOURCE_GIT_COMMIT")) + .or_else(|| env_commit("GITHUB_SHA")) + .or_else(|| file_commit(source_commit)) + .or_else(|| git_commit(repo_root)) + .unwrap_or_else(|| UNKNOWN_COMMIT.to_string()) +} + +fn env_commit(key: &str) -> Option { + env::var(key).ok().and_then(|value| normalize_commit(&value)) +} + +fn file_commit(path: &PathBuf) -> Option { + fs::read_to_string(path).ok().and_then(|value| normalize_commit(&value)) +} + +fn git_commit(repo_root: &PathBuf) -> Option { + let output = Command::new("git") + .args(["rev-parse", "--short=9", "HEAD"]) + .current_dir(repo_root) + .output() + .ok()?; + + if !output.status.success() { + return None; + } + + String::from_utf8(output.stdout) + .ok() + .and_then(|value| normalize_commit(&value)) +} + +fn normalize_commit(value: &str) -> Option { + let value = value.trim(); + if value.is_empty() { + return None; + } + + Some(value.chars().take(DISPLAY_COMMIT_LEN).collect()) +} diff --git a/apps/gpgui-helper/src-tauri/src/cli.rs b/apps/gpgui-helper/src-tauri/src/cli.rs index ed92ffe..532fb1a 100644 --- a/apps/gpgui-helper/src-tauri/src/cli.rs +++ b/apps/gpgui-helper/src-tauri/src/cli.rs @@ -7,7 +7,14 @@ use log::info; use crate::app::App; -const VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), " (", compile_time::date_str!(), ")"); +const VERSION: &str = concat!( + env!("CARGO_PKG_VERSION"), + " (", + env!("GPGUI_HELPER_GIT_COMMIT"), + " ", + compile_time::date_str!(), + ")" +); const GP_API_KEY: &[u8; 32] = &[0; 32]; #[derive(Parser)] diff --git a/apps/gpservice/build.rs b/apps/gpservice/build.rs new file mode 100644 index 0000000..bec97de --- /dev/null +++ b/apps/gpservice/build.rs @@ -0,0 +1,60 @@ +use std::{env, fs, path::PathBuf, process::Command}; + +const UNKNOWN_COMMIT: &str = "unknown"; +const DISPLAY_COMMIT_LEN: usize = 9; + +fn main() { + println!("cargo:rerun-if-env-changed=GPSERVICE_GIT_COMMIT"); + println!("cargo:rerun-if-env-changed=SOURCE_GIT_COMMIT"); + println!("cargo:rerun-if-env-changed=GITHUB_SHA"); + + let repo_root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is set")).join("../.."); + let source_commit = repo_root.join("SOURCE_COMMIT"); + println!("cargo:rerun-if-changed={}", source_commit.display()); + println!( + "cargo:rustc-env=GPSERVICE_GIT_COMMIT={}", + resolve_commit(&repo_root, &source_commit) + ); +} + +fn resolve_commit(repo_root: &PathBuf, source_commit: &PathBuf) -> String { + env_commit("GPSERVICE_GIT_COMMIT") + .or_else(|| env_commit("SOURCE_GIT_COMMIT")) + .or_else(|| env_commit("GITHUB_SHA")) + .or_else(|| file_commit(source_commit)) + .or_else(|| git_commit(repo_root)) + .unwrap_or_else(|| UNKNOWN_COMMIT.to_string()) +} + +fn env_commit(key: &str) -> Option { + env::var(key).ok().and_then(|value| normalize_commit(&value)) +} + +fn file_commit(path: &PathBuf) -> Option { + fs::read_to_string(path).ok().and_then(|value| normalize_commit(&value)) +} + +fn git_commit(repo_root: &PathBuf) -> Option { + let output = Command::new("git") + .args(["rev-parse", "--short=9", "HEAD"]) + .current_dir(repo_root) + .output() + .ok()?; + + if !output.status.success() { + return None; + } + + String::from_utf8(output.stdout) + .ok() + .and_then(|value| normalize_commit(&value)) +} + +fn normalize_commit(value: &str) -> Option { + let value = value.trim(); + if value.is_empty() { + return None; + } + + Some(value.chars().take(DISPLAY_COMMIT_LEN).collect()) +} diff --git a/apps/gpservice/src/cli.rs b/apps/gpservice/src/cli.rs index 54e6ff7..2256e92 100644 --- a/apps/gpservice/src/cli.rs +++ b/apps/gpservice/src/cli.rs @@ -16,7 +16,14 @@ use tokio::sync::{mpsc, watch}; use crate::{vpn_task::VpnTask, ws_server::WsServer}; -const VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), " (", compile_time::date_str!(), ")"); +const VERSION: &str = concat!( + env!("CARGO_PKG_VERSION"), + " (", + env!("GPSERVICE_GIT_COMMIT"), + " ", + compile_time::date_str!(), + ")" +); #[derive(Parser)] #[command(version = VERSION)] diff --git a/apps/gpservice/src/vpn_task.rs b/apps/gpservice/src/vpn_task.rs index 5be7263..5d16528 100644 --- a/apps/gpservice/src/vpn_task.rs +++ b/apps/gpservice/src/vpn_task.rs @@ -46,6 +46,7 @@ impl VpnTaskContext { .os(args.openconnect_os()) .os_version(args.os_version()) .client_version(args.client_version()) + .host_id(args.host_id()) .certificate(args.certificate()) .sslkey(args.sslkey()) .key_password(args.key_password()) diff --git a/apps/gpservice/src/ws_server.rs b/apps/gpservice/src/ws_server.rs index 36d0e66..6b90d7a 100644 --- a/apps/gpservice/src/ws_server.rs +++ b/apps/gpservice/src/ws_server.rs @@ -3,7 +3,13 @@ use std::sync::Arc; use axum::extract::ws::Message; use common::constants::GP_AUTH_BINARY; use gpapi::{ - service::{event::WsEvent, request::WsRequest, vpn_env::VpnEnv, vpn_state::VpnState}, + os_profile::HostIdentity, + service::{ + event::WsEvent, + request::WsRequest, + vpn_env::{HostInfo, VpnEnv}, + vpn_state::VpnState, + }, utils::{crypto::Crypto, lock_file::LockFile, redact::Redaction}, }; use log::{info, warn}; @@ -59,11 +65,16 @@ impl WsServerContext { // Send current VPN state to new client info!("Sending current environment to new client"); + let host_info = HostInfo { + host_identity: HostIdentity::collect(), + }; + let vpn_env = VpnEnv { vpn_state: self.vpn_state_rx.borrow().clone(), vpnc_script: find_vpnc_script().map(|s| s.to_owned()), csd_wrapper: find_csd_wrapper().map(|s| s.to_owned()), auth_executable: GP_AUTH_BINARY.to_owned(), + host_info, }; if let Err(err) = conn.send_event(&WsEvent::VpnEnv(vpn_env)).await { diff --git a/crates/auth/Cargo.toml b/crates/auth/Cargo.toml index fb65a69..1324834 100644 --- a/crates/auth/Cargo.toml +++ b/crates/auth/Cargo.toml @@ -29,7 +29,7 @@ regex = { workspace = true, optional = true } tokio-util = { workspace = true, optional = true } html-escape = { version = "0.2.13", optional = true } -[target.'cfg(not(target_os = "macos"))'.dependencies] +[target.'cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))'.dependencies] webkit2gtk = { version = "2", optional = true } [target.'cfg(target_os = "macos")'.dependencies] diff --git a/crates/auth/src/lib.rs b/crates/auth/src/lib.rs index 439062e..5081def 100644 --- a/crates/auth/src/lib.rs +++ b/crates/auth/src/lib.rs @@ -1,7 +1,7 @@ use anyhow::bail; use gpapi::{ gp_params::GpParams, - portal::{Prelogin, prelogin}, + portal::{Prelogin, PreloginOptions, prelogin}, }; #[cfg(feature = "browser-auth")] @@ -15,8 +15,15 @@ mod webview; #[cfg(feature = "webview-auth")] pub use webview::*; -pub async fn auth_prelogin(server: &str, gp_params: &GpParams) -> anyhow::Result { - match prelogin(server, gp_params).await? { +pub async fn auth_prelogin( + server: &str, + gp_params: &GpParams, + external_browser_requested: bool, +) -> anyhow::Result { + // gpauth only performs the initial portal/gateway prelogin. Portal policy is + // not available here, so gateway prelogin stays on the embedded value. + let options = PreloginOptions::default().external_browser_requested(external_browser_requested); + match prelogin(server, gp_params, options).await? { Prelogin::Saml(prelogin) => Ok(prelogin.saml_request().to_string()), Prelogin::Standard(_) => bail!("Received non-SAML prelogin response"), } diff --git a/crates/auth/src/webview.rs b/crates/auth/src/webview.rs index fc0a97a..bd15c88 100644 --- a/crates/auth/src/webview.rs +++ b/crates/auth/src/webview.rs @@ -1,8 +1,20 @@ mod auth_messenger; mod webview_auth; -#[cfg_attr(not(target_os = "macos"), path = "webview/unix.rs")] -#[cfg_attr(target_os = "macos", path = "webview/macos.rs")] +#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))] +#[path = "webview/gtk.rs"] mod platform_impl; +#[cfg(target_os = "macos")] +#[path = "webview/macos.rs"] +mod platform_impl; + +#[cfg(not(any( + target_os = "macos", + target_os = "linux", + target_os = "freebsd", + target_os = "openbsd" +)))] +compile_error!("webview-auth is only supported on macOS and GTK/WebKitGTK Unix targets"); + pub use webview_auth::WebviewAuthenticator; diff --git a/crates/auth/src/webview/auth_messenger.rs b/crates/auth/src/webview/auth_messenger.rs index 7df8cb3..85567c9 100644 --- a/crates/auth/src/webview/auth_messenger.rs +++ b/crates/auth/src/webview/auth_messenger.rs @@ -7,7 +7,7 @@ use tokio_util::sync::CancellationToken; #[derive(Debug)] pub(crate) enum AuthDataLocation { - #[cfg(not(target_os = "macos"))] + #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))] Headers, Body, } @@ -15,7 +15,7 @@ pub(crate) enum AuthDataLocation { #[derive(Debug)] pub(crate) enum AuthError { /// Failed to load page due to TLS error - #[cfg(not(target_os = "macos"))] + #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))] TlsError, /// 1. Found auth data in headers/body but it's invalid /// 2. Loaded an empty page, failed to load page. etc. @@ -34,7 +34,7 @@ impl AuthError { } } -#[cfg(not(target_os = "macos"))] +#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))] impl AuthError { pub fn not_found_in_headers() -> Self { Self::NotFound(AuthDataLocation::Headers) @@ -155,7 +155,7 @@ impl AuthMessenger { } } - #[cfg(not(target_os = "macos"))] + #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))] pub fn read_from_response(&self, auth_response: &impl super::webview_auth::GetHeader) { use log::warn; diff --git a/crates/auth/src/webview/unix.rs b/crates/auth/src/webview/gtk.rs similarity index 81% rename from crates/auth/src/webview/unix.rs rename to crates/auth/src/webview/gtk.rs index 9c8c5ce..a907613 100644 --- a/crates/auth/src/webview/unix.rs +++ b/crates/auth/src/webview/gtk.rs @@ -5,8 +5,8 @@ use gpapi::utils::redact::redact_uri; use log::warn; use tauri::webview::PlatformWebview; use webkit2gtk::{ - LoadEvent, TLSErrorsPolicy, URIResponseExt, WebResource, WebResourceExt, WebViewExt, WebsiteDataManagerExt, - gio::Cancellable, glib::GString, + LoadEvent, SettingsExt, TLSErrorsPolicy, URIResponseExt, WebResource, WebResourceExt, WebViewExt, + WebsiteDataManagerExt, gio::Cancellable, glib::GString, }; use super::{ @@ -33,6 +33,26 @@ impl PlatformWebviewExt for PlatformWebview { bail!("Failed to get website data manager"); } + fn user_agent(&self) -> anyhow::Result { + let Some(settings) = self.inner().settings() else { + bail!("Failed to get webview settings"); + }; + + settings + .user_agent() + .map(GString::into) + .ok_or_else(|| anyhow::anyhow!("Failed to get webview user agent")) + } + + fn set_user_agent(&self, user_agent: &str) -> anyhow::Result<()> { + let Some(settings) = self.inner().settings() else { + bail!("Failed to get webview settings"); + }; + + settings.set_user_agent(Some(user_agent)); + Ok(()) + } + fn load_url(&self, url: &str) -> anyhow::Result<()> { self.inner().load_uri(url); Ok(()) diff --git a/crates/auth/src/webview/macos.rs b/crates/auth/src/webview/macos.rs index b130be7..5127c3d 100644 --- a/crates/auth/src/webview/macos.rs +++ b/crates/auth/src/webview/macos.rs @@ -1,7 +1,8 @@ +use anyhow::bail; use block2::RcBlock; use log::warn; use objc2::runtime::AnyObject; -use objc2_foundation::{NSError, NSString, NSURL, NSURLRequest}; +use objc2_foundation::{NSError, NSObject, NSObjectNSKeyValueCoding, NSString, NSURL, NSURLRequest}; use objc2_web_kit::WKWebView; use tauri::webview::PlatformWebview; @@ -13,6 +14,29 @@ impl PlatformWebviewExt for PlatformWebview { Ok(()) } + fn user_agent(&self) -> anyhow::Result { + unsafe { + let wv: &NSObject = &*self.inner().cast(); + let Some(value) = wv.valueForKey(&NSString::from_str("userAgent")) else { + bail!("Failed to get webview user agent"); + }; + let Some(user_agent) = value.downcast_ref::() else { + bail!("Webview user agent is not a string"); + }; + + Ok(user_agent.to_string()) + } + } + + fn set_user_agent(&self, user_agent: &str) -> anyhow::Result<()> { + unsafe { + let wv: &WKWebView = &*self.inner().cast(); + wv.setCustomUserAgent(Some(&NSString::from_str(user_agent))); + } + + Ok(()) + } + fn load_url(&self, url: &str) -> anyhow::Result<()> { unsafe { let wv: &WKWebView = &*self.inner().cast(); diff --git a/crates/auth/src/webview/webview_auth.rs b/crates/auth/src/webview/webview_auth.rs index 7780b70..9811753 100644 --- a/crates/auth/src/webview/webview_auth.rs +++ b/crates/auth/src/webview/webview_auth.rs @@ -1,7 +1,12 @@ use std::{sync::Arc, time::Duration}; use anyhow::bail; -use gpapi::{auth::SamlAuthData, gp_params::GpParams, utils::redact::redact_uri}; +use gpapi::{ + auth::SamlAuthData, + gp_params::GpParams, + os_profile::{WebviewUserAgent, WebviewUserAgentTransform}, + utils::redact::redact_uri, +}; use log::{info, warn}; use tauri::{ AppHandle, WebviewUrl, WebviewWindow, WindowEvent, @@ -16,6 +21,10 @@ use super::auth_messenger::{AuthError, AuthEvent, AuthMessenger}; pub trait PlatformWebviewExt { fn ignore_tls_errors(&self) -> anyhow::Result<()>; + fn user_agent(&self) -> anyhow::Result; + + fn set_user_agent(&self, user_agent: &str) -> anyhow::Result<()>; + fn load_url(&self, url: &str) -> anyhow::Result<()>; fn load_html(&self, html: &str) -> anyhow::Result<()>; @@ -33,7 +42,7 @@ pub trait PlatformWebviewExt { } } -#[cfg(not(target_os = "macos"))] +#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))] pub trait GetHeader { fn get_header(&self, key: &str) -> Option; } @@ -42,6 +51,7 @@ pub struct WebviewAuthenticator<'a> { server: &'a str, gp_params: &'a GpParams, auth_request: Option<&'a str>, + webview_user_agent: Option, clean: bool, is_retrying: tokio::sync::RwLock, @@ -53,6 +63,7 @@ impl<'a> WebviewAuthenticator<'a> { server, gp_params, auth_request: None, + webview_user_agent: None, clean: false, is_retrying: Default::default(), } @@ -63,6 +74,11 @@ impl<'a> WebviewAuthenticator<'a> { self } + pub fn with_webview_user_agent(mut self, user_agent: WebviewUserAgent) -> Self { + self.webview_user_agent = Some(user_agent); + self + } + pub fn with_clean(mut self, clean: bool) -> Self { self.clean = clean; self @@ -116,7 +132,7 @@ impl<'a> WebviewAuthenticator<'a> { match auth_messenger.subscribe().await? { AuthEvent::Close => bail!("Authentication cancelled"), AuthEvent::RaiseWindow => self.raise_window(&auth_window), - #[cfg(not(target_os = "macos"))] + #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))] AuthEvent::Error(AuthError::TlsError) => bail!(gpapi::error::PortalError::TlsError), AuthEvent::Error(AuthError::NotFound(location)) => { info!( @@ -168,15 +184,16 @@ impl<'a> WebviewAuthenticator<'a> { let auth_request = match self.auth_request { Some(auth_request) => auth_request.to_string(), - None => auth_prelogin(&self.server, &self.gp_params).await?, + None => auth_prelogin(&self.server, &self.gp_params, false).await?, }; let (tx, rx) = oneshot::channel::>(); let ignore_tls_errors = self.gp_params.ignore_tls_errors(); + let webview_user_agent = self.webview_user_agent.clone(); // Set up webview auth_window.with_webview(move |wv| { - #[cfg(not(target_os = "macos"))] + #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))] { use super::platform_impl::PlatformWebviewOnResponse; wv.on_response(Box::new(move |response| match response { @@ -190,7 +207,7 @@ impl<'a> WebviewAuthenticator<'a> { wv.ignore_tls_errors()?; } - wv.load_auth_request(&auth_request) + load_auth_request_with_user_agent(&wv, webview_user_agent.as_ref(), &auth_request) }(); if let Err(result) = tx.send(result) { @@ -240,10 +257,15 @@ impl<'a> WebviewAuthenticator<'a> { document.body.appendChild(loading); "#)?; - let auth_request = auth_prelogin(&self.server, &self.gp_params).await?; + let auth_request = auth_prelogin(&self.server, &self.gp_params, false).await?; + let (tx, rx) = oneshot::channel::>(); + let webview_user_agent = self.webview_user_agent.clone(); auth_window.with_webview(move |wv| { - let result = wv.load_auth_request(&auth_request); + let result = || -> anyhow::Result<()> { + load_auth_request_with_user_agent(&wv, webview_user_agent.as_ref(), &auth_request) + }(); + if let Err(result) = tx.send(result) { warn!("Failed to send retry auth result: {:?}", result); } @@ -265,7 +287,7 @@ impl<'a> WebviewAuthenticator<'a> { #[cfg(target_os = "macos")] let result = auth_window.show(); - #[cfg(not(target_os = "macos"))] + #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))] let result = { use gpapi::utils::window::WindowExt; auth_window.raise() @@ -276,3 +298,175 @@ impl<'a> WebviewAuthenticator<'a> { } } } + +fn load_auth_request_with_user_agent( + wv: &impl PlatformWebviewExt, + plan: Option<&WebviewUserAgent>, + auth_request: &str, +) -> anyhow::Result<()> { + if let Some(plan) = plan { + let user_agent = compose_webview_user_agent(plan, || wv.user_agent())?; + wv.set_user_agent(&user_agent)?; + } + + wv.load_auth_request(auth_request) +} + +fn compose_webview_user_agent( + plan: &WebviewUserAgent, + native_user_agent: impl FnOnce() -> anyhow::Result, +) -> anyhow::Result { + let (prefix, default_user_agent, transform) = match plan { + WebviewUserAgent::Native { prefix, transform } => (prefix.as_str(), native_user_agent()?, *transform), + WebviewUserAgent::Projected { + prefix, + default_user_agent, + } => ( + prefix.as_str(), + default_user_agent.clone(), + WebviewUserAgentTransform::None, + ), + }; + + let default_user_agent = apply_webview_user_agent_transform(transform, &default_user_agent); + prepend_webview_user_agent_prefix(prefix, &default_user_agent) +} + +fn apply_webview_user_agent_transform(transform: WebviewUserAgentTransform, user_agent: &str) -> String { + match transform { + WebviewUserAgentTransform::None => user_agent.to_string(), + WebviewUserAgentTransform::LinuxPanGpuiVersion => linux_pan_gpui_user_agent(user_agent), + } +} + +fn linux_pan_gpui_user_agent(user_agent: &str) -> String { + if user_agent.contains("PanGPUI Version/10.0") { + return user_agent.to_string(); + } + + let Some(start) = user_agent.find("Version/") else { + return user_agent.to_string(); + }; + let end = user_agent[start..] + .find(char::is_whitespace) + .map(|offset| start + offset) + .unwrap_or(user_agent.len()); + + format!("{}PanGPUI Version/10.0{}", &user_agent[..start], &user_agent[end..]) +} + +fn prepend_webview_user_agent_prefix(prefix: &str, default_user_agent: &str) -> anyhow::Result { + let prefix = prefix.trim(); + if prefix.is_empty() { + return Ok(default_user_agent.to_string()); + } + + let default_user_agent = default_user_agent.trim(); + if default_user_agent.is_empty() { + bail!("Failed to read default webview user agent"); + } + + if default_user_agent.starts_with(prefix) { + return Ok(default_user_agent.to_string()); + } + + Ok(format!("{} {}", prefix, default_user_agent)) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn prepends_prefix_to_default_user_agent() { + let user_agent = prepend_webview_user_agent_prefix("PAN GlobalProtect/6.3.3", "Mozilla/5.0").unwrap(); + + assert_eq!(user_agent, "PAN GlobalProtect/6.3.3 Mozilla/5.0"); + } + + #[test] + fn leaves_already_prefixed_user_agent_unchanged() { + let user_agent = + prepend_webview_user_agent_prefix("PAN GlobalProtect/6.3.3", "PAN GlobalProtect/6.3.3 Mozilla/5.0").unwrap(); + + assert_eq!(user_agent, "PAN GlobalProtect/6.3.3 Mozilla/5.0"); + } + + #[test] + fn blank_prefix_leaves_default_user_agent_unchanged() { + let user_agent = prepend_webview_user_agent_prefix(" ", "Mozilla/5.0").unwrap(); + + assert_eq!(user_agent, "Mozilla/5.0"); + } + + #[test] + fn non_blank_prefix_requires_default_user_agent() { + let err = prepend_webview_user_agent_prefix("PAN GlobalProtect/6.3.3", " ").unwrap_err(); + + assert!(err.to_string().contains("default webview user agent")); + } + + #[test] + fn native_plan_reads_native_default_user_agent() { + let plan = WebviewUserAgent::Native { + prefix: "PAN GlobalProtect/6.3.3".to_string(), + transform: WebviewUserAgentTransform::None, + }; + let user_agent = compose_webview_user_agent(&plan, || Ok("Mozilla/5.0".to_string())).unwrap(); + + assert_eq!(user_agent, "PAN GlobalProtect/6.3.3 Mozilla/5.0"); + } + + #[test] + fn linux_transform_replaces_version_token_with_pan_gpui_version() { + let user_agent = linux_pan_gpui_user_agent( + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/60.5 Safari/605.1.15", + ); + + assert_eq!( + user_agent, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/605.1.15 (KHTML, like Gecko) PanGPUI Version/10.0 Safari/605.1.15" + ); + } + + #[test] + fn linux_transform_does_not_duplicate_pan_gpui_version() { + let user_agent = linux_pan_gpui_user_agent( + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/602.1 (KHTML, like Gecko) PanGPUI Version/10.0 Safari/602.1", + ); + + assert_eq!( + user_agent, + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/602.1 (KHTML, like Gecko) PanGPUI Version/10.0 Safari/602.1" + ); + } + + #[test] + fn native_linux_plan_applies_pan_gpui_transform_before_prefix() { + let plan = WebviewUserAgent::Native { + prefix: "PAN GlobalProtect/6.3.3".to_string(), + transform: WebviewUserAgentTransform::LinuxPanGpuiVersion, + }; + let user_agent = + compose_webview_user_agent(&plan, || Ok("Mozilla/5.0 Version/60.5 Safari/605.1.15".to_string())).unwrap(); + + assert_eq!( + user_agent, + "PAN GlobalProtect/6.3.3 Mozilla/5.0 PanGPUI Version/10.0 Safari/605.1.15" + ); + } + + #[test] + fn projected_plan_uses_profile_default_user_agent() { + let plan = WebviewUserAgent::Projected { + prefix: "PAN GlobalProtect/6.3.3".to_string(), + default_user_agent: "Mozilla/5.0 projected".to_string(), + }; + let user_agent = compose_webview_user_agent(&plan, || { + panic!("projected webview user agent should not read the native default") + }) + .unwrap(); + + assert_eq!(user_agent, "PAN GlobalProtect/6.3.3 Mozilla/5.0 projected"); + } +} diff --git a/crates/common/src/constants.rs b/crates/common/src/constants.rs index ac0169f..13ffb50 100644 --- a/crates/common/src/constants.rs +++ b/crates/common/src/constants.rs @@ -1,5 +1,7 @@ pub const GP_USER_AGENT: &str = "PAN GlobalProtect"; -pub const GP_CLIENT_VERSION: &str = "6.3.0-33"; +pub const GP_CLIENT_VERSION_LINUX: &str = "6.3.3-619"; +pub const GP_CLIENT_VERSION_WINDOWS: &str = "6.3.3-650"; +pub const GP_CLIENT_VERSION_MACOS: &str = "6.3.3-915"; pub const GP_SERVICE_LOCK_FILE: &str = "/var/run/gpservice.lock"; pub const GP_CALLBACK_PORT_FILENAME: &str = "gpcallback.port"; @@ -27,16 +29,43 @@ pub const GP_GUI_HELPER_BINARY: &str = "/usr/local/bin/gpgui-helper"; #[cfg(all(not(debug_assertions), target_os = "macos", target_arch = "x86_64"))] pub const GP_AUTH_BINARY: &str = "/usr/local/bin/gpauth"; +// Release binaries - BSD package layout +#[cfg(all(not(debug_assertions), any(target_os = "freebsd", target_os = "openbsd")))] +pub const GP_CLIENT_BINARY: &str = "/usr/local/bin/gpclient"; +#[cfg(all(not(debug_assertions), any(target_os = "freebsd", target_os = "openbsd")))] +pub const GP_SERVICE_BINARY: &str = "/usr/local/bin/gpservice"; +#[cfg(all(not(debug_assertions), any(target_os = "freebsd", target_os = "openbsd")))] +pub const GP_GUI_BINARY: &str = "/usr/local/bin/gpgui"; +#[cfg(all(not(debug_assertions), any(target_os = "freebsd", target_os = "openbsd")))] +pub const GP_GUI_HELPER_BINARY: &str = "/usr/local/bin/gpgui-helper"; +#[cfg(all(not(debug_assertions), any(target_os = "freebsd", target_os = "openbsd")))] +pub const GP_AUTH_BINARY: &str = "/usr/local/bin/gpauth"; + // Release binaries - Linux -#[cfg(all(not(debug_assertions), not(target_os = "macos")))] +#[cfg(all( + not(debug_assertions), + not(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd")) +))] pub const GP_CLIENT_BINARY: &str = "/usr/bin/gpclient"; -#[cfg(all(not(debug_assertions), not(target_os = "macos")))] +#[cfg(all( + not(debug_assertions), + not(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd")) +))] pub const GP_SERVICE_BINARY: &str = "/usr/bin/gpservice"; -#[cfg(all(not(debug_assertions), not(target_os = "macos")))] +#[cfg(all( + not(debug_assertions), + not(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd")) +))] pub const GP_GUI_BINARY: &str = "/usr/bin/gpgui"; -#[cfg(all(not(debug_assertions), not(target_os = "macos")))] +#[cfg(all( + not(debug_assertions), + not(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd")) +))] pub const GP_GUI_HELPER_BINARY: &str = "/usr/bin/gpgui-helper"; -#[cfg(all(not(debug_assertions), not(target_os = "macos")))] +#[cfg(all( + not(debug_assertions), + not(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd")) +))] pub const GP_AUTH_BINARY: &str = "/usr/bin/gpauth"; // Debug binaries are set in build.rs via environment variables diff --git a/crates/gpapi/Cargo.toml b/crates/gpapi/Cargo.toml index 027adc6..6131f12 100644 --- a/crates/gpapi/Cargo.toml +++ b/crates/gpapi/Cargo.toml @@ -32,10 +32,11 @@ uzers.workspace = true serde_urlencoded.workspace = true md5.workspace = true sha256.workspace = true -machine-uid.workspace = true uuid = { workspace = true, features = ["v5"] } chrono.workspace = true humantime.workspace = true +netdev.workspace = true +os_info = { version = "3", default-features = false } # Optional dependencies for features tauri = { workspace = true, optional = true } @@ -45,14 +46,13 @@ clap-verbosity-flag = { workspace = true, optional = true } env_logger = { workspace = true, optional = true } log-reload = { version = "0.1", optional = true } -# Dependencies for macOS and Windows only -[target.'cfg(any(target_os="macos", target_os="windows"))'.dependencies] -os_info = { version = "3", default-features = false } - # Dependencies for Linux and other OSes only [target.'cfg(not(any(target_os="macos", target_os="windows")))'.dependencies] gtk = { version = "0.18", optional = true } +[dev-dependencies] +proptest.workspace = true + [features] tauri = ["dep:tauri", "dep:gtk"] clap = ["dep:clap", "dep:clap-verbosity-flag"] diff --git a/crates/gpapi/src/auth.rs b/crates/gpapi/src/auth.rs index ebd7dd7..f786771 100644 --- a/crates/gpapi/src/auth.rs +++ b/crates/gpapi/src/auth.rs @@ -9,7 +9,7 @@ use crate::{error::AuthDataParseError, utils::base64::decode_to_string}; pub type AuthDataParseResult = anyhow::Result; -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, Clone)] #[serde(rename_all = "camelCase")] pub struct SamlAuthData { #[serde(alias = "un")] @@ -17,9 +17,11 @@ pub struct SamlAuthData { prelogin_cookie: Option, portal_userauthcookie: Option, token: Option, + #[serde(skip_serializing_if = "Option::is_none")] + host_id: Option, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, Clone)] #[serde(rename_all = "camelCase")] pub enum SamlAuthResult { Success(SamlAuthData), @@ -33,6 +35,13 @@ impl SamlAuthResult { SamlAuthResult::Failure(_) => false, } } + + pub fn host_id(&self) -> Option<&str> { + match self { + SamlAuthResult::Success(auth_data) => auth_data.host_id(), + SamlAuthResult::Failure(_) => None, + } + } } impl SamlAuthData { @@ -62,9 +71,16 @@ impl SamlAuthData { prelogin_cookie: Some(prelogin_cookie), portal_userauthcookie: Some(portal_userauthcookie), token: None, + host_id: None, }) } + pub fn with_host_id(mut self, host_id: impl Into) -> Self { + let host_id = host_id.into(); + self.host_id = (!host_id.trim().is_empty()).then_some(host_id); + self + } + pub fn from_html(html: &str) -> AuthDataParseResult { match parse_xml_tag(html, "saml-auth-status") { Some(status) if status == "1" => { @@ -72,7 +88,11 @@ impl SamlAuthData { let prelogin_cookie = parse_xml_tag(html, "prelogin-cookie"); let portal_userauthcookie = parse_xml_tag(html, "portal-userauthcookie"); - SamlAuthData::new(username, prelogin_cookie, portal_userauthcookie).map_err(AuthDataParseError::Invalid) + let auth_data = + SamlAuthData::new(username, prelogin_cookie, portal_userauthcookie).map_err(AuthDataParseError::Invalid)?; + auth_data.log_summary("html"); + + Ok(auth_data) } Some(status) => Err(AuthDataParseError::Invalid(anyhow::anyhow!( "SAML auth status: {}", @@ -102,6 +122,7 @@ impl SamlAuthData { AuthDataParseError::Invalid(anyhow::anyhow!(e)) })?; + auth_data.log_summary("gpcallback-cas"); return Ok(auth_data); } @@ -122,9 +143,32 @@ impl SamlAuthData { self.prelogin_cookie.as_deref() } + pub fn portal_userauthcookie(&self) -> Option<&str> { + self.portal_userauthcookie.as_deref() + } + pub fn token(&self) -> Option<&str> { self.token.as_deref() } + + pub fn host_id(&self) -> Option<&str> { + self.host_id.as_deref() + } + + fn log_summary(&self, source: &str) { + info!( + "Parsed SAML auth data: source={}, username_present={}, prelogin_cookie_len={}, portal_userauthcookie_len={}, token_len={}", + source, + !self.username.is_empty(), + optional_len(self.prelogin_cookie.as_deref()), + optional_len(self.portal_userauthcookie.as_deref()), + optional_len(self.token.as_deref()) + ); + } +} + +fn optional_len(value: Option<&str>) -> usize { + value.unwrap_or_default().len() } fn parse_xml_tag(html: &str, tag: &str) -> Option { @@ -160,11 +204,46 @@ mod tests { #[test] fn auth_data_from_gpcallback_non_cas() { - let auth_data = "PGh0bWw+PCEtLSA8c2FtbC1hdXRoLXN0YXR1cz4xPC9zYW1sLWF1dGgtc3RhdHVzPjxwcmVsb2dpbi1jb29raWU+cHJlbG9naW4tY29va2llPC9wcmVsb2dpbi1jb29raWU+PHNhbWwtdXNlcm5hbWU+eHl6QGVtYWlsLmNvbTwvc2FtbC11c2VybmFtZT48c2FtbC1zbG8+bm88L3NhbWwtc2xvPjxzYW1sLVNlc3Npb25Ob3RPbk9yQWZ0ZXI+PC9zYW1sLVNlc3Npb25Ob3RPbk9yQWZ0ZXI+IC0tPjwvaHRtbD4="; + let auth_data = "PGh0bWw+PCEtLSA8c2FtbC1hdXRoLXN0YXR1cz4xPC9zYW1sLWF1dGgtc3RhdHVzPjxwcmVsb2dpbi1jb29raWU+cHJlbG9naW4tY29va2llPC9wcmVsb2dpbi1jb29raWU+PHBvcnRhbC11c2VyYXV0aGNvb2tpZT5wb3J0YWwtdXNlcmF1dGhjb29raWU8L3BvcnRhbC11c2VyYXV0aGNvb2tpZT48c2FtbC11c2VybmFtZT54eXpAZW1haWwuY29tPC9zYW1sLXVzZXJuYW1lPjxzYW1sLXNsbz5ubzwvc2FtbC1zbG8+IC0tPjwvaHRtbD4="; let auth_data = SamlAuthData::from_gpcallback(auth_data).unwrap(); assert_eq!(auth_data.username(), "xyz@email.com"); assert_eq!(auth_data.prelogin_cookie(), Some("prelogin-cookie")); + assert_eq!(auth_data.portal_userauthcookie(), Some("portal-userauthcookie")); + } + + #[test] + fn auth_result_success_can_carry_host_id() { + let auth_data = SamlAuthData::new( + Some("alice@example.com".to_string()), + Some("prelogin-cookie".to_string()), + None, + ) + .unwrap() + .with_host_id("host-seed"); + let result = SamlAuthResult::Success(auth_data); + + assert_eq!(result.host_id(), Some("host-seed")); + + let value = serde_json::to_value(result).unwrap(); + assert_eq!(value["success"]["hostId"], "host-seed"); + } + + #[test] + fn auth_result_success_omits_empty_host_id() { + let auth_data = SamlAuthData::new( + Some("alice@example.com".to_string()), + Some("prelogin-cookie".to_string()), + None, + ) + .unwrap() + .with_host_id(" "); + let result = SamlAuthResult::Success(auth_data); + + assert_eq!(result.host_id(), None); + + let value = serde_json::to_value(result).unwrap(); + assert!(value["success"].get("hostId").is_none()); } } diff --git a/crates/gpapi/src/clap/args.rs b/crates/gpapi/src/clap/args.rs index 58631c5..0c192cb 100644 --- a/crates/gpapi/src/clap/args.rs +++ b/crates/gpapi/src/clap/args.rs @@ -1,37 +1,22 @@ use clap::{ValueEnum, builder::PossibleValue}; -use crate::gp_params::ClientOs; +use crate::{ + gp_params::CscMode, + os_profile::{ClientOs, runtime_client_os}, +}; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)] pub enum Os { + #[value(name = "Linux")] Linux, + #[value(name = "Windows")] Windows, + #[value(name = "Mac")] Mac, } -impl Os { - pub fn as_str(&self) -> &'static str { - match self { - Os::Linux => "Linux", - Os::Windows => "Windows", - Os::Mac => "Mac", - } - } -} - -impl From<&str> for Os { - fn from(os: &str) -> Self { - match os.to_lowercase().as_str() { - "linux" => Os::Linux, - "windows" => Os::Windows, - "mac" => Os::Mac, - _ => Os::Linux, - } - } -} - -impl From<&Os> for ClientOs { - fn from(value: &Os) -> Self { +impl From for ClientOs { + fn from(value: Os) -> Self { match value { Os::Linux => ClientOs::Linux, Os::Windows => ClientOs::Windows, @@ -40,25 +25,41 @@ impl From<&Os> for ClientOs { } } -impl ValueEnum for Os { +impl Default for Os { + fn default() -> Self { + match runtime_client_os() { + ClientOs::Linux => Os::Linux, + ClientOs::Windows => Os::Windows, + ClientOs::Mac => Os::Mac, + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn default_os_uses_runtime_client_os() { + assert_eq!(ClientOs::from(Os::default()), runtime_client_os()); + } +} + +impl ValueEnum for CscMode { fn value_variants<'a>() -> &'a [Self] { - &[Os::Linux, Os::Windows, Os::Mac] + &[CscMode::Auto, CscMode::Yes, CscMode::No] } - fn to_possible_value(&self) -> Option { - match self { - Os::Linux => Some(PossibleValue::new("Linux")), - Os::Windows => Some(PossibleValue::new("Windows")), - Os::Mac => Some(PossibleValue::new("Mac")), - } + fn to_possible_value(&self) -> Option { + Some(PossibleValue::new(self.as_str())) } fn from_str(input: &str, _: bool) -> Result { match input.to_lowercase().as_str() { - "linux" => Ok(Os::Linux), - "windows" => Ok(Os::Windows), - "mac" => Ok(Os::Mac), - _ => Err(format!("Invalid OS: {}", input)), + "auto" => Ok(CscMode::Auto), + "yes" => Ok(CscMode::Yes), + "no" => Ok(CscMode::No), + _ => Err(format!("Invalid CSC mode: {}", input)), } } } diff --git a/crates/gpapi/src/cookie_store.rs b/crates/gpapi/src/cookie_store.rs index 9a9f523..7a9cfd3 100644 --- a/crates/gpapi/src/cookie_store.rs +++ b/crates/gpapi/src/cookie_store.rs @@ -1,7 +1,6 @@ use std::{ fs, io::Write, - os::unix::fs::PermissionsExt, path::{Path, PathBuf}, }; @@ -16,13 +15,20 @@ pub struct StoredCookie { pub version: u32, pub server: String, pub username: String, + pub host_id: String, pub last_gateway: String, pub auth_cookie: AuthCookieCredential, pub saved_at: u64, } impl StoredCookie { - pub fn new(server: String, username: String, last_gateway: String, auth_cookie: AuthCookieCredential) -> Self { + pub fn new( + server: String, + username: String, + host_id: String, + last_gateway: String, + auth_cookie: AuthCookieCredential, + ) -> Self { let saved_at = std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) .map(|d| d.as_secs()) @@ -31,6 +37,7 @@ impl StoredCookie { version: STORE_VERSION, server, username, + host_id, last_gateway, auth_cookie, saved_at, @@ -46,10 +53,10 @@ pub fn cookie_path(custom: Option<&str>) -> PathBuf { PathBuf::from(home).join(".config/gpclient/cookie.json") } -pub fn load(path: &Path, server: &str) -> Option { +pub fn load(path: &Path, server: &str, host_id: &str) -> Option { let bytes = fs::read(path).ok()?; let stored: StoredCookie = serde_json::from_slice(&bytes).ok()?; - if stored.version != STORE_VERSION || stored.server != server { + if stored.version != STORE_VERSION || stored.server != server || stored.host_id != host_id { return None; } Some(stored) @@ -60,12 +67,12 @@ pub fn save(path: &Path, stored: &StoredCookie) -> anyhow::Result<()> { .parent() .ok_or_else(|| anyhow::anyhow!("cookie path has no parent directory"))?; fs::create_dir_all(parent)?; - fs::set_permissions(parent, fs::Permissions::from_mode(0o700))?; + set_private_dir_permissions(parent)?; let mut tmp = tempfile::NamedTempFile::new_in(parent)?; tmp.write_all(&serde_json::to_vec(stored)?)?; tmp.flush()?; - fs::set_permissions(tmp.path(), fs::Permissions::from_mode(0o600))?; + set_private_file_permissions(tmp.path())?; tmp.persist(path)?; Ok(()) } @@ -74,6 +81,60 @@ pub fn clear(path: &Path) { let _ = fs::remove_file(path); } +use permissions::{set_private_dir_permissions, set_private_file_permissions}; + +mod permissions { + use std::path::Path; + + #[cfg(unix)] + mod unix { + use std::{fs, os::unix::fs::PermissionsExt, path::Path}; + + pub(super) fn set_private_dir(path: &Path) -> anyhow::Result<()> { + fs::set_permissions(path, fs::Permissions::from_mode(0o700))?; + Ok(()) + } + + pub(super) fn set_private_file(path: &Path) -> anyhow::Result<()> { + fs::set_permissions(path, fs::Permissions::from_mode(0o600))?; + Ok(()) + } + + #[cfg(test)] + pub(super) fn file_mode(path: &Path) -> Option { + Some(fs::metadata(path).ok()?.permissions().mode() & 0o777) + } + } + + pub(super) fn set_private_dir_permissions(path: &Path) -> anyhow::Result<()> { + #[cfg(unix)] + unix::set_private_dir(path)?; + #[cfg(not(unix))] + let _ = path; + Ok(()) + } + + pub(super) fn set_private_file_permissions(path: &Path) -> anyhow::Result<()> { + #[cfg(unix)] + unix::set_private_file(path)?; + #[cfg(not(unix))] + let _ = path; + Ok(()) + } + + #[cfg(test)] + pub(super) fn file_mode(path: &Path) -> Option { + #[cfg(unix)] + return unix::file_mode(path); + + #[cfg(not(unix))] + { + let _ = path; + None + } + } +} + #[cfg(test)] mod tests { use super::*; @@ -82,6 +143,7 @@ mod tests { StoredCookie::new( "vpn.example.com".to_string(), "alice".to_string(), + "host-1".to_string(), "gw1.example.com".to_string(), AuthCookieCredential::new("alice", "user-auth", "prelogon-auth"), ) @@ -94,15 +156,24 @@ mod tests { let s = sample(); save(&path, &s).unwrap(); - let mode = fs::metadata(&path).unwrap().permissions().mode() & 0o777; - assert_eq!(mode, 0o600, "cookie file must be mode 0600, got {:o}", mode); + if let Some(mode) = permissions::file_mode(&path) { + assert_eq!(mode, 0o600, "cookie file must be mode 0600, got {:o}", mode); + } - let loaded = load(&path, "vpn.example.com").unwrap(); + let loaded = load(&path, "vpn.example.com", "host-1").unwrap(); assert_eq!(loaded.username, "alice"); + assert_eq!(loaded.host_id, "host-1"); assert_eq!(loaded.last_gateway, "gw1.example.com"); assert_eq!(loaded.auth_cookie.user_auth_cookie(), "user-auth"); - assert!(load(&path, "other.example.com").is_none(), "must reject mismatched server"); + assert!( + load(&path, "other.example.com", "host-1").is_none(), + "must reject mismatched server" + ); + assert!( + load(&path, "vpn.example.com", "host-2").is_none(), + "must reject mismatched host id" + ); clear(&path); assert!(!path.exists()); } @@ -114,6 +185,6 @@ mod tests { let mut s = sample(); s.version = STORE_VERSION + 1; save(&path, &s).unwrap(); - assert!(load(&path, "vpn.example.com").is_none()); + assert!(load(&path, "vpn.example.com", "host-1").is_none()); } } diff --git a/crates/gpapi/src/credential.rs b/crates/gpapi/src/credential.rs index a745df1..6c94537 100644 --- a/crates/gpapi/src/credential.rs +++ b/crates/gpapi/src/credential.rs @@ -1,5 +1,3 @@ -use std::collections::HashMap; - use anyhow::bail; use serde::{Deserialize, Serialize}; use specta::Type; @@ -41,14 +39,21 @@ impl From<&CachedCredential> for PasswordCredential { pub struct PreloginCredential { username: String, prelogin_cookie: Option, + portal_userauthcookie: Option, token: Option, } impl PreloginCredential { - pub fn new(username: &str, prelogin_cookie: Option<&str>, token: Option<&str>) -> Self { + pub fn new( + username: &str, + prelogin_cookie: Option<&str>, + portal_userauthcookie: Option<&str>, + token: Option<&str>, + ) -> Self { Self { username: username.to_string(), prelogin_cookie: prelogin_cookie.map(|s| s.to_string()), + portal_userauthcookie: portal_userauthcookie.map(|s| s.to_string()), token: token.map(|s| s.to_string()), } } @@ -61,6 +66,10 @@ impl PreloginCredential { self.prelogin_cookie.as_deref() } + pub fn portal_userauthcookie(&self) -> Option<&str> { + self.portal_userauthcookie.as_deref() + } + pub fn token(&self) -> Option<&str> { self.token.as_deref() } @@ -70,9 +79,10 @@ impl From for PreloginCredential { fn from(value: SamlAuthData) -> Self { let username = value.username().to_string(); let prelogin_cookie = value.prelogin_cookie(); + let portal_userauthcookie = value.portal_userauthcookie(); let token = value.token(); - Self::new(&username, prelogin_cookie, token) + Self::new(&username, prelogin_cookie, portal_userauthcookie, token) } } @@ -82,6 +92,8 @@ pub struct AuthCookieCredential { username: String, user_auth_cookie: String, prelogon_user_auth_cookie: String, + #[serde(skip)] + password: Option, } impl AuthCookieCredential { @@ -90,9 +102,16 @@ impl AuthCookieCredential { username: username.to_string(), user_auth_cookie: user_auth_cookie.to_string(), prelogon_user_auth_cookie: prelogon_user_auth_cookie.to_string(), + password: None, } } + pub fn with_password(mut self, password: impl Into) -> Self { + let password = password.into(); + self.password = (!password.trim().is_empty()).then_some(password); + self + } + pub fn username(&self) -> &str { &self.username } @@ -104,6 +123,19 @@ impl AuthCookieCredential { pub fn prelogon_user_auth_cookie(&self) -> &str { &self.prelogon_user_auth_cookie } + + pub fn password(&self) -> Option<&str> { + self.password.as_deref() + } + + pub fn can_authenticate_gateway(&self) -> bool { + is_gateway_auth_cookie(&self.user_auth_cookie) || is_gateway_auth_cookie(&self.prelogon_user_auth_cookie) + } +} + +fn is_gateway_auth_cookie(value: &str) -> bool { + let value = value.trim(); + !value.is_empty() && value != "empty" } #[derive(Debug, Serialize, Deserialize, Type, Clone)] @@ -135,6 +167,13 @@ impl CachedCredential { self.auth_cookie.as_ref() } + pub fn can_authenticate_gateway(&self) -> bool { + self + .auth_cookie + .as_ref() + .is_some_and(AuthCookieCredential::can_authenticate_gateway) + } + pub fn set_auth_cookie(&mut self, auth_cookie: AuthCookieCredential) { self.auth_cookie = Some(auth_cookie); } @@ -180,42 +219,20 @@ impl Credential { } } - pub fn to_params(&self) -> HashMap<&str, &str> { - let mut params = HashMap::new(); - params.insert("user", self.username()); - - let (passwd, prelogin_cookie, portal_userauthcookie, portal_prelogonuserauthcookie, token) = match self { - Credential::Password(cred) => (Some(cred.password()), None, None, None, None), - Credential::Prelogin(cred) => (None, cred.prelogin_cookie(), None, None, cred.token()), - Credential::AuthCookie(cred) => ( - None, - None, - Some(cred.user_auth_cookie()), - Some(cred.prelogon_user_auth_cookie()), - None, - ), - Credential::Cached(cred) => ( - cred.password(), - None, - cred.auth_cookie.as_ref().map(|c| c.user_auth_cookie()), - cred.auth_cookie.as_ref().map(|c| c.prelogon_user_auth_cookie()), - None, - ), - }; - - params.insert("passwd", passwd.unwrap_or_default()); - params.insert("prelogin-cookie", prelogin_cookie.unwrap_or_default()); - params.insert("portal-userauthcookie", portal_userauthcookie.unwrap_or_default()); - params.insert( - "portal-prelogonuserauthcookie", - portal_prelogonuserauthcookie.unwrap_or_default(), - ); - - if let Some(token) = token { - params.insert("token", token); + pub fn password(&self) -> Option<&str> { + match self { + Credential::Password(cred) => Some(cred.password()), + Credential::Cached(cred) => cred.password(), + Credential::Prelogin(_) | Credential::AuthCookie(_) => None, } + } - params + pub fn can_authenticate_gateway(&self) -> bool { + match self { + Credential::AuthCookie(cred) => cred.can_authenticate_gateway(), + Credential::Cached(cred) => cred.can_authenticate_gateway(), + Credential::Password(_) | Credential::Prelogin(_) => true, + } } } @@ -255,3 +272,87 @@ impl From<&CachedCredential> for Credential { Self::Cached(value.clone()) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn prelogin_credential_keeps_saml_cookies() { + let auth_data = SamlAuthData::new( + Some("alice@example.com".to_string()), + Some("prelogin-cookie".to_string()), + Some("portal-userauthcookie".to_string()), + ) + .unwrap(); + + let cred = Credential::from(auth_data); + let Credential::Prelogin(prelogin) = cred else { + panic!("expected prelogin credential"); + }; + + assert_eq!(prelogin.username(), "alice@example.com"); + assert_eq!(prelogin.prelogin_cookie(), Some("prelogin-cookie")); + assert_eq!(prelogin.portal_userauthcookie(), Some("portal-userauthcookie")); + assert_eq!(prelogin.token(), None); + } + + #[test] + fn prelogin_credential_keeps_cas_token_without_cookies() { + let auth_data = + SamlAuthData::from_gpcallback("globalprotectcallback:cas-as=1&un=alice@example.com&token=cas-token").unwrap(); + + let cred = Credential::from(auth_data); + let Credential::Prelogin(prelogin) = cred else { + panic!("expected prelogin credential"); + }; + + assert_eq!(prelogin.username(), "alice@example.com"); + assert_eq!(prelogin.prelogin_cookie(), None); + assert_eq!(prelogin.portal_userauthcookie(), None); + assert_eq!(prelogin.token(), Some("cas-token")); + } + + #[test] + fn auth_cookie_runtime_password_is_not_serialized() { + let value = serde_json::to_value( + AuthCookieCredential::new("alice", "user-cookie", "prelogon-cookie").with_password("secret"), + ) + .unwrap(); + + assert_eq!(value.get("password"), None); + } + + #[test] + fn auth_cookie_with_empty_sentinels_cannot_authenticate_gateway() { + let cred = AuthCookieCredential::new("alice", "empty", "empty"); + + assert!(!cred.can_authenticate_gateway()); + } + + #[test] + fn auth_cookie_with_blank_values_cannot_authenticate_gateway() { + let cred = AuthCookieCredential::new("alice", "", " "); + + assert!(!cred.can_authenticate_gateway()); + } + + #[test] + fn auth_cookie_with_real_cookie_can_authenticate_gateway() { + let cred = AuthCookieCredential::new("alice", "empty", "portal-prelogon-cookie"); + + assert!(cred.can_authenticate_gateway()); + } + + #[test] + fn cached_credential_without_real_auth_cookie_cannot_authenticate_gateway() { + let cred = CachedCredential::new( + "alice".to_string(), + None, + Some(AuthCookieCredential::new("alice", "empty", "empty")), + ); + + assert!(!cred.can_authenticate_gateway()); + assert!(!Credential::from(&cred).can_authenticate_gateway()); + } +} diff --git a/crates/gpapi/src/gateway/hip.rs b/crates/gpapi/src/gateway/hip.rs deleted file mode 100644 index 652b103..0000000 --- a/crates/gpapi/src/gateway/hip.rs +++ /dev/null @@ -1,173 +0,0 @@ -use std::collections::HashMap; - -use log::{info, warn}; -use reqwest::Client; -use xmltree::Element; - -use crate::{ - gp_params::GpParams, - process::hip_launcher::HipLauncher, - utils::{normalize_server, xml::ElementExt}, -}; - -struct HipReporter<'a> { - server: String, - cookie: &'a str, - md5: &'a str, - csd_wrapper: &'a str, - gp_params: &'a GpParams, - client: Client, -} - -impl HipReporter<'_> { - async fn report(&self) -> anyhow::Result<()> { - let client_ip = self.retrieve_client_ip().await?; - - let hip_needed = match self.check_hip(&client_ip).await { - Ok(hip_needed) => hip_needed, - Err(err) => { - warn!("Failed to check HIP: {}", err); - return Ok(()); - } - }; - - if !hip_needed { - info!("HIP report not needed"); - return Ok(()); - } - - info!("HIP report needed, generating report..."); - let report = self.generate_report(&client_ip).await?; - - if let Err(err) = self.submit_hip(&client_ip, &report).await { - warn!("Failed to submit HIP report: {}", err); - } - - Ok(()) - } - - async fn retrieve_client_ip(&self) -> anyhow::Result { - let config_url = format!("{}/ssl-vpn/getconfig.esp", self.server); - let mut params: HashMap<&str, &str> = HashMap::new(); - - params.insert("client-type", "1"); - params.insert("protocol-version", "p1"); - params.insert("internal", "no"); - params.insert("ipv6-support", "yes"); - params.insert("clientos", self.gp_params.client_os()); - params.insert("hmac-algo", "sha1,md5,sha256"); - params.insert("enc-algo", "aes-128-cbc,aes-256-cbc"); - - if let Some(os_version) = self.gp_params.os_version() { - params.insert("os-version", os_version); - } - if let Some(client_version) = self.gp_params.client_version() { - params.insert("app-version", client_version); - } - - let params = merge_cookie_params(self.cookie, ¶ms)?; - - let res = self.client.post(&config_url).form(¶ms).send().await?; - let res_xml = res.error_for_status()?.text().await?; - let root = Element::parse(res_xml.as_bytes())?; - - // Get - let ip = root - .descendant_text("ip-address") - .ok_or_else(|| anyhow::anyhow!("ip-address not found"))?; - - Ok(ip.to_string()) - } - - async fn check_hip(&self, client_ip: &str) -> anyhow::Result { - let url = format!("{}/ssl-vpn/hipreportcheck.esp", self.server); - let mut params = HashMap::new(); - - params.insert("client-role", "global-protect-full"); - params.insert("client-ip", client_ip); - params.insert("md5", self.md5); - - let params = merge_cookie_params(self.cookie, ¶ms)?; - let res = self.client.post(&url).form(¶ms).send().await?; - let res_xml = res.error_for_status()?.text().await?; - - is_hip_needed(&res_xml) - } - - async fn generate_report(&self, client_ip: &str) -> anyhow::Result { - let launcher = HipLauncher::new(self.csd_wrapper) - .cookie(self.cookie) - .md5(self.md5) - .client_ip(client_ip) - .client_os(self.gp_params.client_os()) - .client_version(self.gp_params.client_version()); - - launcher.launch().await - } - - async fn submit_hip(&self, client_ip: &str, report: &str) -> anyhow::Result<()> { - let url = format!("{}/ssl-vpn/hipreport.esp", self.server); - - let mut params = HashMap::new(); - params.insert("client-role", "global-protect-full"); - params.insert("client-ip", client_ip); - params.insert("report", report); - - let params = merge_cookie_params(self.cookie, ¶ms)?; - let res = self.client.post(&url).form(¶ms).send().await?; - let res_xml = res.error_for_status()?.text().await?; - - info!("HIP check response: {}", res_xml); - - Ok(()) - } -} - -fn is_hip_needed(res_xml: &str) -> anyhow::Result { - let root = Element::parse(res_xml.as_bytes())?; - let hip_needed = root - .descendant_text("hip-report-needed") - .ok_or_else(|| anyhow::anyhow!("hip-report-needed not found"))?; - - Ok(hip_needed == "yes") -} - -fn merge_cookie_params(cookie: &str, params: &HashMap<&str, &str>) -> anyhow::Result> { - let cookie_params = serde_urlencoded::from_str::>(cookie)?; - let params = params - .iter() - .map(|(k, v)| (k.to_string(), v.to_string())) - .chain(cookie_params) - .collect::>(); - - Ok(params) -} - -// Compute md5 for fields except authcookie,preferred-ip,preferred-ipv6 -fn build_csd_token(cookie: &str) -> anyhow::Result { - let mut cookie_params = serde_urlencoded::from_str::>(cookie)?; - cookie_params.retain(|(k, _)| k != "authcookie" && k != "preferred-ip" && k != "preferred-ipv6"); - - let token = serde_urlencoded::to_string(cookie_params)?; - let md5 = format!("{:x}", md5::compute(token)); - - Ok(md5) -} - -pub async fn hip_report(gateway: &str, cookie: &str, csd_wrapper: &str, gp_params: &GpParams) -> anyhow::Result<()> { - let client = Client::try_from(gp_params)?; - let md5 = build_csd_token(cookie)?; - - info!("Submit HIP report md5: {}", md5); - - let reporter = HipReporter { - server: normalize_server(gateway)?, - cookie, - md5: &md5, - csd_wrapper, - gp_params, - client, - }; - - reporter.report().await -} diff --git a/crates/gpapi/src/gateway/login.rs b/crates/gpapi/src/gateway/login.rs index e9619a9..158edae 100644 --- a/crates/gpapi/src/gateway/login.rs +++ b/crates/gpapi/src/gateway/login.rs @@ -1,4 +1,4 @@ -use std::{borrow::Cow, collections::HashMap}; +use std::{borrow::Cow, net::UdpSocket}; use anyhow::bail; use log::{debug, info, warn}; @@ -9,7 +9,9 @@ use xmltree::Element; use crate::{ credential::Credential, error::PortalError, + gateway::GatewayLoginContext, gp_params::GpParams, + params::gateway_login::{self, GatewayLoginInput}, utils::{normalize_server, parse_gp_response, remove_url_scheme, xml::ElementExt}, }; @@ -19,7 +21,16 @@ pub enum GatewayLogin { } pub async fn gateway_login(gateway: &str, cred: &Credential, gp_params: &GpParams) -> anyhow::Result { - gateway_login_with_options(gateway, cred, gp_params, false).await + gateway_login_with_options(gateway, cred, gp_params, None, false).await +} + +pub async fn gateway_login_with_context( + gateway: &str, + cred: &Credential, + gp_params: &GpParams, + context: &GatewayLoginContext, +) -> anyhow::Result { + gateway_login_with_options(gateway, cred, gp_params, Some(context), false).await } pub async fn gateway_login_with_extend_lifetime( @@ -27,13 +38,14 @@ pub async fn gateway_login_with_extend_lifetime( cred: &Credential, gp_params: &GpParams, ) -> anyhow::Result { - gateway_login_with_options(gateway, cred, gp_params, true).await + gateway_login_with_options(gateway, cred, gp_params, None, true).await } async fn gateway_login_with_options( gateway: &str, cred: &Credential, gp_params: &GpParams, + context: Option<&GatewayLoginContext>, extend_lifetime: bool, ) -> anyhow::Result { let url = normalize_server(gateway)?; @@ -42,14 +54,33 @@ async fn gateway_login_with_options( let login_url = format!("{}/ssl-vpn/login.esp", url); let client = Client::try_from(gp_params)?; - let params = build_gateway_login_params(&gateway, cred, gp_params, extend_lifetime); + let client_ip = context.and_then(|context| { + context + .client_ip() + .map(|ip| ip.to_string()) + .or_else(|| detect_local_ipv4(context.host())) + }); + let request_params = gateway_login::build(&GatewayLoginInput { + gp_params, + cred, + gateway_host: &gateway, + context, + client_ip: client_ip.as_deref(), + extend_lifetime, + }); info!("Perform gateway login, user_agent: {}", gp_params.user_agent()); + log_gateway_login_context(context, client_ip.as_deref(), gp_params); - let res = client.post(&login_url).form(¶ms).send().await.map_err(|e| { - warn!("Network error: {:?}", e); - anyhow::anyhow!(PortalError::NetworkError(e)) - })?; + let res = client + .post(&login_url) + .form(&request_params.body) + .send() + .await + .map_err(|e| { + warn!("Network error: {:?}", e); + anyhow::anyhow!(PortalError::NetworkError(e)) + })?; let res = parse_gp_response(res).await.map_err(|err| { warn!("{err}"); @@ -80,31 +111,29 @@ async fn gateway_login_with_options( Ok(GatewayLogin::Cookie(cookie)) } -fn build_gateway_login_params( - gateway: &str, - cred: &Credential, - gp_params: &GpParams, - extend_lifetime: bool, -) -> HashMap { - let mut params = cred - .to_params() - .into_iter() - .map(|(key, value)| (key.to_string(), value.to_string())) - .collect::>(); +fn detect_local_ipv4(host: &str) -> Option { + let socket = UdpSocket::bind("0.0.0.0:0").ok()?; + socket.connect((host, 443)).ok()?; + let ip = socket.local_addr().ok()?.ip(); - params.extend( - gp_params - .to_params() - .into_iter() - .map(|(key, value)| (key.to_string(), value.to_string())), + if ip.is_ipv4() { Some(ip.to_string()) } else { None } +} + +fn log_gateway_login_context(context: Option<&GatewayLoginContext>, client_ip: Option<&str>, gp_params: &GpParams) { + let Some(context) = context else { + return; + }; + + info!( + "Gateway login context: host_present={}, gateway_name_present={}, connect_method_present={}, selection_type={}, internal={}, clientgpversion_present={}, client_ip_present={}", + !context.host().is_empty(), + !context.name().is_empty(), + context.connect_method().is_some(), + context.selection().as_login_param(), + context.kind().as_login_param(), + gp_params.client_version().is_some(), + client_ip.is_some() ); - params.insert("server".to_string(), gateway.to_string()); - - if extend_lifetime { - params.insert("extend-lifetime".to_string(), "true".to_string()); - } - - params } fn build_gateway_token(element: &Element, computer: &str) -> anyhow::Result { @@ -205,26 +234,6 @@ thisForm.inputStr.value = "5ef64e83000119ed";"#; assert_eq!(input_str, "5ef64e83000119ed"); } - #[test] - fn normal_gateway_login_params_do_not_extend_lifetime() { - let cred = Credential::Password(crate::credential::PasswordCredential::new("alice", "secret")); - let gp_params = GpParams::builder().build(); - - let params = build_gateway_login_params("vpn.example.com", &cred, &gp_params, false); - - assert!(!params.contains_key("extend-lifetime")); - } - - #[test] - fn extension_gateway_login_params_extend_lifetime() { - let cred = Credential::Password(crate::credential::PasswordCredential::new("alice", "secret")); - let gp_params = GpParams::builder().build(); - - let params = build_gateway_login_params("vpn.example.com", &cred, &gp_params, true); - - assert_eq!(params.get("extend-lifetime").map(String::as_str), Some("true")); - } - #[test] fn gateway_token_keeps_upstream_cookie_fields() { let res = r#" diff --git a/crates/gpapi/src/gateway/mod.rs b/crates/gpapi/src/gateway/mod.rs index 189ded2..dd09a7c 100644 --- a/crates/gpapi/src/gateway/mod.rs +++ b/crates/gpapi/src/gateway/mod.rs @@ -1,4 +1,3 @@ -pub mod hip; mod login; mod parse_gateways; pub mod session; @@ -23,10 +22,119 @@ pub(crate) struct PriorityRule { pub struct Gateway { pub(crate) name: String, pub(crate) address: String, + #[serde(default)] + pub(crate) kind: GatewayKind, pub(crate) priority: u32, pub(crate) priority_rules: Vec, } +#[derive(Debug, Serialize, Deserialize, Type, Clone, Copy, PartialEq, Eq)] +#[serde(rename_all = "camelCase")] +pub enum GatewayKind { + Internal, + External, +} + +impl GatewayKind { + pub fn as_login_param(self) -> &'static str { + match self { + GatewayKind::Internal => "yes", + GatewayKind::External => "no", + } + } +} + +impl Default for GatewayKind { + fn default() -> Self { + Self::External + } +} + +#[derive(Debug, Serialize, Deserialize, Type, Clone, Copy, PartialEq, Eq)] +#[serde(rename_all = "camelCase")] +pub enum GatewaySelection { + Auto, + Manual, +} + +impl GatewaySelection { + pub fn as_login_param(self) -> &'static str { + match self { + GatewaySelection::Auto => "auto", + GatewaySelection::Manual => "manual", + } + } +} + +impl Default for GatewaySelection { + fn default() -> Self { + Self::Auto + } +} + +#[derive(Debug, Clone)] +pub struct GatewayLoginContext { + host: String, + name: String, + kind: GatewayKind, + selection: GatewaySelection, + connect_method: Option, + client_ip: Option, +} + +impl GatewayLoginContext { + pub fn new(gateway: &Gateway, selection: GatewaySelection) -> Self { + let name = if gateway.name().is_empty() { + gateway.server() + } else { + gateway.name() + }; + + Self { + host: gateway.server().to_string(), + name: name.to_string(), + kind: gateway.kind(), + selection, + connect_method: None, + client_ip: None, + } + } + + pub fn with_connect_method(mut self, connect_method: Option<&str>) -> Self { + self.connect_method = connect_method.filter(|s| !s.is_empty()).map(|s| s.to_string()); + self + } + + pub fn with_client_ip(mut self, client_ip: Option) -> Self { + self.client_ip = client_ip.filter(|s| !s.is_empty()); + self + } + + pub(crate) fn host(&self) -> &str { + &self.host + } + + pub(crate) fn name(&self) -> &str { + &self.name + } + + pub(crate) fn kind(&self) -> GatewayKind { + self.kind + } + + pub(crate) fn selection(&self) -> GatewaySelection { + self.selection + } + + pub(crate) fn connect_method(&self) -> Option<&str> { + self.connect_method.as_deref() + } + + pub(crate) fn client_ip(&self) -> Option<&str> { + self.client_ip.as_deref() + } +} + impl Display for Gateway { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{} ({})", self.name, self.address) @@ -38,6 +146,7 @@ impl Gateway { Self { name, address, + kind: GatewayKind::External, priority: 0, priority_rules: vec![], } @@ -50,4 +159,28 @@ impl Gateway { pub fn server(&self) -> &str { &self.address } + + pub fn kind(&self) -> GatewayKind { + self.kind + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn deserializes_gateway_without_kind_as_external() { + let gateway: Gateway = serde_json::from_str( + r#"{ + "name": "US East", + "address": "us-east.example.com", + "priority": 1, + "priorityRules": [] + }"#, + ) + .unwrap(); + + assert_eq!(gateway.kind(), GatewayKind::External); + } } diff --git a/crates/gpapi/src/gateway/parse_gateways.rs b/crates/gpapi/src/gateway/parse_gateways.rs index 489b876..6d08d11 100644 --- a/crates/gpapi/src/gateway/parse_gateways.rs +++ b/crates/gpapi/src/gateway/parse_gateways.rs @@ -3,21 +3,28 @@ use xmltree::Element; use crate::utils::xml::ElementExt; -use super::{Gateway, PriorityRule}; +use super::{Gateway, GatewayKind, PriorityRule}; pub(crate) fn parse_gateways(element: &Element, prefer_internal: bool) -> Option> { let node_gateways = element.descendant("gateways")?; let internal_gateway_list = if prefer_internal { info!("Try to parse the internal gateways..."); - node_gateways.descendant("internal").and_then(|n| n.child("list")) + node_gateways + .descendant("internal") + .and_then(|n| n.child("list")) + .map(|list| (list, GatewayKind::Internal)) } else { None }; let gateway_list = internal_gateway_list.or_else(|| { info!("Try to parse the external gateways..."); - node_gateways.descendant("external").and_then(|n| n.child("list")) + node_gateways + .descendant("external") + .and_then(|n| n.child("list")) + .map(|list| (list, GatewayKind::External)) })?; + let (gateway_list, kind) = gateway_list; let gateways = gateway_list .children("entry") @@ -28,12 +35,13 @@ pub(crate) fn parse_gateways(element: &Element, prefer_internal: bool) -> Option let priority = parse_priority(gateway_item); let priority_rules = gateway_item .child("priority-rule") - .map(|n| parse_priority_rules(n)) + .map(parse_priority_rules) .unwrap_or_default(); Gateway { name, address, + kind, priority, priority_rules, } @@ -62,3 +70,54 @@ fn parse_priority(element: &Element) -> u32 { .and_then(|s| s.parse().ok()) .unwrap_or(u32::MAX) } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parse_external_gateways_marks_gateway_kind() { + let xml = r#" + + + + + + US_East + + + + + +"#; + let root = Element::parse(xml.as_bytes()).unwrap(); + + let gateways = parse_gateways(&root, false).unwrap(); + + assert_eq!(gateways[0].name(), "US_East"); + assert_eq!(gateways[0].server(), "us1.vpn.example.com"); + assert_eq!(gateways[0].kind(), GatewayKind::External); + } + + #[test] + fn parse_internal_gateways_marks_gateway_kind_when_preferred() { + let xml = r#" + + + + + + Internal + + + + + +"#; + let root = Element::parse(xml.as_bytes()).unwrap(); + + let gateways = parse_gateways(&root, true).unwrap(); + + assert_eq!(gateways[0].kind(), GatewayKind::Internal); + } +} diff --git a/crates/gpapi/src/gateway/session.rs b/crates/gpapi/src/gateway/session.rs index 381e913..f7e6eb6 100644 --- a/crates/gpapi/src/gateway/session.rs +++ b/crates/gpapi/src/gateway/session.rs @@ -13,7 +13,7 @@ use crate::{ gateway::login::{GatewayLogin, gateway_login_with_extend_lifetime}, gp_params::GpParams, session::SessionRequestArgs, - utils::{normalize_server, parse_gp_response, xml::ElementExt}, + utils::{normalize_server, parse_gp_response, request::create_identity, xml::ElementExt}, }; const EXTEND_SESSION_MESSAGE: &str = "User Session Extension"; @@ -120,16 +120,19 @@ fn validate_extension_login(login: GatewayLogin) -> anyhow::Result<()> { } fn build_session_client(args: &SessionRequestArgs) -> anyhow::Result { - let mut builder = GpParams::builder(); - builder.user_agent(args.user_agent().as_deref().unwrap_or_default()); - builder.client_os(args.os().unwrap_or_default()); - builder.os_version(args.os_version()); - builder.client_version(args.client_version()); - builder.certificate(args.certificate()); - builder.sslkey(args.sslkey()); - builder.key_password(args.key_password()); + let mut builder = Client::builder(); - Client::try_from(&builder.build()) + if let Some(user_agent) = args.user_agent() { + builder = builder.user_agent(user_agent); + } + + if let Some(cert) = args.certificate() { + info!("Using client certificate authentication..."); + let identity = create_identity(&cert, args.sslkey().as_deref(), args.key_password().as_deref())?; + builder = builder.identity(identity); + } + + Ok(builder.build()?) } fn parse_cookie_form(args: &SessionRequestArgs) -> anyhow::Result> { @@ -165,15 +168,25 @@ fn unix_timestamp() -> u64 { #[cfg(test)] mod tests { - use crate::{gp_params::ClientOs, session::SessionRequestArgs}; + use crate::{ + os_profile::{ClientOs, HostIdentity, OsProfile}, + session::SessionRequestArgs, + }; use super::*; fn build_session_args() -> SessionRequestArgs { + let profile = OsProfile::builder(ClientOs::Mac) + .host_identity(HostIdentity::new( + "test-mac".to_string(), + "host-id".to_string(), + "serial".to_string(), + "aa:bb:cc:dd:ee:ff".to_string(), + )) + .client_version("6.3.1-12".to_string()) + .build(); SessionRequestArgs::new("authcookie=AUTH&portal=vpn.example.com&user=alice&preferred-ip=10.0.0.10".to_string()) - .with_os(Some(ClientOs::Mac)) - .with_os_version(Some("macOS 15.0".to_string())) - .with_client_version(Some("6.3.1-12".to_string())) + .with_user_agent(profile.user_agent().to_string()) .with_disable_ipv6(true) } diff --git a/crates/gpapi/src/gp_params.rs b/crates/gpapi/src/gp_params.rs index 948a549..6cc5cbd 100644 --- a/crates/gpapi/src/gp_params.rs +++ b/crates/gpapi/src/gp_params.rs @@ -1,76 +1,59 @@ -use std::collections::HashMap; - -use common::constants::GP_USER_AGENT; use log::info; use reqwest::Client; use serde::{Deserialize, Serialize}; use specta::Type; -use crate::utils::host_utils; -use crate::utils::request::create_identity; +use crate::{ + os_profile::{ClientOs, HostIdentity, OsProfile}, + utils::request::create_identity, +}; -#[derive(Debug, Serialize, Deserialize, Clone, Type, Default)] -pub enum ClientOs { - #[cfg_attr(not(target_os = "macos"), default)] - Linux, - Windows, - #[cfg_attr(target_os = "macos", default)] - Mac, +#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Type, Default)] +#[serde(rename_all = "lowercase")] +pub enum CscMode { + #[default] + Auto, + Yes, + No, } -impl From<&str> for ClientOs { - fn from(os: &str) -> Self { - match os { - "Linux" => ClientOs::Linux, - "Windows" => ClientOs::Windows, - "Mac" => ClientOs::Mac, - _ => ClientOs::Linux, - } - } -} - -impl ClientOs { - pub fn as_str(&self) -> &str { +impl CscMode { + pub fn effective(self, client_os: ClientOs) -> bool { match self { - ClientOs::Linux => "Linux", - ClientOs::Windows => "Windows", - ClientOs::Mac => "Mac", + CscMode::Auto => client_os.default_csc_support(), + CscMode::Yes => true, + CscMode::No => false, } } - pub fn to_openconnect_os(&self) -> &str { + pub fn as_str(self) -> &'static str { match self { - ClientOs::Linux => "linux", - ClientOs::Windows => "win", - ClientOs::Mac => "mac-intel", + CscMode::Auto => "auto", + CscMode::Yes => "yes", + CscMode::No => "no", } } } -#[derive(Debug, Serialize, Deserialize, Type, Default, Clone)] +#[derive(Debug, Clone)] pub struct GpParams { - is_gateway: bool, - user_agent: String, - client_os: ClientOs, - os_version: Option, - client_version: Option, - computer: String, - // Endpoint identifier. PAN-OS binds the portal's authentication-override cookie - // (portal-userauthcookie) to this value; without it the portal returns an empty - // cookie and the gateway then rejects SAML with saml-auth-status=-1 (issue #491). - host_id: String, + os_profile: OsProfile, + // Transport ignore_tls_errors: bool, certificate: Option, sslkey: Option, key_password: Option, - // Used for MFA + // Feature + csc_mode: CscMode, + // Per-request state + is_gateway: bool, input_str: Option, otp: Option, } impl GpParams { - pub fn builder() -> GpParamsBuilder { - GpParamsBuilder::new() + pub fn builder(os_profile: OsProfile) -> GpParamsBuilder { + GpParamsBuilder::new(os_profile) } pub(crate) fn is_gateway(&self) -> bool { @@ -82,27 +65,63 @@ impl GpParams { } pub(crate) fn user_agent(&self) -> &str { - &self.user_agent - } - - pub(crate) fn computer(&self) -> &str { - &self.computer + self.os_profile.user_agent() } pub fn ignore_tls_errors(&self) -> bool { self.ignore_tls_errors } + // ─── OsProfile accessor ───────────────────────────────────────────────── + + pub fn os_profile(&self) -> &OsProfile { + &self.os_profile + } + + // ─── Delegated identity accessors ──────────────────────────────────────── + pub fn client_os(&self) -> &str { - self.client_os.as_str() + self.os_profile.client_os().as_str() + } + + pub(crate) fn computer(&self) -> &str { + self.os_profile.computer() } pub fn os_version(&self) -> Option<&str> { - self.os_version.as_deref() + Some(self.os_profile.os_version()) } pub fn client_version(&self) -> Option<&str> { - self.client_version.as_deref() + Some(self.os_profile.client_version()) + } + + pub(crate) fn host_id(&self) -> &str { + self.os_profile.host_id() + } + + pub(crate) fn serialno(&self) -> &str { + self.os_profile.serialno() + } + + pub fn host_identity(&self) -> &HostIdentity { + self.os_profile.host_identity() + } + + // ─── Feature accessors ────────────────────────────────────────────────── + + pub(crate) fn effective_csc_support(&self) -> bool { + self.csc_mode.effective(self.os_profile.client_os()) + } + + pub fn csc_mode(&self) -> CscMode { + self.csc_mode + } + + // ─── Per-request state ────────────────────────────────────────────────── + + pub(crate) fn input_str(&self) -> Option<&str> { + self.input_str.as_deref() } pub fn set_input_str(&mut self, input_str: &str) { @@ -113,48 +132,15 @@ impl GpParams { self.otp = Some(otp.to_string()); } - pub(crate) fn to_params(&self) -> HashMap<&str, &str> { - let mut params: HashMap<&str, &str> = HashMap::new(); - let client_os = self.client_os.as_str(); - - // Common params - params.insert("prot", "https:"); - params.insert("jnlpReady", "jnlpReady"); - params.insert("ok", "Login"); - params.insert("direct", "yes"); - params.insert("ipv6-support", "yes"); - params.insert("clientVer", "4100"); - params.insert("clientos", client_os); - params.insert("computer", &self.computer); - params.insert("host-id", &self.host_id); - - // MFA - params.insert("inputStr", self.input_str.as_deref().unwrap_or_default()); - if let Some(otp) = &self.otp { - params.insert("passwd", otp); - } - - if let Some(os_version) = &self.os_version { - params.insert("os-version", os_version); - } - - // NOTE: Do not include clientgpversion for now - // if let Some(client_version) = &self.client_version { - // params.insert("clientgpversion", client_version); - // } - - params + pub(crate) fn otp(&self) -> Option<&str> { + self.otp.as_deref() } } pub struct GpParamsBuilder { is_gateway: bool, - user_agent: String, - client_os: ClientOs, - os_version: Option, - client_version: Option, - computer: String, - host_id: String, + os_profile: OsProfile, + csc_mode: CscMode, ignore_tls_errors: bool, certificate: Option, sslkey: Option, @@ -162,18 +148,11 @@ pub struct GpParamsBuilder { } impl GpParamsBuilder { - pub fn new() -> Self { - let computer = whoami::fallible::hostname().unwrap_or_else(|_| String::from("localhost")); - + pub fn new(os_profile: OsProfile) -> Self { Self { is_gateway: false, - user_agent: GP_USER_AGENT.to_string(), - client_os: ClientOs::Linux, - os_version: Default::default(), - client_version: Default::default(), - computer, - // Stable per-machine UUID (same derivation the HIP report uses) - host_id: host_utils::derive_uuid(&[]), + os_profile, + csc_mode: Default::default(), ignore_tls_errors: false, certificate: Default::default(), sslkey: Default::default(), @@ -186,33 +165,8 @@ impl GpParamsBuilder { self } - pub fn user_agent(&mut self, user_agent: &str) -> &mut Self { - self.user_agent = user_agent.to_string(); - self - } - - pub fn client_os(&mut self, client_os: ClientOs) -> &mut Self { - self.client_os = client_os; - self - } - - pub fn os_version>>(&mut self, os_version: T) -> &mut Self { - self.os_version = os_version.into(); - self - } - - pub fn client_version>>(&mut self, client_version: T) -> &mut Self { - self.client_version = client_version.into(); - self - } - - pub fn computer(&mut self, computer: &str) -> &mut Self { - self.computer = computer.to_string(); - self - } - - pub fn host_id(&mut self, host_id: &str) -> &mut Self { - self.host_id = host_id.to_string(); + pub fn csc_mode(&mut self, csc_mode: CscMode) -> &mut Self { + self.csc_mode = csc_mode; self } @@ -238,36 +192,26 @@ impl GpParamsBuilder { pub fn build(&self) -> GpParams { GpParams { - is_gateway: self.is_gateway, - user_agent: self.user_agent.clone(), - client_os: self.client_os.clone(), - os_version: self.os_version.clone(), - client_version: self.client_version.clone(), - computer: self.computer.clone(), - host_id: self.host_id.clone(), + os_profile: self.os_profile.clone(), ignore_tls_errors: self.ignore_tls_errors, certificate: self.certificate.clone(), sslkey: self.sslkey.clone(), key_password: self.key_password.clone(), + csc_mode: self.csc_mode, + is_gateway: self.is_gateway, input_str: Default::default(), otp: Default::default(), } } } -impl Default for GpParamsBuilder { - fn default() -> Self { - Self::new() - } -} - impl TryFrom<&GpParams> for Client { type Error = anyhow::Error; fn try_from(value: &GpParams) -> Result { let mut builder = Client::builder() .danger_accept_invalid_certs(value.ignore_tls_errors) - .user_agent(&value.user_agent); + .user_agent(value.user_agent()); if let Some(cert) = value.certificate.as_deref() { info!("Using client certificate authentication..."); @@ -279,3 +223,327 @@ impl TryFrom<&GpParams> for Client { Ok(client) } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::os_profile::runtime_client_os; + + fn profile(client_os: ClientOs) -> OsProfile { + OsProfile::builder(client_os).build() + } + + #[test] + fn default_client_versions_match_observed_official_clients() { + assert_eq!(ClientOs::Linux.default_client_version(), "6.3.3-619"); + assert_eq!(ClientOs::Windows.default_client_version(), "6.3.3-650"); + assert_eq!(ClientOs::Mac.default_client_version(), "6.3.3-915"); + } + + #[test] + fn builder_uses_os_profile_client_version_when_unspecified() { + let params = GpParams::builder(profile(ClientOs::Mac)).build(); + + assert_eq!(params.client_version(), Some("6.3.3-915")); + } + + #[test] + fn builder_keeps_explicit_client_version() { + let profile = OsProfile::builder(ClientOs::Mac) + .client_version("6.2.9-1".to_string()) + .build(); + let params = GpParams::builder(profile).build(); + + assert_eq!(params.client_version(), Some("6.2.9-1")); + } + + #[test] + fn builder_uses_os_profile_version_when_unspecified() { + let params = GpParams::builder(profile(ClientOs::Mac)).build(); + let default_os_version = ClientOs::Mac.default_os_version(); + + assert_eq!(params.os_version(), Some(default_os_version.as_str())); + } + + #[test] + fn os_profile_accessor_returns_profile() { + let params = GpParams::builder(profile(ClientOs::Linux)).build(); + let profile = params.os_profile(); + + assert_eq!(profile.client_os(), ClientOs::Linux); + } + + #[test] + fn delegates_identity_to_os_profile() { + let identity = HostIdentity::new( + "test-computer".to_string(), + "test-host-id".to_string(), + "test-serial".to_string(), + "aa:bb:cc:dd:ee:ff".to_string(), + ); + let params = GpParams::builder(OsProfile::builder(ClientOs::Linux).host_identity(identity).build()).build(); + + assert!(!params.host_id().is_empty()); + assert_eq!(params.host_identity().host_id(), "test-host-id"); + assert_eq!(params.host_identity().serialno(), "test-serial"); + assert_eq!(params.host_identity().mac_addr(), "aa:bb:cc:dd:ee:ff"); + } + + #[test] + fn builder_accepts_pre_built_os_profile() { + let profile = OsProfile::builder(ClientOs::Mac) + .computer_name_override("MyMac") + .build(); + let expected_os_version = profile.os_version().to_string(); + + let params = GpParams::builder(profile).build(); + + assert_eq!(params.computer(), "MyMac"); + assert_eq!(params.os_version(), Some(expected_os_version.as_str())); + assert_eq!(params.client_os(), "Mac"); + } + + // ─── Delegation tests (Requirement 4.1) ────────────────────────────────── + + #[test] + fn delegates_computer_to_os_profile() { + let profile = OsProfile::builder(ClientOs::Mac) + .computer_name_override("MyComputer") + .build(); + let params = GpParams::builder(profile).build(); + + assert_eq!(params.computer(), "MyComputer"); + assert_eq!(params.computer(), params.os_profile().computer()); + } + + #[test] + fn delegates_client_os_string_to_os_profile() { + let params = GpParams::builder(profile(ClientOs::Windows)).build(); + + assert_eq!(params.client_os(), "Windows"); + assert_eq!(params.client_os(), params.os_profile().client_os().as_str()); + } + + #[test] + fn delegates_host_identity_to_os_profile() { + let identity = HostIdentity::new( + "delegated-computer".to_string(), + "delegated-host".to_string(), + "delegated-serial".to_string(), + "01:02:03:04:05:06".to_string(), + ); + let params = GpParams::builder( + OsProfile::builder(ClientOs::Linux) + .host_identity(identity.clone()) + .build(), + ) + .build(); + + // The accessor returns the same HostIdentity stored on the inner OsProfile + assert_eq!(params.host_identity(), params.os_profile().host_identity()); + assert_eq!(params.host_identity().host_id(), "delegated-host"); + assert_eq!(params.host_identity().serialno(), "delegated-serial"); + assert_eq!(params.host_identity().mac_addr(), "01:02:03:04:05:06"); + } + + // ─── Builder constructs OsProfile from individual fields (Req 4.1) ─────── + + #[test] + fn builder_uses_provided_os_profile() { + let identity = HostIdentity::new( + "identity-host".to_string(), + "host-7".to_string(), + "serial-7".to_string(), + "aa:bb:cc:11:22:33".to_string(), + ); + let profile = OsProfile::builder(ClientOs::Linux) + .computer_name_override("linux-host") + .client_version("6.0.0-1".to_string()) + .host_identity(identity) + .build(); + let params = GpParams::builder(profile).build(); + + let profile = params.os_profile(); + assert_eq!(profile.client_os(), ClientOs::Linux); + assert_eq!(profile.computer(), "linux-host"); + assert_eq!(profile.os_version(), ClientOs::Linux.default_os_version()); + assert_eq!(profile.client_version(), "6.0.0-1"); + assert_eq!(profile.host_identity().host_id(), "host-7"); + assert_eq!(profile.host_identity().serialno(), "serial-7"); + assert_eq!(profile.host_identity().mac_addr(), "aa:bb:cc:11:22:33"); + assert!(!profile.host_id().is_empty()); + assert!(!profile.serialno().is_empty()); + assert!(!profile.mac_addr().is_empty()); + } + + // ─── TryFrom<&GpParams> for Client (Requirement 4.7) ───────────────────── + + #[test] + fn try_from_gp_params_constructs_reqwest_client() { + let params = GpParams::builder(profile(runtime_client_os())).build(); + let client = Client::try_from(¶ms); + + assert!(client.is_ok(), "Client construction should succeed with default params"); + } + + #[test] + fn try_from_gp_params_with_ignore_tls_errors() { + let params = GpParams::builder(profile(runtime_client_os())) + .ignore_tls_errors(true) + .build(); + let client = Client::try_from(¶ms); + + assert!( + client.is_ok(), + "Client should construct successfully with ignore_tls_errors enabled" + ); + } + + #[test] + fn try_from_gp_params_with_custom_user_agent() { + let params = GpParams::builder( + OsProfile::builder(runtime_client_os()) + .user_agent("custom-agent/1.0") + .build(), + ) + .build(); + let client = Client::try_from(¶ms); + + assert!(client.is_ok(), "Client should construct with a custom user agent"); + } + + #[test] + fn try_from_gp_params_with_invalid_certificate_returns_error() { + // When a certificate path is provided but the file does not exist or is malformed, + // Client construction should fail rather than silently succeed. + let params = GpParams::builder(profile(runtime_client_os())) + .certificate("/nonexistent/path/to/cert.pem".to_string()) + .build(); + let client = Client::try_from(¶ms); + + assert!( + client.is_err(), + "Client construction should fail when certificate path is invalid" + ); + } + + // ─── User Agent Delegation Tests (Requirements 3.2, 3.3, 3.4, 3.5, 3.6) ── + + #[test] + fn user_agent_delegates_to_os_profile_for_default_build() { + let params = GpParams::builder(profile(runtime_client_os())).build(); + + assert_eq!( + params.user_agent(), + params.os_profile().user_agent(), + "GpParams::user_agent() should delegate to os_profile().user_agent()" + ); + } + + #[test] + fn builder_uses_profile_user_agent() { + let params = GpParams::builder(OsProfile::builder(runtime_client_os()).user_agent("custom").build()).build(); + + assert_eq!(params.user_agent(), "custom"); + } + + #[test] + fn builder_os_profile_without_user_agent_delegates_to_profile() { + let profile = OsProfile::builder(ClientOs::Mac).client_version("6.1.0").build(); + let expected_ua = profile.user_agent().to_string(); + + let params = GpParams::builder(profile).build(); + + assert_eq!(params.user_agent(), expected_ua); + } + + #[test] + fn profile_user_agent_override_wins_before_gp_params_construction() { + let profile = OsProfile::builder(ClientOs::Mac) + .client_version("6.1.0") + .user_agent("override") + .build(); + let params = GpParams::builder(profile).build(); + + assert_eq!(params.user_agent(), "override"); + } + + #[test] + fn try_from_gp_params_succeeds_with_delegated_user_agent() { + let params = GpParams::builder( + OsProfile::builder(runtime_client_os()) + .user_agent("delegated-agent/2.0") + .build(), + ) + .build(); + let client = Client::try_from(¶ms); + + assert!( + client.is_ok(), + "TryFrom<&GpParams> for Client should succeed with delegated user_agent" + ); + } + + // ─── Property-Based Tests ───────────────────────────────────────────────── + + mod prop_tests { + use super::*; + use proptest::prelude::*; + + fn arb_client_os() -> impl Strategy { + prop_oneof![Just(ClientOs::Linux), Just(ClientOs::Windows), Just(ClientOs::Mac),] + } + + // **Validates: Requirements 3.2, 3.4** + // + // Property 4: GpParams delegates user_agent to OsProfile + // For any GpParams instance (whether built from individual fields or from a + // pre-built OsProfile, with or without a user_agent override), + // gp_params.user_agent() == gp_params.os_profile().user_agent(). + proptest! { + #![proptest_config(ProptestConfig::with_cases(100))] + #[test] + fn gp_params_delegates_user_agent_to_os_profile( + client_os in arb_client_os(), + user_agent_override in proptest::option::of("[a-zA-Z0-9/_.-]{1,30}"), + ) { + let identity = HostIdentity::new( + "prop-computer".to_string(), + "prop-host".to_string(), + "prop-serial".to_string(), + "aa:bb:cc:dd:ee:ff".to_string(), + ); + + let mut profile_builder = OsProfile::builder(client_os) + .client_version("6.1.0-1") + .computer_name_override("test-host") + .host_identity(identity); + if let Some(ref ua) = user_agent_override { + profile_builder = profile_builder.user_agent(ua); + } + let params = GpParams::builder(profile_builder.build()).build(); + + prop_assert_eq!( + params.user_agent(), + params.os_profile().user_agent(), + "GpParams::user_agent() must always equal GpParams::os_profile().user_agent()" + ); + } + } + + // **Validates: Requirements 3.3** + // + // Property 5: GpParams uses the user agent from OsProfile. + // For any non-empty string set via OsProfileBuilder::user_agent(), the resulting + // GpParams::user_agent() returns that override value. + proptest! { + #[test] + fn builder_uses_profile_user_agent(ua in "[^\\s]{1,50}") { + let profile = OsProfile::builder(runtime_client_os()).user_agent(&ua).build(); + let params = GpParams::builder(profile).build(); + + prop_assert_eq!(params.user_agent(), ua.as_str()); + } + } + } +} diff --git a/crates/gpapi/src/lib.rs b/crates/gpapi/src/lib.rs index c318242..c953202 100644 --- a/crates/gpapi/src/lib.rs +++ b/crates/gpapi/src/lib.rs @@ -4,6 +4,8 @@ pub mod credential; pub mod error; pub mod gateway; pub mod gp_params; +pub mod os_profile; +pub mod params; pub mod portal; pub mod process; pub mod service; diff --git a/crates/gpapi/src/os_profile/host_identity.rs b/crates/gpapi/src/os_profile/host_identity.rs new file mode 100644 index 0000000..f14a3f4 --- /dev/null +++ b/crates/gpapi/src/os_profile/host_identity.rs @@ -0,0 +1,581 @@ +use serde::{Deserialize, Serialize}; +use specta::Type; + +use super::{ClientOs, serial_number}; +use platform::RuntimeNativeHostIdentity; + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Type)] +#[serde(rename_all = "camelCase")] +pub struct HostIdentity { + computer: String, + host_id: String, + #[serde(rename = "serialno")] + serial_number: String, + #[serde(rename = "macAddr")] + mac_address: String, +} + +impl HostIdentity { + pub fn collect() -> Self { + Self::collect_with_host_id(None) + } + + pub(crate) fn collect_with_host_id(host_id: Option<&str>) -> Self { + RuntimeNativeHostIdentity::collect(host_id).into_host_identity() + } + + #[cfg(test)] + pub(crate) fn new(computer: String, host_id: String, serialno: String, mac_addr: String) -> Self { + Self::from_parts(computer, host_id, serialno, mac_addr) + } + + pub(crate) fn from_parts(computer: String, host_id: String, serialno: String, mac_addr: String) -> Self { + let host_id = non_empty(host_id, fallback_host_id()); + let computer = non_empty(computer, fallback_hostname()); + let serial_number = non_empty(serialno, derive_serial_number(&host_id)); + let mac_address = normalize_mac_colon(&mac_addr).unwrap_or_else(|| derive_mac_address(&host_id)); + + Self { + computer, + host_id, + serial_number, + mac_address, + } + } + + pub fn computer(&self) -> &str { + &self.computer + } + + pub fn host_id(&self) -> &str { + &self.host_id + } + + pub fn serialno(&self) -> &str { + &self.serial_number + } + + pub fn mac_addr(&self) -> &str { + &self.mac_address + } + + pub fn with_computer(mut self, computer: String) -> Self { + if !computer.trim().is_empty() { + self.computer = computer; + } + self + } + + pub(crate) fn runtime_os() -> ClientOs { + RuntimeNativeHostIdentity::runtime_os() + } +} + +pub(super) fn fallback_hostname() -> String { + whoami::hostname().unwrap_or_else(|_| String::from("localhost")) +} + +#[derive(Debug, Clone)] +struct NativeHostIdentitySnapshot { + host_id: String, + computer: String, + serial_number: Option, + mac_address: Option, +} + +impl NativeHostIdentitySnapshot { + fn into_host_identity(self) -> HostIdentity { + let host_id = non_empty(self.host_id, fallback_host_id()); + HostIdentity::from_parts( + self.computer, + host_id.clone(), + self.serial_number.unwrap_or_else(|| derive_serial_number(&host_id)), + self.mac_address.unwrap_or_else(|| derive_mac_address(&host_id)), + ) + } +} + +fn non_empty(value: String, fallback: String) -> String { + if value.trim().is_empty() { fallback } else { value } +} + +fn fallback_host_id() -> String { + derive_uuid_from_seed(&fallback_hostname(), &["runtime-host-id"]) +} + +fn resolve_host_id(host_id_override: Option<&str>, collect: impl FnOnce() -> String) -> String { + host_id_override + .filter(|value| !value.trim().is_empty()) + .map(str::to_string) + .unwrap_or_else(collect) +} + +fn derive_serial_number(host_id: &str) -> String { + serial_number::vmware_from_uuid(host_id).unwrap_or_else(|| { + let uuid = derive_uuid_from_seed(host_id, &["runtime-serialno"]); + serial_number::vmware_from_uuid(&uuid).expect("derived UUID should format as VMware serial") + }) +} + +fn derive_mac_address(host_id: &str) -> String { + let uuid = derive_uuid_from_seed(host_id, &["runtime-mac"]); + let compact = uuid.replace('-', ""); + let bytes = compact + .as_bytes() + .chunks(2) + .take(6) + .map(|chunk| std::str::from_utf8(chunk).unwrap_or("00").to_lowercase()) + .collect::>(); + + bytes.join(":") +} + +fn normalize_mac_colon(value: &str) -> Option { + let compact = value + .trim() + .replace('-', ":") + .split(':') + .map(|part| part.to_lowercase()) + .collect::>(); + let valid = compact.len() == 6 + && compact + .iter() + .all(|part| part.len() == 2 && part.chars().all(|ch| ch.is_ascii_hexdigit())); + + valid.then(|| compact.join(":")) +} + +fn primary_mac_colon() -> Option { + netdev::get_default_interface() + .ok() + .and_then(|iface| iface.mac_addr.map(|mac| mac.address())) + .and_then(|mac| normalize_mac_colon(&mac)) +} + +fn derive_uuid_from_seed(seed: &str, parts: &[&str]) -> String { + use uuid::Uuid; + + let namespace = Uuid::NAMESPACE_DNS; + let name = format!("{}-{}", seed, parts.join("-")); + + Uuid::new_v5(&namespace, name.as_bytes()).hyphenated().to_string() +} + +#[cfg(target_os = "macos")] +mod platform { + use std::process::Command; + + use super::{ + ClientOs, NativeHostIdentitySnapshot, derive_mac_address, fallback_hostname, normalize_mac_colon, + primary_mac_colon, resolve_host_id, + }; + + pub(super) struct RuntimeNativeHostIdentity; + + impl RuntimeNativeHostIdentity { + pub(super) fn runtime_os() -> ClientOs { + ClientOs::Mac + } + + pub(super) fn collect(host_id_override: Option<&str>) -> NativeHostIdentitySnapshot { + let native_mac = macos_builtin_mac().or_else(primary_mac_colon); + let host_id = resolve_host_id(host_id_override, || { + native_mac + .clone() + .unwrap_or_else(|| derive_mac_address(&fallback_hostname())) + }); + NativeHostIdentitySnapshot { + host_id, + computer: macos_computer_name().unwrap_or_else(fallback_hostname), + serial_number: collect_macos_serial_number(), + mac_address: native_mac, + } + } + } + + fn macos_computer_name() -> Option { + ["ComputerName", "LocalHostName"].into_iter().find_map(|name| { + let output = Command::new("scutil").args(["--get", name]).output().ok()?; + if !output.status.success() { + return None; + } + + String::from_utf8(output.stdout) + .ok() + .map(|value| value.trim().to_string()) + .filter(|value| !value.is_empty()) + }) + } + + fn macos_builtin_mac() -> Option { + macos_networksetup_mac("Wi-Fi") + .or_else(|| macos_networksetup_mac("AirPort")) + .or_else(macos_system_profiler_wifi_mac) + } + + fn macos_networksetup_mac(port_name: &str) -> Option { + let output = Command::new("networksetup") + .arg("-listallhardwareports") + .output() + .ok()?; + if !output.status.success() { + return None; + } + + let stdout = String::from_utf8(output.stdout).ok()?; + let mut in_port = false; + for line in stdout.lines() { + if let Some(port) = line.strip_prefix("Hardware Port: ") { + in_port = port == port_name; + continue; + } + + if in_port && let Some(mac) = line.strip_prefix("Ethernet Address: ") { + return normalize_mac_colon(mac); + } + } + + None + } + + fn macos_system_profiler_wifi_mac() -> Option { + let output = Command::new("system_profiler").arg("SPNetworkDataType").output().ok()?; + if !output.status.success() { + return None; + } + + let stdout = String::from_utf8(output.stdout).ok()?; + let mut in_wifi = false; + for line in stdout.lines() { + let trimmed = line.trim(); + if trimmed.ends_with(':') && !trimmed.starts_with("MAC Address:") { + in_wifi = trimmed == "Wi-Fi:" || trimmed == "AirPort:"; + continue; + } + + if in_wifi && let Some(mac) = trimmed.strip_prefix("MAC Address: ") { + return normalize_mac_colon(mac); + } + } + + None + } + + fn collect_macos_serial_number() -> Option { + let output = Command::new("ioreg") + .args(["-rd1", "-c", "IOPlatformExpertDevice"]) + .output() + .ok()?; + let stdout = String::from_utf8(output.stdout).ok()?; + + stdout.lines().find_map(|line| { + line + .split_once("IOPlatformSerialNumber") + .and_then(|(_, value)| value.split_once('=')) + .map(|(_, value)| value.trim().trim_matches('"').to_string()) + .filter(|value| !value.is_empty()) + }) + } +} + +#[cfg(target_os = "windows")] +mod platform { + use std::process::Command; + + use super::{ClientOs, NativeHostIdentitySnapshot, fallback_hostname, primary_mac_colon, resolve_host_id}; + + pub(super) struct RuntimeNativeHostIdentity; + + impl RuntimeNativeHostIdentity { + pub(super) fn runtime_os() -> ClientOs { + ClientOs::Windows + } + + pub(super) fn collect(host_id_override: Option<&str>) -> NativeHostIdentitySnapshot { + let host_id = resolve_host_id(host_id_override, Self::host_id); + NativeHostIdentitySnapshot { + host_id, + computer: fallback_hostname(), + serial_number: collect_windows_serial_number(), + mac_address: primary_mac_colon(), + } + } + + fn host_id() -> String { + windows_machine_seed().unwrap_or_else(fallback_hostname) + } + } + + fn collect_windows_serial_number() -> Option { + let output = Command::new("wmic") + .args(["bios", "get", "serialnumber"]) + .output() + .ok()?; + let stdout = String::from_utf8(output.stdout).ok()?; + + stdout + .lines() + .map(str::trim) + .filter(|line| !line.is_empty() && *line != "SerialNumber") + .map(str::to_string) + .next() + } + + fn windows_machine_seed() -> Option { + collect_windows_csproduct_uuid().or_else(collect_windows_machine_guid) + } + + fn collect_windows_csproduct_uuid() -> Option { + let output = Command::new("wmic").args(["csproduct", "get", "uuid"]).output().ok()?; + let stdout = String::from_utf8(output.stdout).ok()?; + + stdout + .lines() + .map(str::trim) + .filter(|line| !line.is_empty() && *line != "UUID") + .map(str::to_string) + .next() + } + + fn collect_windows_machine_guid() -> Option { + let output = Command::new("reg") + .args(["query", r"HKLM\SOFTWARE\Microsoft\Cryptography", "/v", "MachineGuid"]) + .output() + .ok()?; + if !output.status.success() { + return None; + } + let stdout = String::from_utf8(output.stdout).ok()?; + + stdout.lines().find_map(|line| { + let mut parts = line.split_whitespace(); + if parts.next()? != "MachineGuid" { + return None; + } + + parts.last().map(str::to_string) + }) + } +} + +#[cfg(not(any(target_os = "macos", target_os = "windows")))] +mod platform { + use super::{ + ClientOs, NativeHostIdentitySnapshot, derive_uuid_from_seed, fallback_hostname, primary_mac_colon, resolve_host_id, + }; + use log::debug; + + pub(super) struct RuntimeNativeHostIdentity; + + impl RuntimeNativeHostIdentity { + pub(super) fn runtime_os() -> ClientOs { + ClientOs::Linux + } + + pub(super) fn collect(host_id_override: Option<&str>) -> NativeHostIdentitySnapshot { + if let Some(host_id) = host_id_override.filter(|value| !value.trim().is_empty()) { + debug!("Runtime host-id source: explicit override ({})", host_id); + } + let host_id = resolve_host_id(host_id_override, Self::host_id); + NativeHostIdentitySnapshot { + host_id, + computer: fallback_hostname(), + serial_number: collect_linux_serial_number(), + mac_address: primary_mac_colon(), + } + } + + fn host_id() -> String { + if let Some(host_id) = collect_linux_product_uuid() { + debug!("Runtime host-id source: /sys/class/dmi/id/product_uuid ({})", host_id); + return host_id; + } + + let (source_name, source) = collect_linux_fallback_seed().unwrap_or_else(|| { + let hostname = fallback_hostname(); + ("hostname", hostname) + }); + let host_id = derive_uuid_from_seed(&source, &[]); + debug!("Runtime host-id source: derived from {} ({})", source_name, host_id); + host_id + } + } + + fn collect_linux_product_uuid() -> Option { + read_linux_identity_file("/sys/class/dmi/id/product_uuid").and_then(|value| normalize_uuid(&value)) + } + + fn normalize_uuid(value: &str) -> Option { + uuid::Uuid::parse_str(value.trim()) + .ok() + .map(|uuid| uuid.hyphenated().to_string()) + } + + fn collect_linux_fallback_seed() -> Option<(&'static str, String)> { + ["/etc/machine-id", "/var/lib/dbus/machine-id"] + .iter() + .find_map(|path| read_linux_identity_file(path).map(|value| (*path, value))) + } + + fn read_linux_identity_file(path: &str) -> Option { + std::fs::read_to_string(path) + .ok() + .map(|value| value.trim().to_string()) + .filter(|value| is_usable_linux_identity_value(value)) + } + + fn is_usable_linux_identity_value(value: &str) -> bool { + !value.is_empty() && value != "None" && value != "To Be Filled By O.E.M." + } + + fn collect_linux_serial_number() -> Option { + ["/sys/class/dmi/id/product_serial", "/sys/class/dmi/id/product_uuid"] + .iter() + .find_map(|path| read_linux_identity_file(path)) + } + + #[cfg(test)] + mod tests { + use super::*; + + #[test] + fn normalize_uuid_preserves_real_uuid_identity() { + assert_eq!( + normalize_uuid("5A784D56-6461-19AC-9EA9-D36A3B9C6CEF"), + Some("5a784d56-6461-19ac-9ea9-d36a3b9c6cef".to_string()) + ); + assert_eq!(normalize_uuid("not-a-uuid"), None); + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn collect_produces_non_empty_identity() { + let identity = HostIdentity::collect(); + + assert!(!identity.computer().is_empty()); + assert!(!identity.host_id().is_empty()); + assert!(!identity.serialno().is_empty()); + assert!(!identity.mac_addr().is_empty()); + assert_mac(identity.mac_addr(), ':'); + } + + #[test] + fn collect_with_host_id_uses_provided_host_id() { + let identity = HostIdentity::collect_with_host_id(Some("provided-host-id")); + + assert_eq!(identity.host_id(), "provided-host-id"); + assert!(!identity.computer().is_empty()); + assert!(!identity.serialno().is_empty()); + assert!(!identity.mac_addr().is_empty()); + } + + #[test] + fn collect_with_blank_host_id_falls_back_to_runtime_host_id() { + let identity = HostIdentity::collect_with_host_id(Some(" ")); + + assert!(!identity.host_id().is_empty()); + assert_ne!(identity.host_id(), " "); + } + + #[test] + fn resolve_host_id_does_not_collect_when_override_is_provided() { + let host_id = resolve_host_id(Some("provided-host-id"), || { + panic!("runtime host id should not be collected") + }); + + assert_eq!(host_id, "provided-host-id"); + } + + #[test] + fn host_identity_normalizes_mac_to_lowercase_colon_format() { + let identity = HostIdentity::new( + "computer".to_string(), + "host-id".to_string(), + "serial-number".to_string(), + "AA-BB-CC-DD-EE-FF".to_string(), + ); + + assert_eq!(identity.mac_addr(), "aa:bb:cc:dd:ee:ff"); + } + + #[test] + fn native_snapshot_uses_host_id_as_derivation_seed() { + let native = RuntimeNativeHostIdentity::collect(None); + + assert!(!native.host_id.is_empty()); + } + + #[test] + fn serialization_keeps_globalprotect_field_names() { + let identity = HostIdentity::new( + "computer".to_string(), + "host-id".to_string(), + "serial-number".to_string(), + "aa:bb:cc:dd:ee:ff".to_string(), + ); + let value = serde_json::to_value(identity).unwrap(); + + assert_eq!(value["hostId"], "host-id"); + assert_eq!(value["computer"], "computer"); + assert!(value.get("osVersion").is_none()); + assert!(value.get("softwareVersion").is_none()); + assert_eq!(value["serialno"], "serial-number"); + assert_eq!(value["macAddr"], "aa:bb:cc:dd:ee:ff"); + } + + #[test] + fn native_identity_falls_back_to_derived_values_when_missing() { + let native = NativeHostIdentitySnapshot { + host_id: "native-host-id".to_string(), + computer: "native-computer".to_string(), + serial_number: None, + mac_address: None, + }; + + let identity = native.into_host_identity(); + + assert_eq!(identity.computer(), "native-computer"); + assert_eq!(identity.host_id(), "native-host-id"); + assert!(identity.serialno().starts_with("VMware-")); + assert_mac(identity.mac_addr(), ':'); + } + + #[test] + fn derived_serial_uses_vmware_uuid_byte_order_when_host_id_is_uuid() { + let identity = HostIdentity::new( + "computer".to_string(), + "5a784d56-6461-19ac-9ea9-d36a3b9c6cef".to_string(), + String::new(), + "aa:bb:cc:dd:ee:ff".to_string(), + ); + + assert_eq!( + identity.serialno(), + "VMware-56 4d 78 5a 61 64 ac 19-9e a9 d3 6a 3b 9c 6c ef" + ); + } + + #[test] + fn empty_host_id_falls_back_to_non_empty_value() { + let identity = HostIdentity::new(String::new(), String::new(), String::new(), String::new()); + + assert!(!identity.host_id().is_empty()); + assert!(!identity.computer().is_empty()); + assert!(!identity.serialno().is_empty()); + assert!(!identity.mac_addr().is_empty()); + } + + fn assert_mac(value: &str, separator: char) { + let parts: Vec<&str> = value.split(separator).collect(); + assert_eq!(parts.len(), 6, "MAC should have 6 octets"); + for part in &parts { + assert_eq!(part.len(), 2); + assert!(part.chars().all(|c| c.is_ascii_hexdigit())); + } + } +} diff --git a/crates/gpapi/src/os_profile/mod.rs b/crates/gpapi/src/os_profile/mod.rs new file mode 100644 index 0000000..c8aa942 --- /dev/null +++ b/crates/gpapi/src/os_profile/mod.rs @@ -0,0 +1,1303 @@ +pub mod host_identity; +mod serial_number; + +pub use host_identity::HostIdentity; + +use common::constants::{GP_CLIENT_VERSION_LINUX, GP_CLIENT_VERSION_MACOS, GP_CLIENT_VERSION_WINDOWS, GP_USER_AGENT}; +use serde::{Deserialize, Serialize}; +use specta::Type; + +const DEFAULT_MACOS_VERSION: &str = "13.4.0"; +const DEFAULT_LINUX_DISTRO: &str = "Ubuntu 24.04.3 LTS"; +const DEFAULT_WINDOWS_DISTRO: &str = "Windows 11 Pro"; +const DEFAULT_WINDOWS_VERSION: &str = "10.0.22631.0"; +const DEFAULT_LINUX_WEBVIEW_USER_AGENT: &str = + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/602.1 (KHTML, like Gecko) PanGPUI Version/10.0 Safari/602.1"; +const DEFAULT_MACOS_WEBVIEW_USER_AGENT: &str = + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko)"; +const DEFAULT_WINDOWS_WEBVIEW_USER_AGENT: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0"; + +// ─── ClientOs ──────────────────────────────────────────────────────────────── + +#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Type)] +pub enum ClientOs { + Linux, + Windows, + Mac, +} + +impl From<&str> for ClientOs { + fn from(os: &str) -> Self { + match os { + "Linux" => ClientOs::Linux, + "Windows" => ClientOs::Windows, + "Mac" => ClientOs::Mac, + _ => ClientOs::Linux, + } + } +} + +impl ClientOs { + pub fn as_str(&self) -> &'static str { + match self { + ClientOs::Linux => "Linux", + ClientOs::Windows => "Windows", + ClientOs::Mac => "Mac", + } + } + + pub fn to_openconnect_os(&self) -> &str { + match self { + ClientOs::Linux => "linux", + ClientOs::Windows => "win", + ClientOs::Mac => "mac-intel", + } + } + + pub fn default_client_version(&self) -> &'static str { + match self { + ClientOs::Linux => GP_CLIENT_VERSION_LINUX, + ClientOs::Windows => GP_CLIENT_VERSION_WINDOWS, + ClientOs::Mac => GP_CLIENT_VERSION_MACOS, + } + } + + pub fn default_os_version(&self) -> String { + default_os_version(self) + } + + pub(crate) fn default_csc_support(&self) -> bool { + match self { + ClientOs::Linux => false, + ClientOs::Mac | ClientOs::Windows => true, + } + } +} + +// ─── PreloginParamLocation ─────────────────────────────────────────────────── + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub(crate) enum PreloginParamLocation { + Body, + Query, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum PreloginBrowserMode { + Embedded, + External, +} + +// ─── WebviewUserAgent ─────────────────────────────────────────────────────── + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum WebviewUserAgent { + Native { + prefix: String, + transform: WebviewUserAgentTransform, + }, + Projected { + prefix: String, + default_user_agent: String, + }, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum WebviewUserAgentTransform { + None, + LinuxPanGpuiVersion, +} + +// ─── Target behavior ──────────────────────────────────────────────────────── + +mod target { + use super::*; + + pub(super) fn os_version(client_os: ClientOs) -> String { + match client_os { + ClientOs::Linux => linux_os_string(), + ClientOs::Windows => windows_os_string(), + ClientOs::Mac => macos_os_string(), + } + } + + pub(super) fn software_version(client_os: ClientOs) -> String { + match client_os { + ClientOs::Linux => String::new(), + ClientOs::Windows => windows_version(), + ClientOs::Mac => macos_version(), + } + } + + pub(super) fn prelogin_param_location(client_os: ClientOs) -> PreloginParamLocation { + match client_os { + ClientOs::Linux | ClientOs::Mac => PreloginParamLocation::Body, + ClientOs::Windows => PreloginParamLocation::Query, + } + } + + pub(super) fn saml_password(client_os: ClientOs) -> &'static str { + match client_os { + ClientOs::Linux => "SAMLPASS", + ClientOs::Mac | ClientOs::Windows => "", + } + } + + pub(super) fn external_browser_os_value(client_os: ClientOs) -> &'static str { + match client_os { + ClientOs::Linux => "4", + ClientOs::Mac => "3", + ClientOs::Windows => "2", + } + } + + pub(super) fn supports_macos_plist_csc(client_os: ClientOs) -> bool { + matches!(client_os, ClientOs::Mac) + } + + pub(super) fn supports_linux_process_csc(client_os: ClientOs) -> bool { + matches!(client_os, ClientOs::Linux) + } + + pub(super) fn supports_windows_registry_csc(client_os: ClientOs) -> bool { + matches!(client_os, ClientOs::Windows) + } + + pub(super) fn kerberos_support_in_query(client_os: ClientOs) -> bool { + match client_os { + ClientOs::Linux => false, + ClientOs::Mac | ClientOs::Windows => true, + } + } + + pub(super) fn os_vendor(client_os: ClientOs) -> &'static str { + match client_os { + ClientOs::Linux => "Linux", + ClientOs::Mac => "Apple", + ClientOs::Windows => "Microsoft", + } + } + + pub(super) fn webview_user_agent_default(client_os: ClientOs) -> &'static str { + match client_os { + ClientOs::Linux => DEFAULT_LINUX_WEBVIEW_USER_AGENT, + ClientOs::Mac => DEFAULT_MACOS_WEBVIEW_USER_AGENT, + ClientOs::Windows => DEFAULT_WINDOWS_WEBVIEW_USER_AGENT, + } + } + + pub(super) fn webview_user_agent_transform(client_os: ClientOs) -> WebviewUserAgentTransform { + match client_os { + ClientOs::Linux => WebviewUserAgentTransform::LinuxPanGpuiVersion, + ClientOs::Mac | ClientOs::Windows => WebviewUserAgentTransform::None, + } + } +} + +// ─── ProfileHostIdentity ──────────────────────────────────────────────────── + +#[derive(Debug, Clone, PartialEq, Eq)] +struct ProfileHostIdentity { + computer: String, + host_id: String, + serial_number: String, + mac_address: String, +} + +impl ProfileHostIdentity { + fn for_client_os(client_os: ClientOs, host_identity: &HostIdentity, computer_override: Option) -> Self { + target_identity::project(client_os, host_identity, computer_override) + } + + fn computer(&self) -> &str { + &self.computer + } + + fn host_id(&self) -> &str { + &self.host_id + } + + fn serialno(&self) -> &str { + &self.serial_number + } + + fn mac_addr(&self) -> &str { + &self.mac_address + } +} + +// ─── OsProfile ─────────────────────────────────────────────────────────────── + +#[derive(Debug, Clone)] +pub struct OsProfile { + client_os: ClientOs, + os_version: String, + software_version: String, + os_vendor: &'static str, + client_version: String, + host_identity: HostIdentity, + profile_identity: ProfileHostIdentity, + user_agent: String, +} + +impl OsProfile { + pub fn builder(client_os: ClientOs) -> OsProfileBuilder { + OsProfileBuilder::new(client_os) + } + + // ─── Identity accessors ────────────────────────────────────────────────── + + pub fn client_os(&self) -> ClientOs { + self.client_os + } + + pub fn computer(&self) -> &str { + self.profile_identity.computer() + } + + pub fn os_version(&self) -> &str { + &self.os_version + } + + pub fn client_version(&self) -> &str { + &self.client_version + } + + pub fn host_identity(&self) -> &HostIdentity { + &self.host_identity + } + + pub fn user_agent(&self) -> &str { + &self.user_agent + } + + pub fn webview_user_agent(&self) -> WebviewUserAgent { + if self.is_native() { + WebviewUserAgent::Native { + prefix: self.user_agent.clone(), + transform: target::webview_user_agent_transform(self.client_os), + } + } else { + WebviewUserAgent::Projected { + prefix: self.user_agent.clone(), + default_user_agent: target::webview_user_agent_default(self.client_os).to_string(), + } + } + } + + pub fn host_id(&self) -> &str { + self.profile_identity.host_id() + } + + pub fn serialno(&self) -> &str { + self.profile_identity.serialno() + } + + pub fn mac_addr(&self) -> &str { + self.profile_identity.mac_addr() + } + + /// Returns true when the target client OS matches the runtime OS. + /// + /// Used to decide whether to consult real OS-level state (e.g. the actual + /// network interface) versus simulated values for emulation. + pub fn is_native(&self) -> bool { + runtime_client_os() == self.client_os + } + + /// Default software version string for the target OS, matching the + /// official client values. + pub fn software_version(&self) -> &str { + &self.software_version + } + + // ─── Behavioral methods ────────────────────────────────────────────────── + + pub(crate) fn prelogin_param_location(&self) -> PreloginParamLocation { + target::prelogin_param_location(self.client_os) + } + + pub(crate) fn portal_default_browser(&self, browser_mode: PreloginBrowserMode) -> &'static str { + match browser_mode { + PreloginBrowserMode::Embedded => "-10", + PreloginBrowserMode::External => target::external_browser_os_value(self.client_os), + } + } + + pub(crate) fn gateway_default_browser(&self, browser_mode: PreloginBrowserMode) -> &'static str { + match browser_mode { + PreloginBrowserMode::Embedded => "0", + PreloginBrowserMode::External => target::external_browser_os_value(self.client_os), + } + } + + pub(crate) fn saml_password(&self) -> &'static str { + target::saml_password(self.client_os) + } + + pub(crate) fn gateway_server_uses_resolved_ipv4(&self) -> bool { + true + } + + pub(crate) fn supports_macos_plist_csc(&self) -> bool { + target::supports_macos_plist_csc(self.client_os) + } + + pub(crate) fn supports_linux_process_csc(&self) -> bool { + target::supports_linux_process_csc(self.client_os) + } + + pub(crate) fn supports_windows_registry_csc(&self) -> bool { + target::supports_windows_registry_csc(self.client_os) + } + + pub(crate) fn kerberos_support_in_query(&self) -> bool { + target::kerberos_support_in_query(self.client_os) + } + + pub fn os_vendor(&self) -> &'static str { + self.os_vendor + } +} + +// ─── OsProfileBuilder ──────────────────────────────────────────────────────── + +#[derive(Debug, Clone)] +pub struct OsProfileBuilder { + client_os: ClientOs, + client_version: Option, + computer_name_override: Option, + host_id_override: Option, + host_identity: Option, + user_agent: Option, +} + +impl OsProfileBuilder { + pub fn new(client_os: ClientOs) -> Self { + Self { + client_os, + client_version: None, + computer_name_override: None, + host_id_override: None, + host_identity: None, + user_agent: None, + } + } + + pub fn computer_name_override(mut self, name: impl Into) -> Self { + self.computer_name_override = Some(name.into()); + self + } + + pub fn client_version(mut self, version: impl Into) -> Self { + self.client_version = Some(version.into()); + self + } + + pub fn host_identity(mut self, identity: HostIdentity) -> Self { + self.host_identity = Some(identity); + self + } + + pub fn host_id_override(mut self, host_id: impl Into) -> Self { + let host_id = host_id.into(); + self.host_id_override = if host_id.trim().is_empty() { None } else { Some(host_id) }; + self + } + + pub fn user_agent(mut self, ua: impl Into) -> Self { + let ua = ua.into(); + self.user_agent = if ua.trim().is_empty() { None } else { Some(ua) }; + self + } + + pub fn build(self) -> OsProfile { + let client_version = self + .client_version + .filter(|v| !v.trim().is_empty()) + .unwrap_or_else(|| self.client_os.default_client_version().to_string()); + + let host_identity = match (self.host_identity, self.host_id_override) { + (Some(identity), _) => identity, + (None, host_id) => HostIdentity::collect_with_host_id(host_id.as_deref()), + }; + let profile_identity = + ProfileHostIdentity::for_client_os(self.client_os, &host_identity, self.computer_name_override); + let os_version = target::os_version(self.client_os); + let software_version = target::software_version(self.client_os); + let os_vendor = target::os_vendor(self.client_os); + + let user_agent = self + .user_agent + .unwrap_or_else(|| format!("{}/{} ({})", GP_USER_AGENT, client_version, os_version)); + + OsProfile { + client_os: self.client_os, + os_version, + software_version, + os_vendor, + client_version, + host_identity, + profile_identity, + user_agent, + } + } +} + +// ─── Default helpers ───────────────────────────────────────────────────────── + +pub fn default_computer_name(client_os: &ClientOs) -> String { + ProfileHostIdentity::for_client_os(*client_os, &HostIdentity::collect(), None) + .computer() + .to_string() +} + +pub fn default_os_version(client_os: &ClientOs) -> String { + target::os_version(*client_os) +} + +pub fn default_software_version(client_os: &ClientOs) -> String { + target::software_version(*client_os) +} + +pub fn runtime_client_os() -> ClientOs { + HostIdentity::runtime_os() +} + +fn linux_os_string() -> String { + if runtime_client_os() == ClientOs::Linux { + format!("Linux {}", runtime_distro_or(DEFAULT_LINUX_DISTRO)) + } else { + format!("Linux {}", DEFAULT_LINUX_DISTRO) + } +} + +fn windows_version() -> String { + if runtime_client_os() == ClientOs::Windows { + match os_info::get().version() { + os_info::Version::Unknown => DEFAULT_WINDOWS_VERSION.to_string(), + v => format!("{}.0", v), + } + } else { + DEFAULT_WINDOWS_VERSION.to_string() + } +} + +fn windows_os_string() -> String { + if runtime_client_os() == ClientOs::Windows { + let edition = os_info::get() + .edition() + .map(|e| e.to_string()) + .unwrap_or_else(|| runtime_distro_or(DEFAULT_WINDOWS_DISTRO)); + format!("Microsoft {} , 64-bit", edition) + } else { + format!("Microsoft {} , 64-bit", DEFAULT_WINDOWS_DISTRO) + } +} + +fn runtime_distro_or(fallback: &str) -> String { + whoami::distro().unwrap_or_else(|_| fallback.to_string()) +} + +fn macos_version() -> String { + if runtime_client_os() == ClientOs::Mac { + match os_info::get().version() { + os_info::Version::Unknown => DEFAULT_MACOS_VERSION.to_string(), + v => v.to_string(), + } + } else { + DEFAULT_MACOS_VERSION.to_string() + } +} + +fn macos_os_string() -> String { + format!("Apple Mac OS X {}", macos_version()) +} + +fn derive_uuid_from_seed(seed: &str, parts: &[&str]) -> String { + use uuid::Uuid; + + let namespace = Uuid::NAMESPACE_DNS; + let name = format!("{}-{}", seed, parts.join("-")); + + Uuid::new_v5(&namespace, name.as_bytes()).hyphenated().to_string() +} + +fn derived_profile_mac(seed: &str, client_os: ClientOs) -> String { + let uuid = derive_uuid_from_seed(seed, &["os-profile", client_os.as_str(), "mac"]); + let compact = uuid.replace('-', ""); + let bytes = compact + .as_bytes() + .chunks(2) + .take(6) + .map(|chunk| std::str::from_utf8(chunk).unwrap_or("00").to_lowercase()) + .collect::>(); + + match client_os { + ClientOs::Linux | ClientOs::Windows => bytes.join("-"), + ClientOs::Mac => bytes.join(":"), + } +} + +fn compact_uuid(seed: &str, client_os: ClientOs, suffix: &str) -> String { + derive_uuid_from_seed(seed, &["os-profile", client_os.as_str(), suffix]) + .replace('-', "") + .to_uppercase() +} + +mod target_identity { + use super::*; + + pub(super) fn project( + client_os: ClientOs, + host_identity: &HostIdentity, + computer_override: Option, + ) -> ProfileHostIdentity { + if client_os == runtime_client_os() { + return native::project(client_os, host_identity, computer_override); + } + + match client_os { + ClientOs::Linux => linux::project(host_identity, computer_override), + ClientOs::Windows => windows::project(host_identity, computer_override), + ClientOs::Mac => macos::project(host_identity, computer_override), + } + } + + fn computer(host_identity: &HostIdentity, computer_override: Option) -> String { + computer_override + .filter(|value| !value.trim().is_empty()) + .unwrap_or_else(|| host_identity.computer().to_string()) + } + + fn profile_mac_for(client_os: ClientOs, mac_address: &str) -> String { + match client_os { + ClientOs::Linux | ClientOs::Windows => mac_address.replace(':', "-"), + ClientOs::Mac => mac_address.replace('-', ":"), + } + } + + mod native { + use super::*; + + pub(super) fn project( + client_os: ClientOs, + host_identity: &HostIdentity, + computer_override: Option, + ) -> ProfileHostIdentity { + ProfileHostIdentity { + computer: computer(host_identity, computer_override), + host_id: match client_os { + ClientOs::Mac => host_identity.host_id().replace('-', ":"), + ClientOs::Linux | ClientOs::Windows => host_identity.host_id().to_string(), + }, + serial_number: host_identity.serialno().to_string(), + mac_address: profile_mac_for(client_os, host_identity.mac_addr()), + } + } + } + + mod linux { + use super::*; + + pub(super) fn project(host_identity: &HostIdentity, computer_override: Option) -> ProfileHostIdentity { + let seed = host_identity.host_id(); + let host_id = derive_uuid_from_seed(seed, &["os-profile", ClientOs::Linux.as_str(), "host-id"]); + ProfileHostIdentity { + computer: computer(host_identity, computer_override), + serial_number: serial_number::vmware_from_uuid(&host_id).expect("projected Linux host ID should be a UUID"), + host_id, + mac_address: derived_profile_mac(seed, ClientOs::Linux), + } + } + } + + mod windows { + use super::*; + + pub(super) fn project(host_identity: &HostIdentity, computer_override: Option) -> ProfileHostIdentity { + let seed = host_identity.host_id(); + ProfileHostIdentity { + computer: computer(host_identity, computer_override), + host_id: derive_uuid_from_seed(seed, &["os-profile", ClientOs::Windows.as_str(), "host-id"]), + serial_number: serial_number::vmware_from_compact_hex(&compact_uuid(seed, ClientOs::Windows, "serialno")) + .expect("projected Windows serial seed should be compact hex"), + mac_address: derived_profile_mac(seed, ClientOs::Windows), + } + } + } + + mod macos { + use super::*; + + pub(super) fn project(host_identity: &HostIdentity, computer_override: Option) -> ProfileHostIdentity { + let seed = host_identity.host_id(); + let mac_address = derived_profile_mac(seed, ClientOs::Mac); + ProfileHostIdentity { + computer: computer(host_identity, computer_override), + host_id: mac_address.clone(), + serial_number: compact_uuid(seed, ClientOs::Mac, "serialno").chars().take(10).collect(), + mac_address, + } + } + } + + #[cfg(test)] + mod tests { + use super::*; + + fn host_identity() -> HostIdentity { + HostIdentity::new( + "real-computer".to_string(), + "real-host-id".to_string(), + "real-serial".to_string(), + "AA-BB-CC-DD-EE-FF".to_string(), + ) + } + + #[test] + fn native_linux_projection_uses_real_identity_with_dash_mac() { + let profile = native::project(ClientOs::Linux, &host_identity(), None); + + assert_eq!(profile.computer(), "real-computer"); + assert_eq!(profile.host_id(), "real-host-id"); + assert_eq!(profile.serialno(), "real-serial"); + assert_eq!(profile.mac_addr(), "aa-bb-cc-dd-ee-ff"); + } + + #[test] + fn native_windows_projection_uses_real_identity_with_dash_mac() { + let profile = native::project(ClientOs::Windows, &host_identity(), None); + + assert_eq!(profile.computer(), "real-computer"); + assert_eq!(profile.host_id(), "real-host-id"); + assert_eq!(profile.serialno(), "real-serial"); + assert_eq!(profile.mac_addr(), "aa-bb-cc-dd-ee-ff"); + } + + #[test] + fn native_macos_projection_uses_real_identity_with_colon_mac() { + let profile = native::project(ClientOs::Mac, &host_identity(), None); + + assert_eq!(profile.computer(), "real-computer"); + assert_eq!(profile.host_id(), "real:host:id"); + assert_eq!(profile.serialno(), "real-serial"); + assert_eq!(profile.mac_addr(), "aa:bb:cc:dd:ee:ff"); + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn csc_support_defaults_match_official_profiles() { + assert!(!ClientOs::Linux.default_csc_support()); + assert!(ClientOs::Mac.default_csc_support()); + assert!(ClientOs::Windows.default_csc_support()); + } + + #[test] + fn prelogin_param_location_matches_official_profiles() { + assert_eq!( + OsProfileBuilder::new(ClientOs::Linux).build().prelogin_param_location(), + PreloginParamLocation::Body + ); + assert_eq!( + OsProfileBuilder::new(ClientOs::Mac).build().prelogin_param_location(), + PreloginParamLocation::Body + ); + assert_eq!( + OsProfileBuilder::new(ClientOs::Windows) + .build() + .prelogin_param_location(), + PreloginParamLocation::Query + ); + } + + #[test] + fn embedded_portal_default_browser_is_minus_ten_for_all() { + assert_eq!( + OsProfileBuilder::new(ClientOs::Linux) + .build() + .portal_default_browser(PreloginBrowserMode::Embedded), + "-10" + ); + assert_eq!( + OsProfileBuilder::new(ClientOs::Mac) + .build() + .portal_default_browser(PreloginBrowserMode::Embedded), + "-10" + ); + assert_eq!( + OsProfileBuilder::new(ClientOs::Windows) + .build() + .portal_default_browser(PreloginBrowserMode::Embedded), + "-10" + ); + } + + #[test] + fn embedded_gateway_default_browser_is_zero_for_all() { + assert_eq!( + OsProfileBuilder::new(ClientOs::Linux) + .build() + .gateway_default_browser(PreloginBrowserMode::Embedded), + "0" + ); + assert_eq!( + OsProfileBuilder::new(ClientOs::Mac) + .build() + .gateway_default_browser(PreloginBrowserMode::Embedded), + "0" + ); + assert_eq!( + OsProfileBuilder::new(ClientOs::Windows) + .build() + .gateway_default_browser(PreloginBrowserMode::Embedded), + "0" + ); + } + + #[test] + fn external_default_browser_values_match_official_profiles() { + assert_eq!( + OsProfileBuilder::new(ClientOs::Linux) + .build() + .portal_default_browser(PreloginBrowserMode::External), + "4" + ); + assert_eq!( + OsProfileBuilder::new(ClientOs::Mac) + .build() + .portal_default_browser(PreloginBrowserMode::External), + "3" + ); + assert_eq!( + OsProfileBuilder::new(ClientOs::Windows) + .build() + .portal_default_browser(PreloginBrowserMode::External), + "2" + ); + + assert_eq!( + OsProfileBuilder::new(ClientOs::Linux) + .build() + .gateway_default_browser(PreloginBrowserMode::External), + "4" + ); + assert_eq!( + OsProfileBuilder::new(ClientOs::Mac) + .build() + .gateway_default_browser(PreloginBrowserMode::External), + "3" + ); + assert_eq!( + OsProfileBuilder::new(ClientOs::Windows) + .build() + .gateway_default_browser(PreloginBrowserMode::External), + "2" + ); + } + + #[test] + fn saml_password_matches_official_profiles() { + assert_eq!( + OsProfileBuilder::new(ClientOs::Linux).build().saml_password(), + "SAMLPASS" + ); + assert_eq!(OsProfileBuilder::new(ClientOs::Mac).build().saml_password(), ""); + assert_eq!(OsProfileBuilder::new(ClientOs::Windows).build().saml_password(), ""); + } + + #[test] + fn gateway_server_uses_resolved_ipv4_for_all() { + assert!( + OsProfileBuilder::new(ClientOs::Linux) + .build() + .gateway_server_uses_resolved_ipv4() + ); + assert!( + OsProfileBuilder::new(ClientOs::Mac) + .build() + .gateway_server_uses_resolved_ipv4() + ); + assert!( + OsProfileBuilder::new(ClientOs::Windows) + .build() + .gateway_server_uses_resolved_ipv4() + ); + } + + #[test] + fn kerberos_support_in_query_matches_official_profiles() { + assert!( + !OsProfileBuilder::new(ClientOs::Linux) + .build() + .kerberos_support_in_query() + ); + assert!(OsProfileBuilder::new(ClientOs::Mac).build().kerberos_support_in_query()); + assert!( + OsProfileBuilder::new(ClientOs::Windows) + .build() + .kerberos_support_in_query() + ); + } + + #[test] + fn os_vendor_matches_official_profiles() { + assert_eq!(OsProfileBuilder::new(ClientOs::Linux).build().os_vendor(), "Linux"); + assert_eq!(OsProfileBuilder::new(ClientOs::Mac).build().os_vendor(), "Apple"); + assert_eq!( + OsProfileBuilder::new(ClientOs::Windows).build().os_vendor(), + "Microsoft" + ); + } + + #[test] + fn supports_macos_plist_csc_only_for_mac() { + assert!( + !OsProfileBuilder::new(ClientOs::Linux) + .build() + .supports_macos_plist_csc() + ); + assert!(OsProfileBuilder::new(ClientOs::Mac).build().supports_macos_plist_csc()); + assert!( + !OsProfileBuilder::new(ClientOs::Windows) + .build() + .supports_macos_plist_csc() + ); + } + + #[test] + fn supports_linux_process_csc_only_for_linux() { + assert!( + OsProfileBuilder::new(ClientOs::Linux) + .build() + .supports_linux_process_csc() + ); + assert!( + !OsProfileBuilder::new(ClientOs::Mac) + .build() + .supports_linux_process_csc() + ); + assert!( + !OsProfileBuilder::new(ClientOs::Windows) + .build() + .supports_linux_process_csc() + ); + } + + #[test] + fn supports_windows_registry_csc_only_for_windows() { + assert!( + !OsProfileBuilder::new(ClientOs::Linux) + .build() + .supports_windows_registry_csc() + ); + assert!( + !OsProfileBuilder::new(ClientOs::Mac) + .build() + .supports_windows_registry_csc() + ); + assert!( + OsProfileBuilder::new(ClientOs::Windows) + .build() + .supports_windows_registry_csc() + ); + } + + // ─── User Agent Tests ─────────────────────────────────────────────────────── + + #[test] + fn user_agent_derived_format_without_override() { + let profile = OsProfileBuilder::new(ClientOs::Linux).client_version("6.0.0").build(); + + assert_eq!( + profile.user_agent(), + format!("PAN GlobalProtect/6.0.0 ({})", default_os_version(&ClientOs::Linux)) + ); + } + + #[test] + fn user_agent_explicit_override_returns_custom_value() { + let profile = OsProfileBuilder::new(ClientOs::Linux) + .client_version("6.0.0") + .user_agent("custom/1.0") + .build(); + + assert_eq!(profile.user_agent(), "custom/1.0"); + } + + #[test] + fn user_agent_empty_override_falls_back_to_derived() { + let profile = OsProfileBuilder::new(ClientOs::Linux) + .client_version("6.0.0") + .user_agent("") + .build(); + + assert_eq!( + profile.user_agent(), + format!("PAN GlobalProtect/6.0.0 ({})", default_os_version(&ClientOs::Linux)) + ); + } + + #[test] + fn user_agent_whitespace_only_override_falls_back_to_derived() { + let profile = OsProfileBuilder::new(ClientOs::Linux) + .client_version("6.0.0") + .user_agent(" ") + .build(); + + assert_eq!( + profile.user_agent(), + format!("PAN GlobalProtect/6.0.0 ({})", default_os_version(&ClientOs::Linux)) + ); + } + + #[test] + fn user_agent_derived_is_non_empty_for_all_client_os_variants() { + for client_os in [ClientOs::Linux, ClientOs::Windows, ClientOs::Mac] { + let profile = OsProfileBuilder::new(client_os).build(); + assert!( + !profile.user_agent().is_empty(), + "user_agent() should be non-empty for {:?}", + client_os + ); + } + } + + #[test] + fn native_webview_user_agent_uses_native_default() { + let profile = OsProfileBuilder::new(runtime_client_os()).build(); + let user_agent = profile.webview_user_agent(); + + assert_eq!( + user_agent, + WebviewUserAgent::Native { + prefix: profile.user_agent().to_string(), + transform: target::webview_user_agent_transform(runtime_client_os()) + } + ); + } + + #[test] + fn projected_linux_webview_user_agent_uses_linux_default() { + if runtime_client_os() == ClientOs::Linux { + return; + } + + let client_os = ClientOs::Linux; + let profile = OsProfileBuilder::new(client_os).build(); + let user_agent = profile.webview_user_agent(); + + assert_eq!( + user_agent, + WebviewUserAgent::Projected { + prefix: profile.user_agent().to_string(), + default_user_agent: DEFAULT_LINUX_WEBVIEW_USER_AGENT.to_string() + } + ); + } + + #[test] + fn projected_macos_webview_user_agent_uses_macos_default() { + if runtime_client_os() == ClientOs::Mac { + return; + } + + let client_os = ClientOs::Mac; + let profile = OsProfileBuilder::new(client_os).build(); + let user_agent = profile.webview_user_agent(); + + assert_eq!( + user_agent, + WebviewUserAgent::Projected { + prefix: profile.user_agent().to_string(), + default_user_agent: DEFAULT_MACOS_WEBVIEW_USER_AGENT.to_string() + } + ); + } + + #[test] + fn projected_windows_webview_user_agent_uses_windows_default() { + if runtime_client_os() == ClientOs::Windows { + return; + } + + let client_os = ClientOs::Windows; + let profile = OsProfileBuilder::new(client_os).build(); + let user_agent = profile.webview_user_agent(); + + assert_eq!( + user_agent, + WebviewUserAgent::Projected { + prefix: profile.user_agent().to_string(), + default_user_agent: DEFAULT_WINDOWS_WEBVIEW_USER_AGENT.to_string() + } + ); + } + + #[test] + fn os_version_strings_match_profiles() { + assert!(default_os_version(&ClientOs::Linux).starts_with("Linux ")); + assert!(default_os_version(&ClientOs::Mac).starts_with("Apple Mac OS X ")); + assert!(default_os_version(&ClientOs::Windows).starts_with("Microsoft ")); + assert_eq!(default_software_version(&ClientOs::Linux), ""); + assert!(!default_software_version(&ClientOs::Mac).is_empty()); + assert!(!default_software_version(&ClientOs::Windows).is_empty()); + } + + #[test] + fn builder_fills_defaults_when_nothing_specified() { + let profile = OsProfileBuilder::new(ClientOs::Linux).build(); + + assert_eq!(profile.client_os(), ClientOs::Linux); + assert!(!profile.computer().is_empty()); + assert!(profile.os_version().starts_with("Linux ")); + assert_eq!(profile.client_version(), GP_CLIENT_VERSION_LINUX); + assert!(!profile.host_id().is_empty()); + } + + #[test] + fn builder_delegates_default_identity_to_host_identity() { + let expected = HostIdentity::collect(); + let profile = OsProfileBuilder::new(runtime_client_os()) + .host_identity(expected.clone()) + .build(); + + assert_eq!(profile.host_identity(), &expected); + } + + #[test] + fn builder_host_id_override_uses_supplied_runtime_identity_seed() { + let profile = OsProfileBuilder::new(runtime_client_os()) + .host_id_override("provided-host-id") + .build(); + + assert_eq!(profile.host_identity().host_id(), "provided-host-id"); + } + + #[test] + fn builder_host_id_override_is_used_as_projected_identity_seed() { + let client_os = match runtime_client_os() { + ClientOs::Linux => ClientOs::Mac, + ClientOs::Mac | ClientOs::Windows => ClientOs::Linux, + }; + + let first = OsProfileBuilder::new(client_os) + .host_id_override("provided-host-id") + .build(); + let second = OsProfileBuilder::new(client_os) + .host_id_override("provided-host-id") + .build(); + + assert_eq!(first.host_identity().host_id(), "provided-host-id"); + assert_eq!(first.host_id(), second.host_id()); + assert_ne!(first.host_id(), "provided-host-id"); + } + + #[test] + fn builder_uses_explicit_values_when_provided() { + let identity = HostIdentity::new( + "identity-computer".to_string(), + "test-host-id".to_string(), + "test-serial".to_string(), + "aa:bb:cc:dd:ee:ff".to_string(), + ); + let profile = OsProfileBuilder::new(ClientOs::Mac) + .computer_name_override("MyMac") + .client_version("6.2.0-100") + .host_identity(identity.clone()) + .build(); + + assert_eq!(profile.client_os(), ClientOs::Mac); + assert_eq!(profile.computer(), "MyMac"); + assert!(profile.os_version().starts_with("Apple Mac OS X ")); + assert_eq!(profile.client_version(), "6.2.0-100"); + assert_eq!(profile.host_identity(), &identity); + assert!(!profile.host_id().is_empty()); + assert!(!profile.serialno().is_empty()); + assert!(!profile.mac_addr().is_empty()); + } + + #[test] + fn builder_ignores_empty_strings() { + let profile = OsProfileBuilder::new(ClientOs::Windows) + .computer_name_override("") + .client_version("") + .build(); + + // Should fall back to defaults, not use empty strings + assert!(!profile.computer().is_empty()); + assert!(profile.os_version().starts_with("Microsoft ")); + assert_eq!(profile.client_version(), GP_CLIENT_VERSION_WINDOWS); + } + + #[test] + fn identity_accessors_delegate_to_host_identity() { + let identity = HostIdentity::new( + "test-computer".to_string(), + "host-123".to_string(), + "serial-456".to_string(), + "11:22:33:44:55:66".to_string(), + ); + let profile = OsProfileBuilder::new(runtime_client_os()) + .host_identity(identity) + .build(); + + assert!(!profile.host_id().is_empty()); + assert_eq!(profile.serialno(), "serial-456"); + assert!(!profile.mac_addr().is_empty()); + } + + #[test] + fn local_hostname_override_changes_only_projected_computer() { + let identity = HostIdentity::new( + "real-computer".to_string(), + "real-host-id".to_string(), + "real-serial".to_string(), + "11:22:33:44:55:66".to_string(), + ); + + let profile = OsProfileBuilder::new(runtime_client_os()) + .host_identity(identity) + .computer_name_override("profile-computer") + .build(); + + assert_eq!(profile.computer(), "profile-computer"); + assert_eq!(profile.host_identity().computer(), "real-computer"); + } + + #[test] + fn simulated_profile_identity_is_derived_from_real_host_id() { + let client_os = non_native_client_os(); + let identity = HostIdentity::new( + "real-computer".to_string(), + "stable-real-host-id".to_string(), + "real-serial".to_string(), + "11:22:33:44:55:66".to_string(), + ); + + let first = OsProfileBuilder::new(client_os).host_identity(identity.clone()).build(); + let second = OsProfileBuilder::new(client_os).host_identity(identity).build(); + + assert_eq!(first.host_identity().host_id(), "stable-real-host-id"); + assert_ne!(first.host_id(), "stable-real-host-id"); + assert_eq!(first.host_id(), second.host_id()); + assert_eq!(first.serialno(), second.serialno()); + assert_eq!(first.mac_addr(), second.mac_addr()); + } + + #[test] + fn simulated_linux_serial_uses_vmware_style_uuid_bytes() { + if runtime_client_os() == ClientOs::Linux { + return; + } + + let identity = HostIdentity::new( + "real-computer".to_string(), + "stable-real-host-id".to_string(), + "real-serial".to_string(), + "11:22:33:44:55:66".to_string(), + ); + + let profile = OsProfileBuilder::new(ClientOs::Linux).host_identity(identity).build(); + + assert!(profile.serialno().starts_with("VMware-")); + assert_eq!( + profile.serialno().len(), + "VMware-56 4d 78 5a 61 64 ac 19-9e a9 d3 6a 3b 9c 6c ef".len() + ); + } + + #[test] + fn profile_os_versions_are_not_host_identity_fields() { + let identity = HostIdentity::new( + "real-computer".to_string(), + "stable-real-host-id".to_string(), + "real-serial".to_string(), + "11:22:33:44:55:66".to_string(), + ); + let profile = OsProfileBuilder::new(ClientOs::Mac).host_identity(identity).build(); + let value = serde_json::to_value(profile.host_identity()).unwrap(); + + assert!(value.get("osVersion").is_none()); + assert!(value.get("softwareVersion").is_none()); + assert!(profile.os_version().starts_with("Apple Mac OS X ")); + assert!(!profile.software_version().is_empty()); + } + + fn non_native_client_os() -> ClientOs { + match runtime_client_os() { + ClientOs::Linux => ClientOs::Mac, + ClientOs::Mac | ClientOs::Windows => ClientOs::Linux, + } + } + + // ─── Property-Based Tests ───────────────────────────────────────────────── + + mod prop_tests { + use super::*; + use proptest::prelude::*; + + // **Validates: Requirements 1.1, 1.2, 1.3, 1.4, 2.3, 12.1, 12.2** + // + // Property 1: Derived user agent format + // For any valid OsProfile built without a user agent override (with arbitrary + // non-empty client_version), user_agent() returns a non-empty string matching + // the format "PAN GlobalProtect/{client_version} ({profile.os_version})". + proptest! { + #[test] + fn derived_user_agent_format( + cv in "\\S{1,50}", + ) { + let profile = OsProfileBuilder::new(ClientOs::Linux) + .client_version(cv.clone()) + .build(); + + let expected = format!("PAN GlobalProtect/{} ({})", cv, profile.os_version()); + prop_assert_eq!(profile.user_agent(), expected.as_str()); + prop_assert!(!profile.user_agent().is_empty()); + } + } + + // **Validates: Requirements 2.2, 12.3** + // + // Property 2: Override returns verbatim + // For any non-whitespace-only string provided to OsProfileBuilder::user_agent(), + // the resulting OsProfile::user_agent() returns the exact input. + proptest! { + #[test] + fn override_returns_verbatim(ua in "[^\\s][\\s\\S]{0,49}") { + let profile = OsProfileBuilder::new(ClientOs::Linux) + .user_agent(ua.clone()) + .build(); + + prop_assert_eq!(profile.user_agent(), ua.as_str()); + } + } + + // **Validates: Requirements 2.4** + // + // Property 3: Whitespace override falls back to derived + // For any string composed entirely of whitespace characters provided to + // OsProfileBuilder::user_agent(), the resulting OsProfile::user_agent() + // returns the derived format (not the whitespace string). + proptest! { + #[test] + fn whitespace_override_falls_back_to_derived(ws in "[ \\t\\n]{1,20}") { + let profile = OsProfileBuilder::new(ClientOs::Linux) + .client_version("6.0.0") + .user_agent(ws.clone()) + .build(); + + // The result must be the derived format, not the whitespace string + let expected = format!("PAN GlobalProtect/6.0.0 ({})", profile.os_version()); + prop_assert_eq!(profile.user_agent(), expected.as_str()); + prop_assert_ne!(profile.user_agent(), ws.as_str()); + } + } + } +} diff --git a/crates/gpapi/src/os_profile/serial_number.rs b/crates/gpapi/src/os_profile/serial_number.rs new file mode 100644 index 0000000..8abdc08 --- /dev/null +++ b/crates/gpapi/src/os_profile/serial_number.rs @@ -0,0 +1,78 @@ +pub(super) fn vmware_from_uuid(uuid: &str) -> Option { + let parts: Vec<&str> = uuid.split('-').collect(); + if parts.len() != 5 + || parts[0].len() != 8 + || parts[1].len() != 4 + || parts[2].len() != 4 + || parts[3].len() != 4 + || parts[4].len() != 12 + || !parts.iter().all(|part| part.chars().all(|ch| ch.is_ascii_hexdigit())) + { + return None; + } + + let compact = [ + reverse_hex_bytes(parts[0]), + reverse_hex_bytes(parts[1]), + reverse_hex_bytes(parts[2]), + parts[3].to_lowercase(), + parts[4].to_lowercase(), + ] + .concat(); + + vmware_from_compact_hex(&compact) +} + +pub(super) fn vmware_from_compact_hex(compact: &str) -> Option { + let compact = compact.trim().to_lowercase(); + if compact.len() != 32 || !compact.chars().all(|ch| ch.is_ascii_hexdigit()) { + return None; + } + + Some(format!( + "VMware-{} {} {} {} {} {} {} {}-{} {} {} {} {} {} {} {}", + &compact[0..2], + &compact[2..4], + &compact[4..6], + &compact[6..8], + &compact[8..10], + &compact[10..12], + &compact[12..14], + &compact[14..16], + &compact[16..18], + &compact[18..20], + &compact[20..22], + &compact[22..24], + &compact[24..26], + &compact[26..28], + &compact[28..30], + &compact[30..32] + )) +} + +fn reverse_hex_bytes(value: &str) -> String { + value + .as_bytes() + .chunks(2) + .rev() + .map(|chunk| std::str::from_utf8(chunk).unwrap_or_default().to_lowercase()) + .collect() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn vmware_serial_from_uuid_uses_smbios_byte_order() { + assert_eq!( + vmware_from_uuid("5a784d56-6461-19ac-9ea9-d36a3b9c6cef").unwrap(), + "VMware-56 4d 78 5a 61 64 ac 19-9e a9 d3 6a 3b 9c 6c ef" + ); + } + + #[test] + fn invalid_uuid_is_rejected() { + assert_eq!(vmware_from_uuid("not-a-uuid"), None); + } +} diff --git a/crates/gpapi/src/params/credential.rs b/crates/gpapi/src/params/credential.rs new file mode 100644 index 0000000..3774285 --- /dev/null +++ b/crates/gpapi/src/params/credential.rs @@ -0,0 +1,62 @@ +use crate::{credential::Credential, gp_params::GpParams}; + +const EMPTY_PORTAL_COOKIE: &str = "empty"; + +fn portal_cookie_param(value: Option<&str>) -> String { + match value { + Some(value) if !value.is_empty() => value.to_string(), + _ => EMPTY_PORTAL_COOKIE.to_string(), + } +} + +pub(crate) fn build(cred: &Credential, gp_params: &GpParams) -> Vec<(String, String)> { + let mut params = Vec::new(); + params.push(("user".to_string(), cred.username().to_string())); + + let (passwd, prelogin_cookie, portal_userauthcookie, portal_prelogonuserauthcookie, token) = match cred { + Credential::Password(cred) => (Some(cred.password()), None, None, None, None), + Credential::Prelogin(cred) => ( + Some(gp_params.os_profile().saml_password()), + cred.prelogin_cookie(), + cred.portal_userauthcookie(), + None, + cred.token(), + ), + Credential::AuthCookie(cred) => ( + Some( + cred + .password() + .unwrap_or_else(|| gp_params.os_profile().saml_password()), + ), + None, + Some(cred.user_auth_cookie()), + Some(cred.prelogon_user_auth_cookie()), + None, + ), + Credential::Cached(cred) => ( + cred.password(), + None, + cred.auth_cookie().map(|cred| cred.user_auth_cookie()), + cred.auth_cookie().map(|cred| cred.prelogon_user_auth_cookie()), + None, + ), + }; + + params.push(("passwd".to_string(), passwd.unwrap_or_default().to_string())); + params.push(( + "prelogin-cookie".to_string(), + prelogin_cookie.unwrap_or_default().to_string(), + )); + params.push(( + "portal-userauthcookie".to_string(), + portal_cookie_param(portal_userauthcookie), + )); + params.push(( + "portal-prelogonuserauthcookie".to_string(), + portal_cookie_param(portal_prelogonuserauthcookie), + )); + + params.push(("token".to_string(), token.unwrap_or_default().to_string())); + + params +} diff --git a/crates/gpapi/src/params/gateway_login.rs b/crates/gpapi/src/params/gateway_login.rs new file mode 100644 index 0000000..7f4a66b --- /dev/null +++ b/crates/gpapi/src/params/gateway_login.rs @@ -0,0 +1,487 @@ +use std::net::ToSocketAddrs; + +use super::{RequestParams, credential as credential_params}; +use crate::{credential::Credential, gateway::GatewayLoginContext, gp_params::GpParams}; + +/// Inputs required to build gateway login request parameters. +pub(crate) struct GatewayLoginInput<'a> { + pub gp_params: &'a GpParams, + pub cred: &'a Credential, + pub gateway_host: &'a str, + pub context: Option<&'a GatewayLoginContext>, + pub client_ip: Option<&'a str>, + pub extend_lifetime: bool, +} + +/// Build request parameters for the gateway login endpoint. +/// +/// Resolves the `server` parameter to an IPv4 address when +/// `profile.gateway_server_uses_resolved_ipv4()` is true. +/// Sets `gw` and `gateway-name` to the gateway FQDN. +pub(crate) fn build(input: &GatewayLoginInput) -> RequestParams { + let profile = input.gp_params.os_profile(); + let mut body: Vec<(String, String)> = Vec::new(); + + // Credential params (user, passwd, prelogin-cookie, portal-userauthcookie, etc.) + body.extend(credential_params::build(input.cred, input.gp_params)); + + // Common login params + body.push(("prot".into(), "https:".into())); + body.push(("jnlpReady".into(), "jnlpReady".into())); + body.push(("ok".into(), "Login".into())); + body.push(("direct".into(), "yes".into())); + body.push(("ipv6-support".into(), "yes".into())); + body.push(("clientVer".into(), "4100".into())); + body.push(("clientos".into(), profile.client_os().as_str().into())); + body.push(("computer".into(), profile.computer().into())); + body.push(( + "inputStr".into(), + input.gp_params.input_str().unwrap_or_default().into(), + )); + if let Some(otp) = input.gp_params.otp() { + body.push(("passwd".into(), otp.into())); + } + if let Some(os_version) = input.gp_params.os_version() { + body.push(("os-version".into(), os_version.into())); + } + + // Server — resolve to IPv4 when profile requires it + let server = resolve_server(input); + body.push(("server".into(), server)); + + // Identity fields + body.push(("host-id".into(), profile.host_id().into())); + body.push(("serialno".into(), profile.serialno().into())); + body.push(("preferred-ip".into(), String::new())); + body.push(("preferred-ipv6".into(), String::new())); + + // Client version + if let Some(client_version) = input.gp_params.client_version() { + body.push(("clientgpversion".into(), client_version.to_string())); + } + + // Context-dependent fields + if let Some(context) = input.context { + let gateway_host = context.host().to_string(); + body.push(("host".into(), gateway_host.clone())); + body.push(("gw".into(), gateway_host.clone())); + body.push(("gateway-name".into(), gateway_host)); + body.push(("internal".into(), context.kind().as_login_param().to_string())); + body.push(( + "selection-type".into(), + context.selection().as_login_param().to_string(), + )); + body.push(("client-ipv6".into(), String::new())); + + if let Some(connect_method) = context.connect_method() { + body.push(("connect-method".into(), connect_method.to_string())); + } + + if let Some(client_version) = input.gp_params.client_version() { + // Ensure clientgpversion is set in the context block (override earlier value if present) + if let Some(pos) = body.iter().position(|(k, _)| k == "clientgpversion") { + body[pos].1 = client_version.to_string(); + } else { + body.push(("clientgpversion".into(), client_version.to_string())); + } + } + + if let Some(client_ip) = input.client_ip { + body.push(("client-ip".into(), client_ip.to_string())); + } + } + + // Extend lifetime + if input.extend_lifetime { + body.push(("extend-lifetime".into(), "true".into())); + } + + RequestParams { body, query: vec![] } +} + +/// Resolve the gateway server to an IPv4 address if the profile requires it. +/// +/// Falls back to the original gateway host if resolution fails. +fn resolve_server(input: &GatewayLoginInput) -> String { + if !input.gp_params.os_profile().gateway_server_uses_resolved_ipv4() { + return input.gateway_host.to_string(); + } + + if let Some(context) = input.context { + resolve_to_ipv4(context.host()).unwrap_or_else(|| input.gateway_host.to_string()) + } else { + input.gateway_host.to_string() + } +} + +/// Attempt DNS resolution of a hostname to its first IPv4 address. +fn resolve_to_ipv4(host: &str) -> Option { + (host, 443) + .to_socket_addrs() + .ok()? + .find(|addr| addr.ip().is_ipv4()) + .map(|addr| addr.ip().to_string()) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{ + credential::{AuthCookieCredential, PasswordCredential}, + gateway::{Gateway, GatewayKind, GatewaySelection}, + os_profile::{ClientOs, HostIdentity, OsProfile}, + }; + + fn test_identity() -> HostIdentity { + HostIdentity::new( + "test-computer".to_string(), + "host-id-123".to_string(), + "serial-456".to_string(), + "aa-bb-cc-dd-ee-ff".to_string(), + ) + } + + fn test_profile(os: ClientOs) -> OsProfile { + OsProfile::builder(os).host_identity(test_identity()).build() + } + + fn make_gp_params() -> GpParams { + GpParams::builder(test_profile(ClientOs::Linux)).build() + } + + fn make_credential() -> Credential { + Credential::Password(PasswordCredential::new("alice", "secret")) + } + + #[test] + fn build_without_context_includes_identity_fields() { + let profile = test_profile(ClientOs::Linux); + let gp_params = make_gp_params(); + let cred = make_credential(); + + let input = GatewayLoginInput { + gp_params: &gp_params, + cred: &cred, + gateway_host: "vpn.example.com", + context: None, + client_ip: None, + extend_lifetime: false, + }; + + let result = build(&input); + + let find = |key: &str| result.body.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str()); + + assert_eq!(find("host-id"), Some(profile.host_id())); + assert_eq!(find("serialno"), Some(profile.serialno())); + assert_eq!(find("preferred-ip"), Some("")); + assert_eq!(find("preferred-ipv6"), Some("")); + assert_eq!(find("token"), Some("")); + assert_eq!(find("server"), Some("vpn.example.com")); + } + + #[test] + fn build_without_context_excludes_context_fields() { + let gp_params = make_gp_params(); + let cred = make_credential(); + + let input = GatewayLoginInput { + gp_params: &gp_params, + cred: &cred, + gateway_host: "vpn.example.com", + context: None, + client_ip: None, + extend_lifetime: false, + }; + + let result = build(&input); + + let has_key = |key: &str| result.body.iter().any(|(k, _)| k == key); + + assert!(!has_key("host")); + assert!(!has_key("gw")); + assert!(!has_key("gateway-name")); + assert!(!has_key("internal")); + assert!(!has_key("selection-type")); + assert!(!has_key("connect-method")); + assert!(!has_key("client-ip")); + assert!(!has_key("client-ipv6")); + } + + #[test] + fn build_with_context_includes_gateway_fqdn() { + let gp_params = make_gp_params(); + let cred = make_credential(); + let gateway = Gateway { + name: "US_East".to_string(), + address: "us1.vpn.example.com".to_string(), + kind: GatewayKind::External, + priority: 1, + priority_rules: vec![], + }; + let context = GatewayLoginContext::new(&gateway, GatewaySelection::Auto); + + let input = GatewayLoginInput { + gp_params: &gp_params, + cred: &cred, + gateway_host: "us1.vpn.example.com", + context: Some(&context), + client_ip: Some("192.168.0.10"), + extend_lifetime: false, + }; + + let result = build(&input); + + let find = |key: &str| result.body.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str()); + + assert_eq!(find("gw"), Some("us1.vpn.example.com")); + assert_eq!(find("gateway-name"), Some("us1.vpn.example.com")); + assert_eq!(find("host"), Some("us1.vpn.example.com")); + assert_eq!(find("internal"), Some("no")); + assert_eq!(find("selection-type"), Some("auto")); + assert_eq!(find("client-ip"), Some("192.168.0.10")); + assert_eq!(find("client-ipv6"), Some("")); + } + + #[test] + fn mac_profile_uses_fqdn_for_gateway_display() { + let gp_params = GpParams::builder(test_profile(ClientOs::Mac)).build(); + let cred = make_credential(); + let gateway = Gateway { + name: "US_East".to_string(), + address: "us1.vpn.example.com".to_string(), + kind: GatewayKind::External, + priority: 1, + priority_rules: vec![], + }; + let context = GatewayLoginContext::new(&gateway, GatewaySelection::Auto); + + let input = GatewayLoginInput { + gp_params: &gp_params, + cred: &cred, + gateway_host: "us1.vpn.example.com", + context: Some(&context), + client_ip: None, + extend_lifetime: false, + }; + + let result = build(&input); + + let find = |key: &str| result.body.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str()); + + assert_eq!(find("gw"), Some("us1.vpn.example.com")); + assert_eq!(find("gateway-name"), Some("us1.vpn.example.com")); + } + + #[test] + fn linux_prelogin_credential_uses_profile_saml_password() { + let gp_params = GpParams::builder(test_profile(ClientOs::Linux)).build(); + let cred = Credential::Prelogin(crate::credential::PreloginCredential::new( + "alice", + Some("prelogin-cookie"), + None, + None, + )); + + let input = GatewayLoginInput { + gp_params: &gp_params, + cred: &cred, + gateway_host: "vpn.example.com", + context: None, + client_ip: None, + extend_lifetime: false, + }; + + let result = build(&input); + + let passwd = result.body.iter().find(|(k, _)| k == "passwd").map(|(_, v)| v.as_str()); + assert_eq!(passwd, Some("SAMLPASS")); + } + + #[test] + fn portal_auth_cookie_login_leaves_gateway_prelogin_cookie_empty() { + let gp_params = GpParams::builder(test_profile(ClientOs::Linux)).build(); + let cred = Credential::AuthCookie(AuthCookieCredential::new("alice", "empty", "empty")); + + let input = GatewayLoginInput { + gp_params: &gp_params, + cred: &cred, + gateway_host: "vpn.example.com", + context: None, + client_ip: None, + extend_lifetime: false, + }; + + let result = build(&input); + let find = |key: &str| result.body.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str()); + + assert_eq!(find("passwd"), Some("SAMLPASS")); + assert_eq!(find("prelogin-cookie"), Some("")); + assert_eq!(find("portal-userauthcookie"), Some("empty")); + assert_eq!(find("portal-prelogonuserauthcookie"), Some("empty")); + } + + #[test] + fn portal_auth_cookie_login_reuses_portal_password_when_available() { + let gp_params = GpParams::builder(test_profile(ClientOs::Linux)).build(); + let cred = Credential::AuthCookie( + AuthCookieCredential::new("alice", "portal-user-cookie", "portal-prelogon-cookie").with_password("secret"), + ); + + let input = GatewayLoginInput { + gp_params: &gp_params, + cred: &cred, + gateway_host: "vpn.example.com", + context: None, + client_ip: None, + extend_lifetime: false, + }; + + let result = build(&input); + let find = |key: &str| result.body.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str()); + + assert_eq!(find("passwd"), Some("secret")); + assert_eq!(find("prelogin-cookie"), Some("")); + assert_eq!(find("portal-userauthcookie"), Some("portal-user-cookie")); + assert_eq!(find("portal-prelogonuserauthcookie"), Some("portal-prelogon-cookie")); + } + + #[test] + fn extend_lifetime_adds_param() { + let gp_params = make_gp_params(); + let cred = make_credential(); + + let input = GatewayLoginInput { + gp_params: &gp_params, + cred: &cred, + gateway_host: "vpn.example.com", + context: None, + client_ip: None, + extend_lifetime: true, + }; + + let result = build(&input); + + let find = |key: &str| result.body.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str()); + assert_eq!(find("extend-lifetime"), Some("true")); + } + + #[test] + fn no_extend_lifetime_omits_param() { + let gp_params = make_gp_params(); + let cred = make_credential(); + + let input = GatewayLoginInput { + gp_params: &gp_params, + cred: &cred, + gateway_host: "vpn.example.com", + context: None, + client_ip: None, + extend_lifetime: false, + }; + + let result = build(&input); + + let has_key = |key: &str| result.body.iter().any(|(k, _)| k == key); + assert!(!has_key("extend-lifetime")); + } + + #[test] + fn context_connect_method_included_when_present() { + let gp_params = make_gp_params(); + let cred = make_credential(); + let gateway = Gateway::new("GW".to_string(), "vpn.example.com".to_string()); + let context = GatewayLoginContext::new(&gateway, GatewaySelection::Manual).with_connect_method(Some("on-demand")); + + let input = GatewayLoginInput { + gp_params: &gp_params, + cred: &cred, + gateway_host: "vpn.example.com", + context: Some(&context), + client_ip: None, + extend_lifetime: false, + }; + + let result = build(&input); + + let find = |key: &str| result.body.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str()); + assert_eq!(find("connect-method"), Some("on-demand")); + assert_eq!(find("selection-type"), Some("manual")); + } + + #[test] + fn all_params_in_body_not_query() { + let gp_params = make_gp_params(); + let cred = make_credential(); + + let input = GatewayLoginInput { + gp_params: &gp_params, + cred: &cred, + gateway_host: "vpn.example.com", + context: None, + client_ip: None, + extend_lifetime: false, + }; + + let result = build(&input); + + assert!(result.query.is_empty()); + assert!(!result.body.is_empty()); + } + + #[test] + fn server_resolves_to_ipv4_with_context_using_localhost() { + let gp_params = make_gp_params(); + let cred = make_credential(); + let gateway = Gateway::new("Local".to_string(), "localhost".to_string()); + let context = GatewayLoginContext::new(&gateway, GatewaySelection::Auto); + + let input = GatewayLoginInput { + gp_params: &gp_params, + cred: &cred, + gateway_host: "localhost", + context: Some(&context), + client_ip: None, + extend_lifetime: false, + }; + + let result = build(&input); + + let server = result + .body + .iter() + .find(|(k, _)| k == "server") + .map(|(_, v)| v.as_str()) + .expect("server param should exist"); + // localhost resolves to 127.0.0.1 (IPv4) + assert_eq!(server, "127.0.0.1"); + } + + #[test] + fn server_falls_back_to_host_when_resolution_fails() { + let gp_params = make_gp_params(); + let cred = make_credential(); + let gateway = Gateway::new("GW".to_string(), "nonexistent.invalid.test".to_string()); + let context = GatewayLoginContext::new(&gateway, GatewaySelection::Auto); + + let input = GatewayLoginInput { + gp_params: &gp_params, + cred: &cred, + gateway_host: "nonexistent.invalid.test", + context: Some(&context), + client_ip: None, + extend_lifetime: false, + }; + + let result = build(&input); + + let server = result + .body + .iter() + .find(|(k, _)| k == "server") + .map(|(_, v)| v.as_str()) + .expect("server param should exist"); + // Falls back to the original gateway host when DNS resolution fails + assert_eq!(server, "nonexistent.invalid.test"); + } +} diff --git a/crates/gpapi/src/params/gateway_prelogin.rs b/crates/gpapi/src/params/gateway_prelogin.rs new file mode 100644 index 0000000..bc85a19 --- /dev/null +++ b/crates/gpapi/src/params/gateway_prelogin.rs @@ -0,0 +1,125 @@ +use super::RequestParams; +use crate::os_profile::{OsProfile, PreloginBrowserMode, PreloginParamLocation}; + +/// Build request parameters for the gateway prelogin endpoint. +/// +/// Same as portal prelogin but uses the gateway-specific embedded browser value. +pub(crate) fn build(profile: &OsProfile, browser_mode: PreloginBrowserMode) -> RequestParams { + let default_browser = profile.gateway_default_browser(browser_mode); + + let params: Vec<(String, String)> = vec![ + ("tmp".into(), "tmp".into()), + ("clientVer".into(), "4100".into()), + ("clientos".into(), profile.client_os().as_str().into()), + ("os-version".into(), profile.os_version().into()), + ("host-id".into(), profile.host_id().into()), + ("ipv6-support".into(), "yes".into()), + ("default-browser".into(), default_browser.into()), + ("cas-support".into(), "yes".into()), + ("data".into(), "eyJjYXNfZW1iZWRkZWRfYnJvd3NlciI6InllcyJ9".into()), + ]; + + let mut query: Vec<(String, String)> = vec![]; + if profile.kerberos_support_in_query() { + query.push(("kerberos-support".into(), "yes".into())); + } + + match profile.prelogin_param_location() { + PreloginParamLocation::Body => RequestParams { body: params, query }, + PreloginParamLocation::Query => RequestParams { + body: vec![], + query: params.into_iter().chain(query).collect(), + }, + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::os_profile::ClientOs; + + #[test] + fn linux_places_params_in_body() { + let profile = OsProfile::builder(ClientOs::Linux).build(); + let result = build(&profile, PreloginBrowserMode::Embedded); + + assert!(!result.body.is_empty()); + assert!(result.query.is_empty()); + } + + #[test] + fn mac_places_params_in_body_with_kerberos_query() { + let profile = OsProfile::builder(ClientOs::Mac).build(); + let result = build(&profile, PreloginBrowserMode::Embedded); + + assert!(!result.body.is_empty()); + assert_eq!(result.query.len(), 1); + assert_eq!(result.query[0], ("kerberos-support".into(), "yes".into())); + } + + #[test] + fn windows_places_all_params_in_query() { + let profile = OsProfile::builder(ClientOs::Windows).build(); + let result = build(&profile, PreloginBrowserMode::Embedded); + + assert!(result.body.is_empty()); + // 9 base params + 1 kerberos-support + assert_eq!(result.query.len(), 10); + } + + #[test] + fn uses_embedded_gateway_default_browser_value() { + let profile = OsProfile::builder(ClientOs::Linux).build(); + let result = build(&profile, PreloginBrowserMode::Embedded); + + let browser_param = result + .body + .iter() + .find(|(k, _)| k == "default-browser") + .expect("default-browser param should exist"); + assert_eq!(browser_param.1, "0"); + } + + #[test] + fn uses_target_value_when_external_browser_is_requested() { + let profile = OsProfile::builder(ClientOs::Linux).build(); + let result = build(&profile, PreloginBrowserMode::External); + + let browser_param = result + .body + .iter() + .find(|(k, _)| k == "default-browser") + .expect("default-browser param should exist"); + assert_eq!(browser_param.1, "4"); + } + + #[test] + fn includes_all_required_params() { + let profile = OsProfile::builder(ClientOs::Linux).build(); + let result = build(&profile, PreloginBrowserMode::Embedded); + + let keys: Vec<&str> = result.body.iter().map(|(k, _)| k.as_str()).collect(); + assert!(keys.contains(&"tmp")); + assert!(keys.contains(&"clientVer")); + assert!(keys.contains(&"clientos")); + assert!(keys.contains(&"os-version")); + assert!(keys.contains(&"host-id")); + assert!(keys.contains(&"ipv6-support")); + assert!(keys.contains(&"default-browser")); + assert!(keys.contains(&"cas-support")); + assert!(keys.contains(&"data")); + } + + #[test] + fn data_param_is_cas_embedded_browser_base64() { + let profile = OsProfile::builder(ClientOs::Linux).build(); + let result = build(&profile, PreloginBrowserMode::Embedded); + + let data_param = result + .body + .iter() + .find(|(k, _)| k == "data") + .expect("data param should exist"); + assert_eq!(data_param.1, "eyJjYXNfZW1iZWRkZWRfYnJvd3NlciI6InllcyJ9"); + } +} diff --git a/crates/gpapi/src/params/mod.rs b/crates/gpapi/src/params/mod.rs new file mode 100644 index 0000000..c4cf79b --- /dev/null +++ b/crates/gpapi/src/params/mod.rs @@ -0,0 +1,15 @@ +pub(crate) mod credential; +pub mod gateway_login; +pub mod gateway_prelogin; +pub mod portal_getconfig; +pub mod portal_prelogin; + +/// Ordered request parameters split into body (form data) and query string. +/// +/// Uses `Vec<(String, String)>` instead of `HashMap` to preserve parameter +/// ordering, as some servers may be sensitive to order. +#[derive(Debug, Clone, Default)] +pub struct RequestParams { + pub body: Vec<(String, String)>, + pub query: Vec<(String, String)>, +} diff --git a/crates/gpapi/src/params/portal_getconfig.rs b/crates/gpapi/src/params/portal_getconfig.rs new file mode 100644 index 0000000..4559556 --- /dev/null +++ b/crates/gpapi/src/params/portal_getconfig.rs @@ -0,0 +1,304 @@ +use super::{RequestParams, credential as credential_params}; +use crate::{credential::Credential, gp_params::GpParams, os_profile::ClientOs, portal::csc::swg_nonce}; + +/// Build request parameters for the portal getconfig endpoint. +/// +/// This builder produces the form body for `getconfig.esp`. It deliberately +/// excludes `server`, `prot`, `direct`, and `jnlpReady` which are not sent +/// by the official client for this endpoint. +/// +/// For SAML (prelogin) credentials the password is set to `SAMLPASS` on Linux +/// and left empty on macOS/Windows, matching official client behavior. +pub(crate) fn build(cred: &Credential, gp_params: &GpParams, server: &str) -> RequestParams { + let profile = gp_params.os_profile(); + let nonce = if profile.client_os() == ClientOs::Linux { + "0".to_string() + } else { + swg_nonce() + }; + + let mut body = credential_params::build(cred, gp_params); + body.push(("inputStr".into(), gp_params.input_str().unwrap_or_default().into())); + + // Fixed params + body.push(("ok".into(), "Login".into())); + body.push(("clientVer".into(), "4100".into())); + + // OS params + body.push(("clientos".into(), profile.client_os().as_str().into())); + body.push(("clientgpversion".into(), profile.client_version().into())); + body.push(("computer".into(), profile.computer().into())); + body.push(("os-version".into(), profile.os_version().into())); + body.push(("host-id".into(), profile.host_id().into())); + body.push(("ipv6-support".into(), "yes".into())); + body.push(("serialno".into(), profile.serialno().into())); + + // CSC fields + body.push(("csc-digest".into(), String::new())); + body.push(("config-digest".into(), String::new())); + body.push(( + "csc-support".into(), + if gp_params.effective_csc_support() { "yes" } else { "no" }.into(), + )); + + // Host and SWG + body.push(("host".into(), server.into())); + body.push(("swg-auth-token".into(), "0".into())); + body.push(("swg-nonce".into(), nonce)); + + RequestParams { body, query: vec![] } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{ + credential::{PasswordCredential, PreloginCredential}, + gp_params::CscMode, + os_profile::{ClientOs, HostIdentity, OsProfile}, + }; + + fn test_profile(os: ClientOs) -> OsProfile { + OsProfile::builder(os) + .computer_name_override("test-computer") + .client_version("6.3.3-100") + .host_identity(HostIdentity::new( + "test-computer".into(), + "test-host-id".into(), + "test-serial".into(), + "aa:bb:cc:dd:ee:ff".into(), + )) + .build() + } + + fn password_cred() -> Credential { + Credential::from(PasswordCredential::new("alice", "secret")) + } + + fn prelogin_cred() -> Credential { + Credential::Prelogin(PreloginCredential::new( + "alice", + Some("my-prelogin-cookie"), + Some("my-userauthcookie"), + None, + )) + } + + #[test] + fn excludes_forbidden_params() { + let profile = test_profile(ClientOs::Linux); + let cred = password_cred(); + let gp_params = GpParams::builder(profile.clone()).build(); + let result = build(&cred, &gp_params, "vpn.example.com"); + + let keys: Vec<&str> = result.body.iter().map(|(k, _)| k.as_str()).collect(); + assert!(!keys.contains(&"server")); + assert!(!keys.contains(&"prot")); + assert!(!keys.contains(&"direct")); + assert!(!keys.contains(&"jnlpReady")); + } + + #[test] + fn includes_required_params() { + let profile = test_profile(ClientOs::Linux); + let cred = password_cred(); + let gp_params = GpParams::builder(profile.clone()).build(); + let result = build(&cred, &gp_params, "vpn.example.com"); + + let keys: Vec<&str> = result.body.iter().map(|(k, _)| k.as_str()).collect(); + assert!(keys.contains(&"clientgpversion")); + assert!(keys.contains(&"host-id")); + assert!(keys.contains(&"serialno")); + assert!(keys.contains(&"token")); + } + + #[test] + fn includes_identity_from_profile() { + let profile = test_profile(ClientOs::Mac); + let cred = password_cred(); + let gp_params = GpParams::builder(profile.clone()).build(); + let result = build(&cred, &gp_params, "vpn.example.com"); + + let find = |key: &str| result.body.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str()); + + assert_eq!(find("host-id"), Some(profile.host_id())); + assert_eq!(find("serialno"), Some(profile.serialno())); + assert_eq!(find("clientgpversion"), Some("6.3.3-100")); + assert_eq!(find("computer"), Some("test-computer")); + assert_eq!(find("os-version"), Some(profile.os_version())); + assert_eq!(find("clientos"), Some("Mac")); + } + + #[test] + fn linux_saml_sets_passwd_to_samlpass() { + let profile = test_profile(ClientOs::Linux); + let cred = prelogin_cred(); + let gp_params = GpParams::builder(profile.clone()).build(); + let result = build(&cred, &gp_params, "vpn.example.com"); + + let passwd = result.body.iter().find(|(k, _)| k == "passwd").map(|(_, v)| v.as_str()); + assert_eq!(passwd, Some("SAMLPASS")); + } + + #[test] + fn mac_saml_sets_passwd_to_empty() { + let profile = test_profile(ClientOs::Mac); + let cred = prelogin_cred(); + let gp_params = GpParams::builder(profile.clone()).build(); + let result = build(&cred, &gp_params, "vpn.example.com"); + + let passwd = result.body.iter().find(|(k, _)| k == "passwd").map(|(_, v)| v.as_str()); + assert_eq!(passwd, Some("")); + } + + #[test] + fn saml_without_portal_auth_cookies_uses_empty_sentinel() { + let profile = test_profile(ClientOs::Mac); + let cred = Credential::Prelogin(PreloginCredential::new("alice", Some("my-prelogin-cookie"), None, None)); + let gp_params = GpParams::builder(profile.clone()).build(); + let result = build(&cred, &gp_params, "vpn.example.com"); + + let find = |key: &str| result.body.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str()); + + assert_eq!(find("portal-userauthcookie"), Some("empty")); + assert_eq!(find("portal-prelogonuserauthcookie"), Some("empty")); + } + + #[test] + fn saml_blank_portal_auth_cookie_uses_empty_sentinel() { + let profile = test_profile(ClientOs::Mac); + let cred = Credential::Prelogin(PreloginCredential::new( + "alice", + Some("my-prelogin-cookie"), + Some(""), + None, + )); + let gp_params = GpParams::builder(profile.clone()).build(); + let result = build(&cred, &gp_params, "vpn.example.com"); + + let portal_cookie = result + .body + .iter() + .find(|(k, _)| k == "portal-userauthcookie") + .map(|(_, v)| v.as_str()); + + assert_eq!(portal_cookie, Some("empty")); + } + + #[test] + fn windows_saml_sets_passwd_to_empty() { + let profile = test_profile(ClientOs::Windows); + let cred = prelogin_cred(); + let gp_params = GpParams::builder(profile.clone()).build(); + let result = build(&cred, &gp_params, "vpn.example.com"); + + let passwd = result.body.iter().find(|(k, _)| k == "passwd").map(|(_, v)| v.as_str()); + assert_eq!(passwd, Some("")); + } + + #[test] + fn password_cred_sends_actual_password() { + let profile = test_profile(ClientOs::Linux); + let cred = password_cred(); + let gp_params = GpParams::builder(profile.clone()).build(); + let result = build(&cred, &gp_params, "vpn.example.com"); + + let passwd = result.body.iter().find(|(k, _)| k == "passwd").map(|(_, v)| v.as_str()); + assert_eq!(passwd, Some("secret")); + } + + #[test] + fn includes_csc_support_fields() { + let profile = test_profile(ClientOs::Mac); + let cred = password_cred(); + let gp_params = GpParams::builder(profile.clone()).build(); + let result = build(&cred, &gp_params, "vpn.example.com"); + + let find = |key: &str| result.body.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str()); + + assert_eq!(find("csc-support"), Some("yes")); + assert_eq!(find("csc-digest"), Some("")); + assert_eq!(find("config-digest"), Some("")); + assert_eq!(find("swg-auth-token"), Some("0")); + assert!(find("swg-nonce").is_some()); + } + + #[test] + fn linux_uses_zero_swg_nonce() { + let profile = test_profile(ClientOs::Linux); + let cred = prelogin_cred(); + let gp_params = GpParams::builder(profile.clone()).build(); + let result = build(&cred, &gp_params, "vpn.example.com"); + + let nonce = result + .body + .iter() + .find(|(k, _)| k == "swg-nonce") + .map(|(_, v)| v.as_str()); + assert_eq!(nonce, Some("0")); + } + + #[test] + fn linux_defaults_csc_support_to_no() { + let profile = test_profile(ClientOs::Linux); + let cred = password_cred(); + let gp_params = GpParams::builder(profile.clone()).build(); + let result = build(&cred, &gp_params, "vpn.example.com"); + + let csc = result + .body + .iter() + .find(|(k, _)| k == "csc-support") + .map(|(_, v)| v.as_str()); + assert_eq!(csc, Some("no")); + } + + #[test] + fn csc_mode_override_works() { + let cred = password_cred(); + let gp_params = GpParams::builder(test_profile(ClientOs::Linux)) + .csc_mode(CscMode::Yes) + .build(); + let result = build(&cred, &gp_params, "vpn.example.com"); + + let csc = result + .body + .iter() + .find(|(k, _)| k == "csc-support") + .map(|(_, v)| v.as_str()); + assert_eq!(csc, Some("yes")); + } + + #[test] + fn host_param_is_server_value() { + let profile = test_profile(ClientOs::Linux); + let cred = password_cred(); + let gp_params = GpParams::builder(profile.clone()).build(); + let result = build(&cred, &gp_params, "vpn.example.com"); + + let host = result.body.iter().find(|(k, _)| k == "host").map(|(_, v)| v.as_str()); + assert_eq!(host, Some("vpn.example.com")); + } + + #[test] + fn token_is_empty_for_password_cred() { + let profile = test_profile(ClientOs::Linux); + let cred = password_cred(); + let gp_params = GpParams::builder(profile.clone()).build(); + let result = build(&cred, &gp_params, "vpn.example.com"); + + let token = result.body.iter().find(|(k, _)| k == "token").map(|(_, v)| v.as_str()); + assert_eq!(token, Some("")); + } + + #[test] + fn all_params_in_body_not_query() { + let profile = test_profile(ClientOs::Linux); + let cred = password_cred(); + let gp_params = GpParams::builder(profile.clone()).build(); + let result = build(&cred, &gp_params, "vpn.example.com"); + + assert!(!result.body.is_empty()); + assert!(result.query.is_empty()); + } +} diff --git a/crates/gpapi/src/params/portal_prelogin.rs b/crates/gpapi/src/params/portal_prelogin.rs new file mode 100644 index 0000000..8bed47e --- /dev/null +++ b/crates/gpapi/src/params/portal_prelogin.rs @@ -0,0 +1,147 @@ +use super::RequestParams; +use crate::os_profile::{OsProfile, PreloginBrowserMode, PreloginParamLocation}; + +/// Build request parameters for the portal prelogin endpoint. +/// +/// Parameters are placed in the request body for Linux/macOS and in the query +/// string for Windows, based on `profile.prelogin_param_location()`. +/// +/// When `profile.kerberos_support_in_query()` is true (macOS/Windows), +/// `kerberos-support=yes` is added as a query parameter. +pub(crate) fn build(profile: &OsProfile, browser_mode: PreloginBrowserMode) -> RequestParams { + let default_browser = profile.portal_default_browser(browser_mode); + + let params: Vec<(String, String)> = vec![ + ("tmp".into(), "tmp".into()), + ("clientVer".into(), "4100".into()), + ("clientos".into(), profile.client_os().as_str().into()), + ("os-version".into(), profile.os_version().into()), + ("host-id".into(), profile.host_id().into()), + ("ipv6-support".into(), "yes".into()), + ("default-browser".into(), default_browser.into()), + ("cas-support".into(), "yes".into()), + ("data".into(), "eyJjYXNfZW1iZWRkZWRfYnJvd3NlciI6InllcyJ9".into()), + ]; + + let mut query: Vec<(String, String)> = vec![]; + if profile.kerberos_support_in_query() { + query.push(("kerberos-support".into(), "yes".into())); + } + + match profile.prelogin_param_location() { + PreloginParamLocation::Body => RequestParams { body: params, query }, + PreloginParamLocation::Query => RequestParams { + body: vec![], + query: params.into_iter().chain(query).collect(), + }, + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::os_profile::ClientOs; + + #[test] + fn linux_places_params_in_body() { + let profile = OsProfile::builder(ClientOs::Linux).build(); + let result = build(&profile, PreloginBrowserMode::Embedded); + + assert!(!result.body.is_empty()); + assert!(result.query.is_empty()); + } + + #[test] + fn mac_places_params_in_body_with_kerberos_query() { + let profile = OsProfile::builder(ClientOs::Mac).build(); + let result = build(&profile, PreloginBrowserMode::Embedded); + + assert!(!result.body.is_empty()); + assert_eq!(result.query.len(), 1); + assert_eq!(result.query[0], ("kerberos-support".into(), "yes".into())); + } + + #[test] + fn windows_places_all_params_in_query() { + let profile = OsProfile::builder(ClientOs::Windows).build(); + let result = build(&profile, PreloginBrowserMode::Embedded); + + assert!(result.body.is_empty()); + // 9 base params + 1 kerberos-support + assert_eq!(result.query.len(), 10); + } + + #[test] + fn uses_embedded_portal_default_browser_value() { + let profile = OsProfile::builder(ClientOs::Linux).build(); + let result = build(&profile, PreloginBrowserMode::Embedded); + + let browser_param = result + .body + .iter() + .find(|(k, _)| k == "default-browser") + .expect("default-browser param should exist"); + assert_eq!(browser_param.1, "-10"); + } + + #[test] + fn uses_target_value_when_external_browser_is_requested() { + let profile = OsProfile::builder(ClientOs::Linux).build(); + let result = build(&profile, PreloginBrowserMode::External); + + let browser_param = result + .body + .iter() + .find(|(k, _)| k == "default-browser") + .expect("default-browser param should exist"); + assert_eq!(browser_param.1, "4"); + } + + #[test] + fn includes_all_required_params() { + let profile = OsProfile::builder(ClientOs::Linux).build(); + let result = build(&profile, PreloginBrowserMode::Embedded); + + let keys: Vec<&str> = result.body.iter().map(|(k, _)| k.as_str()).collect(); + assert!(keys.contains(&"tmp")); + assert!(keys.contains(&"clientVer")); + assert!(keys.contains(&"clientos")); + assert!(keys.contains(&"os-version")); + assert!(keys.contains(&"host-id")); + assert!(keys.contains(&"ipv6-support")); + assert!(keys.contains(&"default-browser")); + assert!(keys.contains(&"cas-support")); + assert!(keys.contains(&"data")); + } + + #[test] + fn data_param_is_cas_embedded_browser_base64() { + let profile = OsProfile::builder(ClientOs::Linux).build(); + let result = build(&profile, PreloginBrowserMode::Embedded); + + let data_param = result + .body + .iter() + .find(|(k, _)| k == "data") + .expect("data param should exist"); + assert_eq!(data_param.1, "eyJjYXNfZW1iZWRkZWRfYnJvd3NlciI6InllcyJ9"); + } + + #[test] + fn kerberos_not_in_query_for_linux() { + let profile = OsProfile::builder(ClientOs::Linux).build(); + let result = build(&profile, PreloginBrowserMode::Embedded); + + let has_kerberos = result.query.iter().any(|(k, _)| k == "kerberos-support"); + assert!(!has_kerberos); + } + + #[test] + fn kerberos_in_query_for_windows() { + let profile = OsProfile::builder(ClientOs::Windows).build(); + let result = build(&profile, PreloginBrowserMode::Embedded); + + let has_kerberos = result.query.iter().any(|(k, _)| k == "kerberos-support"); + assert!(has_kerberos); + } +} diff --git a/crates/gpapi/src/portal/config.rs b/crates/gpapi/src/portal/config.rs index 0f77d4d..d34c1b9 100644 --- a/crates/gpapi/src/portal/config.rs +++ b/crates/gpapi/src/portal/config.rs @@ -1,3 +1,5 @@ +use std::collections::HashMap; + use anyhow::bail; use dns_lookup::lookup_addr; use log::{debug, info, warn}; @@ -11,9 +13,12 @@ use crate::{ error::PortalError, gateway::{Gateway, parse_gateways}, gp_params::GpParams, - utils::{normalize_server, parse_gp_response, remove_url_scheme, xml::ElementExt}, + params, + utils::{normalize_server, parse_gp_response, redact::redact_form_params, remove_url_scheme, xml::ElementExt}, }; +use super::csc; + #[derive(Debug, Serialize, Type)] #[serde(rename_all = "camelCase")] pub struct PortalConfig { @@ -21,6 +26,7 @@ pub struct PortalConfig { auth_cookie: AuthCookieCredential, config_cred: Credential, gateways: Vec, + connect_method: Option, config_digest: Option, /** * Variants: @@ -37,6 +43,10 @@ pub struct PortalConfig { * Whether the portal policy allows extending the gateway session. */ allow_extend_session: Option, + /** + * Whether the portal policy enables default-browser authentication. + */ + default_browser: Option, } impl PortalConfig { @@ -60,6 +70,10 @@ impl PortalConfig { self.internal_host_detection } + pub fn connect_method(&self) -> Option<&str> { + self.connect_method.as_deref() + } + pub fn version(&self) -> Option<&str> { self.version.as_deref() } @@ -68,6 +82,10 @@ impl PortalConfig { self.allow_extend_session } + pub fn default_browser(&self) -> Option { + self.default_browser + } + /// In-place sort the gateways by region pub fn sort_gateways(&mut self, region: &str) { let preferred_gateway = self.find_preferred_gateway(region); @@ -118,16 +136,17 @@ pub async fn retrieve_config(portal: &str, cred: &Credential, gp_params: &GpPara let url = format!("{}/global-protect/getconfig.esp", portal); let client = Client::try_from(gp_params)?; - let mut params = cred.to_params(); - let extra_params = gp_params.to_params(); - - params.extend(extra_params); - params.insert("server", &server); - params.insert("host", &server); + let request_params = params::portal_getconfig::build(cred, gp_params, &server); + let body_pairs: Vec<(&str, &str)> = request_params + .body + .iter() + .map(|(k, v)| (k.as_str(), v.as_str())) + .collect(); info!("Retrieve the portal config, user_agent: {}", gp_params.user_agent()); + info!("Portal config request params: {}", redact_form_params(&body_pairs)); - let res = client.post(&url).form(¶ms).send().await.map_err(|e| { + let res = client.post(&url).form(&request_params.body).send().await.map_err(|e| { warn!("Network error: {:?}", e); anyhow::anyhow!(PortalError::NetworkError(e)) })?; @@ -152,11 +171,86 @@ pub async fn retrieve_config(portal: &str, cred: &Credential, gp_params: &GpPara debug!("Portal config response: {}", res_xml); let root = Element::parse(res_xml.as_bytes()).map_err(|e| PortalError::ConfigError(e.to_string()))?; + if csc::is_config_criteria(&root) { + info!("Portal returned CSC criteria: {}", csc_criteria_summary(&root)); + if !gp_params.effective_csc_support() { + bail!(PortalError::ConfigError( + "Portal returned CSC criteria but CSC support is disabled".to_string() + )); + } + let csc_xml = retrieve_csc_config(&client, &portal, &root, cred.username(), gp_params).await?; + debug!("Portal CSC config response: {}", csc_xml); + let root = Element::parse(csc_xml.as_bytes()).map_err(|e| PortalError::ConfigError(e.to_string()))?; + return parse_portal_config(&server, cred, root); + } + + info!("Portal did not return CSC criteria"); + parse_portal_config(&server, cred, root) +} + +async fn retrieve_csc_config( + client: &Client, + portal: &str, + root: &Element, + username: &str, + gp_params: &GpParams, +) -> anyhow::Result { + let csc_req = csc::build_csc_request(root, username, gp_params)?; + let swg_nonce = csc::swg_nonce(); + let params = csc::csc_params(&csc_req, username, gp_params, &swg_nonce); + let url = format!("{}/global-protect/getconfig_csc.esp", portal); + + info!("Portal CSC config request summary: {}", csc_req.summary()); + info!("Portal CSC config request params: {}", redact_params(¶ms)); + + let res = client.post(&url).form(¶ms).send().await.map_err(|e| { + warn!("Network error: {:?}", e); + anyhow::anyhow!(PortalError::NetworkError(e)) + })?; + + parse_gp_response(res).await.or_else(|err| { + if err.status == StatusCode::NOT_FOUND { + bail!(PortalError::ConfigError("CSC config endpoint not found".to_string())); + } + + if err.is_status_error() { + warn!("{err}"); + bail!("Portal CSC config error: {}", err.reason); + } + + Err(anyhow::anyhow!(PortalError::ConfigError(err.reason))) + }) +} + +fn redact_params(params: &HashMap<&str, &str>) -> String { + let params = params.iter().map(|(key, value)| (*key, *value)).collect::>(); + redact_form_params(¶ms) +} + +fn csc_criteria_summary(root: &Element) -> String { + let auth_cookie = present(root.descendant_text("portal-csc-auth-cookie").as_deref()); + let config_digest = present(root.descendant_text("config-digest").as_deref()); + let custom_check_entries = root + .descendant("custom-checks") + .map(|custom_checks| custom_checks.descendants("entry").len()) + .unwrap_or_default(); + + format!("auth_cookie={auth_cookie}, config_digest={config_digest}, custom_check_entries={custom_check_entries}") +} + +fn present(value: Option<&str>) -> &'static str { + match value { + Some(value) if !value.is_empty() => "present", + _ => "empty", + } +} + +fn parse_portal_config(server: &str, cred: &Credential, root: Element) -> anyhow::Result { let mut ihd_enabled = false; let mut prefer_internal = false; if let Some(ihd_node) = root.descendant("internal-host-detection") { ihd_enabled = true; - prefer_internal = internal_host_detect(&ihd_node) + prefer_internal = internal_host_detect(ihd_node) } let mut gateways = parse_gateways(&root, prefer_internal).unwrap_or_else(|| { @@ -169,27 +263,41 @@ pub async fn retrieve_config(portal: &str, cred: &Credential, gp_params: &GpPara .descendant_text("portal-prelogonuserauthcookie") .unwrap_or_default(); let config_digest = root.descendant_text("config-digest"); + let connect_method = parse_connect_method(&root); if gateways.is_empty() { gateways.push(Gateway::new(server.to_string(), server.to_string())); + } else { + info!("Found {} gateways in portal config", gateways.len()); } let version = root.descendant_text("version").map(|s| s.to_string()); info!("Detected portal version: {:?}", version); let allow_extend_session = parse_allow_extend_session(&root); + let default_browser = parse_default_browser(&root); Ok(PortalConfig { portal: server.to_string(), auth_cookie: AuthCookieCredential::new(cred.username(), &user_auth_cookie, &prelogon_user_auth_cookie), config_cred: cred.clone(), gateways, + connect_method, config_digest: config_digest.map(|s| s.to_string()), internal_host_detection: if ihd_enabled { Some(prefer_internal) } else { None }, version, allow_extend_session, + default_browser, }) } +fn parse_default_browser(root: &Element) -> Option { + match root.descendant_text("default-browser")?.trim() { + "yes" => Some(true), + "no" => Some(false), + _ => None, + } +} + fn parse_allow_extend_session(root: &Element) -> Option { match root.descendant_text("allow-extend-session")?.trim() { "yes" => Some(true), @@ -198,6 +306,13 @@ fn parse_allow_extend_session(root: &Element) -> Option { } } +fn parse_connect_method(root: &Element) -> Option { + root + .descendant_text("connect-method") + .filter(|s| !s.is_empty()) + .map(|s| s.to_string()) +} + // Perform DNS lookup and compare the result with the expected hostname fn internal_host_detect(element: &Element) -> bool { let ip_info = [ @@ -208,23 +323,24 @@ fn internal_host_detect(element: &Element) -> bool { info!("Found internal-host-detection, performing DNS lookup"); for (ip_address, host) in ip_info.iter() { - if let (Some(ip_address), Some(host)) = (ip_address.as_deref(), host.as_deref()) { - if !ip_address.is_empty() && !host.is_empty() { - match ip_address.parse::() { - Ok(ip) => match lookup_addr(&ip) { - Ok(host_lookup) if host_lookup.to_lowercase() == host.to_lowercase() => { - return true; - } - Ok(host_lookup) => { - info!( - "rDNS lookup for {} returned {}, expected {}", - ip_address, host_lookup, host - ); - } - Err(err) => warn!("rDNS lookup failed for {}: {}", ip_address, err), - }, - Err(err) => warn!("Invalid IP address {}: {}", ip_address, err), - } + if let (Some(ip_address), Some(host)) = (ip_address.as_deref(), host.as_deref()) + && !ip_address.is_empty() + && !host.is_empty() + { + match ip_address.parse::() { + Ok(ip) => match lookup_addr(&ip) { + Ok(host_lookup) if host_lookup.to_lowercase() == host.to_lowercase() => { + return true; + } + Ok(host_lookup) => { + info!( + "rDNS lookup for {} returned {}, expected {}", + ip_address, host_lookup, host + ); + } + Err(err) => warn!("rDNS lookup failed for {}: {}", ip_address, err), + }, + Err(err) => warn!("Invalid IP address {}: {}", ip_address, err), } } } @@ -267,4 +383,58 @@ mod tests { assert_eq!(parse_allow_extend_session(&root), None); } + + #[test] + fn parses_default_browser_yes() { + let root = parse_xml("yes"); + + assert_eq!(parse_default_browser(&root), Some(true)); + } + + #[test] + fn parses_default_browser_no() { + let root = parse_xml("no"); + + assert_eq!(parse_default_browser(&root), Some(false)); + } + + #[test] + fn leaves_absent_default_browser_unknown() { + let root = parse_xml(""); + + assert_eq!(parse_default_browser(&root), None); + } + + #[test] + fn parses_connect_method() { + let root = parse_xml("on-demand"); + + assert_eq!(parse_connect_method(&root).as_deref(), Some("on-demand")); + } + + #[test] + fn parses_csc_policy_response_as_portal_config() { + let root = parse_xml( + r#" + user-cookie + prelogon-cookie + + + + + us1.vpn.example.com + + + + + "#, + ); + let cred = Credential::from(crate::credential::PasswordCredential::new("alice", "secret")); + + let config = parse_portal_config("vpn.example.com", &cred, root).unwrap(); + + assert_eq!(config.auth_cookie().user_auth_cookie(), "user-cookie"); + assert_eq!(config.auth_cookie().prelogon_user_auth_cookie(), "prelogon-cookie"); + assert_eq!(config.gateways().len(), 1); + } } diff --git a/crates/gpapi/src/portal/csc.rs b/crates/gpapi/src/portal/csc.rs new file mode 100644 index 0000000..2a9f394 --- /dev/null +++ b/crates/gpapi/src/portal/csc.rs @@ -0,0 +1,735 @@ +use std::{ + collections::HashMap, + fmt::Write, + fs, + process::Command, + time::{SystemTime, UNIX_EPOCH}, +}; + +use xmltree::{Element, EmitterConfig, XMLNode}; + +use crate::{gp_params::GpParams, utils::xml::ElementExt}; + +const DIGEST_PLACEHOLDER: &str = "__#_PAN_CSC_DATA_DIGEST_#__"; + +pub(super) struct CscRequest { + pub(super) auth_cookie: String, + pub(super) config_digest: String, + pub(super) csc_digest: String, + pub(super) csc_data: String, + summary: CscBuildSummary, + host_id: String, + serial_number: String, +} + +impl CscRequest { + pub(super) fn summary(&self) -> String { + format!( + "digest_len={}, xml_len={}, plist_entries={}, plist_present={}, plist_missing={}, process_entries={}, process_present={}, process_missing={}", + self.csc_digest.len(), + self.csc_data.len(), + self.summary.plist_entries, + self.summary.plist_present, + self.summary.plist_missing, + self.summary.process_entries, + self.summary.process_present, + self.summary.process_missing, + ) + } +} + +#[derive(Default)] +struct CscBuildSummary { + plist_entries: usize, + plist_present: usize, + plist_missing: usize, + process_entries: usize, + process_present: usize, + process_missing: usize, +} + +struct CscDataInput<'a> { + criteria: &'a Element, + auth_cookie: &'a str, + username: &'a str, + gp_params: &'a GpParams, + host_id: &'a str, + serial_number: &'a str, + csc_digest: &'a str, +} + +pub(super) trait CscDataReader { + fn read_preference(&self, domain: &str, key: &str) -> Option; + fn process_exists(&self, name: &str) -> bool; +} + +struct SystemCscDataReader; + +impl CscDataReader for SystemCscDataReader { + fn read_preference(&self, domain: &str, key: &str) -> Option { + read_macos_preference(domain, key) + } + + fn process_exists(&self, name: &str) -> bool { + linux_process_names().iter().any(|process_name| process_name == name) + } +} + +pub(crate) fn swg_nonce() -> String { + let millis = SystemTime::now() + .duration_since(UNIX_EPOCH) + .map(|duration| duration.as_millis()) + .unwrap_or_default(); + + (millis % 2_147_483_647).to_string() +} + +pub(super) fn is_config_criteria(root: &Element) -> bool { + root.name == "config-criteria" +} + +pub(super) fn build_csc_request(root: &Element, username: &str, gp_params: &GpParams) -> anyhow::Result { + let reader = SystemCscDataReader; + build_csc_request_with_reader(root, username, gp_params, &reader) +} + +pub(super) fn build_csc_request_with_reader( + root: &Element, + username: &str, + gp_params: &GpParams, + reader: &dyn CscDataReader, +) -> anyhow::Result { + let auth_cookie = root + .descendant_text("portal-csc-auth-cookie") + .filter(|value| !value.is_empty()) + .ok_or_else(|| anyhow::anyhow!("CSC criteria response does not contain portal-csc-auth-cookie"))?; + let config_digest = root.descendant_text("config-digest").unwrap_or_default(); + let host_id = gp_params.host_id().to_string(); + let serial_number = gp_params.serialno().to_string(); + + let mut summary = CscBuildSummary::default(); + let csc_data = build_csc_data( + CscDataInput { + criteria: root, + auth_cookie: &auth_cookie, + username, + gp_params, + host_id: &host_id, + serial_number: &serial_number, + csc_digest: DIGEST_PLACEHOLDER, + }, + reader, + &mut summary, + )?; + let csc_digest = pan_md5_hex(csc_data.as_bytes()); + let csc_data = csc_data.replace(DIGEST_PLACEHOLDER, &csc_digest); + + Ok(CscRequest { + auth_cookie, + config_digest, + csc_digest, + csc_data, + summary, + host_id, + serial_number, + }) +} + +pub(super) fn csc_params<'a>( + req: &'a CscRequest, + username: &'a str, + gp_params: &'a GpParams, + swg_nonce: &'a str, +) -> HashMap<&'a str, &'a str> { + let mut params = HashMap::new(); + + params.insert("user", username); + params.insert("clientVer", "4100"); + params.insert("clientos", gp_params.client_os()); + params.insert("os-version", gp_params.os_version().unwrap_or_default()); + params.insert("hostid", req.host_id.as_str()); + params.insert("serialno", req.serial_number.as_str()); + params.insert("portal-cc-auth-cookie", req.auth_cookie.as_str()); + params.insert("config-digest", req.config_digest.as_str()); + params.insert("csc-digest", req.csc_digest.as_str()); + params.insert("csc-data", req.csc_data.as_str()); + params.insert("swg-auth-token", "0"); + params.insert("swg-nonce", swg_nonce); + + params +} + +fn build_csc_data( + input: CscDataInput<'_>, + reader: &dyn CscDataReader, + summary: &mut CscBuildSummary, +) -> anyhow::Result { + let mut root = Element::new("hip-report"); + push_text(&mut root, "portal-csc-auth-cookie", input.auth_cookie); + push_text(&mut root, "user-name", &urlencoding::encode(input.username)); + push_text(&mut root, "client-os", &client_os_report_value(input.gp_params)); + push_text(&mut root, "host-id", input.host_id); + push_text(&mut root, "device-serial-number", input.serial_number); + push_text(&mut root, "csc-digest", input.csc_digest); + root.children.push(XMLNode::Element(Element::new("categories"))); + let custom_checks = build_custom_checks(input.criteria, input.gp_params, reader, summary); + if !custom_checks.children.is_empty() { + root.children.push(XMLNode::Element(custom_checks)); + } + + let mut bytes = Vec::new(); + root.write_with_config( + &mut bytes, + EmitterConfig::new() + .perform_indent(true) + .indent_string("\t") + .write_document_declaration(true), + )?; + + String::from_utf8(bytes) + .map(|xml| { + let mut xml = xml.replace("", "\n\t"); + xml.push('\n'); + xml + }) + .map_err(Into::into) +} + +fn build_custom_checks( + criteria: &Element, + gp_params: &GpParams, + reader: &dyn CscDataReader, + summary: &mut CscBuildSummary, +) -> Element { + let mut custom_checks = Element::new("custom-checks"); + let Some(requested_checks) = criteria.descendant("custom-checks") else { + return custom_checks; + }; + + if gp_params.os_profile().supports_macos_plist_csc() + && let Some(plist) = requested_checks + .child("mac-os") + .and_then(|mac_os| mac_os.child("plist")) + { + custom_checks + .children + .push(XMLNode::Element(build_plist_checks(plist, reader, summary))); + } + + if gp_params.os_profile().supports_linux_process_csc() + && let Some(process_list) = requested_checks + .child("linux") + .and_then(|linux| linux.child("process-list")) + .or_else(|| requested_checks.child("process-list")) + { + custom_checks.children.push(XMLNode::Element(build_process_list_checks( + process_list, + reader, + summary, + ))); + } + + if gp_params.os_profile().supports_windows_registry_csc() + && let Some(registry_key) = requested_checks + .child("windows") + .and_then(|windows| windows.child("registry-key")) + .or_else(|| requested_checks.child("registry-key")) + { + custom_checks + .children + .push(XMLNode::Element(build_registry_key_checks(registry_key))); + } + + custom_checks +} + +fn build_plist_checks(plist: &Element, reader: &dyn CscDataReader, summary: &mut CscBuildSummary) -> Element { + let mut out = Element::new("plist"); + + for entry in plist.children("entry") { + let domain = entry.attr("name").unwrap_or_default(); + let mut out_entry = Element::new("entry"); + out_entry.attributes.insert("name".to_string(), domain.to_string()); + + let keys = plist_entry_keys(entry); + let values: Vec<_> = keys + .iter() + .map(|key| { + let value = reader.read_preference(domain, key); + (key.as_str(), value) + }) + .collect(); + let plist_exists = values.iter().any(|(_, value)| value.is_some()); + summary.plist_entries += keys.len(); + summary.plist_present += values.iter().filter(|(_, value)| value.is_some()).count(); + summary.plist_missing += values.iter().filter(|(_, value)| value.is_none()).count(); + + push_text(&mut out_entry, "exist", yes_no(plist_exists)); + push_text(&mut out_entry, "value", ""); + + let mut preference_value = Element::new("preference-value"); + for (key, value) in values { + let mut pref_entry = Element::new("entry"); + pref_entry.attributes.insert("name".to_string(), key.to_string()); + push_text(&mut pref_entry, "exist", yes_no(value.is_some())); + push_text(&mut pref_entry, "value", value.as_deref().unwrap_or_default()); + preference_value.children.push(XMLNode::Element(pref_entry)); + } + + out_entry.children.push(XMLNode::Element(preference_value)); + out.children.push(XMLNode::Element(out_entry)); + } + + out +} + +fn build_process_list_checks( + process_list: &Element, + reader: &dyn CscDataReader, + summary: &mut CscBuildSummary, +) -> Element { + let mut out = Element::new("process-list"); + + for process_name in process_list_names(process_list) { + let exists = reader.process_exists(&process_name); + summary.process_entries += 1; + if exists { + summary.process_present += 1; + } else { + summary.process_missing += 1; + } + + let mut entry = Element::new("entry"); + entry.attributes.insert("name".to_string(), process_name.clone()); + push_text(&mut entry, "exist", yes_no(exists)); + push_text(&mut entry, "value", if exists { &process_name } else { "" }); + out.children.push(XMLNode::Element(entry)); + } + + out +} + +fn plist_entry_keys(entry: &Element) -> Vec { + let keys: Vec = entry + .descendants("member") + .into_iter() + .filter_map(|element| element.get_text()) + .map(|text| text.to_string()) + .collect(); + + if keys.is_empty() { + entry + .attr("name") + .map(|name| vec![name.to_string()]) + .unwrap_or_default() + } else { + keys + } +} + +fn process_list_names(process_list: &Element) -> Vec { + let mut names: Vec = process_list + .descendants("member") + .into_iter() + .filter_map(|element| element.get_text()) + .map(|text| text.trim().to_string()) + .filter(|text| !text.is_empty()) + .collect(); + + names.extend( + process_list + .children("entry") + .into_iter() + .filter_map(|entry| entry.attr("name")) + .map(str::to_string), + ); + + names.sort(); + names.dedup(); + names +} + +fn build_registry_key_checks(registry_key: &Element) -> Element { + let mut out = Element::new("registry-key"); + + for name in registry_key_names(registry_key) { + let mut entry = Element::new("entry"); + entry.attributes.insert("name".to_string(), name); + push_text(&mut entry, "exist", "no"); + push_text(&mut entry, "value", ""); + out.children.push(XMLNode::Element(entry)); + } + + out +} + +fn registry_key_names(registry_key: &Element) -> Vec { + let mut names: Vec = registry_key + .descendants("member") + .into_iter() + .filter_map(|element| element.get_text()) + .map(|text| text.trim().to_string()) + .filter(|text| !text.is_empty()) + .collect(); + + names.extend( + registry_key + .children("entry") + .into_iter() + .filter_map(|entry| entry.attr("name")) + .map(str::to_string), + ); + + names.sort(); + names.dedup(); + names +} + +fn pan_md5_hex(value: &[u8]) -> String { + let digest = md5::compute(value); + let mut out = String::new(); + for byte in digest.0 { + write!(&mut out, "{:x}", byte).expect("writing to String should not fail"); + } + out +} + +fn read_macos_preference(domain: &str, key: &str) -> Option { + if cfg!(not(target_os = "macos")) { + return None; + } + + let output = Command::new("defaults").args(["read", domain, key]).output().ok()?; + if !output.status.success() { + return None; + } + + String::from_utf8(output.stdout) + .ok() + .map(|value| value.trim().to_string()) + .filter(|value| !value.is_empty()) +} + +fn linux_process_names() -> Vec { + let Ok(entries) = fs::read_dir("/proc") else { + return Vec::new(); + }; + + entries + .filter_map(Result::ok) + .filter_map(|entry| { + entry + .file_name() + .to_str() + .filter(|name| name.chars().all(|ch| ch.is_ascii_digit())) + .map(|_| entry.path().join("stat")) + }) + .filter_map(|path| fs::read_to_string(path).ok()) + .filter_map(|stat| { + let start = stat.find('(')?; + let end = stat.rfind(')')?; + stat.get(start + 1..end).map(str::to_string) + }) + .filter(|name| !name.is_empty()) + .collect() +} + +fn client_os_report_value(gp_params: &GpParams) -> String { + gp_params + .os_version() + .unwrap_or_else(|| gp_params.client_os()) + .replace(' ', "+") +} + +fn push_text(parent: &mut Element, name: &str, value: &str) { + let mut element = Element::new(name); + element.children.push(XMLNode::Text(value.to_string())); + parent.children.push(XMLNode::Element(element)); +} + +fn yes_no(value: bool) -> &'static str { + if value { "yes" } else { "no" } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{ + gp_params::GpParams, + os_profile::{ClientOs, HostIdentity, OsProfile}, + }; + + struct TestCscDataReader { + values: HashMap, + processes: Vec, + } + + impl CscDataReader for TestCscDataReader { + fn read_preference(&self, domain: &str, key: &str) -> Option { + self.values.get(&format!("{domain}:{key}")).cloned() + } + + fn process_exists(&self, name: &str) -> bool { + self.processes.iter().any(|process| process == name) + } + } + + fn parse_xml(xml: &str) -> Element { + Element::parse(xml.as_bytes()).unwrap() + } + + fn gp_params(client_os: ClientOs) -> GpParams { + let profile = OsProfile::builder(client_os) + .host_identity(HostIdentity::new( + "test-computer".to_string(), + "host-id".to_string(), + "serial".to_string(), + "aa:bb:cc:dd:ee:ff".to_string(), + )) + .build(); + GpParams::builder(profile).build() + } + + #[test] + fn detects_config_criteria_response() { + assert!(is_config_criteria(&parse_xml(""))); + assert!(!is_config_criteria(&parse_xml(""))); + } + + #[test] + fn builds_macos_plist_csc_report_with_existing_value() { + let root = parse_xml( + r#" + + + + + ExampleKey + + + + + cookie + "#, + ); + let reader = TestCscDataReader { + values: HashMap::from([( + "com.example.settings:ExampleKey".to_string(), + "ExampleValue".to_string(), + )]), + processes: Vec::new(), + }; + + let req = build_csc_request_with_reader(&root, "alice@example.com", &gp_params(ClientOs::Mac), &reader).unwrap(); + + assert_eq!(req.auth_cookie, "cookie"); + assert!(req.csc_data.contains("alice%40example.com")); + assert!(req.csc_data.contains("Apple+Mac+OS+X+")); + assert!(req.csc_data.contains("yes")); + assert!(req.csc_data.contains("ExampleValue")); + assert!( + req + .csc_data + .contains(&format!("{}", req.csc_digest)) + ); + assert!(!req.csc_data.contains(DIGEST_PLACEHOLDER)); + } + + #[test] + fn reports_missing_macos_plist_value() { + let root = parse_xml( + r#" + + + + Missing + + + + cookie + "#, + ); + let reader = TestCscDataReader { + values: HashMap::new(), + processes: Vec::new(), + }; + + let req = build_csc_request_with_reader(&root, "alice", &gp_params(ClientOs::Mac), &reader).unwrap(); + + assert!(req.csc_data.contains("no")); + assert!(req.csc_data.contains("") || req.csc_data.contains("")); + } + + #[test] + fn empty_csc_report_uses_official_format_for_digest() { + let root = parse_xml( + r#" + + cookie + "#, + ); + let reader = TestCscDataReader { + values: HashMap::new(), + processes: Vec::new(), + }; + + let req = build_csc_request_with_reader(&root, "alice", &gp_params(ClientOs::Mac), &reader).unwrap(); + let digest_input = req.csc_data.replace(&req.csc_digest, DIGEST_PLACEHOLDER); + + assert_eq!(req.csc_digest, pan_md5_hex(digest_input.as_bytes())); + assert!( + req + .csc_data + .contains("\n\tcookie") + ); + assert!(req.csc_data.contains("\n\t\n\t\n")); + assert!(req.csc_data.ends_with("\n")); + } + + #[test] + fn unsupported_client_os_ignores_macos_plist_branch() { + let root = parse_xml( + r#" + + + + HipID + + + + cookie + "#, + ); + let reader = TestCscDataReader { + values: HashMap::from([("com.example:HipID".to_string(), "present".to_string())]), + processes: Vec::new(), + }; + + let req = build_csc_request_with_reader(&root, "alice", &gp_params(ClientOs::Linux), &reader).unwrap(); + + assert!(!req.csc_data.contains("")); + assert!(!req.csc_data.contains("no")); + assert!(!req.csc_data.contains("present")); + } + + #[test] + fn builds_linux_process_list_report() { + let root = parse_xml( + r#" + + + + + + + + + cookie + "#, + ); + let reader = TestCscDataReader { + values: HashMap::new(), + processes: vec!["present-process".to_string()], + }; + + let req = build_csc_request_with_reader(&root, "alice", &gp_params(ClientOs::Linux), &reader).unwrap(); + + assert!(req.csc_data.contains(r#""#)); + assert!(req.csc_data.contains("present-process")); + assert!(req.csc_data.contains(r#""#)); + assert!(req.summary().contains("process_entries=2")); + assert!(req.summary().contains("process_present=1")); + assert!(req.summary().contains("process_missing=1")); + } + + #[test] + fn builds_windows_registry_key_report() { + let root = parse_xml( + r#" + + + + + + + + cookie + "#, + ); + let reader = TestCscDataReader { + values: HashMap::new(), + processes: Vec::new(), + }; + + let req = build_csc_request_with_reader(&root, "alice", &gp_params(ClientOs::Windows), &reader).unwrap(); + + assert!(req.csc_data.contains("")); + assert!(req.csc_data.contains("")); + assert!( + req + .csc_data + .contains(r#""#) + ); + assert!(req.csc_data.contains("no")); + assert!(req.csc_data.contains("") || req.csc_data.contains("")); + } + + #[test] + fn uses_pan_non_padded_md5_digest() { + assert_eq!(pan_md5_hex(b""), "d41d8cd98f0b24e980998ecf8427e"); + assert_ne!(pan_md5_hex(b""), format!("{:x}", md5::compute(b""))); + } + + #[test] + fn builds_getconfig_csc_params() { + let req = CscRequest { + auth_cookie: "cookie".to_string(), + config_digest: "config-digest".to_string(), + csc_digest: "csc-digest".to_string(), + csc_data: "hostserial" + .to_string(), + summary: CscBuildSummary::default(), + host_id: "host".to_string(), + serial_number: "serial".to_string(), + }; + let nonce = "123"; + let gp_params = gp_params(ClientOs::Mac); + let params = csc_params(&req, "alice", &gp_params, nonce); + + assert_eq!(params.get("user"), Some(&"alice")); + assert_eq!(params.get("hostid"), Some(&"host")); + assert_eq!(params.get("serialno"), Some(&"serial")); + assert_eq!(params.get("portal-cc-auth-cookie"), Some(&"cookie")); + assert_eq!(params.get("config-digest"), Some(&"config-digest")); + assert_eq!(params.get("csc-digest"), Some(&"csc-digest")); + assert_eq!(params.get("csc-data"), Some(&req.csc_data.as_str())); + assert_eq!(params.get("swg-auth-token"), Some(&"0")); + assert_eq!(params.get("swg-nonce"), Some(&"123")); + } + + #[test] + fn generated_getconfig_csc_params_include_final_digest_and_data() { + let root = parse_xml( + r#" + + cookie + "#, + ); + let reader = TestCscDataReader { + values: HashMap::new(), + processes: Vec::new(), + }; + let gp_params = gp_params(ClientOs::Linux); + let req = build_csc_request_with_reader(&root, "alice", &gp_params, &reader).unwrap(); + let params = csc_params(&req, "alice", &gp_params, "123"); + + assert_eq!(params.get("csc-digest"), Some(&req.csc_digest.as_str())); + assert_eq!(params.get("csc-data"), Some(&req.csc_data.as_str())); + assert!( + req + .csc_data + .contains(&format!("{}", req.csc_digest)) + ); + assert!(!req.csc_data.contains(DIGEST_PLACEHOLDER)); + } +} diff --git a/crates/gpapi/src/portal/mod.rs b/crates/gpapi/src/portal/mod.rs index 8c111db..aa5ab06 100644 --- a/crates/gpapi/src/portal/mod.rs +++ b/crates/gpapi/src/portal/mod.rs @@ -1,4 +1,5 @@ mod config; +pub(crate) mod csc; mod prelogin; pub use config::*; diff --git a/crates/gpapi/src/portal/prelogin.rs b/crates/gpapi/src/portal/prelogin.rs index a4b9cf7..26d9013 100644 --- a/crates/gpapi/src/portal/prelogin.rs +++ b/crates/gpapi/src/portal/prelogin.rs @@ -8,20 +8,11 @@ use xmltree::Element; use crate::{ error::PortalError, gp_params::GpParams, + os_profile::PreloginBrowserMode, + params::{gateway_prelogin, portal_prelogin}, utils::{base64, normalize_server, parse_gp_response, xml::ElementExt}, }; -const REQUIRED_PARAMS: [&str; 8] = [ - "tmp", - "clientVer", - "clientos", - "os-version", - "host-id", - "ipv6-support", - "default-browser", - "cas-support", -]; - #[derive(Debug, Serialize, Type, Clone)] #[serde(rename_all = "camelCase")] pub struct SamlPrelogin { @@ -96,27 +87,64 @@ impl Prelogin { } } -pub async fn prelogin(portal: &str, gp_params: &GpParams) -> anyhow::Result { +#[derive(Debug, Clone, Copy, Default)] +pub struct PreloginOptions { + external_browser_requested: bool, + portal_default_browser_enabled: bool, +} + +impl PreloginOptions { + pub fn external_browser_requested(mut self, external_browser_requested: bool) -> Self { + self.external_browser_requested = external_browser_requested; + self + } + + pub fn portal_default_browser_enabled(mut self, portal_default_browser_enabled: bool) -> Self { + self.portal_default_browser_enabled = portal_default_browser_enabled; + self + } + + fn browser_mode(self, is_gateway: bool) -> PreloginBrowserMode { + if self.external_browser_requested && (!is_gateway || self.portal_default_browser_enabled) { + PreloginBrowserMode::External + } else { + PreloginBrowserMode::Embedded + } + } +} + +pub async fn prelogin(portal: &str, gp_params: &GpParams, options: PreloginOptions) -> anyhow::Result { let user_agent = gp_params.user_agent(); let is_gateway = gp_params.is_gateway(); let prelogin_type = if is_gateway { "Gateway" } else { "Portal" }; - info!("{} prelogin with user_agent: {}", prelogin_type, user_agent); - let portal = normalize_server(portal)?; let path = if is_gateway { "ssl-vpn" } else { "global-protect" }; let prelogin_url = format!("{portal}/{}/prelogin.esp", path); - let mut params = gp_params.to_params(); + let browser_mode = options.browser_mode(is_gateway); + let request_params = if is_gateway { + gateway_prelogin::build(gp_params.os_profile(), browser_mode) + } else { + portal_prelogin::build(gp_params.os_profile(), browser_mode) + }; + let default_browser = request_param(&request_params, "default-browser").unwrap_or(""); - params.insert("tmp", "tmp"); - params.insert("default-browser", "1"); - params.insert("cas-support", "yes"); - - params.retain(|k, _| REQUIRED_PARAMS.iter().any(|required_param| required_param == k)); + info!( + "{} prelogin with user_agent: {}, default_browser: {}", + prelogin_type, user_agent, default_browser + ); let client = Client::try_from(gp_params)?; - let res = client.post(&prelogin_url).form(¶ms).send().await.map_err(|e| { + let mut request = client.post(&prelogin_url); + if !request_params.query.is_empty() { + request = request.query(&request_params.query); + } + if !request_params.body.is_empty() { + request = request.form(&request_params.body); + } + + let res = request.send().await.map_err(|e| { warn!("Network error: {:?}", e); anyhow::anyhow!(PortalError::NetworkError(e)) })?; @@ -144,6 +172,14 @@ pub async fn prelogin(portal: &str, gp_params: &GpParams) -> anyhow::Result(params: &'a crate::params::RequestParams, name: &str) -> Option<&'a str> { + params + .body + .iter() + .chain(params.query.iter()) + .find_map(|(key, value)| (key == name).then_some(value.as_str())) +} + fn parse_res_xml(res_xml: &str, is_gateway: bool) -> anyhow::Result { let root = Element::parse(res_xml.as_bytes())?; @@ -203,3 +239,81 @@ fn parse_res_xml(res_xml: &str, is_gateway: bool) -> anyhow::Result { Ok(Prelogin::Standard(standard_prelogin)) } + +#[cfg(test)] +mod tests { + use super::PreloginOptions; + use crate::{ + gp_params::GpParams, + os_profile::{ClientOs, HostIdentity, OsProfile, PreloginBrowserMode}, + params::{gateway_prelogin, portal_prelogin}, + }; + + fn gp_params(client_os: ClientOs) -> GpParams { + let profile = OsProfile::builder(client_os) + .host_identity(HostIdentity::new( + "test-computer".to_string(), + "host-id".to_string(), + "serial".to_string(), + "aa:bb:cc:dd:ee:ff".to_string(), + )) + .build(); + GpParams::builder(profile).build() + } + + #[test] + fn portal_prelogin_params_include_official_profile_fields() { + let gp_params = gp_params(ClientOs::Linux); + let request_params = portal_prelogin::build(gp_params.os_profile(), PreloginBrowserMode::Embedded); + + let body: std::collections::HashMap<&str, &str> = request_params + .body + .iter() + .map(|(k, v)| (k.as_str(), v.as_str())) + .collect(); + let query: std::collections::HashMap<&str, &str> = request_params + .query + .iter() + .map(|(k, v)| (k.as_str(), v.as_str())) + .collect(); + + assert_eq!(body.get("host-id"), Some(&gp_params.os_profile().host_id())); + assert_eq!(body.get("default-browser"), Some(&"-10")); + assert_eq!(body.get("cas-support"), Some(&"yes")); + assert_eq!(body.get("data"), Some(&r#"eyJjYXNfZW1iZWRkZWRfYnJvd3NlciI6InllcyJ9"#)); + // Linux does not place kerberos-support in the query string. + assert_eq!(query.get("kerberos-support"), None); + } + + #[test] + fn gateway_prelogin_uses_gateway_default_browser() { + let gp_params = gp_params(ClientOs::Mac); + let request_params = gateway_prelogin::build(gp_params.os_profile(), PreloginBrowserMode::Embedded); + + let body: std::collections::HashMap<&str, &str> = request_params + .body + .iter() + .map(|(k, v)| (k.as_str(), v.as_str())) + .collect(); + + assert_eq!(body.get("default-browser"), Some(&"0")); + } + + #[test] + fn browser_mode_uses_external_for_portal_when_requested() { + let options = PreloginOptions::default().external_browser_requested(true); + + assert_eq!(options.browser_mode(false), PreloginBrowserMode::External); + } + + #[test] + fn browser_mode_requires_portal_policy_for_gateway_external() { + let options = PreloginOptions::default().external_browser_requested(true); + + assert_eq!(options.browser_mode(true), PreloginBrowserMode::Embedded); + + let options = options.portal_default_browser_enabled(true); + + assert_eq!(options.browser_mode(true), PreloginBrowserMode::External); + } +} diff --git a/crates/gpapi/src/process/auth_launcher.rs b/crates/gpapi/src/process/auth_launcher.rs index ab80bdc..df01afa 100644 --- a/crates/gpapi/src/process/auth_launcher.rs +++ b/crates/gpapi/src/process/auth_launcher.rs @@ -4,7 +4,7 @@ use anyhow::bail; use common::constants::GP_AUTH_BINARY; use tokio::process::Command; -use crate::{auth::SamlAuthResult, credential::Credential}; +use crate::{auth::SamlAuthResult, credential::Credential, os_profile::OsProfile}; use super::command_traits::CommandExt; @@ -13,9 +13,9 @@ pub struct SamlAuthLauncher<'a> { auth_executable: Option<&'a str>, gateway: bool, saml_request: Option<&'a str>, - user_agent: Option<&'a str>, os: Option<&'a str>, - os_version: Option<&'a str>, + host_id: Option<&'a str>, + client_version: Option<&'a str>, fix_openssl: bool, ignore_tls_errors: bool, #[cfg(feature = "webview-auth")] @@ -35,9 +35,9 @@ impl<'a> SamlAuthLauncher<'a> { auth_executable: None, gateway: false, saml_request: None, - user_agent: None, os: None, - os_version: None, + host_id: None, + client_version: None, fix_openssl: false, ignore_tls_errors: false, #[cfg(feature = "webview-auth")] @@ -66,18 +66,10 @@ impl<'a> SamlAuthLauncher<'a> { self } - pub fn user_agent(mut self, user_agent: &'a str) -> Self { - self.user_agent = Some(user_agent); - self - } - - pub fn os(mut self, os: &'a str) -> Self { - self.os = Some(os); - self - } - - pub fn os_version(mut self, os_version: Option<&'a str>) -> Self { - self.os_version = os_version; + pub fn os_profile(mut self, profile: &'a OsProfile) -> Self { + self.os = Some(profile.client_os().as_str()); + self.host_id = Some(profile.host_identity().host_id()); + self.client_version = Some(profile.client_version()); self } @@ -133,16 +125,16 @@ impl<'a> SamlAuthLauncher<'a> { auth_cmd.arg("--saml-request").arg(saml_request); } - if let Some(user_agent) = self.user_agent { - auth_cmd.arg("--user-agent").arg(user_agent); - } - if let Some(os) = self.os { auth_cmd.arg("--os").arg(os); } - if let Some(os_version) = self.os_version { - auth_cmd.arg("--os-version").arg(os_version); + if let Some(host_id) = self.host_id { + auth_cmd.arg("--host-id").arg(host_id); + } + + if let Some(client_version) = self.client_version { + auth_cmd.arg("--client-version").arg(client_version); } if self.fix_openssl { @@ -195,3 +187,36 @@ impl<'a> SamlAuthLauncher<'a> { Credential::try_from(auth_result) } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::os_profile::{ClientOs, OsProfileBuilder}; + + #[test] + fn os_profile_sets_os_from_profile() { + let profile = OsProfileBuilder::new(ClientOs::Linux).client_version("6.0.0").build(); + + let launcher = SamlAuthLauncher::new("portal.example.com").os_profile(&profile); + + assert_eq!(launcher.os, Some("Linux")); + } + + #[test] + fn os_profile_sets_host_id_from_profile_runtime_identity() { + let profile = OsProfileBuilder::new(ClientOs::Linux).client_version("6.0.0").build(); + + let launcher = SamlAuthLauncher::new("portal.example.com").os_profile(&profile); + + assert_eq!(launcher.host_id, Some(profile.host_identity().host_id())); + } + + #[test] + fn os_profile_sets_client_version_from_profile() { + let profile = OsProfileBuilder::new(ClientOs::Linux).client_version("6.0.0").build(); + + let launcher = SamlAuthLauncher::new("portal.example.com").os_profile(&profile); + + assert_eq!(launcher.client_version, Some("6.0.0")); + } +} diff --git a/crates/gpapi/src/process/users.rs b/crates/gpapi/src/process/users.rs index 265f1d4..8c39fbf 100644 --- a/crates/gpapi/src/process/users.rs +++ b/crates/gpapi/src/process/users.rs @@ -3,12 +3,18 @@ use std::env; use anyhow::bail; use uzers::User; +#[derive(Debug, PartialEq, Eq)] +enum RealUserLookup { + Uid(u32), + Name(String), +} + pub fn get_user_by_name(username: &str) -> anyhow::Result { uzers::get_user_by_name(username).ok_or_else(|| anyhow::anyhow!("User ({}) not found", username)) } pub fn get_non_root_user() -> anyhow::Result { - let current_user = whoami::username(); + let current_user = current_username()?; let user = if current_user == "root" { get_real_user()? @@ -24,16 +30,87 @@ pub fn get_non_root_user() -> anyhow::Result { } pub fn get_current_user() -> anyhow::Result { - let current_user = whoami::username(); + let current_user = current_username()?; get_user_by_name(¤t_user) } +fn current_username() -> anyhow::Result { + whoami::username().map_err(|err| anyhow::anyhow!("Failed to resolve current user: {err}")) +} + fn get_real_user() -> anyhow::Result { - // Read the UID from SUDO_UID or PKEXEC_UID environment variable if available. - let uid = match env::var("SUDO_UID") { - Ok(uid) => uid.parse::()?, - _ => env::var("PKEXEC_UID")?.parse::()?, - }; + match real_user_lookup(|key| env::var(key).ok())? { + RealUserLookup::Uid(uid) => uzers::get_user_by_uid(uid).ok_or_else(|| anyhow::anyhow!("User not found")), + RealUserLookup::Name(name) => get_user_by_name(&name), + } +} + +fn real_user_lookup(env_var: impl Fn(&str) -> Option) -> anyhow::Result { + if let Some(uid) = env_var("SUDO_UID") { + return Ok(RealUserLookup::Uid(uid.parse::()?)); + } + + if let Some(uid) = env_var("PKEXEC_UID") { + return Ok(RealUserLookup::Uid(uid.parse::()?)); + } + + if let Some(user) = env_var("DOAS_USER").filter(|user| !user.trim().is_empty()) { + return Ok(RealUserLookup::Name(user)); + } + + bail!("User not found") +} + +#[cfg(test)] +mod tests { + use super::*; + + fn lookup(vars: &[(&str, &str)]) -> anyhow::Result { + real_user_lookup(|key| { + vars + .iter() + .find(|(name, _)| *name == key) + .map(|(_, value)| value.to_string()) + }) + } + + #[test] + fn real_user_lookup_uses_sudo_uid() { + assert_eq!(lookup(&[("SUDO_UID", "1000")]).unwrap(), RealUserLookup::Uid(1000)); + } + + #[test] + fn real_user_lookup_uses_pkexec_uid() { + assert_eq!(lookup(&[("PKEXEC_UID", "1001")]).unwrap(), RealUserLookup::Uid(1001)); + } + + #[test] + fn real_user_lookup_uses_doas_user() { + assert_eq!( + lookup(&[("DOAS_USER", "alice")]).unwrap(), + RealUserLookup::Name("alice".to_string()) + ); + } + + #[test] + fn real_user_lookup_prefers_uid_over_doas_user() { + assert_eq!( + lookup(&[("SUDO_UID", "1000"), ("PKEXEC_UID", "1001"), ("DOAS_USER", "alice")]).unwrap(), + RealUserLookup::Uid(1000) + ); + assert_eq!( + lookup(&[("PKEXEC_UID", "1001"), ("DOAS_USER", "alice")]).unwrap(), + RealUserLookup::Uid(1001) + ); + } + + #[test] + fn real_user_lookup_ignores_blank_doas_user() { + assert!(lookup(&[("DOAS_USER", " ")]).is_err()); + } - uzers::get_user_by_uid(uid).ok_or_else(|| anyhow::anyhow!("User not found")) + #[test] + fn real_user_lookup_errors_without_root_origin_env() { + assert!(lookup(&[]).is_err()); + } } diff --git a/crates/gpapi/src/service/request.rs b/crates/gpapi/src/service/request.rs index ce99835..ecdf3f7 100644 --- a/crates/gpapi/src/service/request.rs +++ b/crates/gpapi/src/service/request.rs @@ -3,7 +3,10 @@ use std::collections::HashMap; use serde::{Deserialize, Serialize}; use specta::Type; -use crate::{gateway::Gateway, gp_params::ClientOs}; +use crate::{ + gateway::Gateway, + os_profile::{ClientOs, OsProfile}, +}; use super::vpn_state::ConnectInfo; @@ -36,6 +39,7 @@ pub struct ConnectArgs { os: Option, os_version: Option, client_version: Option, + host_id: Option, certificate: Option, sslkey: Option, @@ -65,6 +69,7 @@ impl ConnectArgs { os: None, os_version: None, client_version: None, + host_id: None, certificate: None, sslkey: None, key_password: None, @@ -110,6 +115,10 @@ impl ConnectArgs { self.client_version.clone() } + pub fn host_id(&self) -> Option { + self.host_id.clone() + } + pub fn certificate(&self) -> Option { self.certificate.clone() } @@ -201,23 +210,12 @@ impl ConnectRequest { self } - pub fn with_user_agent>>(mut self, user_agent: T) -> Self { - self.args.user_agent = user_agent.into(); - self - } - - pub fn with_os>>(mut self, os: T) -> Self { - self.args.os = os.into(); - self - } - - pub fn with_os_version>>(mut self, os_version: T) -> Self { - self.args.os_version = os_version.into(); - self - } - - pub fn with_client_version(mut self, client_version: &str) -> Self { - self.args.client_version = Some(client_version.to_string()); + pub fn with_os_profile(mut self, profile: &OsProfile) -> Self { + self.args.os = Some(profile.client_os()); + self.args.os_version = Some(profile.os_version().to_string()); + self.args.client_version = Some(profile.client_version().to_string()); + self.args.host_id = Some(profile.host_identity().host_id().to_string()); + self.args.user_agent = Some(profile.user_agent().to_string()); self } @@ -314,6 +312,12 @@ mod tests { use serde_json::json; use super::*; + use crate::os_profile::OsProfileBuilder; + + fn test_connect_info() -> ConnectInfo { + let gateway = Gateway::new("Gateway".to_string(), "vpn.example.com".to_string()); + ConnectInfo::new("portal.example.com".to_string(), gateway.clone(), vec![gateway]) + } #[test] fn connect_request_serializes_allow_extend_session() { @@ -324,4 +328,25 @@ mod tests { assert_eq!(value["args"]["allowExtendSession"], json!(true)); } + + #[test] + fn with_os_profile_sets_user_agent_from_profile() { + let profile = OsProfileBuilder::new(ClientOs::Linux).client_version("6.0.0").build(); + + let req = ConnectRequest::new(test_connect_info(), "cookie".to_string()).with_os_profile(&profile); + + assert_eq!(req.args().user_agent(), Some(profile.user_agent().to_string())); + } + + #[test] + fn with_os_profile_sets_host_id_from_profile_runtime_identity() { + let profile = OsProfileBuilder::new(ClientOs::Linux).build(); + + let req = ConnectRequest::new(test_connect_info(), "cookie".to_string()).with_os_profile(&profile); + + assert_eq!( + req.args().host_id(), + Some(profile.host_identity().host_id().to_string()) + ); + } } diff --git a/crates/gpapi/src/service/vpn_env.rs b/crates/gpapi/src/service/vpn_env.rs index 2cc7121..062f00c 100644 --- a/crates/gpapi/src/service/vpn_env.rs +++ b/crates/gpapi/src/service/vpn_env.rs @@ -1,6 +1,17 @@ use serde::{Deserialize, Serialize}; -use crate::service::vpn_state::VpnState; +use crate::{os_profile::HostIdentity, service::vpn_state::VpnState}; + +/// The single DTO carrying all host facts gpservice ships to gpgui. +/// +/// Populated by gpservice at WS connection time and sent inside `VpnEnv`. +/// gpgui stores it in a process-wide `OnceLock` and routes `AppSettings`, +/// `Constants`, and `OsProfile` construction through it. +#[derive(Debug, Serialize, Deserialize, Clone)] +pub struct HostInfo { + /// Host identity collected by gpservice for the runtime OS. + pub host_identity: HostIdentity, +} /// Represents the VPN environment configuration. /// When a client connects, the gpservice sends the current VPN environment @@ -19,4 +30,7 @@ pub struct VpnEnv { /// The gpauth executable path /// Used by the client to launch gpauth for authentication pub auth_executable: String, + + /// Host identity collected by gpservice. + pub host_info: HostInfo, } diff --git a/crates/gpapi/src/session.rs b/crates/gpapi/src/session.rs index 3a55fc9..5400ec2 100644 --- a/crates/gpapi/src/session.rs +++ b/crates/gpapi/src/session.rs @@ -4,8 +4,6 @@ use chrono::{Local, TimeZone}; use serde::{Deserialize, Serialize}; use specta::Type; -use crate::gp_params::ClientOs; - #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Type)] pub struct SessionWarning { pub prior_secs: u32, @@ -16,9 +14,6 @@ pub struct SessionWarning { pub struct SessionRequestArgs { cookie: String, user_agent: Option, - os: Option, - os_version: Option, - client_version: Option, certificate: Option, sslkey: Option, key_password: Option, @@ -30,9 +25,6 @@ impl SessionRequestArgs { Self { cookie, user_agent: None, - os: None, - os_version: None, - client_version: None, certificate: None, sslkey: None, key_password: None, @@ -45,21 +37,6 @@ impl SessionRequestArgs { self } - pub fn with_os>>(mut self, os: T) -> Self { - self.os = os.into(); - self - } - - pub fn with_os_version>>(mut self, os_version: T) -> Self { - self.os_version = os_version.into(); - self - } - - pub fn with_client_version>>(mut self, client_version: T) -> Self { - self.client_version = client_version.into(); - self - } - pub fn with_certificate>>(mut self, certificate: T) -> Self { self.certificate = certificate.into(); self @@ -88,18 +65,6 @@ impl SessionRequestArgs { self.user_agent.clone() } - pub fn os(&self) -> Option { - self.os.clone() - } - - pub fn os_version(&self) -> Option { - self.os_version.clone() - } - - pub fn client_version(&self) -> Option { - self.client_version.clone() - } - pub fn certificate(&self) -> Option { self.certificate.clone() } @@ -299,4 +264,11 @@ mod tests { fn reschedule_after_extension_requires_lifetime() { assert!(SessionInfo::default().rescheduled_after_extension().is_none()); } + + #[test] + fn with_user_agent_sets_session_user_agent() { + let args = SessionRequestArgs::new("cookie".to_string()).with_user_agent("agent/1.0".to_string()); + + assert_eq!(args.user_agent(), Some("agent/1.0".to_string())); + } } diff --git a/crates/gpapi/src/utils/host_utils.rs b/crates/gpapi/src/utils/host_utils.rs deleted file mode 100644 index b7f982a..0000000 --- a/crates/gpapi/src/utils/host_utils.rs +++ /dev/null @@ -1,108 +0,0 @@ -use std::sync::OnceLock; - -const DEFAULT_MACOS_VERSION: &str = "13.4.0"; -#[cfg(not(target_os = "linux"))] -const DEFAULT_LINUX_DISTRO: &str = "Ubuntu 24.04.3 LTS"; -#[cfg(not(target_os = "windows"))] -const DEFAULT_WINDOWS_DISTRO: &str = "Windows 11 Pro"; -const DEFAULT_WINDOWS_VERSION: &str = "10.0.22631.0"; -const DEFAULT_MACHINE_ID: &str = "DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF"; - -static MACHINE_ID: OnceLock<&'static str> = OnceLock::new(); -static MACOS_VERSION: OnceLock<&'static str> = OnceLock::new(); -static MACOS_OS_STRING: OnceLock = OnceLock::new(); -static LINUX_OS_STRING: OnceLock = OnceLock::new(); -static WINDOWS_VERSION: OnceLock<&'static str> = OnceLock::new(); -static WINDOWS_OS_STRING: OnceLock = OnceLock::new(); - -/// On macOS, get the OS version, or fallback to default -/// On other OSes, always return default -pub fn get_macos_version() -> &'static str { - MACOS_VERSION.get_or_init(|| { - #[cfg(target_os = "macos")] - { - match os_info::get().version() { - os_info::Version::Unknown => DEFAULT_MACOS_VERSION, - v => v.to_string().leak(), - } - } - - #[cfg(not(target_os = "macos"))] - DEFAULT_MACOS_VERSION - }) -} - -pub fn get_macos_os_string() -> &'static str { - MACOS_OS_STRING.get_or_init(|| format!("Apple Mac OS X {}", get_macos_version())) -} - -/// On Linux, use the real distro name if possible -/// On other OSes, fallback to default -pub fn get_linux_os_string() -> &'static str { - LINUX_OS_STRING.get_or_init(|| { - #[cfg(target_os = "linux")] - { - format!("Linux {}", whoami::distro()) - } - #[cfg(not(target_os = "linux"))] - { - format!("Linux {}", DEFAULT_LINUX_DISTRO) - } - }) -} - -/// On Windows, get the OS version, or fallback to default -/// On other OSes, always return default -pub fn get_windows_version() -> &'static str { - WINDOWS_VERSION.get_or_init(|| { - #[cfg(target_os = "windows")] - { - match os_info::get().version() { - os_info::Version::Unknown => DEFAULT_WINDOWS_VERSION, - v => format!("{}.0", v).leak(), - } - } - #[cfg(not(target_os = "windows"))] - DEFAULT_WINDOWS_VERSION - }) -} - -/// On Windows, use the real edition if possible -/// On other OSes, fallback to default -/// The trailing space is intentional -pub fn get_windows_os_string() -> &'static str { - WINDOWS_OS_STRING.get_or_init(|| { - #[cfg(target_os = "windows")] - { - let edition = os_info::get() - .edition() - .map(|e| e.to_string()) - .unwrap_or_else(|| whoami::distro()); - format!("Microsoft {} , 64-bit", edition) - } - #[cfg(not(target_os = "windows"))] - { - format!("Microsoft {} , 64-bit", DEFAULT_WINDOWS_DISTRO) - } - }) -} - -/// Get machine ID or fallback to default -pub fn get_machine_id() -> &'static str { - MACHINE_ID.get_or_init(|| { - machine_uid::get() - .map(|id| id.to_string().leak() as &'static str) - .unwrap_or(DEFAULT_MACHINE_ID) - }) -} - -/// Generate a UUID v5 based on machine ID and provided seeds -pub fn derive_uuid(seeds: &[&str]) -> String { - use uuid::Uuid; - - let namespace = Uuid::NAMESPACE_DNS; - let name = format!("{}-{}", get_machine_id(), seeds.join("-")); - - let uuid = Uuid::new_v5(&namespace, name.as_bytes()); - uuid.hyphenated().to_string() -} diff --git a/crates/gpapi/src/utils/mod.rs b/crates/gpapi/src/utils/mod.rs index c48a5d1..120995e 100644 --- a/crates/gpapi/src/utils/mod.rs +++ b/crates/gpapi/src/utils/mod.rs @@ -5,7 +5,6 @@ pub mod checksum; pub mod crypto; pub mod endpoint; pub mod env_utils; -pub mod host_utils; pub mod lock_file; pub mod openssl; pub mod redact; diff --git a/crates/gpapi/src/utils/redact.rs b/crates/gpapi/src/utils/redact.rs index 1864a2e..712c847 100644 --- a/crates/gpapi/src/utils/redact.rs +++ b/crates/gpapi/src/utils/redact.rs @@ -123,6 +123,46 @@ pub fn redact_uri(uri: &str) -> String { url.to_string() } +pub fn redact_form_params(params: &[(&str, &str)]) -> String { + let mut pairs = params + .iter() + .map(|(key, value)| (*key, redact_form_value(key, value))) + .collect::>(); + + pairs.sort_by(|(left, _), (right, _)| left.cmp(right)); + + form_urlencoded::Serializer::new(String::new()) + .extend_pairs(pairs) + .finish() +} + +fn redact_form_value(key: &str, value: &str) -> String { + if value.is_empty() || is_safe_form_param(key) { + return value.to_string(); + } + + format!("redacted-{}", value.len()) +} + +fn is_safe_form_param(key: &str) -> bool { + matches!( + key, + "clientVer" + | "clientos" + | "config-digest" + | "csc-digest" + | "csc-support" + | "direct" + | "ipv6-support" + | "jnlpReady" + | "ok" + | "os-version" + | "prot" + | "swg-auth-token" + | "swg-nonce" + ) +} + fn redact_query(query: Option<&str>) -> Option { let query = query?; @@ -190,6 +230,20 @@ mod tests { assert_eq!(redact_uri(uri), "https://f**********r/baz?qux=q**********x"); } + #[test] + fn it_should_redact_form_params() { + let params = [ + ("portal-userauthcookie", "secret-cookie"), + ("csc-support", "yes"), + ("prelogin-cookie", ""), + ]; + + assert_eq!( + redact_form_params(¶ms), + "csc-support=yes&portal-userauthcookie=redacted-13&prelogin-cookie=" + ); + } + #[test] fn it_should_redact_data_uri() { let uri = "data:text/plain;a"; diff --git a/crates/gpapi/src/utils/window.rs b/crates/gpapi/src/utils/window.rs index 1d3d9e2..b902256 100644 --- a/crates/gpapi/src/utils/window.rs +++ b/crates/gpapi/src/utils/window.rs @@ -24,26 +24,49 @@ mod unix { use anyhow::bail; use gtk::{ EventBox, - glib::Cast, + glib::{self, Cast}, traits::{EventBoxExt, GtkWindowExt, WidgetExt}, }; use log::info; use tauri::WebviewWindow; use tokio::process::Command; + /// Wrapper to mark a non-Send closure as Send for dispatch to the GTK main thread. + /// + /// SAFETY: The caller must ensure the closure is only executed on the GTK main + /// thread. This is guaranteed by `glib::MainContext::default().invoke()`. + struct SendFn(Box); + unsafe impl Send for SendFn {} + + impl SendFn { + fn invoke(self) { + (self.0)(); + } + } + pub fn raise_window(win: &WebviewWindow) -> anyhow::Result<()> { let is_wayland = std::env::var("XDG_SESSION_TYPE").unwrap_or_default() == "wayland"; if is_wayland { let gtk_win = win.gtk_window()?; - if let Some(header) = gtk_win.titlebar() { - let _ = header.downcast::().map(|event_box| { - event_box.set_above_child(false); - }); - } - gtk_win.hide(); - gtk_win.show_all(); + // GTK operations must run on the main thread. When this function is called + // from a background thread (e.g., rspc handler on a tokio worker), calling + // GTK widget methods directly causes crashes in GTK's CSS subsystem + // (gtk_css_value_inherit_free assertion failure). Dispatch to the main + // thread via glib::MainContext to ensure thread safety. + let send_fn = SendFn(Box::new(move || { + if let Some(header) = gtk_win.titlebar() { + let _ = header.downcast::().map(|event_box| { + event_box.set_above_child(false); + }); + } + + gtk_win.hide(); + gtk_win.show_all(); + })); + + glib::MainContext::default().invoke(move || send_fn.invoke()); } else { if !win.is_visible()? { win.show()?; diff --git a/crates/gpapi/src/utils/xml.rs b/crates/gpapi/src/utils/xml.rs index 5da8e7a..0e13849 100644 --- a/crates/gpapi/src/utils/xml.rs +++ b/crates/gpapi/src/utils/xml.rs @@ -46,10 +46,10 @@ impl ElementExt for Element { } for child in &self.children { - if let Some(element) = child.as_element() { - if let Some(found) = element.descendant(name) { - return Some(found); - } + if let Some(element) = child.as_element() + && let Some(found) = element.descendant(name) + { + return Some(found); } } diff --git a/crates/openconnect/build.rs b/crates/openconnect/build.rs index 15ad7a2..c63f764 100644 --- a/crates/openconnect/build.rs +++ b/crates/openconnect/build.rs @@ -143,6 +143,13 @@ fn build_openconnect(deps_dir: &PathBuf, out_dir: &PathBuf) -> PathBuf { config.env("LIBS", "-liconv"); } + #[cfg(any(target_os = "freebsd", target_os = "openbsd"))] + { + config.ldflag("-L/usr/local/lib"); + config.ldflag("-liconv"); + config.env("LIBS", "-liconv"); + } + let dst = config.build(); let lib_dir = dst.join("lib"); @@ -190,6 +197,12 @@ fn main() { println!("cargo:rerun-if-changed=src/ffi/vpn.c"); println!("cargo:rerun-if-changed=src/ffi/vpn.h"); + #[cfg(any(target_os = "freebsd", target_os = "openbsd"))] + { + println!("cargo:rustc-link-search=native=/usr/local/lib"); + println!("cargo:rustc-link-lib=iconv"); + } + // Prevent silent fallback to dynamic libraries #[cfg(target_os = "linux")] { diff --git a/crates/openconnect/deps/patches/0006-Add-host-id-to-GlobalProtect-HIP-script.patch b/crates/openconnect/deps/patches/0006-Add-host-id-to-GlobalProtect-HIP-script.patch new file mode 100644 index 0000000..db9f3ce --- /dev/null +++ b/crates/openconnect/deps/patches/0006-Add-host-id-to-GlobalProtect-HIP-script.patch @@ -0,0 +1,101 @@ +From 78078b21f53801b31fef352ec0de40d319edcae9 Mon Sep 17 00:00:00 2001 +From: Kevin Yue +Date: Sat, 13 Jun 2026 12:00:00 +0800 +Subject: [PATCH 6/6] Add host ID to GlobalProtect HIP script arguments + +--- + gpst.c | 4 ++++ + library.c | 15 +++++++++++++++ + openconnect-internal.h | 4 ++++ + openconnect.h | 3 +++ + 4 files changed, 26 insertions(+) + +diff --git a/gpst.c b/gpst.c +index 78c16d1c..f1e1f6bb 100644 +--- a/gpst.c ++++ b/gpst.c +@@ -1019,6 +1019,10 @@ static int run_hip_script(struct openconnect_info *vpninfo) + hip_argv[i++] = "--client-os"; + hip_argv[i++] = gpst_os_name(vpninfo); + hip_argv[i++] = "--os-version"; + hip_argv[i++] = openconnect_get_gp_os_version(vpninfo); ++ if (openconnect_get_gp_host_id(vpninfo)) { ++ hip_argv[i++] = "--host-id"; ++ hip_argv[i++] = openconnect_get_gp_host_id(vpninfo); ++ } + hip_argv[i++] = "--cookie"; + hip_argv[i++] = vpninfo->cookie; + if (vpninfo->ip_info.addr) { +diff --git a/library.c b/library.c +index 03f47004..9e585119 100644 +--- a/library.c ++++ b/library.c +@@ -900,6 +900,7 @@ void openconnect_vpninfo_free(struct openconnect_info *vpninfo) + free(vpninfo->useragent); + free(vpninfo->gp_app_version); + free(vpninfo->gp_os_version); ++ free(vpninfo->gp_host_id); + free(vpninfo->authgroup); + #ifdef HAVE_LIBSTOKEN + if (vpninfo->stoken_pin) +@@ -1049,6 +1050,20 @@ const char *openconnect_get_gp_os_version(struct openconnect_info *vpninfo) + return vpninfo->gp_os_version ?: vpninfo->platname; + } + ++int openconnect_set_gp_host_id(struct openconnect_info *vpninfo, ++ const char *gp_host_id) ++{ ++ UTF8CHECK(gp_host_id); ++ ++ STRDUP(vpninfo->gp_host_id, gp_host_id); ++ return 0; ++} ++ ++const char *openconnect_get_gp_host_id(struct openconnect_info *vpninfo) ++{ ++ return vpninfo->gp_host_id; ++} ++ + int openconnect_set_urlpath(struct openconnect_info *vpninfo, + const char *urlpath) + { +diff --git a/openconnect-internal.h b/openconnect-internal.h +index a7e80659..76034fbd 100644 +--- a/openconnect-internal.h ++++ b/openconnect-internal.h +@@ -788,6 +788,7 @@ struct openconnect_info { + char *version_string; + char *gp_app_version; + char *gp_os_version; ++ char *gp_host_id; + + const char *quit_reason; + const char *delay_tunnel_reason; /* If non-null, provides a reason why protocol is not yet ready for tunnel setup */ +@@ -1684,6 +1685,9 @@ const char *openconnect_get_gp_app_version(struct openconnect_info *vpninfo); + /* Get the OS version string for GP */ + const char *openconnect_get_gp_os_version(struct openconnect_info *vpninfo); + ++/* Get the host ID string for GP */ ++const char *openconnect_get_gp_host_id(struct openconnect_info *vpninfo); ++ + /* version.c */ + extern const char openconnect_version_str[]; + +diff --git a/openconnect.h b/openconnect.h +index 40de2811..3c65c090 100644 +--- a/openconnect.h ++++ b/openconnect.h +@@ -472,8 +472,11 @@ int openconnect_set_useragent(struct openconnect_info *vpninfo, + int openconnect_set_gp_app_version(struct openconnect_info *vpninfo, + const char *gp_app_version); + int openconnect_set_gp_os_version(struct openconnect_info *vpninfo, + const char *gp_os_version); ++int openconnect_set_gp_host_id(struct openconnect_info *vpninfo, ++ const char *gp_host_id); ++ + + int openconnect_passphrase_from_fsid(struct openconnect_info *vpninfo); + int openconnect_obtain_cookie(struct openconnect_info *vpninfo); + int openconnect_init_ssl(void); +-- +2.50.1 (Apple Git-155) diff --git a/crates/openconnect/src/ffi/mod.rs b/crates/openconnect/src/ffi/mod.rs index ef49717..391a3ef 100644 --- a/crates/openconnect/src/ffi/mod.rs +++ b/crates/openconnect/src/ffi/mod.rs @@ -15,6 +15,7 @@ pub(crate) struct ConnectOptions { pub os: *const c_char, pub os_version: *const c_char, pub client_version: *const c_char, + pub host_id: *const c_char, pub local_hostname: *const c_char, pub script: *const c_char, diff --git a/crates/openconnect/src/ffi/vpn.c b/crates/openconnect/src/ffi/vpn.c index 690f840..1c98df6 100644 --- a/crates/openconnect/src/ffi/vpn.c +++ b/crates/openconnect/src/ffi/vpn.c @@ -80,6 +80,7 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback) INFO("USER_AGENT: %s", options->user_agent); INFO("OS: %s", options->os); INFO("CLIENT_VERSION: %s", options->client_version); + INFO("HOST_ID: %s", options->host_id ? options->host_id : "(not set)"); INFO("VPNC_SCRIPT: %s", options->script); INFO("SCRIPT_TUN: %d", g_script_tun); INFO("CSD_USER: %d", options->csd_uid); @@ -120,6 +121,10 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback) options->client_version); } + if (options->host_id) { + openconnect_set_gp_host_id(vpninfo, options->host_id); + } + effective_local_hostname = options->local_hostname; if (!effective_local_hostname && !uname(&utsbuf)) { effective_local_hostname = utsbuf.nodename; diff --git a/crates/openconnect/src/ffi/vpn.h b/crates/openconnect/src/ffi/vpn.h index cb077c8..66a7e7e 100644 --- a/crates/openconnect/src/ffi/vpn.h +++ b/crates/openconnect/src/ffi/vpn.h @@ -25,6 +25,7 @@ typedef struct vpn_options { const char *os; const char *os_version; const char *client_version; + const char *host_id; const char *local_hostname; const char *script; diff --git a/crates/openconnect/src/vpn.rs b/crates/openconnect/src/vpn.rs index ad11302..5de2ca5 100644 --- a/crates/openconnect/src/vpn.rs +++ b/crates/openconnect/src/vpn.rs @@ -64,6 +64,7 @@ pub struct Vpn { os: CString, os_version: Option, client_version: Option, + host_id: Option, local_hostname: Option, script: CString, @@ -124,6 +125,7 @@ impl Vpn { os: self.os.as_ptr(), os_version: Self::option_to_ptr(&self.os_version), client_version: Self::option_to_ptr(&self.client_version), + host_id: Self::option_to_ptr(&self.host_id), local_hostname: Self::option_to_ptr(&self.local_hostname), script: self.script.as_ptr(), @@ -185,6 +187,7 @@ pub struct VpnBuilder { os: Option, os_version: Option, client_version: Option, + host_id: Option, local_hostname: Option, certificate: Option, @@ -217,6 +220,7 @@ impl VpnBuilder { os: None, os_version: None, client_version: None, + host_id: None, local_hostname: None, certificate: None, @@ -271,6 +275,11 @@ impl VpnBuilder { self } + pub fn host_id>>(mut self, host_id: T) -> Self { + self.host_id = host_id.into(); + self + } + pub fn local_hostname>>(mut self, local_hostname: T) -> Self { self.local_hostname = local_hostname.into(); self @@ -378,6 +387,7 @@ impl VpnBuilder { os: Self::to_cstring(&os), os_version: self.os_version.as_deref().map(Self::to_cstring), client_version: self.client_version.as_deref().map(Self::to_cstring), + host_id: self.host_id.as_deref().map(Self::to_cstring), local_hostname: self.local_hostname.as_deref().map(Self::to_cstring), script: Self::to_cstring(&script), @@ -453,4 +463,39 @@ mod tests { assert_eq!(info.lifetime_secs, None); assert_eq!(info.lifetime_warning, None); } + + #[test] + fn connect_options_include_host_id() { + let vpn = Vpn { + server: CString::new("gateway.example.com").unwrap(), + cookie: CString::new("cookie").unwrap(), + user_agent: CString::new("agent").unwrap(), + os: CString::new("linux").unwrap(), + os_version: None, + client_version: None, + host_id: Some(CString::new("profile-host-id").unwrap()), + local_hostname: None, + script: CString::new("/bin/true").unwrap(), + interface: None, + script_tun: false, + certificate: None, + sslkey: None, + key_password: None, + servercert: None, + csd_uid: 0, + csd_wrapper: None, + reconnect_timeout: 300, + mtu: 0, + disable_ipv6: false, + no_dtls: false, + dpd_interval: 0, + no_xmlpost: false, + callback: Default::default(), + }; + + let options = vpn.build_connect_options(); + + let host_id = unsafe { CStr::from_ptr(options.host_id) }.to_str().unwrap(); + assert_eq!(host_id, "profile-host-id"); + } } diff --git a/crates/openconnect/src/vpn_utils.rs b/crates/openconnect/src/vpn_utils.rs index e5f81c2..47e2b50 100644 --- a/crates/openconnect/src/vpn_utils.rs +++ b/crates/openconnect/src/vpn_utils.rs @@ -3,6 +3,7 @@ use std::{io, path::Path}; use is_executable::IsExecutable; const VPNC_SCRIPT_LOCATIONS: &[&str] = &[ + "/usr/local/libexec/gpclient/vpnc-script", "/usr/libexec/gpclient/vpnc-script", "/usr/lib/gpclient/vpnc-script", "/usr/local/share/vpnc-scripts/vpnc-script", @@ -19,6 +20,7 @@ const VPNC_SCRIPT_LOCATIONS: &[&str] = &[ ]; const CSD_WRAPPER_LOCATIONS: &[&str] = &[ + "/usr/local/libexec/gpclient/hipreport.sh", "/usr/libexec/gpclient/hipreport.sh", #[cfg(target_arch = "x86_64")] "/usr/lib/x86_64-linux-gnu/openconnect/hipreport.sh", @@ -44,11 +46,11 @@ fn find_executable(locations: &[&'static str]) -> Option<&'static str> { } pub fn find_vpnc_script() -> Option<&'static str> { - find_executable(&VPNC_SCRIPT_LOCATIONS) + find_executable(VPNC_SCRIPT_LOCATIONS) } pub fn find_csd_wrapper() -> Option<&'static str> { - find_executable(&CSD_WRAPPER_LOCATIONS) + find_executable(CSD_WRAPPER_LOCATIONS) } /// If file exists, check if it is executable diff --git a/packaging/apk/APKBUILD.in b/packaging/apk/APKBUILD.in index 086f72b..38ae6b9 100644 --- a/packaging/apk/APKBUILD.in +++ b/packaging/apk/APKBUILD.in @@ -58,6 +58,7 @@ build() { make build \ INCLUDE_GUI="${INCLUDE_GUI:-0}" \ BUILD_GUI_HELPER="${BUILD_GUI_HELPER:-1}" \ + BUILD_WEBVIEW_AUTH="${BUILD_WEBVIEW_AUTH:-1}" \ LIBXML2_STATIC="${LIBXML2_STATIC:-1}" } diff --git a/packaging/bsd/com.yuezk.gpgui.policy b/packaging/bsd/com.yuezk.gpgui.policy new file mode 100644 index 0000000..a8081dd --- /dev/null +++ b/packaging/bsd/com.yuezk.gpgui.policy @@ -0,0 +1,18 @@ + + + + The GlobalProtect-openconnect Project + https://github.com/yuezk/GlobalProtect-openconnect + gpgui + + Run GPService as root + Authentication is required to run the GPService as root + + auth_admin + auth_admin + yes + + /usr/local/bin/gpservice + true + + diff --git a/packaging/bsd/freebsd/MANIFEST.in b/packaging/bsd/freebsd/MANIFEST.in new file mode 100644 index 0000000..aff1919 --- /dev/null +++ b/packaging/bsd/freebsd/MANIFEST.in @@ -0,0 +1,53 @@ +name: "@PKG_NAME@" +version: "@VERSION@" +origin: "security/@PKG_NAME@" +comment: "GlobalProtect VPN client based on OpenConnect" +maintainer: "Kevin Yue " +www: "https://github.com/yuezk/GlobalProtect-openconnect" +abi: "@ABI@" +arch: "@ARCH@" +prefix: "@PREFIX@" +licenselogic: single +licenses: ["GPLv3"] +categories: ["security", "net"] +deps: { + "gmp": { + origin: "math/gmp" + version: "*" + } + "gnome-keyring": { + origin: "security/gnome-keyring" + version: "*" + } + "gnutls": { + origin: "security/gnutls" + version: "*" + } + "libayatana-appindicator": { + origin: "devel/libayatana-appindicator" + version: "*" + } + "libxml2": { + origin: "textproc/libxml2" + version: "*" + } + "nettle": { + origin: "security/nettle" + version: "*" + } + "p11-kit": { + origin: "security/p11-kit" + version: "*" + } + "polkit": { + origin: "sysutils/polkit" + version: "*" + } + "webkit2-gtk_41": { + origin: "www/webkit2-gtk" + version: "*" + } +} +desc: < "$LOGFILE" exit 1 diff --git a/packaging/files/usr/libexec/gpclient/vpnc-script b/packaging/files/usr/libexec/gpclient/vpnc-script index 92b6051..d14c911 100755 --- a/packaging/files/usr/libexec/gpclient/vpnc-script +++ b/packaging/files/usr/libexec/gpclient/vpnc-script @@ -336,7 +336,11 @@ if [ -n "$IPROUTE" ]; then del_vpngateway_route() { echo "$VPNGATEWAY" | grep -q : && FAMILY=-6 || FAMILY=-4 - $IPROUTE route $route_syntax_del "$VPNGATEWAY" + # iproute2 deletes only one matching route at a time. The connect path may + # add one host route per matching uplink, so remove them until none remain. + while $IPROUTE $FAMILY route $route_syntax_del "$VPNGATEWAY" 2>/dev/null ; do + : + done if [ $FAMILY != -4 ]; then $IPROUTE $FAMILY route flush cache 2>/dev/null fi diff --git a/scripts/gh-release.sh b/scripts/gh-release.sh index d9935a9..9cf1a24 100755 --- a/scripts/gh-release.sh +++ b/scripts/gh-release.sh @@ -2,10 +2,11 @@ # Usage: ./scripts/gh-release.sh -set -e +set -euo pipefail +shopt -s nullglob REPO="yuezk/GlobalProtect-openconnect" -TAG=$1 +TAG=${1:-} SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" PROJECT_DIR="$(dirname "$SCRIPT_DIR")" @@ -17,34 +18,51 @@ if [ -z "$TAG" ]; then exit 1 fi +upload_files() { + local files=("$@") + + if [ ${#files[@]} -eq 0 ]; then + echo "No release assets found to upload" + exit 1 + fi + + gh -R "$REPO" release upload "$TAG" "${files[@]}" +} + +release_assets() { + "$SCRIPT_DIR/release-assets.sh" "$TAG" +} + # For snapshot release, we don't create a release, just clear the existing assets and upload new ones. # This is to avoid notification spam. release_snapshot() { RELEASE_NOTES='**!!! DO NOT USE THIS RELEASE IN PRODUCTION !!!**' - # Get the existing assets - gh -R "$REPO" release view "$TAG" --json assets --jq '.assets[].name' \ - | xargs -I {} gh -R "$REPO" release delete-asset "$TAG" {} --yes + while IFS= read -r asset; do + if [ -n "$asset" ]; then + gh -R "$REPO" release delete-asset "$TAG" "$asset" --yes + fi + done < <(gh -R "$REPO" release view "$TAG" --json assets --jq '.assets[].name') echo "Uploading new assets..." # Upload all artifacts for snapshot release because we don't need to guarantee stability. - gh -R "$REPO" release upload "$TAG" \ - "$PROJECT_DIR"/.build/artifacts/artifact-*/* + mapfile -t files < <(release_assets) + upload_files "${files[@]}" } release_tag() { echo "Removing existing release..." - gh -R "$REPO" release delete $TAG --yes --cleanup-tag || true + gh -R "$REPO" release delete "$TAG" --yes --cleanup-tag || true echo "Creating release..." - # Only upload the source tarball and GUI components for tagged release. - # Other components will be built in `release.yml` from the standalone - # source tarball and uploaded. This is to ensure the source tarball is stable. - gh -R "$REPO" release create $TAG \ + # Upload source tarballs, GUI components, and BSD packages. Other Linux + # packages are built in `release.yml` from the standalone source tarball. + gh -R "$REPO" release create "$TAG" \ --title "$TAG" \ - --notes "$RELEASE_NOTES" \ - "$PROJECT_DIR"/.build/artifacts/artifact-source*/* \ - "$PROJECT_DIR"/.build/artifacts/artifact-gpgui-*/* + --notes "$RELEASE_NOTES" + + mapfile -t files < <(release_assets) + upload_files "${files[@]}" } if [[ $TAG == *"snapshot" ]]; then diff --git a/scripts/release-assets.sh b/scripts/release-assets.sh new file mode 100755 index 0000000..f3871bf --- /dev/null +++ b/scripts/release-assets.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +set -euo pipefail +shopt -s nullglob + +SELECTION=${1:-} + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +PROJECT_DIR="$(dirname "$SCRIPT_DIR")" +ARTIFACT_DIR=${2:-"$PROJECT_DIR/.build/artifacts"} + +if [ -z "$SELECTION" ]; then + echo "Usage: ./scripts/release-assets.sh [artifact-dir]" >&2 + exit 1 +fi + +if [[ "$SELECTION" == *"snapshot"* ]]; then + SELECTION=snapshot +elif [ "$SELECTION" != "all" ]; then + SELECTION=tag +fi + +case "$SELECTION" in + snapshot|all) + printf '%s\n' "$ARTIFACT_DIR"/artifact-*/* + ;; + tag) + printf '%s\n' \ + "$ARTIFACT_DIR"/artifact-source*/* \ + "$ARTIFACT_DIR"/artifact-gpgui-*/* \ + "$ARTIFACT_DIR"/artifact-bsd-*/* + ;; + *) + echo "Unknown release asset selection: $SELECTION" >&2 + exit 1 + ;; +esac