Compare commits

..
Author SHA1 Message Date
Kevin Yue 88e0b5b9e4 fix(gpclient): honor the requested username when reusing cookies 2026-11-30 13:58:56 +08:00
Kevin Yue 89f6364a7b fix(vpn): pin the OpenConnect AES-GCM MTU correction
Refs #730.
2026-11-25 21:31:44 +08:00
Francis DevereuxandKevin Yue 69155d04b9 feat(gphip): add HIP detection for BitDefender GravityZone on Linux (#729)
* feat(gphip): add HIP detection for BitDefender GravityZone on Linux

* fix(gphip): reuse trusted paths for Bitdefender detection

---------

Co-authored-by: Kevin Yue <[email protected]>
2026-11-23 22:48:33 +08:00
Kevin Yue 2160bd82f8 Merge pull request #727 from yuezk/chore/promote-v3.7.1
release: promote GP Connect 3.7.1 and the Nix flake
2026-11-22 00:34:09 +08:00
Kevin Yue 2a4d23f595 docs: refresh GP Connect 3.7.1 download links 2026-11-22 00:31:25 +08:00
Kevin Yue 1e140ca764 release: validate Nix packages for v3.7.1 2026-11-22 00:29:49 +08:00
Kevin Yue 541a269d4c Release 3.7.1 2026-11-21 22:33:08 +08:00
Kevin Yue dd70148936 Merge pull request #725 from yuezk/chore/promote-v3.7.0
release: promote GP Connect 3.7.0 and the Nix flake
2026-11-21 12:37:00 +08:00
Kevin Yue 3ee6d16b11 Refresh the installation guide for GP Connect 3.7.0 2026-11-21 12:34:42 +08:00
Kevin Yue 9dc99289b3 release: validate Nix packages for v3.7.0 2026-11-21 12:34:18 +08:00
20 changed files with 692 additions and 200 deletions

No files matched your search

Generated
+13 -13
View File
@@ -292,7 +292,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
[[package]]
name = "auth"
version = "3.7.0"
version = "3.7.1"
dependencies = [
"anyhow",
"block2",
@@ -554,7 +554,7 @@ dependencies = [
[[package]]
name = "browser-launcher"
version = "3.7.0"
version = "3.7.1"
dependencies = [
"anyhow",
"log",
@@ -919,7 +919,7 @@ dependencies = [
[[package]]
name = "common"
version = "3.7.0"
version = "3.7.1"
dependencies = [
"tempfile",
]
@@ -2133,7 +2133,7 @@ dependencies = [
[[package]]
name = "gp-xml"
version = "3.7.0"
version = "3.7.1"
dependencies = [
"url",
"xmltree",
@@ -2141,7 +2141,7 @@ dependencies = [
[[package]]
name = "gpapi"
version = "3.7.0"
version = "3.7.1"
dependencies = [
"anyhow",
"base64 0.23.1",
@@ -2205,7 +2205,7 @@ dependencies = [
[[package]]
name = "gpauth"
version = "3.7.0"
version = "3.7.1"
dependencies = [
"anyhow",
"auth",
@@ -2223,7 +2223,7 @@ dependencies = [
[[package]]
name = "gpclient"
version = "3.7.0"
version = "3.7.1"
dependencies = [
"anyhow",
"clap",
@@ -2254,7 +2254,7 @@ dependencies = [
[[package]]
name = "gpgui-helper"
version = "3.7.0"
version = "3.7.1"
dependencies = [
"anyhow",
"clap",
@@ -2275,7 +2275,7 @@ dependencies = [
[[package]]
name = "gphip"
version = "3.7.0"
version = "3.7.1"
dependencies = [
"anyhow",
"askama",
@@ -2294,7 +2294,7 @@ dependencies = [
[[package]]
name = "gpservice"
version = "3.7.0"
version = "3.7.1"
dependencies = [
"anyhow",
"axum",
@@ -2332,7 +2332,7 @@ dependencies = [
[[package]]
name = "gptunnel"
version = "3.7.0"
version = "3.7.1"
dependencies = [
"gpapi",
"log",
@@ -2344,7 +2344,7 @@ dependencies = [
[[package]]
name = "gpvpnc"
version = "3.7.0"
version = "3.7.1"
dependencies = [
"base64 0.23.1",
"ipnet",
@@ -3860,7 +3860,7 @@ dependencies = [
[[package]]
name = "openconnect"
version = "3.7.0"
version = "3.7.1"
dependencies = [
"autotools",
"cc",
+1 -1
View File
@@ -11,7 +11,7 @@ members = [
[workspace.package]
rust-version = "1.91"
version = "3.7.0"
version = "3.7.1"
authors = ["Kevin Yue <[email protected]>"]
homepage = "https://github.com/yuezk/GlobalProtect-openconnect"
edition = "2024"
+131 -146
View File
@@ -1,8 +1,14 @@
# GlobalProtect-openconnect
A GlobalProtect VPN client built on OpenConnect. GP Connect runs on Windows, macOS, Linux, FreeBSD, and OpenBSD.
**GP Connect** is a GlobalProtect VPN client built on OpenConnect. The desktop app runs on Windows, macOS, Linux, FreeBSD, and OpenBSD. The command-line client is `gpclient`.
> **Disclaimer**: GP Connect is an independent third-party client for GlobalProtect VPN networks. It is not affiliated with or endorsed by Palo Alto Networks, Inc.
<p align="center">
<a href="#features">Features</a> ·
<a href="#installation">Installation</a> ·
<a href="#usage">Usage</a> ·
<a href="#troubleshooting">Troubleshooting</a> ·
<a href="#building-from-source">Building from source</a>
</p>
<p align="center">
<picture>
@@ -12,111 +18,71 @@ A GlobalProtect VPN client built on OpenConnect. GP Connect runs on Windows, mac
</picture>
</p>
> **Inspired by** [gp-saml-gui](https://github.com/dlenski/gp-saml-gui)
## Table of Contents
- [Features](#features)
- [Usage](#usage)
- [Command-Line Interface](#command-line-interface)
- [Graphical User Interface](#graphical-user-interface)
- [Installation](#installation)
- [Windows](#windows)
- [macOS](#macos)
- [Debian / Ubuntu](#debian--ubuntu)
- [Arch Linux / Manjaro](#arch-linux--manjaro)
- [Fedora / RHEL](#fedora--rhel)
- [openSUSE](#opensuse)
- [Alpine Linux](#alpine-linux)
- [FreeBSD](#freebsd)
- [OpenBSD](#openbsd)
- [Gentoo](#gentoo)
- [NixOS](#nixos)
- [Docker](#docker)
- [Other Distributions](#other-distributions)
- [Building from Source](#building-from-source)
- [Troubleshooting](#troubleshooting)
- [NetworkManager Integration](#networkmanager-integration)
- [Licensing](#licensing)
GP Connect is an independent project. It is not affiliated with or endorsed by Palo Alto Networks, Inc.
## Features
- **Multi-Platform** – Windows (x64 and ARM64), macOS (Apple silicon), Linux, FreeBSD, and OpenBSD
- **Dual Interfaces** – Desktop GUI (**GP Connect**) and terminal CLI (`gpclient`, on macOS, Linux, and BSD)
- **Native Shell on Linux** – Ultra-low-memory native desktop GUI alongside the webview interface
- **Flexible Routing** – Full System VPN tunnel or local SOCKS5 proxy mode
- **Modern Authentication** – SAML / SSO, MFA, FIDO2 (YubiKey), client certificates, and external browser login
- **Automated HIP Reports** – Built-in HIP report generation or custom scripts
- **Multi-Portal & Direct Gateway** – Manage multiple saved portals or connect directly to a gateway
- **Desktop Integration** – Theme-aware system tray icon, auto-connect on launch, and reconnect on wake
## Usage
### Command-Line Interface
On macOS, Linux, and BSD, the open-source `gpclient` CLI handles authentication, connection lifecycle, and HIP generation:
```bash
# Connect to a portal server
sudo gpclient connect <portal>
# Connect using browser authentication (SSO / SAML)
sudo gpclient connect <portal> --browser
# Connect directly to a gateway server
sudo gpclient connect <gateway> --as-gateway
# Connect with automatic HIP report generation
sudo gpclient connect <portal> --hip
# Headless / remote server authentication (prints auth URL to open in any browser)
sudo gpclient connect <portal> --browser manual
# Disconnect
sudo gpclient disconnect
```
Run `gpclient --help` or `gpclient <command> --help` to view all available commands and options.
### Graphical User Interface
- **Windows**: Open **GP Connect** from the Start menu.
- **macOS**: Open **GP Connect** from Applications.
- **Linux / BSD**: Launch GP Connect from your application menu or run:
```bash
gpclient launch-gui
```
> [!TIP]
> On Linux, GP Connect uses Native Shell when your system supports it. Your saved interface choice takes priority. Switch while disconnected in **Settings → General → Interface**.
>
> If the window stays blank, fully quit GP Connect and run `gpclient launch-gui --interface tauri`. To select Native Shell, use `--interface nsh`. The choice is saved when the interface starts.
- Browser-based SSO and MFA, including security keys supported by the identity provider. Client certificates are also supported.
- System VPN tunnel or local SOCKS5 and HTTP proxies for individual applications.
- Multiple saved portals and direct gateway connections.
- Built-in host information profile (HIP) reporting and support for custom HIP scripts.
- System tray controls and automatic connection on launch.
- Native Shell, a lightweight desktop interface for supported Linux systems.
## Installation
| Platform | Installation instructions |
| --- | --- |
| Windows and macOS | [Windows](#windows) · [macOS](#macos) |
| Linux | [Alpine](#alpine-linux) · [Arch / Manjaro](#arch-linux--manjaro) · [Debian / Ubuntu](#debian--ubuntu) · [Fedora / RHEL](#fedora--rhel) · [Gentoo](#gentoo) · [NixOS](#nixos) · [openSUSE](#opensuse) · [Other distributions](#other-distributions) |
| BSD | [FreeBSD](#freebsd) · [OpenBSD](#openbsd) |
| Container | [Docker](#docker) |
### Windows
1. Download the **x64** or **ARM64** installer for your PC from [GitHub Releases](https://github.com/yuezk/GlobalProtect-openconnect/releases/latest).
2. Run the installer and approve the administrator prompt.
3. Open **GP Connect** from the Start menu.
Download the Windows installer for [x64](https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v3.7.1/GPConnect_3.7.1_windows-x64-setup.exe) or [ARM64](https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v3.7.1/GPConnect_3.7.1_windows-arm64-setup.exe). Run it and approve the administrator prompt.
### macOS
Requires Apple silicon and macOS 13+. Includes both GP Connect and the `gpclient` CLI.
Requires Apple silicon and macOS 13+.
#### Option 1: Homebrew (Recommended)
#### Homebrew
```bash
brew install --cask yuezk/gp-connect/gp-connect
```
#### Option 2: DMG Installer
#### DMG installer
Download the `.dmg` from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page and drag GP Connect into Applications.
Open the [Apple silicon DMG](https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v3.7.1/GPConnect_3.7.1_arm64.dmg) and drag GP Connect into Applications.
### Alpine Linux
Download the APK for [x86_64](https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v3.7.1/globalprotect-openconnect-3.7.1-r1-x86_64.apk) or [ARM64](https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v3.7.1/globalprotect-openconnect-3.7.1-r1-aarch64.apk).
```bash
sudo apk add --allow-untrusted globalprotect-openconnect-*.apk
```
Enable the Alpine `community` repository for WebKitGTK.
### Arch Linux / Manjaro
Install the stable package from the Extra repository.
```bash
sudo pacman -S globalprotect-openconnect
```
For the development version from the main branch, use the AUR package.
```bash
yay -S globalprotect-openconnect-git
```
### Debian / Ubuntu
#### Option 1: PPA (Recommended)
#### Ubuntu PPA
```bash
sudo add-apt-repository ppa:yuezk/globalprotect-openconnect
@@ -124,24 +90,14 @@ sudo apt-get update
sudo apt-get install globalprotect-openconnect
```
#### Option 2: DEB Package
#### Debian or Ubuntu release package
Download the latest `.deb` from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page:
Download the DEB for [amd64](https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v3.7.1/globalprotect-openconnect_3.7.1-1_amd64.deb) or [arm64](https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v3.7.1/globalprotect-openconnect_3.7.1-1_arm64.deb).
```bash
sudo apt install ./globalprotect-openconnect_*.deb
```
### Arch Linux / Manjaro
```bash
# Official Extra repository
sudo pacman -S globalprotect-openconnect
# AUR (git main)
yay -S globalprotect-openconnect-git
```
### Fedora / RHEL
Enable the COPR repository:
@@ -151,36 +107,6 @@ sudo dnf copr enable yuezk/globalprotect-openconnect
sudo dnf install globalprotect-openconnect
```
### openSUSE
Packages are available on the [openSUSE Build Service](https://build.opensuse.org/package/show/home:yuezk/globalprotect-openconnect). Follow the [OBS instructions](https://software.opensuse.org/download.html?project=home%3Ayuezk&package=globalprotect-openconnect) for your distribution.
### Alpine Linux
Download the latest `.apk` package from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page:
```bash
sudo apk add --allow-untrusted globalprotect-openconnect-*.apk
```
*(Requires the `community` repository for WebKitGTK dependencies).*
### FreeBSD
Download the latest FreeBSD package from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page:
```bash
sudo pkg install ./globalprotect-openconnect-*-freebsd-*.pkg
```
### OpenBSD
Download the latest OpenBSD package from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page:
```bash
doas pkg_add -D unsigned ./globalprotect-openconnect-*-openbsd-*.tgz
```
### Gentoo
Add the overlay:
@@ -191,13 +117,15 @@ sudo eselect repository add yuezk git https://github.com/yuezk/gentoo-overlay.gi
sudo emerge --sync yuezk
```
Install the prebuilt package (glibc):
On glibc systems, install the prebuilt package:
```bash
sudo emerge --ask net-vpn/globalprotect-openconnect-bin::yuezk
```
For a source build, use `net-vpn/globalprotect-openconnect::yuezk`. If Portage requests keyword or USE flag changes, review and apply them, then rerun the install command.
The source package is `net-vpn/globalprotect-openconnect::yuezk`. For a headless installation, see the [CLI-only overlay instructions](https://github.com/yuezk/gentoo-overlay#cli-only).
If Portage requests keyword or USE flag changes, review and apply them, then rerun the install command.
### NixOS
@@ -226,38 +154,96 @@ Apply changes:
sudo nixos-rebuild switch
```
### openSUSE
Packages are available on the [openSUSE Build Service](https://build.opensuse.org/package/show/home:yuezk/globalprotect-openconnect). Follow the [OBS instructions](https://software.opensuse.org/download.html?project=home%3Ayuezk&package=globalprotect-openconnect) for your distribution.
### Other Distributions
Download the archive for [x86_64](https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v3.7.1/globalprotect-openconnect_3.7.1_x86_64.bin.tar.xz) or [ARM64](https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v3.7.1/globalprotect-openconnect_3.7.1_aarch64.bin.tar.xz).
```bash
tar -xJf globalprotect-openconnect_*.bin.tar.xz
cd globalprotect-openconnect_3.7.1
sudo make install
```
### FreeBSD
Download the [FreeBSD package for amd64](https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v3.7.1/globalprotect-openconnect-3.7.1-freebsd-amd64.pkg).
```bash
sudo pkg install ./globalprotect-openconnect-*-freebsd-*.pkg
```
### OpenBSD
Download the [OpenBSD package for amd64](https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v3.7.1/globalprotect-openconnect-3.7.1-openbsd-amd64.tgz).
```bash
doas pkg_add -D unsigned ./globalprotect-openconnect-*-openbsd-*.tgz
```
### Docker
Run the CLI client in an official Alpine container:
Run the CLI in the project’s Alpine container. Replace `vpn.example.com` with your portal address.
```bash
docker run --rm -it --cap-add=NET_ADMIN --device=/dev/net/tun \
yuezk/globalprotect-openconnect:latest \
connect <portal> --browser manual
connect vpn.example.com --browser manual
```
*(Add `--network host` on Linux if VPN routes should apply to the host network).*
On Linux, add `--network host` to apply VPN routes to the host network.
### Other Distributions
## Usage
Download `globalprotect-openconnect_${version}_${arch}.bin.tar.xz` from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page:
### Desktop
```bash
tar -xJf globalprotect-openconnect_*.bin.tar.xz
cd globalprotect-openconnect_*
sudo make install
Open **GP Connect**, enter your GlobalProtect portal address, and sign in. On Linux and BSD, you can also launch the app with `gpclient launch-gui`.
### Command line
On Linux, BSD, or macOS with Homebrew, replace `vpn.example.com` with your portal address. Use `doas` instead of `sudo` on OpenBSD.
```sh
sudo gpclient connect vpn.example.com
```
| Command | Action |
| --- | --- |
| `sudo gpclient disconnect` | Disconnect |
| `sudo gpclient connect vpn.example.com --browser` | Sign in with a browser |
| `sudo gpclient connect gateway.example.com --as-gateway` | Connect directly to a gateway |
| `sudo gpclient connect vpn.example.com --hip` | Connect with HIP reporting enabled |
See `gpclient connect --help` for all connection options.
### Connecting over SSH
For portals that allow external-browser sign-in, run this command on the remote host:
```sh
sudo gpclient connect vpn.example.com --browser manual
```
Open the printed URL in a browser that can reach the remote host. After signing in, paste the callback URL into the SSH terminal.
## Troubleshooting
- **Blank Linux window.** Quit GP Connect and run `gpclient launch-gui --interface tauri`. To switch back, quit and rerun with `--interface nsh`.
- **Reporting a problem.** Run `gpclient diagnostics` and include the relevant output in your issue. See the [diagnostics guide](docs/diagnostics.md) for details.
## Building from Source
### Prerequisites (Linux)
- [Rust](https://www.rust-lang.org/tools/install) 1.91 or later
- Build tools: `make`, `pkg-config`, `autoconf`, `automake`, `libtool`, `gettext`
- Libraries: `gmp`, `gnutls`, `nettle`, `libxml2`, `zlib`, `lz4`, `p11-kit`, `libsecret`, and `webkit2gtk-4.1` for the embedded sign-in window and download helper. Native Shell also requires GTK 4.14 or later. The generic glibc build requires glibc 2.39 or later
- Libraries: `gmp`, `gnutls`, `nettle`, `libxml2`, `zlib`, `lz4`, `p11-kit`, `libsecret`, and `webkit2gtk-4.1` for the embedded sign-in window and download helper. Native Shell also requires GTK 4.14 or later.
- Polkit (`pkexec`) for privileged tunnel setup
*(For FreeBSD and OpenBSD instructions, see [Building from Source on FreeBSD and OpenBSD](docs/bsd-source-build.md)).*
For BSD build requirements, see [Building from Source on FreeBSD and OpenBSD](docs/bsd-source-build.md).
### Build Steps
@@ -274,11 +260,6 @@ sudo make install
- `BUILD_WEBVIEW_AUTH=0` – Disable embedded browser authentication in both `gpclient` and `gpauth`. External-browser and manual sign-in remain available.
- `BUILD_GUI_HELPER=0` – Skip building the helper UI.
## Troubleshooting
- **Headless / Remote Login**: When running without a desktop display or over SSH, use `--browser manual`. Open the printed URL in any browser and paste the callback URL back into the terminal.
- **Diagnostics**: If you encounter issues, run `gpclient diagnostics` or follow the [diagnostics guide](docs/diagnostics.md) when opening an issue.
## NetworkManager Integration
- [WMP/GlobalProtect-SAML-NetworkManager](https://github.com/WMP/GlobalProtect-SAML-NetworkManager) – NetworkManager VPN plugin with SAML/SSO support for GNOME and KDE Plasma
@@ -303,3 +284,7 @@ sudo make install
| [gpclient](./apps/gpclient) | Application | [GPL-3.0](./apps/gpclient/LICENSE) |
| [gpauth](./apps/gpauth) | Application | [GPL-3.0](./apps/gpauth/LICENSE) |
| [gpgui-helper](./apps/gpgui-helper) | Application | [GPL-3.0](./apps/gpgui-helper/LICENSE) |
## Acknowledgments
Inspired by [gp-saml-gui](https://github.com/dlenski/gp-saml-gui).
+43
View File
@@ -129,6 +129,49 @@ async fn cached_tunnel_authentication_does_not_require_portal_discovery() {
);
}
#[tokio::test]
async fn explicit_user_skips_another_users_cached_gateway_and_portal_credentials() {
let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
let origin = format!("http://{}", listener.local_addr().unwrap());
let directory = tempfile::tempdir().unwrap();
let cache = directory.path().join("cookie.json");
let args = TestArgs::parse_from([
"test",
&origin,
"--user",
"bob",
"--cookie-cache",
cache.to_str().unwrap(),
])
.connect;
let lock = directory.path().join("client.pid");
let verbose = gpapi::clap::InfoLevelVerbosity::new(0, 0);
let shared = SharedArgs {
ignore_tls_errors: true,
lock_file: &lock,
verbose: &verbose,
log_format: LogFormat::Text,
};
let handler = ConnectHandler::new(&args, &shared);
cookie_store::save(
&cache,
&StoredCookie::new(
args.server.clone(),
"alice".into(),
handler.os_profile.borrow().host_identity().host_id().into(),
origin,
AuthCookieCredential::new("alice", "portal-cookie", ""),
),
)
.unwrap();
assert!(handler.cached_portal_credential(&args.server).is_none());
tokio::select! {
result = handler.try_cached_cookie(&args.server) => assert!(result.is_none()),
_ = listener.accept() => panic!("a mismatched cache entry must be skipped before contacting the gateway"),
}
}
#[tokio::test]
async fn unreachable_gateway_keeps_cached_cookie() {
// Nothing listens here: the cached gateway login gets no answer at all.
+2 -2
View File
@@ -83,7 +83,7 @@ impl ConnectHandler<'_> {
pub(super) async fn try_cached_cookie(&self, server: &str) -> Option<anyhow::Result<()>> {
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)?;
let stored = cookie_store::load(&path, server, &host_id, self.args.user.as_deref())?;
if !stored.auth_cookie.can_authenticate_gateway() {
cookie_store::clear(&path);
return None;
@@ -145,7 +145,7 @@ impl ConnectHandler<'_> {
}
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)?;
let stored = cookie_store::load(&path, server, &host_id, self.args.user.as_deref())?;
if !stored.auth_cookie.can_authenticate_gateway() {
cookie_store::clear(&path);
return None;
+4 -1
View File
@@ -325,7 +325,10 @@ async fn wait_for_brokered_idle(
_ = interval.tick() => {},
}
let idle = matches!(*vpn_state_rx.borrow(), VpnState::Disconnected | VpnState::Failed(_)) && registry.is_empty();
let idle = matches!(
*vpn_state_rx.borrow(),
VpnState::Disconnected | VpnState::UnexpectedDisconnect { .. } | VpnState::Failed(_)
) && registry.is_empty();
if !idle {
idle_since = None;
continue;
+7
View File
@@ -174,6 +174,12 @@ impl RequestDispatcher {
.stop_non_tunnel_attachment(authority.session_id, authority.generation, connection_id)?;
Ok(PendingDispatch::Drain(drain))
}
WsRequest::AbandonReconnect { attempt } => {
let authority = authority
.ok_or_else(|| ServiceResult::rejected(ServiceErrorCode::InvalidRequest, "Connection session is missing"))?;
self.lifecycle.abandon_reconnect(attempt, authority.session_id);
Err(ServiceResult::Accepted)
}
WsRequest::Disconnect(_) => Err(self.lifecycle.request_disconnect()),
request => Ok(PendingDispatch::Other(request)),
}
@@ -259,6 +265,7 @@ impl RequestDispatcher {
ServiceResult::Accepted
}
WsRequest::Connect(_)
| WsRequest::AbandonReconnect { .. }
| WsRequest::StopNonTunnelAttachment { .. }
| WsRequest::Disconnect(_)
| WsRequest::StoreEditedHipReportChunk(_)
+181 -17
View File
@@ -76,6 +76,7 @@ impl LifecycleHandle {
let cancellation = CancellationToken::new();
admissions.current = Some(Admission {
attempt,
restart,
phase: AdmissionPhase::Preparing,
stop_requested: false,
cancellation: cancellation.clone(),
@@ -89,6 +90,19 @@ impl LifecycleHandle {
})
}
pub fn abandon_reconnect(&self, attempt: u64, owner: Uuid) {
let mut admissions = self.admissions.lock().expect("VPN lifecycle admissions mutex poisoned");
// A replacement that already owns admission will publish its own outcome.
if admissions.restart == Some((attempt, owner)) {
admissions.restart = None;
self.state.send_replace(VpnState::UnexpectedDisconnect {
attempt,
owner,
reason: None,
});
}
}
#[cfg(test)]
fn submit_test_connection(
&self,
@@ -217,7 +231,7 @@ impl LifecycleHandle {
true
}
fn clear_attempt(&self, attempt: u64) {
fn clear_attempt(&self, attempt: u64, state: Option<VpnState>) {
let completion = {
let mut admissions = self.admissions.lock().expect("VPN lifecycle admissions mutex poisoned");
let Some(admission) = admissions.current.as_ref() else {
@@ -226,6 +240,20 @@ impl LifecycleHandle {
if admission.attempt != attempt {
return;
}
let state = match admission.restart {
Some((attempt, owner)) if !admission.stop_requested && !admissions.closed => {
let reason = match state {
Some(VpnState::Failed(reason)) => Some(reason),
_ => None,
};
Some(VpnState::UnexpectedDisconnect { attempt, owner, reason })
}
Some(_) if state.is_none() => Some(VpnState::Disconnected),
_ => state,
};
if let Some(state) = state {
self.state.send_replace(state);
}
let completion = Arc::clone(&admission.completion);
admissions.current = None;
completion
@@ -357,7 +385,7 @@ impl Drop for ConnectReservation {
fn drop(&mut self) {
if !self.transferred {
self.cancellation.cancel();
self.lifecycle.clear_attempt(self.attempt);
self.lifecycle.clear_attempt(self.attempt, None);
// A full queue already wakes the actor; a closed queue has no actor to wake.
let _ = self.lifecycle.events.try_send(LifecycleEvent::PreparationReleased);
}
@@ -375,6 +403,7 @@ struct Admissions {
#[derive(Clone)]
struct Admission {
attempt: u64,
restart: Option<(u64, Uuid)>,
phase: AdmissionPhase,
stop_requested: bool,
cancellation: CancellationToken,
@@ -444,6 +473,7 @@ struct ActiveAttempt {
task: tokio::task::JoinHandle<()>,
failure: Option<String>,
reconnect_required: bool,
tunnel_established: bool,
}
pub(crate) struct VpnTask {
@@ -638,6 +668,7 @@ impl VpnTask {
task,
failure: None,
reconnect_required: false,
tunnel_established: false,
});
if activated {
self.send_state(VpnState::Connecting(Box::new(info)));
@@ -720,16 +751,20 @@ impl VpnTask {
self.send_state(VpnState::Connected(Box::new(info.with_members(members, failures))));
}
fn publish_connected(&self, attempt: u64, info: ConnectInfo, session_info: SessionInfo) {
fn publish_connected(&mut self, attempt: u64, info: ConnectInfo, session_info: SessionInfo) {
let connected = VpnState::Connected(Box::new(ConnectedInfo::new(info, Some(session_info))));
let admissions = self
let mut admissions = self
.lifecycle
.admissions
.lock()
.expect("VPN lifecycle admissions mutex poisoned");
if admissions.current.as_ref().is_some_and(|admission| {
if let Some(admission) = admissions.current.as_mut().filter(|admission| {
admission.attempt == attempt && admission.phase == AdmissionPhase::Active && !admission.stop_requested
}) {
admission.restart = None;
if let Some(active) = self.active.as_mut().filter(|active| active.attempt == attempt) {
active.tunnel_established = true;
}
self.send_state(connected);
}
}
@@ -777,19 +812,25 @@ impl VpnTask {
admission.completion.completed.store(true, Ordering::Release);
admission.completion.notify.notify_waiters();
}
} else if let Some(reason) = active.failure {
self.send_state(VpnState::Failed(reason));
self.lifecycle.clear_attempt(attempt);
} else {
self.finish_attempt(attempt);
let unexpectedly_ended = active
.session_id
.filter(|_| active.tunnel_established && !active.cancellation.is_cancelled());
let state = if let Some(owner) = unexpectedly_ended {
VpnState::UnexpectedDisconnect {
attempt,
owner,
reason: active.failure,
}
} else if let Some(reason) = active.failure {
VpnState::Failed(reason)
} else {
VpnState::Disconnected
};
self.lifecycle.clear_attempt(attempt, Some(state));
}
}
fn finish_attempt(&self, attempt: u64) {
self.send_state(VpnState::Disconnected);
self.lifecycle.clear_attempt(attempt);
}
fn send_state(&self, state: VpnState) {
let _ = self.vpn_state_tx.send(state);
}
@@ -1067,6 +1108,7 @@ mod tests {
task: tokio::spawn(async {}),
failure: None,
reconnect_required: false,
tunnel_established: false,
});
task.send_state(VpnState::Connecting(Box::new(info)));
let mut member = gpapi::session::GatewaySessionSummary {
@@ -1087,6 +1129,126 @@ mod tests {
task.end_attempt(0).await;
}
#[tokio::test]
async fn unexpected_disconnect_requires_an_established_tunnel() {
for established in [false, true] {
let (state, observed) = watch::channel(VpnState::Disconnected);
let (mut task, lifecycle) = VpnTask::new(state, false, registry());
let owner = Uuid::new_v4();
let info = ConnectInfo::new(
"portal.example.com".into(),
gpapi::gateway::Gateway::new("vpn".into(), "vpn.example.com".into()),
vec![],
);
let reservation = lifecycle.reserve_connect(None).unwrap();
let cancellation = reservation.cancellation();
assert_eq!(
reservation.commit(
PreparedConnection::lifecycle_fixture(test_connect_request(info.clone())),
None,
None,
Some(owner),
),
ServiceResult::Accepted
);
let _ = task.events.try_recv().unwrap();
assert!(lifecycle.activate_attempt(0));
task.active = Some(ActiveAttempt {
attempt: 0,
session_id: Some(owner),
info: info.clone(),
allow_extend_session: false,
cancellation,
task: tokio::spawn(async {}),
failure: None,
reconnect_required: false,
tunnel_established: false,
});
if established {
task.establish_attempt(0, VpnSessionInfo::default());
assert!(matches!(*observed.borrow(), VpnState::Connected(_)));
}
task.send_state(VpnState::Connecting(Box::new(info)));
task.end_attempt(0).await;
if established {
assert!(matches!(
*observed.borrow(),
VpnState::UnexpectedDisconnect { attempt: 0, owner: actual, .. } if actual == owner
));
} else {
assert!(matches!(*observed.borrow(), VpnState::Disconnected));
}
}
}
#[test]
fn abandoning_reconnect_cannot_end_an_admitted_replacement() {
let (state, mut observed) = watch::channel(VpnState::Disconnected);
let (_task, lifecycle) = VpnTask::new(state, false, registry());
let owner = Uuid::new_v4();
let restart = (7, owner);
lifecycle.admissions.lock().unwrap().restart = Some(restart);
lifecycle.abandon_reconnect(7, Uuid::new_v4());
assert!(!observed.has_changed().unwrap());
let replacement = lifecycle.reserve_connect(Some(restart)).unwrap();
lifecycle.abandon_reconnect(7, owner);
assert!(!observed.has_changed().unwrap());
drop(replacement);
assert!(matches!(
*observed.borrow_and_update(),
VpnState::UnexpectedDisconnect { attempt: 7, owner: actual, .. } if actual == owner
));
lifecycle.abandon_reconnect(7, owner);
assert!(!observed.has_changed().unwrap());
}
#[test]
fn abandoning_an_unclaimed_reconnect_reports_loss_and_rejects_late_admission() {
let (state, observed) = watch::channel(VpnState::Disconnected);
let (_task, lifecycle) = VpnTask::new(state, false, registry());
let owner = Uuid::new_v4();
lifecycle.admissions.lock().unwrap().restart = Some((7, owner));
lifecycle.abandon_reconnect(7, owner);
assert!(matches!(
*observed.borrow(),
VpnState::UnexpectedDisconnect { attempt: 7, owner: actual, .. } if actual == owner
));
assert!(lifecycle.reserve_connect(Some((7, owner))).is_err());
}
#[test]
fn established_replacement_settles_the_original_reconnect() {
let (state, observed) = watch::channel(VpnState::Disconnected);
let (mut task, lifecycle) = VpnTask::new(state, false, registry());
let owner = Uuid::new_v4();
let info = ConnectInfo::new(
"portal.example.com".into(),
gpapi::gateway::Gateway::new("vpn".into(), "vpn.example.com".into()),
vec![],
);
lifecycle.admissions.lock().unwrap().restart = Some((7, owner));
let replacement = lifecycle.reserve_connect(Some((7, owner))).unwrap();
assert_eq!(
replacement.commit(
PreparedConnection::lifecycle_fixture(test_connect_request(info.clone())),
None,
None,
Some(owner),
),
ServiceResult::Accepted
);
assert!(lifecycle.activate_attempt(0));
task.publish_connected(0, info, SessionInfo::default());
lifecycle.abandon_reconnect(7, owner);
assert!(matches!(*observed.borrow(), VpnState::Connected(_)));
lifecycle.clear_attempt(0, Some(VpnState::Disconnected));
assert!(matches!(*observed.borrow(), VpnState::Disconnected));
}
#[tokio::test]
async fn disconnect_completion_waits_for_the_owned_attempt_task() {
let (state, state_rx) = watch::channel(VpnState::Disconnected);
@@ -1122,6 +1284,7 @@ mod tests {
task: worker,
failure: None,
reconnect_required: false,
tunnel_established: true,
});
assert_eq!(lifecycle.request_disconnect(), ServiceResult::Accepted);
let stop = task.events.recv().await.unwrap();
@@ -1169,6 +1332,7 @@ mod tests {
task: tokio::spawn(async {}),
failure: None,
reconnect_required: false,
tunnel_established: false,
});
task.send_state(VpnState::Connecting(Box::new(
task.active.as_ref().unwrap().info.clone(),
@@ -1220,7 +1384,7 @@ mod tests {
fn late_established_event_is_ignored_after_disconnect_is_accepted() {
let (vpn_state_tx, vpn_state_rx) = watch::channel(VpnState::Disconnected);
let state_rx = vpn_state_rx.clone();
let (task, lifecycle) = VpnTask::new(vpn_state_tx, false, registry());
let (mut task, lifecycle) = VpnTask::new(vpn_state_tx, false, registry());
let info = ConnectInfo::new(
"portal.example.com".to_string(),
gpapi::gateway::Gateway::new("vpn".to_string(), "vpn.example.com".to_string()),
@@ -1242,7 +1406,7 @@ mod tests {
#[tokio::test]
async fn disconnect_waiter_completes_for_its_attempt_before_a_later_connect() {
let (vpn_state_tx, _vpn_state_rx) = watch::channel(VpnState::Disconnected);
let (task, lifecycle) = VpnTask::new(vpn_state_tx, false, registry());
let (_task, lifecycle) = VpnTask::new(vpn_state_tx, false, registry());
let request = || {
test_connect_request(ConnectInfo::new(
"portal.example.com".to_string(),
@@ -1261,7 +1425,7 @@ mod tests {
tokio::task::yield_now().await;
}
task.finish_attempt(0);
lifecycle.clear_attempt(0, Some(VpnState::Disconnected));
assert!(matches!(
lifecycle.submit_test_connection(request(), None, None, None),
ServiceResult::Accepted
+1 -1
View File
@@ -733,7 +733,7 @@ mod tests {
async fn watch_vpn_state(mut vpn_state_rx: watch::Receiver<VpnState>, ctx: Arc<WsServerContext>) {
while vpn_state_rx.changed().await.is_ok() {
let vpn_state = vpn_state_rx.borrow().clone();
let vpn_state = vpn_state_rx.borrow_and_update().clone();
ctx.send_event(WsEvent::VpnState(vpn_state)).await;
}
}
+11
View File
@@ -1,5 +1,16 @@
# Changelog
## 3.7.1
### Added
- Show a desktop notification on Windows, Linux, FreeBSD, and OpenBSD when the VPN disconnects unexpectedly and automatic reconnect fails.
### Fixed
- Make the Native Shell Close button visible in light mode and give it a consistent appearance across Linux themes.
- Allow turning off Compatibility Graphics in the Tauri interface.
## 3.7.0
- Linux now opens Native Shell by default on supported systems, including Alpine. Upgrades keep your saved interface choice.
+20 -6
View File
@@ -59,12 +59,15 @@ pub fn cookie_path(custom: Option<&str>) -> Option<PathBuf> {
}
}
pub fn load(path: &Path, server: &str, host_id: &str) -> Option<StoredCookie> {
pub fn load(path: &Path, server: &str, host_id: &str, requested_user: Option<&str>) -> Option<StoredCookie> {
let bytes = zeroize::Zeroizing::new(platform::decode(fs::read(path).ok()?).ok()?);
let stored: StoredCookie = serde_json::from_slice(&bytes).ok()?;
if stored.version != STORE_VERSION || stored.server != server || stored.host_id != host_id {
return None;
}
if requested_user.is_some_and(|user| user != stored.auth_cookie.username()) {
return None;
}
Some(stored)
}
@@ -116,7 +119,7 @@ mod tests {
.windows(b"prelogon-auth".len())
.any(|part| part == b"prelogon-auth")
);
assert!(load(&path, "vpn.example.com", "host-1").is_some());
assert!(load(&path, "vpn.example.com", "host-1", None).is_some());
}
#[test]
@@ -132,24 +135,35 @@ mod tests {
assert_eq!(fs::metadata(&path).unwrap().permissions().mode() & 0o777, 0o600);
}
let loaded = load(&path, "vpn.example.com", "host-1").unwrap();
let loaded = load(&path, "vpn.example.com", "host-1", None).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", "host-1").is_none(),
load(&path, "other.example.com", "host-1", None).is_none(),
"must reject mismatched server"
);
assert!(
load(&path, "vpn.example.com", "host-2").is_none(),
load(&path, "vpn.example.com", "host-2", None).is_none(),
"must reject mismatched host id"
);
clear(&path);
assert!(!path.exists());
}
#[test]
fn matches_explicit_user_against_cached_credential() {
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("cookie.json");
let stored = sample();
save(&path, &stored).unwrap();
assert!(load(&path, &stored.server, &stored.host_id, Some("bob")).is_none());
assert!(load(&path, &stored.server, &stored.host_id, Some("alice")).is_some());
}
#[test]
fn rejects_version_mismatch() {
let dir = tempfile::tempdir().unwrap();
@@ -157,6 +171,6 @@ mod tests {
let mut s = sample();
s.version = STORE_VERSION + 1;
save(&path, &s).unwrap();
assert!(load(&path, "vpn.example.com", "host-1").is_none());
assert!(load(&path, "vpn.example.com", "host-1", None).is_none());
}
}
+3 -1
View File
@@ -127,7 +127,9 @@ pub fn command_path(require_root: bool) -> io::Result<std::ffi::OsString> {
std::env::join_paths(directories).map_err(|error| io::Error::new(io::ErrorKind::InvalidInput, error))
}
fn root_owned_path(path: &Path) -> bool {
/// Whether `path` and every ancestor are root-owned, not symlinks, and not
/// group/world-writable (unless a root-owned sticky ancestor protects them).
pub fn root_owned_path(path: &Path) -> bool {
path.ancestors().all(|part| {
fs::symlink_metadata(part).is_ok_and(|metadata| {
let mode = metadata.permissions().mode();
+1
View File
@@ -427,6 +427,7 @@ pub enum WsRequest {
SetWindowsPatchInterest { enabled: bool },
RefreshWindowsPatches { after: Option<u64> },
Connect(Box<ConnectRequest>),
AbandonReconnect { attempt: u64 },
Disconnect(DisconnectRequest),
StopNonTunnelAttachment { connection_id: uuid::Uuid },
StoreEditedHipReportChunk(StoreEditedHipReportChunkRequest),
+5
View File
@@ -116,6 +116,11 @@ impl ConnectInfo {
pub enum VpnState {
ReconnectRequired(Box<ReconnectRequest>),
Disconnected,
UnexpectedDisconnect {
attempt: u64,
owner: uuid::Uuid,
reason: Option<String>,
},
Failed(String),
Connecting(Box<ConnectInfo>),
Connected(Box<ConnectedInfo>),
+149
View File
@@ -0,0 +1,149 @@
use std::{fs, io, path::Path};
use gpapi::process::collection::{CollectorCommands, root_owned_path};
use serde::Deserialize;
use super::BitdefenderInfo;
const BITDEFENDER_DIR: &str = "/opt/bitdefender-security-tools";
const MAX_VERSION_LEN: usize = 64;
pub(super) fn detect(commands: &CollectorCommands<'_>) -> io::Result<Option<BitdefenderInfo>> {
let dir = Path::new(BITDEFENDER_DIR);
if uzers::get_effective_uid() == 0 {
let cli = dir.join("bin/bduitool");
let status = commands
.run_executable(&cli, &["get", "ps"])?
.filter(|output| output.status.success())
.and_then(|output| String::from_utf8(output.stdout).ok())
.as_deref()
.and_then(parse_product_status);
if status.is_some() {
return Ok(status);
}
}
let Ok(manifest) = dir.join("etc/manifest.json").canonicalize() else {
return Ok(None);
};
if !manifest.is_file() || !root_owned_path(&manifest) {
return Ok(None);
}
let Ok(contents) = fs::read_to_string(&manifest) else {
return Ok(None);
};
Ok(parse_manifest(&contents).map(|version| BitdefenderInfo {
version,
engine_version: None,
real_time_protection: None,
}))
}
/// Parse `bduitool get ps`. All three fields must be present for a full entry.
fn parse_product_status(output: &str) -> Option<BitdefenderInfo> {
let version = product_version(value(output, "Product version:")?)?;
let engine_version = value(output, "Engines version:")
.filter(|version| valid_version(version))?
.to_string();
let real_time_protection = match value(output, "Antimalware status:")? {
"On" => true,
"Off" => false,
_ => return None,
};
Some(BitdefenderInfo {
version,
engine_version: Some(engine_version),
real_time_protection: Some(real_time_protection),
})
}
fn parse_manifest(contents: &str) -> Option<String> {
#[derive(Deserialize)]
struct Manifest {
version: String,
}
let manifest: Manifest = serde_json::from_str(contents).ok()?;
product_version(&manifest.version)
}
/// The official client reports only the first three components, e.g. `7.10.0`.
fn product_version(version: &str) -> Option<String> {
if !valid_version(version) {
return None;
}
let short = version.split('.').take(3).collect::<Vec<_>>().join(".");
Some(short)
}
fn valid_version(version: &str) -> bool {
!version.is_empty()
&& version.len() <= MAX_VERSION_LEN
&& version.chars().all(|ch| ch.is_ascii_digit() || ch == '.')
&& version.split('.').all(|part| !part.is_empty())
}
fn value<'a>(output: &'a str, label: &str) -> Option<&'a str> {
output.lines().find_map(|line| {
let line = line.trim();
let line = line.strip_prefix("- ").unwrap_or(line);
line.strip_prefix(label).map(str::trim)
})
}
#[cfg(test)]
mod tests {
use super::*;
const OBSERVED: &str = "\nProduct version: 7.10.0.200346\nLast product update: 2026-11-21 at 14:42:06 GMT\n\
New product update available: no\nEngines version: 7.101851\nLast security content update: 2026-11-21 at 13:42:12 GMT\n\
Features:\n - Antimalware status: On\n - AntiExploit status: On\n - On-Access YARA status: Off\n";
#[test]
fn parses_observed_product_status() {
let info = parse_product_status(OBSERVED).expect("observed output should parse");
assert_eq!(info.version, "7.10.0");
assert_eq!(info.engine_version.as_deref(), Some("7.101851"));
assert_eq!(info.real_time_protection, Some(true));
}
#[test]
fn antimalware_off_reports_no_real_time_protection() {
let output = OBSERVED.replace("Antimalware status: On", "Antimalware status: Off");
assert_eq!(parse_product_status(&output).unwrap().real_time_protection, Some(false));
}
#[test]
fn incomplete_product_status_is_rejected() {
assert!(parse_product_status(&OBSERVED.replace("Engines version: 7.101851\n", "")).is_none());
assert!(parse_product_status(&OBSERVED.replace(" - Antimalware status: On\n", "")).is_none());
assert!(parse_product_status(&OBSERVED.replace("Antimalware status: On", "Antimalware status: Unknown")).is_none());
assert!(
parse_product_status(&OBSERVED.replace("Engines version: 7.101851", "Engines version: 7.101851\"/>")).is_none()
);
}
#[test]
fn truncates_product_version_to_three_components() {
assert_eq!(product_version("7.10.0.200346").as_deref(), Some("7.10.0"));
assert_eq!(product_version("7.10.0").as_deref(), Some("7.10.0"));
assert_eq!(product_version("7.10").as_deref(), Some("7.10"));
}
#[test]
fn rejects_invalid_versions() {
assert_eq!(product_version(""), None);
assert_eq!(product_version("7.10.0\"/>"), None);
assert_eq!(product_version(&"1".repeat(65)), None);
assert_eq!(product_version("7..10"), None);
}
#[test]
fn parses_manifest_version() {
assert_eq!(
parse_manifest(r#"{"version":"7.10.0.200346","changeset":"e95aa9d9"}"#).as_deref(),
Some("7.10.0")
);
assert_eq!(parse_manifest("not json"), None);
assert_eq!(parse_manifest(r#"{"changeset":"e95aa9d9"}"#), None);
}
}
+97
View File
@@ -9,6 +9,8 @@ use gpapi::collection::{CollectionBudget, CollectionControl};
use gpapi::process::collection::CollectorCommands;
use xmltree::Element;
#[cfg(target_os = "linux")]
mod bitdefender_unix;
#[cfg(target_os = "macos")]
mod domain_macos;
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd", test))]
@@ -355,6 +357,15 @@ struct ClamAvInfo {
real_time_protection: bool,
}
/// Bitdefender Endpoint Security Tools (GravityZone). Engine and real-time
/// protection are only available when `bduitool` can run as root.
#[cfg_attr(not(target_os = "linux"), allow(dead_code))]
struct BitdefenderInfo {
version: String,
engine_version: Option<String>,
real_time_protection: Option<bool>,
}
struct SentinelInfo {
version: String,
real_time_protection: bool,
@@ -378,6 +389,7 @@ struct HostInfo {
defender: Option<DefenderInfo>,
clamav: Option<ClamAvInfo>,
sentinel: Option<SentinelInfo>,
bitdefender: Option<BitdefenderInfo>,
ufw: Option<UfwInfo>,
windows_categories: Option<String>,
windows_updates: Option<gpapi::hip::WindowsUpdateStatus>,
@@ -503,6 +515,7 @@ impl<'p, 'a> HostInfoCollector<'p, 'a> {
defender: None,
clamav: None,
sentinel: None,
bitdefender: None,
ufw: None,
windows_categories: None,
windows_updates: None,
@@ -585,6 +598,10 @@ impl<'p, 'a> HostInfoCollector<'p, 'a> {
if self.profile.client_os() == ClientOs::Linux && self.profile.is_native() {
info.sentinel = sentinel_unix::detect(&commands)?;
}
#[cfg(target_os = "linux")]
if self.profile.client_os() == ClientOs::Linux && self.profile.is_native() {
info.bitdefender = bitdefender_unix::detect(&commands)?;
}
control.check()?;
Ok(info)
}
@@ -1225,6 +1242,86 @@ mod tests {
assert_eq!(report.matches("name=\"Sentinel Agent\"").count(), 1);
}
fn render_linux_report_with_bitdefender(bitdefender: Option<BitdefenderInfo>) -> String {
let input = make_input(make_profile(ClientOs::Linux));
let cookie_params = HashMap::new();
let mut host_info = HostInfoCollector::new(&input.profile, &input, &cookie_params)
.collect_identity(&CollectionBudget::new(Duration::from_secs(10)))
.unwrap();
host_info.bitdefender = bitdefender;
let (generate_time, day, month, year) = get_current_time_components();
let report = HipReportTemplate {
client_version: input.profile.client_version(),
generate_time,
day,
month,
year,
user_name: "test-user",
host_info,
md5: "test-digest",
}
.render()
.unwrap();
let report = format_xml(&report).unwrap();
validate_edited_report(&report).unwrap();
report
}
fn bitdefender_product_info(report: &str) -> &str {
let start = report
.find("name=\"Bitdefender Endpoint Security Tools\"")
.expect("Bitdefender entry should render");
let end = start + report[start..].find("</ProductInfo>").unwrap();
&report[start..end]
}
#[test]
fn linux_report_renders_full_bitdefender_entry() {
let report = render_linux_report_with_bitdefender(Some(BitdefenderInfo {
version: "7.10.0".to_string(),
engine_version: Some("7.101851".to_string()),
real_time_protection: Some(true),
}));
assert!(report.contains(
"vendor=\"Bitdefender\" name=\"Bitdefender Endpoint Security Tools\" version=\"7.10.0\" defver=\"7.101851\" engver=\"7.101851\""
));
let entry = bitdefender_product_info(&report);
assert!(entry.contains("prodType=\"3\" osType=\"1\""));
assert!(entry.contains("<real-time-protection>yes</real-time-protection>"));
assert!(entry.contains("<last-full-scan-time>n/a</last-full-scan-time>"));
}
#[test]
fn linux_report_renders_bitdefender_real_time_protection_off() {
let report = render_linux_report_with_bitdefender(Some(BitdefenderInfo {
version: "7.10.0".to_string(),
engine_version: Some("7.101851".to_string()),
real_time_protection: Some(false),
}));
assert!(bitdefender_product_info(&report).contains("<real-time-protection>no</real-time-protection>"));
}
#[test]
fn linux_report_renders_partial_bitdefender_entry() {
let report = render_linux_report_with_bitdefender(Some(BitdefenderInfo {
version: "7.10.0".to_string(),
engine_version: None,
real_time_protection: None,
}));
let entry = bitdefender_product_info(&report);
assert!(entry.contains("version=\"7.10.0\""));
assert!(!entry.contains("defver="));
assert!(!entry.contains("engver="));
assert!(!entry.contains("real-time-protection"));
assert!(entry.contains("<last-full-scan-time>n/a</last-full-scan-time>"));
}
#[test]
fn linux_report_omits_absent_bitdefender() {
let report = render_linux_report_with_bitdefender(None);
assert!(!report.contains("Bitdefender"));
}
#[test]
fn preview_uses_explicit_pending_digest() {
let input = ReportInput {
+11
View File
@@ -174,6 +174,17 @@
</ProductInfo>
</entry>
{% endif -%}
{% if let Some(bitdefender) = &host_info.bitdefender %}
<entry>
<ProductInfo>
<Prod vendor="Bitdefender" name="Bitdefender Endpoint Security Tools" version="{{ bitdefender.version }}"{% if let Some(engine_version) = &bitdefender.engine_version %} defver="{{ engine_version }}" engver="{{ engine_version }}"{% endif %} datemon="{{ month }}" dateday="{{ day }}" dateyear="{{ year }}" prodType="3" osType="1"/>
{% if let Some(real_time_protection) = bitdefender.real_time_protection -%}
<real-time-protection>{% if real_time_protection %}yes{% else %}no{% endif %}</real-time-protection>
{% endif -%}
<last-full-scan-time>n/a</last-full-scan-time>
</ProductInfo>
</entry>
{% endif -%}
</list>
</entry>
<entry name="disk-backup">
Generated
+3 -3
View File
@@ -63,11 +63,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1794840529,
"narHash": "sha256-ySrWnmZB5UsZTYGHHnBjllT05O5iFjElCRS+mabtfP0=",
"lastModified": 1795217999,
"narHash": "sha256-Z5mAFcY8XTAaWe+RwTchz4Fx1gwaeQ2WD8A8bKX7njY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e21fec321d73511849707a7585e4ea155ee4bf40",
"rev": "680275f0bb6afce84fbac3e75fc47c5f2272400b",
"type": "github"
},
"original": {
+8 -8
View File
@@ -29,8 +29,8 @@
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
pname = "globalprotect-openconnect";
version = cargoToml.workspace.package.version;
releaseTag = "v3.6.0";
releaseVersion = "3.6.0";
releaseTag = "v3.7.1";
releaseVersion = "3.7.1";
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
@@ -55,8 +55,8 @@
cpu = pkgs.stdenv.hostPlatform.parsed.cpu.name;
gpguiHashes = {
x86_64 = "sha256-cWFOqjDpzGSWLZgiDVeEYJMGAMrdfiB15Q6geKSVEEg=";
aarch64 = "sha256-e66fokdJk6/vr1B/6hX37Lt+7OPnXZP+D2N5ht/yM4o=";
x86_64 = "sha256-mY5w91CZp1W70Pjd8lRtxMuON3b6PRLcmWuE4AMd4/s=";
aarch64 = "sha256-Xm6QzVFsFJ3JlrHPCiBlJMgpD/5xZT65q/qZVajw4bQ=";
};
gpguiArchive = pkgs.fetchurl {
@@ -70,8 +70,8 @@
};
nshHashes = {
x86_64 = "sha256-HWQ7Lh0NA6lEjLIPjmvqsB1DhzUPMeZ6NPpyUTfLbng=";
aarch64 = "sha256-GT6arWaFyZNDCMrK676+JlPJnCAJ0DhDugcCMQlPmIM=";
x86_64 = "sha256-qqOtWnR20tDu0n4wRmsxPqjOVR+o8gf8fGWSwZXg/So=";
aarch64 = "sha256-GnVauyUobwocDb6LOzdLDeurttpVB6axHracYorTk+Q=";
};
nshArchive = pkgs.fetchurl {
@@ -94,8 +94,8 @@
'';
binaryHashes = {
x86_64 = "sha256-gK8VWHw1VbXE7wHU1wGYw4fQ0khk24JWUwAQk+47WF8=";
aarch64 = "sha256-nqSuIW1fz742+2rF0QpnN8hswFm5lezC9JEOMs/8OHM=";
x86_64 = "sha256-hP6xdkjblFDqfkHgl8u34vo75Vd0vv7L1Ua+hpqJBC4=";
aarch64 = "sha256-czpKkEs0DPQeghSyCaZ6xayRpLBPcWxAicay4qU8PdE=";
};
binaryArchive = pkgs.fetchurl {