Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90fae8451f | ||
|
|
a93a8135be |
No files matched your search
@@ -334,9 +334,7 @@ jobs:
|
||||
run: npx vitest run
|
||||
|
||||
# `--locked`: test against the committed Cargo.lock, never a re-resolved
|
||||
# one, for the same reason the frontend uses `npm ci`. No plugin fetch
|
||||
# here: a debug build gets a placeholder for the session-manager-plugin
|
||||
# sidecar from build.rs, so tests never build Go or download anything.
|
||||
# one, for the same reason the frontend uses `npm ci`.
|
||||
- name: Backend tests (cargo test)
|
||||
working-directory: ./app/src-tauri
|
||||
run: |
|
||||
@@ -470,14 +468,6 @@ jobs:
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
npx tauri --version || npm install @tauri-apps/cli
|
||||
|
||||
# The AWS Session Manager plugin, bundled as a sidecar (bundle.externalBin)
|
||||
# so AWS workspaces work without the user installing it. Built here from
|
||||
# AWS's Apache-2.0 source (pinned commit + archive SHA-256) with a pinned,
|
||||
# hash-checked Go; the output must match a pinned SHA-256 (reproducible
|
||||
# build). A release build refuses to start without it (build.rs).
|
||||
- name: Build the AWS Session Manager plugin
|
||||
run: bash scripts/build-ssm-plugin.sh x86_64-unknown-linux-gnu
|
||||
|
||||
- name: Build Tauri app
|
||||
working-directory: ./app
|
||||
env:
|
||||
@@ -607,15 +597,6 @@ jobs:
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
npx tauri --version || npm install @tauri-apps/cli
|
||||
|
||||
# The AWS Session Manager plugin sidecar (bundle.externalBin), built from
|
||||
# source (see build-ssm-plugin.sh): both thin slices (tauri-build checks
|
||||
# each arch it compiles) and the lipo'd universal one the bundler copies
|
||||
# into Contents/MacOS. Each must match its pinned SHA-256. Signed exactly
|
||||
# like the app: Go ad-hoc signs the arm64 slice, and with APPLE_* signing
|
||||
# configured Tauri would sign the sidecar with the app's identity.
|
||||
- name: Build the AWS Session Manager plugin
|
||||
run: bash scripts/build-ssm-plugin.sh universal-apple-darwin
|
||||
|
||||
- name: Build Tauri app (universal)
|
||||
working-directory: ./app
|
||||
env:
|
||||
@@ -625,21 +606,6 @@ jobs:
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
npx tauri build --target universal-apple-darwin
|
||||
|
||||
# The sidecar and its notices must be in the bundle Tauri made: the
|
||||
# plugin in Contents/MacOS with both slices, THIRD_PARTY_NOTICES in
|
||||
# Contents/Resources (bundle.resources).
|
||||
- name: Check the bundled Session Manager plugin
|
||||
run: |
|
||||
app_dir="$(ls -d app/src-tauri/target/universal-apple-darwin/release/bundle/macos/*.app | head -n1)"
|
||||
[ -n "$app_dir" ] || { echo "no .app bundle"; exit 1; }
|
||||
plugin="$app_dir/Contents/MacOS/session-manager-plugin"
|
||||
[ -x "$plugin" ] || { echo "missing $plugin"; exit 1; }
|
||||
archs="$(lipo -archs "$plugin")"
|
||||
case " $archs " in *" x86_64 "*) ;; *) echo "plugin lacks x86_64 ($archs)"; exit 1 ;; esac
|
||||
case " $archs " in *" arm64 "*) ;; *) echo "plugin lacks arm64 ($archs)"; exit 1 ;; esac
|
||||
"$plugin" --version
|
||||
[ -f "$app_dir/Contents/Resources/THIRD_PARTY_NOTICES" ] || { echo "missing Contents/Resources/THIRD_PARTY_NOTICES"; exit 1; }
|
||||
|
||||
- name: Collect artifacts
|
||||
run: |
|
||||
mkdir -p artifacts
|
||||
@@ -763,13 +729,6 @@ jobs:
|
||||
set "PATH=%USERPROFILE%\.cargo\bin;C:\Program Files\nodejs;%PATH%"
|
||||
npm run build
|
||||
|
||||
# The AWS Session Manager plugin sidecar (bundle.externalBin), built from
|
||||
# source (see build-ssm-plugin.ps1); must match its pinned SHA-256. It
|
||||
# comes out unsigned, so it ships unsigned in previews, like the
|
||||
# app (releases sign it: see build-app.yml).
|
||||
- name: Build the AWS Session Manager plugin
|
||||
run: powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -File scripts\build-ssm-plugin.ps1
|
||||
|
||||
- name: Build Tauri app
|
||||
working-directory: ./app
|
||||
# Previews are not code-signed: signing is metered, previews are built
|
||||
|
||||
@@ -227,14 +227,6 @@ jobs:
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
npx tauri --version || npm install @tauri-apps/cli
|
||||
|
||||
# The AWS Session Manager plugin, bundled as a sidecar (bundle.externalBin)
|
||||
# so AWS workspaces work without the user installing it. Built here from
|
||||
# AWS's Apache-2.0 source (pinned commit + archive SHA-256) with a pinned,
|
||||
# hash-checked Go; the output must match a pinned SHA-256 (reproducible
|
||||
# build). A release build refuses to start without it (build.rs).
|
||||
- name: Build the AWS Session Manager plugin
|
||||
run: bash scripts/build-ssm-plugin.sh x86_64-unknown-linux-gnu
|
||||
|
||||
- name: Build Tauri app
|
||||
working-directory: ./app
|
||||
run: |
|
||||
@@ -425,36 +417,12 @@ jobs:
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
npx tauri --version || npm install @tauri-apps/cli
|
||||
|
||||
# The AWS Session Manager plugin sidecar (bundle.externalBin), built from
|
||||
# source (see build-ssm-plugin.sh): both thin slices (tauri-build checks
|
||||
# each arch it compiles) and the lipo'd universal one the bundler copies
|
||||
# into Contents/MacOS. Each must match its pinned SHA-256. Signed exactly
|
||||
# like the app: Go ad-hoc signs the arm64 slice, and with APPLE_* signing
|
||||
# configured Tauri would sign the sidecar with the app's identity.
|
||||
- name: Build the AWS Session Manager plugin
|
||||
run: bash scripts/build-ssm-plugin.sh universal-apple-darwin
|
||||
|
||||
- name: Build Tauri app (universal)
|
||||
working-directory: ./app
|
||||
run: |
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
npx tauri build --target universal-apple-darwin
|
||||
|
||||
# The sidecar and its notices must be in the bundle Tauri made: the
|
||||
# plugin in Contents/MacOS with both slices, THIRD_PARTY_NOTICES in
|
||||
# Contents/Resources (bundle.resources).
|
||||
- name: Check the bundled Session Manager plugin
|
||||
run: |
|
||||
app_dir="$(ls -d app/src-tauri/target/universal-apple-darwin/release/bundle/macos/*.app | head -n1)"
|
||||
[ -n "$app_dir" ] || { echo "no .app bundle"; exit 1; }
|
||||
plugin="$app_dir/Contents/MacOS/session-manager-plugin"
|
||||
[ -x "$plugin" ] || { echo "missing $plugin"; exit 1; }
|
||||
archs="$(lipo -archs "$plugin")"
|
||||
case " $archs " in *" x86_64 "*) ;; *) echo "plugin lacks x86_64 ($archs)"; exit 1 ;; esac
|
||||
case " $archs " in *" arm64 "*) ;; *) echo "plugin lacks arm64 ($archs)"; exit 1 ;; esac
|
||||
"$plugin" --version
|
||||
[ -f "$app_dir/Contents/Resources/THIRD_PARTY_NOTICES" ] || { echo "missing Contents/Resources/THIRD_PARTY_NOTICES"; exit 1; }
|
||||
|
||||
- name: Collect artifacts
|
||||
run: |
|
||||
mkdir -p artifacts
|
||||
@@ -688,13 +656,6 @@ jobs:
|
||||
set "PATH=%USERPROFILE%\.cargo\bin;C:\Program Files\nodejs;%PATH%"
|
||||
npm run build
|
||||
|
||||
# The AWS Session Manager plugin sidecar (bundle.externalBin), built from
|
||||
# source (see build-ssm-plugin.ps1); must match its pinned SHA-256. It
|
||||
# comes out unsigned, so Tauri hands it to the sign command and
|
||||
# "Verify signatures" requires our signature on it in both installers.
|
||||
- name: Build the AWS Session Manager plugin
|
||||
run: powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -File scripts\build-ssm-plugin.ps1
|
||||
|
||||
# Releases are signed with Azure Artifact Signing (scripts/windows-*.ps1).
|
||||
# The setup fetches the signing client and a job-local .NET runtime, and
|
||||
# writes the Tauri config holding the sign command, which "Build Tauri
|
||||
|
||||
@@ -27,7 +27,3 @@ screenshot_for_fix/
|
||||
*.tfstate
|
||||
*.tfstate.*
|
||||
.terraform.tfstate.lock.info
|
||||
|
||||
# The bundled AWS session-manager-plugin sidecar (scripts/build-ssm-plugin.*, built from source) and the
|
||||
# debug-build placeholder build.rs writes there. Never committed.
|
||||
app/src-tauri/binaries/
|
||||
@@ -14,8 +14,7 @@ All frontend/tauri commands run from the `app/` directory:
|
||||
cd app
|
||||
npm ci # Install dependencies (required first time)
|
||||
npx tauri dev # Launch app in dev mode with hot reload (Vite on port 1420)
|
||||
npx tauri build # Production build (outputs to src-tauri/target/release/bundle/);
|
||||
# run ../scripts/build-ssm-plugin.sh first (bundled AWS plugin, see Packaging)
|
||||
npx tauri build # Production build (outputs to src-tauri/target/release/bundle/)
|
||||
npm run build # Frontend-only build (tsc + vite)
|
||||
npm run test # Run Vitest once
|
||||
npm run test:watch # Run Vitest in watch mode
|
||||
@@ -1226,77 +1225,10 @@ verbatim copy yields a launcher entry that starts nothing. It keeps `StartupWMCl
|
||||
the bundle sets it, which is what lets the shell match the window to the entry. Extraction uses
|
||||
`--appimage-extract`, which needs no FUSE, so the script works before `fuse2` is installed.
|
||||
|
||||
### The bundled AWS Session Manager plugin
|
||||
|
||||
AWS workspaces connect through AWS's `session-manager-plugin` (`host/ssm.rs`), and the app
|
||||
**bundles it as a Tauri sidecar** (`bundle.externalBin: binaries/session-manager-plugin`) so users
|
||||
need not install it. Tauri copies it beside the app binary with the `-<target-triple>` suffix
|
||||
stripped — `usr/bin/session-manager-plugin` in the AppImage, `Contents/MacOS/` on macOS, the
|
||||
install directory on Windows (`session-manager-plugin.exe`), and `target/<profile>/` under
|
||||
`tauri dev`. `find_plugin()` resolves `TRIPLEC_SSM_PLUGIN` → **that sidecar (beside
|
||||
`current_exe()`)** → `PATH` → AWS's install locations → the install hint; the order is
|
||||
unit-tested (`host/ssm/tests.rs`, `plugin_resolution`).
|
||||
|
||||
- **We build it from source; we never ship AWS's binaries.** AWS distributes its prebuilt plugin
|
||||
as "AWS Content" under the AWS Customer Agreement; the source (github.com/aws/session-manager-plugin)
|
||||
is Apache-2.0. `scripts/build-ssm-plugin.sh <triple>…` (Linux/macOS; any triple, it
|
||||
cross-compiles) and `scripts/build-ssm-plugin.ps1` (the Windows runner, which has no bash) take
|
||||
the tag's **commit** as GitHub's archive (pinned SHA-256, checked before extraction; the
|
||||
vendored SDK's Java `codegen/` and test `snapshot/` trees are not extracted — they reach 258
|
||||
characters, past Windows' MAX_PATH, so the `.ps1` also works under a short `C:\ssm-<8hex>` root)
|
||||
and a
|
||||
**pinned Go** from go.dev (go.dev's published SHA-256), and run the repo's own build — GOPATH
|
||||
mode over its vendored deps, `-ldflags "-s -w"`, `sessionmanagerplugin-main` — with `VERSION`
|
||||
stamped to the tag (the repo's file says `1.3.0.0`; AWS's pipeline stamps the real one, so
|
||||
`--version` would otherwise lie), plus `-trimpath`, no VCS stamp, empty build id, `CGO_ENABLED=0`
|
||||
and a scrubbed Go environment. **The output must equal a pinned SHA-256 per target**: Go builds
|
||||
are reproducible across hosts, so every runner must produce the exact bytes recorded in the
|
||||
scripts (verified locally: Linux-hosted builds of every target, repeated in fresh directories,
|
||||
and the `.ps1` flow, are identical). A mismatch fails the build and means the source, toolchain
|
||||
or flags changed — never "update the hash" without knowing which.
|
||||
- **Each platform job builds its own targets** before `tauri build` (Linux: `x86_64-unknown-linux-gnu`;
|
||||
macOS: `universal-apple-darwin`, i.e. both thin slices — tauri-build checks the arch it compiles —
|
||||
plus the `lipo`'d universal file the bundler wants, whose slices must thin back out byte-identical
|
||||
to the pins; Windows: the `.ps1`). Not one Linux job feeding the others: workflow artifacts do
|
||||
not work on this Gitea (see `build-app-preview.yml`'s header), and with reproducible output and
|
||||
pinned hashes nothing is gained by building once.
|
||||
- **Bumping** the plugin or Go: new pins in **both** scripts, rebuild every target, record the new
|
||||
output hashes, and update `app/src-tauri/THIRD_PARTY_NOTICES` (the scripts refuse to run unless
|
||||
its `Version:`/`Commit:` lines match) including its dependency licences.
|
||||
- **Debug builds get a placeholder; release builds refuse one.** tauri-build fails *any* build
|
||||
whose externalBin file is missing, `cargo test` included. `build.rs` (`ensure_ssm_sidecar`)
|
||||
writes a marked placeholder (`src/sidecar_placeholder.rs`) for a missing file when
|
||||
`PROFILE=debug`, so `cargo test`/`cargo check`/`tauri dev` and CI's `test` job need neither Go
|
||||
nor the network, and `find_plugin()` skips it (falling back to an installed plugin). With
|
||||
`PROFILE=release` a missing file **or** a placeholder stops the build, so a local `cargo build
|
||||
--release` needs the build script first. **build.rs rejects only a missing file or the
|
||||
placeholder, not a stale or wrong binary**: re-run `scripts/build-ssm-plugin.sh` before every
|
||||
local release build (it is a no-op when the file already matches the pin, and rebuilds it
|
||||
otherwise — e.g. after a pin bump, or after a Windows release build signed it in place). `finalize-appimage.sh` asserts the shipped
|
||||
`usr/bin/session-manager-plugin` is an ELF that runs `--version`.
|
||||
- **Windows: our build is unsigned, so the release signs it with our certificate.** Tauri runs
|
||||
`signtool verify /pa` on each sidecar and hands the unsigned one to the sign command, in place
|
||||
under `app\src-tauri\binaries` before any bundle (both MSI and NSIS pack that file);
|
||||
`windows-sign.ps1`'s allowlist includes it (one more metered signature per release: 6).
|
||||
`windows-verify-signatures.ps1` requires exactly one `session-manager-plugin.exe` in the MSI and
|
||||
the file NSIS packed to be validly signed, timestamped, **by the same signing identity
|
||||
(subject + issuer) as the installer** — not the thumbprint: Artifact Signing certificates are
|
||||
short-lived and rotate — and the signing log to show it. The MSI must also carry
|
||||
`THIRD_PARTY_NOTICES`; on macOS a workflow step checks the `.app` holds the two-slice plugin in
|
||||
`Contents/MacOS` and the notices in `Contents/Resources`. Previews ship it unsigned, like the app.
|
||||
- **macOS: signed exactly like the app.** The app is not code-signed (no `APPLE_*`/`signingIdentity`
|
||||
in the workflows); Go's linker ad-hoc signs the arm64 slice (needed to run on Apple Silicon). If
|
||||
signing is ever configured, Tauri signs externalBin with the app's identity, inside-out.
|
||||
- **Licence:** `app/src-tauri/THIRD_PARTY_NOTICES` (bundled as a resource; `usr/lib/Triple-C/` in
|
||||
the AppImage, asserted by `finalize-appimage.sh`) carries the plugin's Apache-2.0 LICENSE and
|
||||
NOTICE, the commit we build, the repo's own `THIRD-PARTY` file verbatim, the licence of every
|
||||
vendored module linked in (`go list -deps` for linux/darwin/windows) and Go's own. Note that the
|
||||
repo's `THIRD-PARTY` file opens with the same "AWS Content" sentence as the binary packages.
|
||||
|
||||
### Windows code signing
|
||||
|
||||
Windows **releases** (`build-app.yml`) are signed with **Azure Artifact Signing**: the app binary,
|
||||
the bundled `session-manager-plugin`, the MSI, the NSIS installer and its uninstaller. Three scripts do it, and "Verify signatures"
|
||||
the MSI, the NSIS installer and its uninstaller. Three scripts do it, and "Verify signatures"
|
||||
fails the job if any of them is unsigned or untimestamped, so an unsigned installer cannot ship
|
||||
quietly. **PR previews are deliberately not signed**, and `build-app-preview.yml` must not
|
||||
reference the signing secrets. Two reasons: signing is metered (about 1000 signatures a month,
|
||||
@@ -1314,13 +1246,12 @@ without releasing (see Releases above).
|
||||
- `scripts/windows-sign.ps1` is the sign command: `signtool sign /dlib` with SHA-256 and the
|
||||
Microsoft timestamp server, retried. Credentials never reach a command line — the dlib reads
|
||||
`AZURE_TENANT_ID` / `AZURE_CLIENT_ID` / `AZURE_CLIENT_SECRET` from the environment.
|
||||
**It signs only an allowlist of what ships**: 6 signatures per release (the app binary twice,
|
||||
**It signs only an allowlist of what ships**: 5 signatures per release (the app binary twice,
|
||||
because Tauri re-patches it between the MSI and NSIS bundles; the MSI; the NSIS installer;
|
||||
its uninstaller; and the `session-manager-plugin` sidecar we build from source). Tauri also presents build-time tools, the WiX extension DLLs and NSIS
|
||||
and its uninstaller). Tauri also presents build-time tools, the WiX extension DLLs and NSIS
|
||||
plugins, and signing those would more than double the metered count for no user-visible
|
||||
benefit. If the app ever ships resource DLLs or sidecars, extend the
|
||||
allowlist, or they will go out unsigned (as `session-manager-plugin`'s entry does; see the
|
||||
section above). Tauri reports a failed sign command only as
|
||||
allowlist, or they will go out unsigned. Tauri reports a failed sign command only as
|
||||
"failed to run powershell", so the script keeps a transcript (`.code-signing/sign-output.log`,
|
||||
`signtool /debug` included), and the job prints it on failure.
|
||||
- `scripts/windows-verify-signatures.ps1` checks `signtool verify /pa` plus a timestamp on the
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -14,8 +14,6 @@
|
||||
|
||||
#[path = "src/command_census.rs"]
|
||||
mod command_census;
|
||||
#[path = "src/sidecar_placeholder.rs"]
|
||||
mod sidecar_placeholder;
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
@@ -81,7 +79,6 @@ fn main() {
|
||||
}
|
||||
|
||||
prune_permissions(&commands);
|
||||
ensure_ssm_sidecar();
|
||||
|
||||
// `AppManifest::commands` takes `&'static [&'static str]` and the struct is `Copy`, so
|
||||
// there is no owned form; leaking is fine in a process that exits right after.
|
||||
@@ -209,50 +206,3 @@ fn check_tauri_config() {
|
||||
fail("capabilities declared outside capabilities/", &problems, LAYOUT_HINT);
|
||||
}
|
||||
}
|
||||
|
||||
/// `bundle.externalBin` names `binaries/session-manager-plugin`, and tauri-build stops on a
|
||||
/// missing `binaries/session-manager-plugin-<target-triple>[.exe]` for every build, tests
|
||||
/// included. The real one is built from AWS's source by `scripts/build-ssm-plugin.sh` (`.ps1` on
|
||||
/// Windows), which CI runs before `tauri build`.
|
||||
///
|
||||
/// - **Release profile:** the real plugin is required. A missing file or a placeholder stops
|
||||
/// the build here, so a placeholder can never ship.
|
||||
/// - **Debug profile** (`cargo test`, `cargo check`, `tauri dev`): a missing file is replaced
|
||||
/// by a placeholder (`src/sidecar_placeholder.rs`) so no test run needs Go or the network. The app's
|
||||
/// `find_plugin` skips a placeholder and falls back to an installed plugin.
|
||||
fn ensure_ssm_sidecar() {
|
||||
let target = std::env::var("TARGET").expect("cargo sets TARGET");
|
||||
let ext = if target.contains("windows") { ".exe" } else { "" };
|
||||
let path = Path::new("binaries").join(format!("session-manager-plugin-{target}{ext}"));
|
||||
println!("cargo:rerun-if-changed={}", path.display());
|
||||
let release = std::env::var("PROFILE").as_deref() == Ok("release");
|
||||
let head = std::fs::read(&path).ok().map(|b| sidecar_placeholder::is_placeholder(&b));
|
||||
let build = if target.contains("windows") {
|
||||
"scripts\\build-ssm-plugin.ps1"
|
||||
} else {
|
||||
"scripts/build-ssm-plugin.sh"
|
||||
};
|
||||
match (head, release) {
|
||||
(Some(false), _) => {}
|
||||
(state, true) => fail(
|
||||
"the AWS Session Manager plugin sidecar is missing",
|
||||
&[format!(
|
||||
"{} is {} (release builds bundle the real plugin)",
|
||||
path.display(),
|
||||
if state.is_some() { "a debug-build placeholder" } else { "missing" }
|
||||
)],
|
||||
&format!("Run {build} {target} from the repository root first."),
|
||||
),
|
||||
(None, false) => {
|
||||
std::fs::create_dir_all("binaries").expect("create src-tauri/binaries");
|
||||
std::fs::write(&path, sidecar_placeholder::contents())
|
||||
.unwrap_or_else(|e| panic!("cannot write {}: {e}", path.display()));
|
||||
println!(
|
||||
"cargo:warning=no {} - wrote a placeholder (debug only; AWS workspaces use an \
|
||||
installed plugin). Run {build} to build the real one.",
|
||||
path.display()
|
||||
);
|
||||
}
|
||||
(Some(true), false) => {}
|
||||
}
|
||||
}
|
||||
@@ -374,9 +374,10 @@ pub(crate) fn ec2_collision_refusal(
|
||||
/// Everything a self-onboarding apply needs settled before it starts: the
|
||||
/// caller's record, the capacity ([`resolve_ec2`]), the module variables
|
||||
/// and, with EC2 capacity, the name check ([`ec2_collision_refusal`]).
|
||||
/// Check-then-apply leaves a narrow race (another admin creating the same
|
||||
/// names in between); only admins apply, and the module would then fail on
|
||||
/// create rather than adopt.
|
||||
/// Check-then-apply leaves a narrow race (someone else creating the same
|
||||
/// names in between); the module would then fail on create rather than
|
||||
/// adopt. Anyone may start this: there is no tier check in the app, and AWS
|
||||
/// refuses (mapped to `AccessDenied`) what the caller isn't permitted.
|
||||
pub(crate) async fn prepare_onboarding<A: OnboardApi>(
|
||||
api: &A,
|
||||
env: &str,
|
||||
|
||||
@@ -198,48 +198,27 @@ fn sdk_error(e: &(dyn std::error::Error + 'static)) -> String {
|
||||
|
||||
// ── The plugin ───────────────────────────────────────────────────────────────
|
||||
|
||||
/// The plugin's file name on this platform: what the bundle holds (Tauri strips the
|
||||
/// `-<target-triple>` suffix of `bundle.externalBin` when it copies the sidecar in) and what
|
||||
/// AWS's installers put on `PATH`.
|
||||
const PLUGIN_FILE: &str =
|
||||
if cfg!(windows) { "session-manager-plugin.exe" } else { "session-manager-plugin" };
|
||||
|
||||
const PLUGIN_INSTALL_HINT: &str = "The AWS Session Manager plugin (session-manager-plugin) is \
|
||||
not installed. It is what connects to a workspace on AWS; install it from \
|
||||
https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html";
|
||||
|
||||
/// Find `session-manager-plugin`, in this order:
|
||||
///
|
||||
/// 1. `TRIPLEC_SSM_PLUGIN`, if set (an error if it names no file — an explicit choice is never
|
||||
/// silently replaced by another plugin);
|
||||
/// 2. **the copy bundled with the app** (`bundle.externalBin`), beside the app's own
|
||||
/// executable: `usr/bin` in the AppImage, `Contents/MacOS` in the macOS bundle, the install
|
||||
/// directory on Windows (and `target/<profile>` under `tauri dev`, where tauri-build copies
|
||||
/// it). A debug build's placeholder (`sidecar_placeholder`) is skipped;
|
||||
/// 3. `PATH`;
|
||||
/// 4. where AWS's installers put it (the GUI app on macOS does not get the shell's `PATH`, so
|
||||
/// the install locations are not optional).
|
||||
///
|
||||
/// 3 and 4 remain for dev builds without a fetched sidecar.
|
||||
/// Find `session-manager-plugin`: `TRIPLEC_SSM_PLUGIN` if set, then `PATH`,
|
||||
/// then where AWS's installers put it (the GUI app on macOS does not get the
|
||||
/// shell's `PATH`, so the install locations are not optional).
|
||||
pub fn find_plugin() -> Result<PathBuf, String> {
|
||||
let exe_dir = std::env::current_exe()
|
||||
.ok()
|
||||
.and_then(|exe| exe.parent().map(Path::to_path_buf));
|
||||
resolve_plugin(&PluginSearch {
|
||||
override_path: std::env::var_os("TRIPLEC_SSM_PLUGIN"),
|
||||
exe_dir,
|
||||
path_var: std::env::var_os("PATH"),
|
||||
install_dirs: plugin_install_dirs(),
|
||||
})
|
||||
}
|
||||
|
||||
/// Where AWS's installers put the plugin, in the order they are tried.
|
||||
fn plugin_install_dirs() -> Vec<PathBuf> {
|
||||
if cfg!(windows) {
|
||||
if let Some(p) = std::env::var_os("TRIPLEC_SSM_PLUGIN").filter(|p| !p.is_empty()) {
|
||||
let p = PathBuf::from(p);
|
||||
return if p.is_file() {
|
||||
Ok(p)
|
||||
} else {
|
||||
Err(format!("TRIPLEC_SSM_PLUGIN names {}, which is not a file", p.display()))
|
||||
};
|
||||
}
|
||||
let name = if cfg!(windows) { "session-manager-plugin.exe" } else { "session-manager-plugin" };
|
||||
let on_path = std::env::var_os("PATH")
|
||||
.map(|paths| std::env::split_paths(&paths).map(|d| d.join(name)).collect::<Vec<_>>())
|
||||
.unwrap_or_default();
|
||||
let installed: Vec<PathBuf> = if cfg!(windows) {
|
||||
["ProgramFiles", "ProgramFiles(x86)"]
|
||||
.iter()
|
||||
.filter_map(|v| std::env::var_os(v))
|
||||
.map(|d| PathBuf::from(d).join(r"Amazon\SessionManagerPlugin\bin"))
|
||||
.map(|d| PathBuf::from(d).join(r"Amazon\SessionManagerPlugin\bin").join(name))
|
||||
.collect()
|
||||
} else {
|
||||
[
|
||||
@@ -249,54 +228,19 @@ fn plugin_install_dirs() -> Vec<PathBuf> {
|
||||
"/usr/bin",
|
||||
]
|
||||
.iter()
|
||||
.map(PathBuf::from)
|
||||
.map(|d| Path::new(d).join(name))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
/// Everything [`find_plugin`] reads from the process, so the order is testable.
|
||||
struct PluginSearch {
|
||||
override_path: Option<std::ffi::OsString>,
|
||||
exe_dir: Option<PathBuf>,
|
||||
path_var: Option<std::ffi::OsString>,
|
||||
install_dirs: Vec<PathBuf>,
|
||||
}
|
||||
|
||||
fn resolve_plugin(search: &PluginSearch) -> Result<PathBuf, String> {
|
||||
if let Some(p) = search.override_path.as_ref().filter(|p| !p.is_empty()) {
|
||||
let p = PathBuf::from(p);
|
||||
return if p.is_file() {
|
||||
Ok(p)
|
||||
} else {
|
||||
Err(format!("TRIPLEC_SSM_PLUGIN names {}, which is not a file", p.display()))
|
||||
};
|
||||
}
|
||||
if let Some(bundled) = search.exe_dir.as_ref().map(|d| d.join(PLUGIN_FILE)) {
|
||||
if bundled.is_file() && !is_sidecar_placeholder(&bundled) {
|
||||
return Ok(bundled);
|
||||
}
|
||||
}
|
||||
let on_path = search
|
||||
.path_var
|
||||
.as_ref()
|
||||
.map(|paths| std::env::split_paths(paths).map(|d| d.join(PLUGIN_FILE)).collect::<Vec<_>>())
|
||||
.unwrap_or_default();
|
||||
};
|
||||
on_path
|
||||
.into_iter()
|
||||
.chain(search.install_dirs.iter().map(|d| d.join(PLUGIN_FILE)))
|
||||
.chain(installed)
|
||||
.find(|p| p.is_file())
|
||||
.ok_or_else(|| PLUGIN_INSTALL_HINT.to_string())
|
||||
}
|
||||
|
||||
/// Whether `path` is the stand-in a debug build bundles when no real plugin was fetched.
|
||||
/// Unreadable counts as "not a placeholder": the spawn then reports the real error.
|
||||
fn is_sidecar_placeholder(path: &Path) -> bool {
|
||||
use std::io::Read;
|
||||
let mut head = [0u8; crate::sidecar_placeholder::MARKER.len()];
|
||||
std::fs::File::open(path)
|
||||
.and_then(|mut f| f.read_exact(&mut head))
|
||||
.map(|()| crate::sidecar_placeholder::is_placeholder(&head))
|
||||
.unwrap_or(false)
|
||||
.ok_or_else(|| {
|
||||
"The AWS Session Manager plugin (session-manager-plugin) is not installed. It is \
|
||||
what connects to a workspace on AWS; install it from \
|
||||
https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html"
|
||||
.to_string()
|
||||
})
|
||||
}
|
||||
|
||||
/// A running plugin process with a listener on the local port.
|
||||
|
||||
@@ -400,135 +400,3 @@ async fn the_keepalive_asks_for_health_without_a_token() {
|
||||
assert!(req.starts_with("GET /v1/health HTTP/1.1\r\n"), "{req}");
|
||||
assert!(!req.to_ascii_lowercase().contains("authorization"), "{req}");
|
||||
}
|
||||
|
||||
// ── Finding the plugin ───────────────────────────────────────────────────────
|
||||
|
||||
mod plugin_resolution {
|
||||
use super::super::{resolve_plugin, PluginSearch, PLUGIN_FILE, PLUGIN_INSTALL_HINT};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
/// A directory holding a fake plugin (contents are never run).
|
||||
fn dir_with_plugin(root: &Path, name: &str) -> PathBuf {
|
||||
let d = root.join(name);
|
||||
std::fs::create_dir_all(&d).unwrap();
|
||||
std::fs::write(d.join(PLUGIN_FILE), b"\x7fELF fake plugin").unwrap();
|
||||
d
|
||||
}
|
||||
|
||||
fn search(
|
||||
override_path: Option<&Path>,
|
||||
exe_dir: Option<&Path>,
|
||||
path: &[&Path],
|
||||
install: &[&Path],
|
||||
) -> PluginSearch {
|
||||
PluginSearch {
|
||||
override_path: override_path.map(|p| p.as_os_str().to_owned()),
|
||||
exe_dir: exe_dir.map(Path::to_path_buf),
|
||||
path_var: Some(std::env::join_paths(path).unwrap()),
|
||||
install_dirs: install.iter().map(|p| p.to_path_buf()).collect(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_override_wins_over_everything() {
|
||||
let t = tempfile::tempdir().unwrap();
|
||||
let chosen = t.path().join("my-plugin");
|
||||
std::fs::write(&chosen, b"x").unwrap();
|
||||
let bundled = dir_with_plugin(t.path(), "app");
|
||||
let on_path = dir_with_plugin(t.path(), "path");
|
||||
let s = search(Some(&chosen), Some(&bundled), &[&on_path], &[]);
|
||||
assert_eq!(resolve_plugin(&s).unwrap(), chosen);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_override_naming_no_file_is_an_error_not_a_fallback() {
|
||||
let t = tempfile::tempdir().unwrap();
|
||||
let bundled = dir_with_plugin(t.path(), "app");
|
||||
let s = search(Some(&t.path().join("missing")), Some(&bundled), &[], &[]);
|
||||
let e = resolve_plugin(&s).unwrap_err();
|
||||
assert!(e.contains("TRIPLEC_SSM_PLUGIN names"), "{e}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_empty_override_is_ignored() {
|
||||
let t = tempfile::tempdir().unwrap();
|
||||
let bundled = dir_with_plugin(t.path(), "app");
|
||||
let mut s = search(None, Some(&bundled), &[], &[]);
|
||||
s.override_path = Some(std::ffi::OsString::new());
|
||||
assert_eq!(resolve_plugin(&s).unwrap(), bundled.join(PLUGIN_FILE));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_bundled_sidecar_wins_over_path_and_installs() {
|
||||
let t = tempfile::tempdir().unwrap();
|
||||
let bundled = dir_with_plugin(t.path(), "app");
|
||||
let on_path = dir_with_plugin(t.path(), "path");
|
||||
let installed = dir_with_plugin(t.path(), "installed");
|
||||
let s = search(None, Some(&bundled), &[&on_path], &[&installed]);
|
||||
assert_eq!(resolve_plugin(&s).unwrap(), bundled.join(PLUGIN_FILE));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn without_a_sidecar_path_comes_before_the_install_locations() {
|
||||
let t = tempfile::tempdir().unwrap();
|
||||
let empty_app = t.path().join("app");
|
||||
std::fs::create_dir_all(&empty_app).unwrap();
|
||||
let first = t.path().join("path-first-empty");
|
||||
std::fs::create_dir_all(&first).unwrap();
|
||||
let on_path = dir_with_plugin(t.path(), "path");
|
||||
let installed = dir_with_plugin(t.path(), "installed");
|
||||
let s = search(None, Some(&empty_app), &[&first, &on_path], &[&installed]);
|
||||
assert_eq!(resolve_plugin(&s).unwrap(), on_path.join(PLUGIN_FILE));
|
||||
|
||||
let s = search(None, Some(&empty_app), &[&first], &[&installed]);
|
||||
assert_eq!(resolve_plugin(&s).unwrap(), installed.join(PLUGIN_FILE));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_debug_placeholder_beside_the_exe_is_skipped() {
|
||||
let t = tempfile::tempdir().unwrap();
|
||||
let app = t.path().join("app");
|
||||
std::fs::create_dir_all(&app).unwrap();
|
||||
std::fs::write(app.join(PLUGIN_FILE), crate::sidecar_placeholder::contents()).unwrap();
|
||||
let on_path = dir_with_plugin(t.path(), "path");
|
||||
let s = search(None, Some(&app), &[&on_path], &[]);
|
||||
assert_eq!(resolve_plugin(&s).unwrap(), on_path.join(PLUGIN_FILE));
|
||||
|
||||
// And with nothing else installed, the install hint, not the placeholder.
|
||||
let s = search(None, Some(&app), &[], &[]);
|
||||
assert_eq!(resolve_plugin(&s).unwrap_err(), PLUGIN_INSTALL_HINT);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_directory_named_like_the_plugin_is_not_a_plugin() {
|
||||
let t = tempfile::tempdir().unwrap();
|
||||
let app = t.path().join("app");
|
||||
std::fs::create_dir_all(app.join(PLUGIN_FILE)).unwrap();
|
||||
let installed = dir_with_plugin(t.path(), "installed");
|
||||
let s = search(None, Some(&app), &[], &[&installed]);
|
||||
assert_eq!(resolve_plugin(&s).unwrap(), installed.join(PLUGIN_FILE));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nothing_anywhere_is_the_install_hint() {
|
||||
let t = tempfile::tempdir().unwrap();
|
||||
let s = search(None, None, &[t.path()], &[t.path()]);
|
||||
let e = resolve_plugin(&s).unwrap_err();
|
||||
assert!(e.contains("is not installed") && e.contains("docs.aws.amazon.com"), "{e}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_bundled_name_is_what_tauri_gives_the_sidecar() {
|
||||
// tauri-build/-bundler strip "-<target-triple>" from bundle.externalBin's
|
||||
// "binaries/session-manager-plugin"; the .exe stays on Windows.
|
||||
let conf: serde_json::Value =
|
||||
serde_json::from_str(include_str!("../../../tauri.conf.json")).unwrap();
|
||||
let bins = conf["bundle"]["externalBin"].as_array().expect("bundle.externalBin");
|
||||
let stems: Vec<&str> = bins
|
||||
.iter()
|
||||
.map(|b| b.as_str().unwrap().rsplit('/').next().unwrap())
|
||||
.collect();
|
||||
let expected = PLUGIN_FILE.trim_end_matches(".exe");
|
||||
assert!(stems.contains(&expected), "{stems:?} has no {expected}");
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ mod logging;
|
||||
mod marketplace;
|
||||
mod models;
|
||||
mod project_lock;
|
||||
mod sidecar_placeholder;
|
||||
mod storage;
|
||||
pub mod url_open;
|
||||
pub mod web_terminal;
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
//! The stand-in `build.rs` writes for the bundled `session-manager-plugin` sidecar in a
|
||||
//! **debug** build that has no real one, and how the app recognises it.
|
||||
//!
|
||||
//! `bundle.externalBin` makes tauri-build fail outright when the per-target file is missing,
|
||||
//! for `cargo test`, `cargo check` and `tauri dev` as much as for a release. The real binary
|
||||
//! is built from AWS's pinned source by `scripts/build-ssm-plugin.sh` (`.ps1` on Windows), with
|
||||
//! a downloaded Go toolchain; requiring that for every test run would put a Go build and the
|
||||
//! network on the path of every `cargo test`. So debug builds get this placeholder instead, a
|
||||
//! release build refuses it (`build.rs`), and `host::ssm::find_plugin` skips it and falls back to
|
||||
//! an installed plugin.
|
||||
//!
|
||||
//! Shared by `build.rs` (through `#[path]`) and the app, so the two cannot disagree.
|
||||
|
||||
/// The first bytes of a placeholder. Not an executable format on any platform.
|
||||
pub const MARKER: &[u8] = b"TRIPLE-C SSM PLUGIN PLACEHOLDER";
|
||||
|
||||
/// The whole placeholder file.
|
||||
#[allow(dead_code)] // build.rs only
|
||||
pub fn contents() -> Vec<u8> {
|
||||
let mut v = MARKER.to_vec();
|
||||
v.extend_from_slice(
|
||||
b"\nNot the AWS Session Manager plugin. Debug builds get this when \
|
||||
app/src-tauri/binaries has no real one; run scripts/build-ssm-plugin.sh \
|
||||
(scripts/build-ssm-plugin.ps1 on Windows) to build the real plugin.\n",
|
||||
);
|
||||
v
|
||||
}
|
||||
|
||||
/// Whether `bytes` (the start of a file) is a placeholder.
|
||||
pub fn is_placeholder(bytes: &[u8]) -> bool {
|
||||
bytes.starts_with(MARKER)
|
||||
}
|
||||
@@ -36,12 +36,6 @@
|
||||
"icons/icon.icns",
|
||||
"icons/icon.png"
|
||||
],
|
||||
"externalBin": [
|
||||
"binaries/session-manager-plugin"
|
||||
],
|
||||
"resources": {
|
||||
"THIRD_PARTY_NOTICES": "THIRD_PARTY_NOTICES"
|
||||
},
|
||||
"linux": {
|
||||
"appimage": {
|
||||
"bundleMediaFramework": true
|
||||
|
||||
@@ -64,10 +64,10 @@ function ErrorLine({
|
||||
}) {
|
||||
return (
|
||||
<div role="alert" className="text-xs text-[var(--error)] leading-snug flex items-center gap-2 flex-wrap">
|
||||
<span>{awsErrorMessage(failure.error)}</span>
|
||||
<span className="min-w-0 break-words">{awsErrorMessage(failure.error)}</span>
|
||||
{failure.error.kind === "sso_expired" && !onSignIn && (
|
||||
<span>
|
||||
Sign in with <code>aws sso login --profile {failure.error.profile}</code> and try again.
|
||||
Sign in with <code className="break-all">aws sso login --profile {failure.error.profile}</code> and try again.
|
||||
</span>
|
||||
)}
|
||||
{failure.error.kind === "sso_expired" && onSignIn && (
|
||||
@@ -124,7 +124,7 @@ function PermissionReportView({ report }: { report: PermissionReport }) {
|
||||
>
|
||||
{badge}
|
||||
</span>
|
||||
<span className="text-xs text-[var(--text-secondary)]">
|
||||
<span className="min-w-0 break-all text-xs text-[var(--text-secondary)]" data-testid="report-identity">
|
||||
{report.identity.arn} · {report.region}
|
||||
</span>
|
||||
</div>
|
||||
@@ -154,8 +154,8 @@ function PermissionReportView({ report }: { report: PermissionReport }) {
|
||||
</summary>
|
||||
<ul className="mt-1 space-y-0.5 pl-4">
|
||||
{t.results.map((r) => (
|
||||
<li key={r.action} className="text-[var(--text-secondary)]">
|
||||
<span className="font-mono">{r.action}</span> — {r.verdict}
|
||||
<li key={r.action} className="text-[var(--text-secondary)] break-words">
|
||||
<span className="font-mono break-all">{r.action}</span> — {r.verdict}
|
||||
{r.note && (
|
||||
<>
|
||||
{" "}
|
||||
@@ -263,7 +263,7 @@ function ConnectionRow({ host }: { host: HostConnection }) {
|
||||
<li
|
||||
ref={rowRef}
|
||||
data-testid={`host-${host.id}`}
|
||||
className="border border-[var(--border-color)] rounded-[var(--radius-control)] p-2.5 space-y-1.5"
|
||||
className="border border-[var(--border-color)] rounded-[var(--radius-control)] p-2.5 space-y-1.5 min-w-0"
|
||||
>
|
||||
{editing ? (
|
||||
<div className="space-y-2">
|
||||
@@ -273,7 +273,7 @@ function ConnectionRow({ host }: { host: HostConnection }) {
|
||||
<input id={id} className={inputClass} list="aws-regions" value={region} onChange={(e) => setRegion(e.target.value)} />
|
||||
)}
|
||||
</Field>
|
||||
<div className="flex gap-2">
|
||||
<div className="flex gap-2 flex-wrap">
|
||||
<Button size="sm" variant="primary" onClick={save} disabled={busy || !name.trim() || !region.trim()}>
|
||||
Save changes
|
||||
</Button>
|
||||
@@ -283,16 +283,16 @@ function ConnectionRow({ host }: { host: HostConnection }) {
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex items-start justify-between gap-2 flex-wrap">
|
||||
<div className="flex items-start justify-between gap-2 flex-wrap" data-testid={`host-header-${host.id}`}>
|
||||
<div className="min-w-0">
|
||||
<div className="text-[13px] font-medium text-[var(--text-primary)]">{host.name}</div>
|
||||
<div className="text-xs text-[var(--text-secondary)]">
|
||||
<div className="text-[13px] font-medium text-[var(--text-primary)] break-words">{host.name}</div>
|
||||
<div className="text-xs text-[var(--text-secondary)] break-words">
|
||||
<span>{auth.method === "profile" ? `Profile: ${auth.name}` : "Access keys"}</span>
|
||||
{" · "}
|
||||
<span>{host.kind.default_region}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex gap-1.5">
|
||||
<div className="flex gap-1.5 flex-wrap">
|
||||
<Button size="sm" onClick={runCheck} disabled={busy} aria-label={`Check ${host.name}`}>
|
||||
Check
|
||||
</Button>
|
||||
@@ -309,7 +309,7 @@ function ConnectionRow({ host }: { host: HostConnection }) {
|
||||
)}
|
||||
{confirmRemove && (
|
||||
<div role="alertdialog" aria-label={`Remove ${host.name}?`} className="flex items-center gap-2 flex-wrap text-xs">
|
||||
<span>Remove {host.name}? Its stored credentials are deleted.</span>
|
||||
<span className="min-w-0 break-words">Remove {host.name}? Its stored credentials are deleted.</span>
|
||||
<Button data-focus="confirm-remove" size="sm" variant="danger" onClick={remove} disabled={busy} aria-label={`Confirm remove ${host.name}`}>
|
||||
Confirm remove
|
||||
</Button>
|
||||
@@ -501,7 +501,7 @@ function AddConnectionForm() {
|
||||
{busy ? "Adding…" : "Add connection"}
|
||||
</Button>
|
||||
{signedInAs && (
|
||||
<p role="status" className="text-xs text-[var(--success)]">
|
||||
<p role="status" className="text-xs text-[var(--success)] break-all">
|
||||
Signed in as {signedInAs}
|
||||
</p>
|
||||
)}
|
||||
@@ -516,7 +516,7 @@ export default function HostsSettings() {
|
||||
const { appSettings } = useSettings();
|
||||
const hosts = appSettings?.hosts ?? [];
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
<div className="space-y-3 min-w-0">
|
||||
<p className="text-xs text-[var(--text-secondary)] leading-snug">
|
||||
Where project environments run. AWS connections check what your credentials can do, and find, deploy and join environments.
|
||||
</p>
|
||||
|
||||
@@ -177,7 +177,7 @@ export default function AdminBundleModal({
|
||||
Saved to <code className="font-mono text-[var(--text-primary)] break-all">{saved}</code>
|
||||
</p>
|
||||
<p>From that folder, run:</p>
|
||||
<pre className="font-mono text-[var(--text-primary)] bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-[var(--radius-control)] p-2 whitespace-pre-wrap">
|
||||
<pre className="font-mono text-[var(--text-primary)] bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-[var(--radius-control)] p-2 whitespace-pre-wrap break-all max-w-full overflow-x-auto">
|
||||
{COMMANDS}
|
||||
</pre>
|
||||
<Button size="sm" onClick={copy}>
|
||||
|
||||
@@ -30,6 +30,7 @@ export default function DeployEnvironmentModal({
|
||||
onClose,
|
||||
onDeploy,
|
||||
onDetect,
|
||||
onBundle,
|
||||
}: {
|
||||
connectionId: string;
|
||||
region: string;
|
||||
@@ -40,6 +41,8 @@ export default function DeployEnvironmentModal({
|
||||
/** Starts the run; resolves to the command's error, or null once started. */
|
||||
onDeploy: (name: string, network: NetworkChoice, maxWorkspaceHours: number) => Promise<AwsError | null>;
|
||||
onDetect: () => void;
|
||||
/** Switch to an environment bundle for an admin (offered when AWS refuses the deploy). */
|
||||
onBundle?: () => void;
|
||||
}) {
|
||||
const [name, setName] = useState("main");
|
||||
const [draft, setDraft] = useState<NetworkDraft>(DEFAULT_NETWORK);
|
||||
@@ -80,7 +83,7 @@ export default function DeployEnvironmentModal({
|
||||
|
||||
const createBoundary = async () => {
|
||||
setBoundaryError(null);
|
||||
const err = await boundary.start(BOUNDARY_STATE_KEY, region, "Permissions boundary", () =>
|
||||
const err = await boundary.start(BOUNDARY_STATE_KEY, region, "boundary", "Permissions boundary", () =>
|
||||
deployAwsPermissionsBoundary(connectionId, region),
|
||||
);
|
||||
if (err?.kind === "access_denied") setBundle({ reason: awsErrorMessage(err) });
|
||||
@@ -125,18 +128,19 @@ export default function DeployEnvironmentModal({
|
||||
<div className="flex gap-2 flex-wrap">
|
||||
<Button
|
||||
size="md"
|
||||
wrap
|
||||
variant="primary"
|
||||
onClick={createBoundary}
|
||||
disabled={!!boundaryRun && !boundaryRun.done}
|
||||
>
|
||||
Create the permissions boundary (needs an account administrator)
|
||||
</Button>
|
||||
<Button size="md" onClick={() => setBundle({})}>
|
||||
<Button size="md" wrap onClick={() => setBundle({})}>
|
||||
Save a bundle for an administrator instead
|
||||
</Button>
|
||||
</div>
|
||||
{boundaryError && (
|
||||
<p role="alert" className="text-[var(--error)]">
|
||||
<p role="alert" className="text-[var(--error)] break-words">
|
||||
{awsErrorMessage(boundaryError)}
|
||||
</p>
|
||||
)}
|
||||
@@ -149,6 +153,7 @@ export default function DeployEnvironmentModal({
|
||||
</p>
|
||||
<Button
|
||||
size="md"
|
||||
wrap
|
||||
onClick={() =>
|
||||
setBundle({
|
||||
reason: boundaryFailed.summary ?? `OpenTofu exited with code ${boundaryFailed.exit_code}`,
|
||||
@@ -179,10 +184,18 @@ export default function DeployEnvironmentModal({
|
||||
First deploy downloads OpenTofu (~30 MB) and the AWS provider (~150 MB).
|
||||
</p>
|
||||
{error && (
|
||||
<p role="alert" className="text-xs text-[var(--error)] leading-snug">
|
||||
<p role="alert" className="text-xs text-[var(--error)] leading-snug break-words">
|
||||
{awsErrorMessage(error)}
|
||||
</p>
|
||||
)}
|
||||
{error?.kind === "access_denied" && onBundle && !repair && (
|
||||
<div className="space-y-1.5 text-xs text-[var(--text-secondary)] leading-snug">
|
||||
<p>An admin can deploy this environment for you from a bundle.</p>
|
||||
<Button size="sm" wrap onClick={onBundle}>
|
||||
Save an environment bundle for an admin…
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</Modal>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { act, renderHook } from "@testing-library/react";
|
||||
import { runKey, useDeployRuns } from "./DeployProgress";
|
||||
import { act, render, renderHook, screen } from "@testing-library/react";
|
||||
import DeployProgressView, { runKey, useDeployRuns } from "./DeployProgress";
|
||||
import type { DeployProgress } from "../../../lib/types";
|
||||
import { progress, tofuEvent } from "./testkit";
|
||||
|
||||
@@ -29,10 +29,10 @@ describe("useDeployRuns", () => {
|
||||
const onDone = vi.fn();
|
||||
const { result } = renderHook(() => useDeployRuns(onDone));
|
||||
await act(async () => {
|
||||
await result.current.start(KEY, "eu-west-1", "Deploy of main", async () => "eu");
|
||||
await result.current.start(KEY, "eu-west-1", "deploy", "Deploy of main", async () => "eu");
|
||||
});
|
||||
await act(async () => {
|
||||
await result.current.start(KEY, "us-east-1", "Deploy of main", async () => "us");
|
||||
await result.current.start(KEY, "us-east-1", "deploy", "Deploy of main", async () => "us");
|
||||
});
|
||||
expect(handlers.size).toBe(2);
|
||||
emit(progress({ op_id: "eu", state_key: KEY, events: [tofuEvent("eu line")] }));
|
||||
@@ -54,8 +54,8 @@ describe("useDeployRuns", () => {
|
||||
it("removes its progress listeners on unmount", async () => {
|
||||
const { result, unmount } = renderHook(() => useDeployRuns());
|
||||
await act(async () => {
|
||||
await result.current.start(KEY, "eu-west-1", "Deploy of main", async () => "a");
|
||||
await result.current.start("boundary/terraform.tfstate", "eu-west-1", "Boundary", async () => "b");
|
||||
await result.current.start(KEY, "eu-west-1", "deploy", "Deploy of main", async () => "a");
|
||||
await result.current.start("boundary/terraform.tfstate", "eu-west-1", "deploy", "Boundary", async () => "b");
|
||||
});
|
||||
expect(handlers.size).toBe(2);
|
||||
unmount();
|
||||
@@ -66,7 +66,7 @@ describe("useDeployRuns", () => {
|
||||
const { result } = renderHook(() => useDeployRuns());
|
||||
let err: unknown;
|
||||
await act(async () => {
|
||||
err = await result.current.start(KEY, "eu-west-1", "Deploy of main", async () => {
|
||||
err = await result.current.start(KEY, "eu-west-1", "deploy", "Deploy of main", async () => {
|
||||
throw { kind: "other", message: "A deployment is already running" };
|
||||
});
|
||||
});
|
||||
@@ -75,3 +75,28 @@ describe("useDeployRuns", () => {
|
||||
expect(result.current.runs).toEqual({});
|
||||
});
|
||||
});
|
||||
|
||||
describe("DeployProgress layout", () => {
|
||||
it("wraps its header and a long failure summary", () => {
|
||||
render(
|
||||
<DeployProgressView
|
||||
connectionId="h1"
|
||||
run={{
|
||||
stateKey: KEY,
|
||||
region: "eu-west-1",
|
||||
kind: "deploy",
|
||||
label: "Deploy of main",
|
||||
opId: "x",
|
||||
events: [],
|
||||
done: true,
|
||||
cancellable: false,
|
||||
result: { ok: false, exit_code: 1, summary: "a very long summary ".repeat(10) },
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
const header = screen.getByTestId("deploy-progress-header");
|
||||
expect(header.className).toContain("flex-wrap");
|
||||
expect(header.firstElementChild?.className).toContain("min-w-0");
|
||||
expect(screen.getByRole("status").firstElementChild?.className).toContain("whitespace-normal");
|
||||
});
|
||||
});
|
||||
@@ -13,10 +13,18 @@ import Button from "../../ui/Button";
|
||||
import Modal from "../../ui/Modal";
|
||||
import StatusIndicator from "../../ui/StatusIndicator";
|
||||
|
||||
/**
|
||||
* What a run does. Decisions about a run (such as offering an admin bundle
|
||||
* when AWS refuses it) key on this, never on its label: a follow of an
|
||||
* existing environment's deploy is labelled like a new deploy.
|
||||
*/
|
||||
export type RunKind = "deploy" | "follow" | "repair" | "update" | "destroy" | "onboard" | "push" | "boundary";
|
||||
|
||||
/** One OpenTofu run this view is showing: a start, or a follow of one already running. */
|
||||
export interface DeployRun {
|
||||
stateKey: string;
|
||||
region: string;
|
||||
kind: RunKind;
|
||||
label: string;
|
||||
/** Null until the starting command resolves. */
|
||||
opId: string | null;
|
||||
@@ -57,7 +65,13 @@ export function useDeployRuns(
|
||||
}, []);
|
||||
|
||||
const start = useCallback(
|
||||
async (stateKey: string, region: string, label: string, run: () => Promise<string>): Promise<AwsError | null> => {
|
||||
async (
|
||||
stateKey: string,
|
||||
region: string,
|
||||
kind: RunKind,
|
||||
label: string,
|
||||
run: () => Promise<string>,
|
||||
): Promise<AwsError | null> => {
|
||||
const k = runKey(region, stateKey);
|
||||
subs.current.get(k)?.unlisten?.();
|
||||
const sub: Subscription = { unlisten: null };
|
||||
@@ -94,7 +108,7 @@ export function useDeployRuns(
|
||||
|
||||
setRuns((prev) => ({
|
||||
...prev,
|
||||
[k]: { stateKey, region, label, opId: null, events: [], done: false, cancellable: false, result: null },
|
||||
[k]: { stateKey, region, kind, label, opId: null, events: [], done: false, cancellable: false, result: null },
|
||||
}));
|
||||
|
||||
const unlisten = await listen<ProgressPayload>(AWS_DEPLOY_PROGRESS_EVENT, ({ payload }) => {
|
||||
@@ -146,7 +160,7 @@ function EventLine({ e }: { e: TofuEvent }) {
|
||||
return (
|
||||
<li className="text-xs leading-snug">
|
||||
{(e.resource || e.action) && (
|
||||
<span className="mr-1.5">
|
||||
<span className="mr-1.5 break-all">
|
||||
{e.resource && <span className="font-mono text-[var(--text-primary)]">{e.resource}</span>}
|
||||
{e.action && <span className="ml-1 text-[var(--text-secondary)]">{e.action}</span>}
|
||||
</span>
|
||||
@@ -154,10 +168,10 @@ function EventLine({ e }: { e: TofuEvent }) {
|
||||
{isError ? (
|
||||
<>
|
||||
<span className="font-semibold text-[var(--error)]">Error: </span>
|
||||
<pre className="whitespace-pre-wrap break-words font-mono text-[var(--error)]">{e.message}</pre>
|
||||
<pre className="max-w-full overflow-x-auto whitespace-pre-wrap break-words font-mono text-[var(--error)]">{e.message}</pre>
|
||||
</>
|
||||
) : (
|
||||
<span className="text-[var(--text-secondary)]">{e.message}</span>
|
||||
<span className="text-[var(--text-secondary)] break-words">{e.message}</span>
|
||||
)}
|
||||
</li>
|
||||
);
|
||||
@@ -205,14 +219,14 @@ export default function DeployProgress({
|
||||
return (
|
||||
<section
|
||||
aria-label={`${run.label} progress`}
|
||||
className="space-y-1.5 border border-[var(--border-color)] rounded-[var(--radius-control)] p-2 bg-[var(--bg-primary)]"
|
||||
className="space-y-1.5 min-w-0 border border-[var(--border-color)] rounded-[var(--radius-control)] p-2 bg-[var(--bg-primary)]"
|
||||
>
|
||||
<div className="flex items-center justify-between gap-2 flex-wrap">
|
||||
<div className="flex items-center gap-2 text-xs">
|
||||
<span className="font-medium text-[var(--text-primary)]">{run.label}</span>
|
||||
<div className="flex items-center justify-between gap-2 flex-wrap" data-testid="deploy-progress-header">
|
||||
<div className="flex items-center gap-2 text-xs flex-wrap min-w-0">
|
||||
<span className="font-medium text-[var(--text-primary)] break-words min-w-0">{run.label}</span>
|
||||
{status && <StatusIndicator tone={status.tone} label={status.label} />}
|
||||
</div>
|
||||
<div className="flex gap-1.5">
|
||||
<div className="flex gap-1.5 flex-wrap">
|
||||
{!run.done && (
|
||||
<Button
|
||||
size="sm"
|
||||
@@ -239,11 +253,12 @@ export default function DeployProgress({
|
||||
</ol>
|
||||
)}
|
||||
{run.done && run.result && (
|
||||
<p role="status" className="text-xs">
|
||||
<p role="status" className="text-xs break-words">
|
||||
{run.result.ok ? (
|
||||
<StatusIndicator tone="ok" label={`Finished${run.result.summary ? `: ${run.result.summary}` : ""}`} />
|
||||
<StatusIndicator wrap tone="ok" label={`Finished${run.result.summary ? `: ${run.result.summary}` : ""}`} />
|
||||
) : (
|
||||
<StatusIndicator
|
||||
wrap
|
||||
tone="error"
|
||||
label={`Failed (exit ${run.result.exit_code})${run.result.summary ? `: ${run.result.summary}` : ""}`}
|
||||
/>
|
||||
@@ -251,7 +266,7 @@ export default function DeployProgress({
|
||||
</p>
|
||||
)}
|
||||
{cancelError && !confirming && (
|
||||
<p role="alert" className="text-xs text-[var(--error)]">
|
||||
<p role="alert" className="text-xs text-[var(--error)] break-words">
|
||||
{awsErrorMessage(cancelError)}
|
||||
</p>
|
||||
)}
|
||||
|
||||
@@ -48,6 +48,7 @@ export default function Ec2CapacityFields({
|
||||
<div className="text-[13px] font-medium text-[var(--text-primary)]">EC2 capacity</div>
|
||||
<SegmentedControl<"none" | "ec2">
|
||||
label="EC2 capacity"
|
||||
className="flex-wrap max-w-full"
|
||||
value={value.enabled ? "ec2" : "none"}
|
||||
onChange={(v) => set({ enabled: v === "ec2" })}
|
||||
segments={[
|
||||
|
||||
@@ -81,7 +81,7 @@ describe("EnvironmentsPanel", () => {
|
||||
expect(within(screen.getByTestId("env-dev")).getByText("Joined")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("offers an admin bundle instead of deploy for a workspace user with nothing found", async () => {
|
||||
it("offers deploy to a workspace user too, with a note and the admin options under a disclosure", async () => {
|
||||
backend(
|
||||
() => scan(),
|
||||
(cmd) => {
|
||||
@@ -91,22 +91,162 @@ describe("EnvironmentsPanel", () => {
|
||||
);
|
||||
render(<EnvironmentsPanel connection={conn} tier="workspace_user" />);
|
||||
await open();
|
||||
expect(await screen.findByText(/needs an environment admin/)).toBeInTheDocument();
|
||||
expect(screen.queryByRole("button", { name: "Deploy a new environment" })).toBeNull();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Show the environment-admin policies" }));
|
||||
expect(await screen.findByText("environment-admin.json")).toBeInTheDocument();
|
||||
const deploy = await screen.findByRole("button", { name: "Deploy a new environment" });
|
||||
expect(deploy.className).toContain("--accent-emphasis");
|
||||
expect(screen.getByTestId("deploy-unconfirmed-note")).toHaveTextContent(
|
||||
"Your permission check didn't confirm environment-admin rights; the deploy will stop with AWS's message if a permission is missing.",
|
||||
);
|
||||
const options = screen.getByTestId("not-admin-options");
|
||||
expect(options.tagName).toBe("DETAILS");
|
||||
expect(within(options).getByText(/Not an admin\?/)).toBeInTheDocument();
|
||||
fireEvent.click(within(options).getByRole("button", { name: "Show the environment-admin policies" }));
|
||||
expect(await within(options).findByRole("button", { name: "Copy environment-admin.json" })).toBeInTheDocument();
|
||||
expect(invoke).toHaveBeenCalledWith("aws_policy_document", { tier: "environment_admin" });
|
||||
fireEvent.click(screen.getByRole("button", { name: "Request an environment from an admin…" }));
|
||||
fireEvent.click(within(options).getByRole("button", { name: "Request an environment from an admin…" }));
|
||||
const dialog = screen.getByRole("dialog");
|
||||
expect(within(dialog).getByRole("button", { name: "Save bundle to folder…" })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("treats a connection with no permission report as not an admin", async () => {
|
||||
it("opens the deploy form for a workspace user", async () => {
|
||||
backend(() => scan());
|
||||
render(<EnvironmentsPanel connection={conn} tier="workspace_user" />);
|
||||
await open();
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Deploy a new environment" }));
|
||||
expect(screen.getByRole("dialog", { name: "Deploy a new environment" })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("an admin sees deploy without the note or the not-an-admin options", async () => {
|
||||
backend(() => scan());
|
||||
render(<EnvironmentsPanel connection={conn} tier="environment_admin" />);
|
||||
await open();
|
||||
expect(await screen.findByRole("button", { name: "Deploy a new environment" })).toBeInTheDocument();
|
||||
expect(screen.queryByTestId("deploy-unconfirmed-note")).toBeNull();
|
||||
expect(screen.queryByTestId("not-admin-options")).toBeNull();
|
||||
});
|
||||
|
||||
it("a connection with no permission report gets deploy with the note", async () => {
|
||||
backend(() => scan());
|
||||
render(<EnvironmentsPanel connection={conn} />);
|
||||
await open();
|
||||
expect(await screen.findByRole("button", { name: "Request an environment from an admin…" })).toBeInTheDocument();
|
||||
expect(screen.queryByRole("button", { name: "Deploy a new environment" })).toBeNull();
|
||||
expect(await screen.findByRole("button", { name: "Deploy a new environment" })).toBeInTheDocument();
|
||||
expect(screen.getByTestId("deploy-unconfirmed-note")).toBeInTheDocument();
|
||||
expect(screen.getByText(/Run Check to see what your credentials can do/)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows the boundary note to anyone when the account has no boundary", async () => {
|
||||
backend(() => scan({ boundary: "no" }));
|
||||
render(<EnvironmentsPanel connection={conn} tier="workspace_user" />);
|
||||
await open();
|
||||
expect(await screen.findByText(/no Triple-C permissions boundary yet/)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("offers a bundle when AWS refuses a deploy run's permission", async () => {
|
||||
backend(
|
||||
() => scan(),
|
||||
(cmd) => {
|
||||
if (cmd === "deploy_aws_environment") return "d1";
|
||||
throw new Error(`unexpected ${cmd}`);
|
||||
},
|
||||
);
|
||||
render(<EnvironmentsPanel connection={conn} tier="workspace_user" />);
|
||||
await open();
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Deploy a new environment" }));
|
||||
fireEvent.click(within(screen.getByRole("dialog")).getByRole("button", { name: "Deploy" }));
|
||||
await waitFor(() => expect(screen.queryByRole("dialog")).toBeNull());
|
||||
const key = "environments/main/terraform.tfstate";
|
||||
emit(
|
||||
progress({
|
||||
op_id: "d1",
|
||||
state_key: key,
|
||||
events: [tofuEvent("creating IAM Role: AccessDenied: User is not authorized to perform iam:CreateRole", { level: "error" })],
|
||||
}),
|
||||
);
|
||||
emit(progress({ op_id: "d1", state_key: key, done: true, cancellable: false, result: { ok: false, exit_code: 1, summary: null } }));
|
||||
const hint = await screen.findByTestId("denied-hint");
|
||||
expect(hint).toHaveTextContent("AWS refused a permission");
|
||||
fireEvent.click(within(hint).getByRole("button", { name: "Save a bundle for an admin…" }));
|
||||
expect(within(screen.getByRole("dialog")).getByRole("button", { name: "Save bundle to folder…" })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("never offers a new-environment bundle for a refused follow of an existing deploy", async () => {
|
||||
const key = "environments/dev/terraform.tfstate";
|
||||
backend(
|
||||
() => scan({ environments: [env({ actions: ["follow"], state: { state: "ready" } })] }),
|
||||
(cmd) => {
|
||||
if (cmd === "follow_aws_deployment") return "f9";
|
||||
throw new Error(`unexpected ${cmd}`);
|
||||
},
|
||||
);
|
||||
render(<EnvironmentsPanel connection={conn} tier="workspace_user" />);
|
||||
await open();
|
||||
await waitFor(() => expect(invoke.mock.calls.some((c) => c[0] === "follow_aws_deployment")).toBe(true));
|
||||
await screen.findByRole("region", { name: "Deploy of dev progress" });
|
||||
emit(
|
||||
progress({
|
||||
op_id: "f9",
|
||||
state_key: key,
|
||||
events: [tofuEvent("AccessDenied: User is not authorized to perform ecs:UpdateService", { level: "error" })],
|
||||
}),
|
||||
);
|
||||
emit(progress({ op_id: "f9", state_key: key, done: true, cancellable: false, result: { ok: false, exit_code: 1, summary: null } }));
|
||||
expect(await screen.findByText(/Failed \(exit 1\)/)).toBeInTheDocument();
|
||||
expect(screen.queryByTestId("denied-hint")).toBeNull();
|
||||
});
|
||||
|
||||
it("marks the not-an-admin disclosure open or closed like the Environments toggle", async () => {
|
||||
backend(() => scan());
|
||||
render(<EnvironmentsPanel connection={conn} tier="workspace_user" />);
|
||||
await open();
|
||||
const options = await screen.findByTestId("not-admin-options");
|
||||
const summary = options.querySelector("summary")!;
|
||||
expect(summary).toHaveTextContent("▸");
|
||||
(options as HTMLDetailsElement).open = true;
|
||||
fireEvent(options, new Event("toggle"));
|
||||
await waitFor(() => expect(summary).toHaveTextContent("▾"));
|
||||
});
|
||||
|
||||
it("shows a refused deploy's AWS message and offers the bundle", async () => {
|
||||
backend(
|
||||
() => scan(),
|
||||
(cmd) => {
|
||||
if (cmd === "deploy_aws_environment")
|
||||
throw { kind: "access_denied", action: "s3:CreateBucket", message: "User is not authorized" };
|
||||
throw new Error(`unexpected ${cmd}`);
|
||||
},
|
||||
);
|
||||
render(<EnvironmentsPanel connection={conn} tier="workspace_user" />);
|
||||
await open();
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Deploy a new environment" }));
|
||||
const dialog = screen.getByRole("dialog");
|
||||
fireEvent.click(within(dialog).getByRole("button", { name: "Deploy" }));
|
||||
expect(await within(dialog).findByText("AWS denied s3:CreateBucket: User is not authorized")).toBeInTheDocument();
|
||||
fireEvent.click(within(dialog).getByRole("button", { name: "Save an environment bundle for an admin…" }));
|
||||
expect(within(screen.getByRole("dialog")).getByRole("button", { name: "Save bundle to folder…" })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("keeps the key rows wrapping in a narrow sidebar", async () => {
|
||||
backend(
|
||||
() => scan({ environments: [env({ actions: ["join", "update", "repair"] })] }),
|
||||
(cmd) => {
|
||||
if (cmd === "aws_policy_document") return [{ name: "a.json", json: "{}" }, { name: "b.json", json: "{}" }];
|
||||
throw new Error(`unexpected ${cmd}`);
|
||||
},
|
||||
);
|
||||
render(<EnvironmentsPanel connection={conn} tier="workspace_user" />);
|
||||
await open();
|
||||
const row = await screen.findByTestId("env-row-dev");
|
||||
expect(row.className).toContain("flex-wrap");
|
||||
expect(row.firstElementChild?.className).toContain("min-w-0");
|
||||
const actions = screen.getByTestId("env-actions-dev");
|
||||
expect(actions.className).toContain("flex-wrap");
|
||||
expect(actions.className).toContain("min-w-0");
|
||||
expect(screen.getByTestId("region-row").className).toContain("flex-wrap");
|
||||
expect(screen.getByRole("button", { name: "Deploy a new environment" }).className).toContain("whitespace-normal");
|
||||
fireEvent.click(screen.getByRole("button", { name: "Show the environment-admin policies" }));
|
||||
const grid = await screen.findByTestId("policy-copy-grid");
|
||||
expect(grid.className).toContain("grid");
|
||||
expect(grid.className).toContain("auto-fill");
|
||||
for (const b of within(grid).getAllByRole("button")) expect(b.className).toContain("whitespace-normal");
|
||||
});
|
||||
|
||||
it("an incomplete environment offers repair and destroy, destroy only after typing its name", async () => {
|
||||
@@ -248,7 +388,43 @@ describe("EnvironmentsPanel", () => {
|
||||
expect(await within(screen.getByTestId("env-dev")).findByText("Joined")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("a workspace user's join opens the onboarding bundle and waits for an admin", async () => {
|
||||
it("a workspace user can join themselves, with the note", async () => {
|
||||
backend(
|
||||
() => scan({ environments: [env()] }),
|
||||
(cmd) => {
|
||||
if (cmd === "onboard_aws_user") return "j1";
|
||||
throw new Error(`unexpected ${cmd}`);
|
||||
},
|
||||
);
|
||||
render(<EnvironmentsPanel connection={conn} tier="workspace_user" />);
|
||||
await open();
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Join dev" }));
|
||||
const dialog = screen.getByRole("dialog", { name: "Join dev" });
|
||||
expect(within(dialog).getByTestId("join-unconfirmed-note")).toBeInTheDocument();
|
||||
fireEvent.click(within(dialog).getByRole("button", { name: "Join" }));
|
||||
await waitFor(() =>
|
||||
expect(invoke).toHaveBeenCalledWith("onboard_aws_user", expect.objectContaining({ environment: "dev" })),
|
||||
);
|
||||
});
|
||||
|
||||
it("a refused join shows AWS's message and offers the onboarding bundle", async () => {
|
||||
backend(
|
||||
() => scan({ environments: [env()] }),
|
||||
(cmd) => {
|
||||
if (cmd === "onboard_aws_user") throw { kind: "access_denied", action: "s3:PutObject", message: "explicit deny" };
|
||||
throw new Error(`unexpected ${cmd}`);
|
||||
},
|
||||
);
|
||||
render(<EnvironmentsPanel connection={conn} tier="workspace_user" />);
|
||||
await open();
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Join dev" }));
|
||||
const dialog = screen.getByRole("dialog", { name: "Join dev" });
|
||||
fireEvent.click(within(dialog).getByRole("button", { name: "Join" }));
|
||||
expect(await within(dialog).findByText("AWS denied s3:PutObject: explicit deny")).toBeInTheDocument();
|
||||
expect(within(dialog).getByText(/AWS refused this with your permissions/)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("a workspace user can switch the join to an onboarding bundle and then waits for an admin", async () => {
|
||||
backend(
|
||||
() => scan({ environments: [env()] }),
|
||||
(cmd) => {
|
||||
@@ -259,6 +435,11 @@ describe("EnvironmentsPanel", () => {
|
||||
render(<EnvironmentsPanel connection={conn} tier="workspace_user" />);
|
||||
await open();
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Join dev" }));
|
||||
fireEvent.click(
|
||||
within(screen.getByRole("dialog", { name: "Join dev" })).getByRole("button", {
|
||||
name: "Save an onboarding bundle for an admin…",
|
||||
}),
|
||||
);
|
||||
const dialog = screen.getByRole("dialog");
|
||||
// Opening the bundle is not a request yet.
|
||||
expect(screen.queryByText("Waiting for an admin to onboard you")).toBeNull();
|
||||
@@ -280,6 +461,14 @@ describe("EnvironmentsPanel", () => {
|
||||
expect(within(screen.getByTestId("env-dev")).getByText("Waiting for an admin to onboard you")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("an admin's join has no unconfirmed note", async () => {
|
||||
backend(() => scan({ environments: [env()] }));
|
||||
render(<EnvironmentsPanel connection={conn} tier="environment_admin" />);
|
||||
await open();
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Join dev" }));
|
||||
expect(within(screen.getByRole("dialog", { name: "Join dev" })).queryByTestId("join-unconfirmed-note")).toBeNull();
|
||||
});
|
||||
|
||||
it("an admin joins with EC2 capacity: a type from the table, max instances and their triple-c-user value", async () => {
|
||||
backend(
|
||||
() => scan({ environments: [env()] }),
|
||||
@@ -422,7 +611,7 @@ describe("EnvironmentsPanel", () => {
|
||||
expect(within(dialog).queryByText(/Choosing None removes/)).toBeNull();
|
||||
});
|
||||
|
||||
it("a joined workspace user's capacity change is a bundle starting from their record", async () => {
|
||||
it("a joined workspace user's capacity bundle starts from their record", async () => {
|
||||
backend(
|
||||
() => scan({ environments: [env({ onboarding: { state: "joined", ec2: compute({ max_instances: 1 }) } })] }),
|
||||
(cmd) => {
|
||||
@@ -434,6 +623,7 @@ describe("EnvironmentsPanel", () => {
|
||||
render(<EnvironmentsPanel connection={conn} tier="workspace_user" />);
|
||||
await open();
|
||||
fireEvent.click(await screen.findByRole("button", { name: "EC2 capacity in dev" }));
|
||||
fireEvent.click(within(screen.getByRole("dialog")).getByRole("button", { name: "Save an onboarding bundle for an admin…" }));
|
||||
const dialog = screen.getByRole("dialog", { name: "Onboarding bundle" });
|
||||
fireEvent.click(within(dialog).getByRole("button", { name: "Save bundle to folder…" }));
|
||||
await waitFor(() =>
|
||||
@@ -525,6 +715,7 @@ describe("EnvironmentsPanel", () => {
|
||||
render(<EnvironmentsPanel connection={conn} tier="workspace_user" />);
|
||||
await open();
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Join dev" }));
|
||||
fireEvent.click(within(screen.getByRole("dialog")).getByRole("button", { name: "Save an onboarding bundle for an admin…" }));
|
||||
fireEvent.click(within(screen.getByRole("dialog")).getByRole("button", { name: "Close" }));
|
||||
expect(screen.queryByText("Waiting for an admin to onboard you")).toBeNull();
|
||||
expect(within(screen.getByTestId("env-dev")).getByRole("button", { name: "Join dev" })).toHaveTextContent("Join");
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
unlockAwsState,
|
||||
updateAwsEnvironment,
|
||||
} from "../../../lib/tauri-commands";
|
||||
import { awsErrorMessage, toAwsError } from "../../../lib/aws-error";
|
||||
import { awsErrorMessage, looksDenied, toAwsError } from "../../../lib/aws-error";
|
||||
import { clearEc2CapacityCache } from "../../../lib/ec2Capacity";
|
||||
import type {
|
||||
AwsError,
|
||||
@@ -34,7 +34,7 @@ import AdminBundleModal from "./AdminBundleModal";
|
||||
import UpdateEnvironmentModal from "./UpdateEnvironmentModal";
|
||||
import DeployEnvironmentModal from "./DeployEnvironmentModal";
|
||||
import JoinEnvironmentModal from "./JoinEnvironmentModal";
|
||||
import DeployProgress, { runKey, useDeployRuns, type DeployRun } from "./DeployProgress";
|
||||
import DeployProgress, { runKey, useDeployRuns, type DeployRun, type RunKind } from "./DeployProgress";
|
||||
import PolicyFiles from "./PolicyFiles";
|
||||
import {
|
||||
COMMON_REGIONS,
|
||||
@@ -45,6 +45,7 @@ import {
|
||||
onboardingStateKey,
|
||||
stateLock,
|
||||
stateStatus,
|
||||
UNCONFIRMED_NOTE,
|
||||
} from "./environmentFormat";
|
||||
|
||||
/** A typed confirmation: the action runs only once the environment's name is typed. */
|
||||
@@ -118,6 +119,7 @@ type Bundle = {
|
||||
type JoinOf = {
|
||||
region: string;
|
||||
name: string;
|
||||
ownerId: string;
|
||||
stateKey: string;
|
||||
recorded: UserCompute | null;
|
||||
reapply: boolean;
|
||||
@@ -131,6 +133,21 @@ const recordedEc2 = (e: DetectedEnvironment): UserCompute | null =>
|
||||
/** A row-level key: the same environment name can exist in every region. */
|
||||
const rowKey = (region: string, name: string) => `${region}:${name}`;
|
||||
|
||||
/**
|
||||
* A failed new deploy or self-onboarding started here that AWS refused a
|
||||
* permission for: the bundle for an admin is the way on. Only those two
|
||||
* kinds: an environment bundle deploys a *new* environment, so a follow,
|
||||
* repair or update of an existing one is never offered it.
|
||||
*/
|
||||
function deniedRun(r: DeployRun): "environment" | "user_onboard" | null {
|
||||
if (r.kind !== "deploy" && r.kind !== "onboard") return null;
|
||||
if (!r.done || !r.result || r.result.ok) return null;
|
||||
const denied =
|
||||
looksDenied(r.result.summary) || r.events.some((e) => e.level === "error" && looksDenied(e.message));
|
||||
if (!denied) return null;
|
||||
return r.kind === "deploy" ? "environment" : "user_onboard";
|
||||
}
|
||||
|
||||
/** The environment a run's state key belongs to, if any. */
|
||||
function runEnvironment(stateKey: string): string | null {
|
||||
const m = /^(?:environments|users)\/([^/]+)\//.exec(stateKey);
|
||||
@@ -139,14 +156,16 @@ function runEnvironment(stateKey: string): string | null {
|
||||
|
||||
/**
|
||||
* The environments a connection can reach in a region (spec §2): detection,
|
||||
* each environment's state and actions, and deploy/join for this caller's tier.
|
||||
* each environment's state and actions, and deploy/join. Deploy and join are
|
||||
* offered to anyone (AWS has the last word and its refusal is shown); an
|
||||
* unconfirmed tier only adds a note and the bundle-for-an-admin alternative.
|
||||
*/
|
||||
export default function EnvironmentsPanel({
|
||||
connection,
|
||||
tier,
|
||||
}: {
|
||||
connection: HostConnection;
|
||||
/** The connection's last permission report; absent means unknown, treated as not an admin. */
|
||||
/** The connection's last permission report; absent means unknown (not confirmed as an admin). */
|
||||
tier?: PermissionSummary;
|
||||
}) {
|
||||
const isAdmin = tier === "environment_admin";
|
||||
@@ -176,6 +195,7 @@ export default function EnvironmentsPanel({
|
||||
// onboarding that didn't finish has no record to start from.
|
||||
const lastEc2 = useRef(new Map<string, Ec2Compute>());
|
||||
const [copyNote, setCopyNote] = useState<string | null>(null);
|
||||
const [notAdminOpen, setNotAdminOpen] = useState(false);
|
||||
const request = useRef(0);
|
||||
const followed = useRef(new Set<string>());
|
||||
|
||||
@@ -210,11 +230,18 @@ export default function EnvironmentsPanel({
|
||||
|
||||
/** Start a run in `runRegion` (always the region of the scan the action came from). */
|
||||
const launch = useCallback(
|
||||
async (runRegion: string, envName: string, stateKey: string, label: string, run: () => Promise<string>) => {
|
||||
async (
|
||||
runRegion: string,
|
||||
envName: string,
|
||||
stateKey: string,
|
||||
kind: RunKind,
|
||||
label: string,
|
||||
run: () => Promise<string>,
|
||||
) => {
|
||||
const rk = rowKey(runRegion, envName);
|
||||
setRowErrors(({ [rk]: _gone, ...rest }) => rest);
|
||||
setPending((p) => ({ ...p, [rk]: true }));
|
||||
const err = await start(stateKey, runRegion, label, run);
|
||||
const err = await start(stateKey, runRegion, kind, label, run);
|
||||
setPending(({ [rk]: _gone, ...rest }) => rest);
|
||||
if (err) setRowErrors((r) => ({ ...r, [rk]: err }));
|
||||
return err;
|
||||
@@ -230,7 +257,7 @@ export default function EnvironmentsPanel({
|
||||
const seen = runKey(scan.region, key);
|
||||
if (!runs[seen] && !followed.current.has(seen)) {
|
||||
followed.current.add(seen);
|
||||
void launch(scan.region, name, key, label, () => followAwsDeployment(connection.id, scan.region, key));
|
||||
void launch(scan.region, name, key, "follow", label, () => followAwsDeployment(connection.id, scan.region, key));
|
||||
}
|
||||
};
|
||||
for (const e of scan.environments) {
|
||||
@@ -261,50 +288,42 @@ export default function EnvironmentsPanel({
|
||||
const stale = detecting || !current;
|
||||
|
||||
const deploy = (runRegion: string, name: string, network: NetworkChoice, hours: number) =>
|
||||
launch(runRegion, name, environmentStateKey(name), `Deploy of ${name}`, () =>
|
||||
launch(runRegion, name, environmentStateKey(name), "deploy", `Deploy of ${name}`, () =>
|
||||
deployAwsEnvironment(connection.id, runRegion, name, network, hours),
|
||||
);
|
||||
// Without `hours`, the environment's recorded cap is kept.
|
||||
const repair = (runRegion: string, name: string, network?: NetworkChoice, hours?: number) =>
|
||||
launch(runRegion, name, environmentStateKey(name), `Repair of ${name}`, () =>
|
||||
launch(runRegion, name, environmentStateKey(name), "repair", `Repair of ${name}`, () =>
|
||||
repairAwsEnvironment(connection.id, runRegion, name, network, hours),
|
||||
);
|
||||
const update = (runRegion: string, name: string, hours: number) =>
|
||||
launch(runRegion, name, environmentStateKey(name), `Update of ${name}`, () =>
|
||||
launch(runRegion, name, environmentStateKey(name), "update", `Update of ${name}`, () =>
|
||||
updateAwsEnvironment(connection.id, runRegion, name, hours),
|
||||
);
|
||||
|
||||
// Join (or, once joined, a change of EC2 capacity): admins choose the
|
||||
// capacity and apply it themselves; others get a bundle for an admin.
|
||||
// Join (or, once joined, a change of EC2 capacity): anyone chooses the
|
||||
// capacity and applies it; the modal offers a bundle for an admin instead.
|
||||
const join = (found: EnvironmentScan, e: DetectedEnvironment) => {
|
||||
const recorded = recordedEc2(e);
|
||||
if (isAdmin) {
|
||||
setJoinOf({
|
||||
region: found.region,
|
||||
name: e.name,
|
||||
stateKey: onboardingStateKey(e.name, found.owner_key),
|
||||
recorded,
|
||||
reapply: e.onboarding?.state === "joined",
|
||||
incomplete: e.onboarding?.state === "incomplete",
|
||||
lastChoice: lastEc2.current.get(rowKey(found.region, e.name)) ?? null,
|
||||
});
|
||||
} else {
|
||||
setBundle({
|
||||
kind: "user_onboard",
|
||||
region: found.region,
|
||||
environment: e.name,
|
||||
ownerId: found.owner_id,
|
||||
recordedEc2: recorded,
|
||||
});
|
||||
}
|
||||
setJoinOf({
|
||||
region: found.region,
|
||||
name: e.name,
|
||||
ownerId: found.owner_id,
|
||||
stateKey: onboardingStateKey(e.name, found.owner_key),
|
||||
recorded: recordedEc2(e),
|
||||
reapply: e.onboarding?.state === "joined",
|
||||
incomplete: e.onboarding?.state === "incomplete",
|
||||
lastChoice: lastEc2.current.get(rowKey(found.region, e.name)) ?? null,
|
||||
});
|
||||
};
|
||||
const onboardBundle = (region: string, environment: string, ownerId: string, recorded: UserCompute | null) =>
|
||||
setBundle({ kind: "user_onboard", region, environment, ownerId, recordedEc2: recorded });
|
||||
const runJoin = (j: JoinOf, ec2: Ec2Choice) => {
|
||||
const key = rowKey(j.region, j.name);
|
||||
if (ec2.kind === "ec2") {
|
||||
const { kind: _kind, ...c } = ec2;
|
||||
lastEc2.current.set(key, c);
|
||||
} else lastEc2.current.delete(key);
|
||||
return launch(j.region, j.name, j.stateKey, `Joining ${j.name}`, () => onboardAwsUser(connection.id, j.region, j.name, ec2));
|
||||
return launch(j.region, j.name, j.stateKey, "onboard", `Joining ${j.name}`, () => onboardAwsUser(connection.id, j.region, j.name, ec2));
|
||||
};
|
||||
|
||||
const rowRuns = (name: string) =>
|
||||
@@ -313,14 +332,40 @@ export default function EnvironmentsPanel({
|
||||
const looseRuns = Object.values(runs).filter(
|
||||
(r) => r.region !== current?.region || !shown.has(runEnvironment(r.stateKey) ?? ""),
|
||||
);
|
||||
const progress = (r: DeployRun) => (
|
||||
<DeployProgress
|
||||
key={runKey(r.region, r.stateKey)}
|
||||
run={r}
|
||||
connectionId={connection.id}
|
||||
onDismiss={() => dismiss(runKey(r.region, r.stateKey))}
|
||||
/>
|
||||
);
|
||||
const progress = (r: DeployRun) => {
|
||||
const denied = deniedRun(r);
|
||||
const env = runEnvironment(r.stateKey);
|
||||
const found = current?.region === r.region ? current : null;
|
||||
const target = env && found ? found.environments.find((e) => e.name === env) : undefined;
|
||||
const offer =
|
||||
denied === "environment" ? true : denied === "user_onboard" ? !!(found && target) : false;
|
||||
return (
|
||||
<div key={runKey(r.region, r.stateKey)} className="space-y-1.5 min-w-0">
|
||||
<DeployProgress run={r} connectionId={connection.id} onDismiss={() => dismiss(runKey(r.region, r.stateKey))} />
|
||||
{offer && (
|
||||
<div className="space-y-1.5 text-xs text-[var(--text-secondary)] leading-snug" data-testid="denied-hint">
|
||||
<p className="break-words">
|
||||
AWS refused a permission this run needs (its message is above). This may need an admin:{" "}
|
||||
{denied === "environment"
|
||||
? "An admin can deploy the environment for you from a bundle."
|
||||
: "An admin can onboard you from a bundle."}
|
||||
</p>
|
||||
<Button
|
||||
size="sm"
|
||||
wrap
|
||||
onClick={() =>
|
||||
denied === "environment"
|
||||
? setBundle({ kind: "environment", region: r.region })
|
||||
: found && target && onboardBundle(r.region, target.name, found.owner_id, recordedEc2(target))
|
||||
}
|
||||
>
|
||||
Save a bundle for an admin…
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const envRow = (found: EnvironmentScan, e: DetectedEnvironment) => {
|
||||
const at = found.region;
|
||||
@@ -349,10 +394,10 @@ export default function EnvironmentsPanel({
|
||||
data-testid={`env-${e.name}`}
|
||||
className="border border-[var(--border-color)] rounded-[var(--radius-control)] p-2 space-y-1.5"
|
||||
>
|
||||
<div className="flex items-start justify-between gap-2 flex-wrap">
|
||||
<div className="min-w-0 space-y-0.5 text-xs">
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<span className="text-[13px] font-medium text-[var(--text-primary)]">{e.name}</span>
|
||||
<div className="flex items-start justify-between gap-2 flex-wrap" data-testid={`env-row-${e.name}`}>
|
||||
<div className="min-w-0 flex-1 basis-40 space-y-0.5 text-xs break-words">
|
||||
<div className="flex items-center gap-2 flex-wrap min-w-0">
|
||||
<span className="text-[13px] font-medium text-[var(--text-primary)] break-all">{e.name}</span>
|
||||
<StatusIndicator tone={status.tone} label={status.label} />
|
||||
{onboarding === "joined" && <StatusIndicator tone="ok" label="Joined" />}
|
||||
{onboarding === "in_progress" && <StatusIndicator tone="busy" label="Onboarding in progress" />}
|
||||
@@ -407,11 +452,11 @@ export default function EnvironmentsPanel({
|
||||
})()}
|
||||
</div>
|
||||
)}
|
||||
{!isAdmin && isWaiting && onboarding !== "joined" && (
|
||||
{isWaiting && onboarding !== "joined" && (
|
||||
<div className="text-[var(--text-secondary)]">Waiting for an admin to onboard you</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex gap-1.5 flex-wrap">
|
||||
<div className="flex gap-1.5 flex-wrap min-w-0 max-w-full" data-testid={`env-actions-${e.name}`}>
|
||||
{has("join") && onboarding !== "joined" && onboarding !== "in_progress" && (
|
||||
<Button
|
||||
size="sm"
|
||||
@@ -420,17 +465,18 @@ export default function EnvironmentsPanel({
|
||||
aria-label={`Join ${e.name}`}
|
||||
onClick={() => join(found, e)}
|
||||
>
|
||||
{!isAdmin && isWaiting ? "Show onboarding bundle" : "Join"}
|
||||
Join
|
||||
</Button>
|
||||
)}
|
||||
{has("join") && onboarding === "joined" && (
|
||||
<Button
|
||||
size="sm"
|
||||
wrap
|
||||
disabled={busy || joinBlocked}
|
||||
aria-label={`EC2 capacity in ${e.name}`}
|
||||
onClick={() => join(found, e)}
|
||||
>
|
||||
{isAdmin ? "Change EC2 capacity" : "EC2 capacity bundle"}
|
||||
Change EC2 capacity
|
||||
</Button>
|
||||
)}
|
||||
{mine("follow") && (
|
||||
@@ -439,7 +485,7 @@ export default function EnvironmentsPanel({
|
||||
disabled={busy}
|
||||
aria-label={`Follow my onboarding to ${e.name}`}
|
||||
onClick={() =>
|
||||
void launch(at, e.name, myKey, `Joining ${e.name}`, () => followAwsDeployment(connection.id, at, myKey))
|
||||
void launch(at, e.name, myKey, "follow", `Joining ${e.name}`, () => followAwsDeployment(connection.id, at, myKey))
|
||||
}
|
||||
>
|
||||
Follow
|
||||
@@ -451,7 +497,7 @@ export default function EnvironmentsPanel({
|
||||
disabled={busy}
|
||||
aria-label={`Push saved state of my onboarding to ${e.name}`}
|
||||
onClick={() =>
|
||||
void launch(at, e.name, myKey, `Push of the saved state of joining ${e.name}`, () =>
|
||||
void launch(at, e.name, myKey, "push", `Push of the saved state of joining ${e.name}`, () =>
|
||||
pushAwsSavedState(connection.id, at, myKey),
|
||||
)
|
||||
}
|
||||
@@ -477,7 +523,7 @@ export default function EnvironmentsPanel({
|
||||
aria-label={`Push saved state of ${e.name}`}
|
||||
onClick={() => {
|
||||
const key = environmentStateKey(e.name);
|
||||
void launch(at, e.name, key, `Push of the saved state of ${e.name}`, () =>
|
||||
void launch(at, e.name, key, "push", `Push of the saved state of ${e.name}`, () =>
|
||||
pushAwsSavedState(connection.id, at, key),
|
||||
);
|
||||
}}
|
||||
@@ -492,7 +538,7 @@ export default function EnvironmentsPanel({
|
||||
aria-label={`Follow ${e.name}`}
|
||||
onClick={() => {
|
||||
const key = environmentStateKey(e.name);
|
||||
void launch(at, e.name, key, `Deploy of ${e.name}`, () => followAwsDeployment(connection.id, at, key));
|
||||
void launch(at, e.name, key, "follow", `Deploy of ${e.name}`, () => followAwsDeployment(connection.id, at, key));
|
||||
}}
|
||||
>
|
||||
Follow
|
||||
@@ -548,7 +594,7 @@ export default function EnvironmentsPanel({
|
||||
</div>
|
||||
</div>
|
||||
{rowError && (
|
||||
<p role="alert" className="text-xs text-[var(--error)] leading-snug">
|
||||
<p role="alert" className="text-xs text-[var(--error)] leading-snug break-words">
|
||||
{awsErrorMessage(rowError)}
|
||||
</p>
|
||||
)}
|
||||
@@ -560,14 +606,14 @@ export default function EnvironmentsPanel({
|
||||
const nothingFound = !!current && current.environments.length === 0;
|
||||
|
||||
return (
|
||||
<div className="pt-1.5 space-y-2">
|
||||
<div className="pt-1.5 space-y-2 min-w-0">
|
||||
<Button size="sm" variant="ghost" aria-expanded={open} onClick={() => setOpen((o) => !o)}>
|
||||
<span aria-hidden="true">{open ? "▾" : "▸"}</span>
|
||||
Environments
|
||||
</Button>
|
||||
{open && (
|
||||
<div className="space-y-2 pl-1">
|
||||
<div className="flex items-end gap-2 flex-wrap">
|
||||
<div className="space-y-2 pl-1 min-w-0">
|
||||
<div className="flex items-end gap-2 flex-wrap min-w-0" data-testid="region-row">
|
||||
<Field label="Region">
|
||||
{(id) => (
|
||||
<select id={id} className={selectClass} value={region} onChange={(e) => setRegion(e.target.value)}>
|
||||
@@ -589,11 +635,11 @@ export default function EnvironmentsPanel({
|
||||
</p>
|
||||
)}
|
||||
{detectError && (
|
||||
<p role="alert" className="text-xs text-[var(--error)] leading-snug">
|
||||
<p role="alert" className="text-xs text-[var(--error)] leading-snug break-words">
|
||||
{awsErrorMessage(detectError)}
|
||||
</p>
|
||||
)}
|
||||
{current && isAdmin && current.boundary === "no" && (
|
||||
{current && current.boundary === "no" && (
|
||||
<p className="text-xs text-[var(--text-secondary)] leading-snug">
|
||||
This account has no Triple-C permissions boundary yet; deploying creates it first.
|
||||
</p>
|
||||
@@ -604,32 +650,54 @@ export default function EnvironmentsPanel({
|
||||
{nothingFound && (
|
||||
<p className="text-xs text-[var(--text-secondary)] leading-snug">
|
||||
No Triple-C environment in {current.region}.
|
||||
{!isAdmin &&
|
||||
" Deploying one needs an environment admin: attach the environment-admin policies to an identity, or send an admin a bundle to deploy."}
|
||||
{!tier && " Run Check to find out whether you can deploy one yourself."}
|
||||
{!tier && " Run Check to see what your credentials can do."}
|
||||
</p>
|
||||
)}
|
||||
{current && isAdmin && (
|
||||
<Button
|
||||
size="md"
|
||||
variant={nothingFound ? "primary" : "secondary"}
|
||||
disabled={stale}
|
||||
onClick={() => setDeployOpen(true)}
|
||||
>
|
||||
Deploy a new environment
|
||||
</Button>
|
||||
)}
|
||||
{nothingFound && !isAdmin && (
|
||||
<div className="space-y-2">
|
||||
<PolicyFiles tier="environment_admin" label="Show the environment-admin policies" onCopy={copy} />
|
||||
<Button size="md" disabled={stale} onClick={() => setBundle({ kind: "environment", region: current.region })}>
|
||||
Request an environment from an admin…
|
||||
{current && (
|
||||
<div className="space-y-1.5 min-w-0" data-testid="deploy-section">
|
||||
<Button
|
||||
size="md"
|
||||
wrap
|
||||
variant={nothingFound ? "primary" : "secondary"}
|
||||
disabled={stale}
|
||||
onClick={() => setDeployOpen(true)}
|
||||
>
|
||||
Deploy a new environment
|
||||
</Button>
|
||||
{copyNote && (
|
||||
<p role="status" className="text-xs text-[var(--text-secondary)]">
|
||||
{copyNote}
|
||||
{!isAdmin && (
|
||||
<p className="text-xs text-[var(--text-secondary)] leading-snug break-words" data-testid="deploy-unconfirmed-note">
|
||||
{UNCONFIRMED_NOTE}
|
||||
</p>
|
||||
)}
|
||||
{!isAdmin && (
|
||||
<details
|
||||
className="text-xs min-w-0"
|
||||
data-testid="not-admin-options"
|
||||
open={notAdminOpen}
|
||||
onToggle={(ev) => setNotAdminOpen(ev.currentTarget.open)}
|
||||
>
|
||||
<summary className="cursor-pointer list-none [&::-webkit-details-marker]:hidden text-[var(--text-primary)] break-words">
|
||||
<span aria-hidden="true" className="mr-1">{notAdminOpen ? "▾" : "▸"}</span>
|
||||
Not an admin? Ask one to deploy it
|
||||
</summary>
|
||||
<div className="mt-1.5 space-y-2 min-w-0">
|
||||
<Button
|
||||
size="sm"
|
||||
wrap
|
||||
disabled={stale}
|
||||
onClick={() => setBundle({ kind: "environment", region: current.region })}
|
||||
>
|
||||
Request an environment from an admin…
|
||||
</Button>
|
||||
<PolicyFiles tier="environment_admin" label="Show the environment-admin policies" onCopy={copy} />
|
||||
{copyNote && (
|
||||
<p role="status" className="text-xs text-[var(--text-secondary)] break-words">
|
||||
{copyNote}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</details>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{looseRuns.map(progress)}
|
||||
@@ -649,6 +717,12 @@ export default function EnvironmentsPanel({
|
||||
repairOf ? repair(current.region, name, network, hours) : deploy(current.region, name, network, hours)
|
||||
}
|
||||
onDetect={() => void detect()}
|
||||
onBundle={() => {
|
||||
const at = current.region;
|
||||
setDeployOpen(false);
|
||||
setRepairOf(null);
|
||||
setBundle({ kind: "environment", region: at });
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{updateOf && (
|
||||
@@ -667,7 +741,7 @@ export default function EnvironmentsPanel({
|
||||
confirmLabel="Destroy"
|
||||
onClose={() => setDestroyOf(null)}
|
||||
onConfirm={() =>
|
||||
launch(destroyOf.region, destroyOf.name, environmentStateKey(destroyOf.name), `Destroy of ${destroyOf.name}`, () =>
|
||||
launch(destroyOf.region, destroyOf.name, environmentStateKey(destroyOf.name), "destroy", `Destroy of ${destroyOf.name}`, () =>
|
||||
destroyIncompleteAwsEnvironment(connection.id, destroyOf.region, destroyOf.name),
|
||||
)
|
||||
}
|
||||
@@ -718,6 +792,12 @@ export default function EnvironmentsPanel({
|
||||
reapply={joinOf.reapply}
|
||||
incomplete={joinOf.incomplete}
|
||||
lastChoice={joinOf.lastChoice}
|
||||
confirmedAdmin={isAdmin}
|
||||
onBundle={() => {
|
||||
const j = joinOf;
|
||||
setJoinOf(null);
|
||||
onboardBundle(j.region, j.name, j.ownerId, j.recorded);
|
||||
}}
|
||||
onJoin={(ec2) => runJoin(joinOf, ec2)}
|
||||
onClose={() => setJoinOf(null)}
|
||||
/>
|
||||
|
||||
@@ -4,12 +4,13 @@ import type { AwsError, Ec2Choice, Ec2Compute, UserCompute } from "../../../lib/
|
||||
import Button from "../../ui/Button";
|
||||
import Modal from "../../ui/Modal";
|
||||
import Ec2CapacityFields from "./Ec2CapacityFields";
|
||||
import { ec2DraftFrom, ec2FromDraft, type Ec2Draft } from "./environmentFormat";
|
||||
import { ec2DraftFrom, ec2FromDraft, UNCONFIRMED_NOTE, type Ec2Draft } from "./environmentFormat";
|
||||
|
||||
/**
|
||||
* Self-onboarding (environment admins): join an environment, or re-apply an
|
||||
* onboarding to change its EC2 capacity. Starts from the recorded capacity,
|
||||
* so a re-apply keeps it unless changed.
|
||||
* Self-onboarding: join an environment, or re-apply an onboarding to change
|
||||
* its EC2 capacity. Starts from the recorded capacity, so a re-apply keeps it
|
||||
* unless changed. Open to anyone: AWS refuses the run when a permission is
|
||||
* missing, and an onboarding bundle for an admin is the alternative.
|
||||
*/
|
||||
export default function JoinEnvironmentModal({
|
||||
environment,
|
||||
@@ -18,6 +19,8 @@ export default function JoinEnvironmentModal({
|
||||
reapply,
|
||||
incomplete = false,
|
||||
lastChoice = null,
|
||||
confirmedAdmin = true,
|
||||
onBundle,
|
||||
onJoin,
|
||||
onClose,
|
||||
}: {
|
||||
@@ -33,6 +36,10 @@ export default function JoinEnvironmentModal({
|
||||
/** The EC2 capacity last chosen here in this run of the app, if any:
|
||||
* the starting point when there is no record. */
|
||||
lastChoice?: Ec2Compute | null;
|
||||
/** The permission check confirmed environment-admin rights; otherwise a note says AWS may refuse. */
|
||||
confirmedAdmin?: boolean;
|
||||
/** Switch to an onboarding bundle for an admin instead. */
|
||||
onBundle?: () => void;
|
||||
/** Starts the run; resolves to the command's error, or null once started. */
|
||||
onJoin: (ec2: Ec2Choice) => Promise<AwsError | null>;
|
||||
onClose: () => void;
|
||||
@@ -73,6 +80,7 @@ export default function JoinEnvironmentModal({
|
||||
>
|
||||
<div className="space-y-3 text-xs text-[var(--text-secondary)] leading-snug">
|
||||
{!reapply && <p>Joining creates your own task role and file system in {environment}.</p>}
|
||||
{!confirmedAdmin && <p data-testid="join-unconfirmed-note">{UNCONFIRMED_NOTE}</p>}
|
||||
{recorded && (
|
||||
<p>Stop your EC2 workspaces before removing EC2 capacity or changing your triple-c-user value: that change can't finish while one runs.</p>
|
||||
)}
|
||||
@@ -89,10 +97,22 @@ export default function JoinEnvironmentModal({
|
||||
</p>
|
||||
)}
|
||||
{error && (
|
||||
<p role="alert" className="text-[var(--error)]">
|
||||
<p role="alert" className="text-[var(--error)] break-words">
|
||||
{awsErrorMessage(error)}
|
||||
</p>
|
||||
)}
|
||||
{onBundle && (
|
||||
<div className="space-y-1.5 pt-1 border-t border-[var(--border-color)]">
|
||||
<p>
|
||||
{error?.kind === "access_denied"
|
||||
? "AWS refused this with your permissions. An admin can onboard you from a bundle instead."
|
||||
: "Can't onboard yourself? An admin can onboard you from a bundle."}
|
||||
</p>
|
||||
<Button size="sm" wrap onClick={onBundle}>
|
||||
Save an onboarding bundle for an admin…
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
|
||||
@@ -28,6 +28,7 @@ export default function NetworkFields({
|
||||
<div className="text-[13px] font-medium text-[var(--text-primary)]">Network</div>
|
||||
<SegmentedControl<NetworkChoice["mode"]>
|
||||
label="Network"
|
||||
className="flex-wrap max-w-full"
|
||||
value={value.mode}
|
||||
onChange={(mode) => set({ mode })}
|
||||
segments={[
|
||||
|
||||
@@ -28,12 +28,12 @@ export default function PolicyFiles({
|
||||
|
||||
if (!files) {
|
||||
return (
|
||||
<div className="space-y-1">
|
||||
<Button size="sm" onClick={load}>
|
||||
<div className="space-y-1 min-w-0">
|
||||
<Button size="sm" wrap onClick={load}>
|
||||
{label}
|
||||
</Button>
|
||||
{error && (
|
||||
<p role="alert" className="text-xs text-[var(--error)]">
|
||||
<p role="alert" className="text-xs text-[var(--error)] break-words">
|
||||
{error}
|
||||
</p>
|
||||
)}
|
||||
@@ -41,30 +41,38 @@ export default function PolicyFiles({
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div className="space-y-1 text-xs">
|
||||
<p className="text-[var(--text-secondary)]">
|
||||
<div className="space-y-1.5 text-xs min-w-0">
|
||||
<p className="text-[var(--text-secondary)] leading-snug break-words">
|
||||
{tier === "workspace_user" ? "Workspace user" : "Environment admin"}:{" "}
|
||||
{files.length === 1
|
||||
? "attach this file as a customer managed policy."
|
||||
: `Attach all ${files.length} files, each as its own customer managed policy.`}
|
||||
</p>
|
||||
{/* One copy button per file, in a grid that drops to one column when narrow. */}
|
||||
<div data-testid="policy-copy-grid" className="grid gap-1.5 grid-cols-[repeat(auto-fill,minmax(9rem,1fr))]">
|
||||
{files.map((f) => (
|
||||
<Button
|
||||
key={f.name}
|
||||
size="sm"
|
||||
wrap
|
||||
className="w-full justify-start break-all"
|
||||
aria-label={`Copy ${f.name}`}
|
||||
onClick={() => onCopy(f)}
|
||||
>
|
||||
Copy <span className="font-mono">{f.name}</span>
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
{files.map((f) => (
|
||||
<div key={f.name} className="space-y-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="font-mono text-[var(--text-primary)]">{f.name}</span>
|
||||
<Button size="sm" aria-label={`Copy ${f.name}`} onClick={() => onCopy(f)}>
|
||||
Copy
|
||||
</Button>
|
||||
</div>
|
||||
<details>
|
||||
<summary className="cursor-pointer text-[var(--text-secondary)]">Show JSON</summary>
|
||||
<pre className="mt-1 max-h-48 overflow-auto whitespace-pre-wrap break-all text-[var(--text-secondary)]">
|
||||
{f.json}
|
||||
</pre>
|
||||
</details>
|
||||
</div>
|
||||
<details key={f.name} className="min-w-0">
|
||||
<summary className="cursor-pointer text-[var(--text-secondary)] break-all">
|
||||
Show JSON of <span className="font-mono">{f.name}</span>
|
||||
</summary>
|
||||
<pre className="mt-1 max-h-48 max-w-full overflow-auto whitespace-pre-wrap break-all text-[var(--text-secondary)]">
|
||||
{f.json}
|
||||
</pre>
|
||||
</details>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -143,3 +143,7 @@ export function computeLine(c: UserCompute): string {
|
||||
const n = c.max_instances === 1 ? "1 instance" : `up to ${c.max_instances} instances`;
|
||||
return `${c.instance_type}, ${n} (triple-c-user ${c.user_tag})`;
|
||||
}
|
||||
|
||||
/** Shown under an action whose permissions the check didn't confirm: AWS has the last word. */
|
||||
export const UNCONFIRMED_NOTE =
|
||||
"Your permission check didn't confirm environment-admin rights; the deploy will stop with AWS's message if a permission is missing.";
|
||||
@@ -74,4 +74,23 @@ describe("Button", () => {
|
||||
fireEvent.click(button);
|
||||
expect(onClick).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("wraps a long label only when asked", () => {
|
||||
render(
|
||||
<>
|
||||
<Button>Short</Button>
|
||||
<Button wrap size="md">
|
||||
Request an environment from an admin…
|
||||
</Button>
|
||||
</>,
|
||||
);
|
||||
const plain = screen.getByRole("button", { name: "Short" });
|
||||
expect(plain.className).toContain("whitespace-nowrap");
|
||||
expect(plain.className).toContain("h-6");
|
||||
const long = screen.getByRole("button", { name: "Request an environment from an admin…" });
|
||||
expect(long.className).toContain("whitespace-normal");
|
||||
expect(long.className).toContain("min-h-8");
|
||||
expect(long.className).toContain("max-w-full");
|
||||
expect(long.className).not.toMatch(/(^|\s)h-8(\s|$)/);
|
||||
});
|
||||
});
|
||||
@@ -19,6 +19,11 @@ interface Props extends ButtonHTMLAttributes<HTMLButtonElement> {
|
||||
unavailable?: boolean;
|
||||
/** Why the button cannot be used. Required for `unavailable` to say anything. */
|
||||
unavailableReason?: string;
|
||||
/**
|
||||
* Let a long label wrap onto more lines instead of forcing the button (and
|
||||
* its row) wider than a narrow container, such as the settings sidebar.
|
||||
*/
|
||||
wrap?: boolean;
|
||||
/** React 19 passes `ref` as a prop; it lands on the `<button>` via `rest`. */
|
||||
ref?: Ref<HTMLButtonElement>;
|
||||
}
|
||||
@@ -48,6 +53,12 @@ const SIZES: Record<ButtonSize, string> = {
|
||||
md: "h-8 px-3 text-[13px] gap-1.5",
|
||||
};
|
||||
|
||||
/** `wrap`: the same sizes as a minimum height, so a second line can grow the button. */
|
||||
const WRAP_SIZES: Record<ButtonSize, string> = {
|
||||
sm: "min-h-6 py-0.5 px-2 text-xs gap-1",
|
||||
md: "min-h-8 py-1 px-3 text-[13px] gap-1.5",
|
||||
};
|
||||
|
||||
export default function Button({
|
||||
variant = "secondary",
|
||||
size = "sm",
|
||||
@@ -55,6 +66,7 @@ export default function Button({
|
||||
type = "button",
|
||||
unavailable = false,
|
||||
unavailableReason = "",
|
||||
wrap = false,
|
||||
children,
|
||||
...rest
|
||||
}: Props) {
|
||||
@@ -71,7 +83,7 @@ export default function Button({
|
||||
type={type}
|
||||
{...rest}
|
||||
{...controlProps}
|
||||
className={`inline-flex items-center justify-center whitespace-nowrap rounded-[var(--radius-control)] font-medium transition-colors disabled:cursor-not-allowed aria-disabled:cursor-not-allowed ${SIZES[size]} ${VARIANTS[variant]} ${className}`}
|
||||
className={`inline-flex items-center justify-center ${wrap ? `whitespace-normal break-words text-left max-w-full min-w-0 ${WRAP_SIZES[size]}` : `whitespace-nowrap ${SIZES[size]}`} rounded-[var(--radius-control)] font-medium transition-colors disabled:cursor-not-allowed aria-disabled:cursor-not-allowed ${VARIANTS[variant]} ${className}`}
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
|
||||
@@ -208,7 +208,7 @@ export default function Modal({
|
||||
</div>
|
||||
|
||||
{footer && (
|
||||
<div className="flex items-center justify-end gap-2 px-5 py-3 border-t border-[var(--border-color)] flex-shrink-0">
|
||||
<div className="flex flex-wrap items-center justify-end gap-2 px-5 py-3 border-t border-[var(--border-color)] flex-shrink-0">
|
||||
{footer}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -53,6 +53,8 @@ interface Props {
|
||||
iconOnly?: boolean;
|
||||
className?: string;
|
||||
title?: string;
|
||||
/** Let a long label (a failure summary) wrap instead of overflowing its container. */
|
||||
wrap?: boolean;
|
||||
}
|
||||
|
||||
export default function StatusIndicator({
|
||||
@@ -61,11 +63,12 @@ export default function StatusIndicator({
|
||||
iconOnly = false,
|
||||
className = "",
|
||||
title,
|
||||
wrap = false,
|
||||
}: Props) {
|
||||
const style = TONES[tone];
|
||||
return (
|
||||
<span
|
||||
className={`inline-flex items-center gap-1 whitespace-nowrap ${className}`}
|
||||
className={`inline-flex gap-1 ${wrap ? "items-baseline whitespace-normal break-words min-w-0 max-w-full" : "items-center whitespace-nowrap"} ${className}`}
|
||||
title={title ?? label}
|
||||
>
|
||||
<span
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { awsErrorMessage, toAwsError } from "./aws-error";
|
||||
import { awsErrorMessage, looksDenied, toAwsError } from "./aws-error";
|
||||
|
||||
describe("toAwsError", () => {
|
||||
it("passes a tagged AwsError through", () => {
|
||||
@@ -21,3 +21,21 @@ describe("toAwsError", () => {
|
||||
expect(toAwsError(null).kind).toBe("other");
|
||||
});
|
||||
});
|
||||
|
||||
describe("access denied", () => {
|
||||
it("shows AWS's message, naming the action when the message doesn't", () => {
|
||||
expect(awsErrorMessage({ kind: "access_denied", action: "iam:CreateRole", message: "User: x is not authorized" })).toBe(
|
||||
"AWS denied iam:CreateRole: User: x is not authorized",
|
||||
);
|
||||
expect(awsErrorMessage({ kind: "access_denied", action: "s3:PutObject", message: "denied s3:PutObject" })).toBe(
|
||||
"AWS denied this request: denied s3:PutObject",
|
||||
);
|
||||
});
|
||||
it("recognises refusals in OpenTofu output", () => {
|
||||
expect(looksDenied("Error: creating IAM Role: AccessDenied: User is not authorized")).toBe(true);
|
||||
expect(looksDenied("api error UnauthorizedOperation: You are not authorized")).toBe(true);
|
||||
expect(looksDenied("Error: creating VPC: VpcLimitExceeded")).toBe(false);
|
||||
expect(looksDenied(null)).toBe(false);
|
||||
expect(looksDenied("blocked by an explicit deny in a service control policy")).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -34,7 +34,22 @@ export function awsErrorMessage(e: AwsError): string {
|
||||
return "The access keys for this connection are missing from the keychain. Remove and re-add the connection.";
|
||||
case "state_bucket_taken":
|
||||
return `The state bucket name ${e.bucket} is already taken by another AWS account.`;
|
||||
case "access_denied":
|
||||
// AWS's own message, named by the action when it doesn't already say it.
|
||||
return e.action && !e.message.includes(e.action)
|
||||
? `AWS denied ${e.action}: ${e.message}`
|
||||
: `AWS denied this request: ${e.message}`;
|
||||
default:
|
||||
return e.message;
|
||||
}
|
||||
}
|
||||
|
||||
// The codes `aws::error` maps to access_denied, and how AWS words a refusal in
|
||||
// OpenTofu's output. A bare "explicit deny" is left out: an SCP or bucket
|
||||
// policy deny isn't something an admin bundle fixes.
|
||||
const DENIED = /AccessDenied|UnauthorizedOperation|not authorized to perform/i;
|
||||
|
||||
/** Whether a line of OpenTofu output (or a run's summary) reads as AWS refusing a permission. */
|
||||
export function looksDenied(text: string | null | undefined): boolean {
|
||||
return !!text && DENIED.test(text);
|
||||
}
|
||||
@@ -1,154 +0,0 @@
|
||||
# build-ssm-plugin.ps1 - build AWS's session-manager-plugin FROM SOURCE for
|
||||
# Windows and put it where Tauri's bundle.externalBin expects it:
|
||||
#
|
||||
# app\src-tauri\binaries\session-manager-plugin-x86_64-pc-windows-msvc.exe
|
||||
#
|
||||
# The Windows runner's half of scripts/build-ssm-plugin.sh - read that header
|
||||
# for the why. The same pins and the same build, so it must produce the same
|
||||
# bytes (Go builds are reproducible across hosts); keep the two in step.
|
||||
#
|
||||
# 1. Source: AWS's tag 1.2.896.0 by COMMIT, as GitHub's archive of that
|
||||
# commit, SHA-256 checked before extraction (and its top directory must
|
||||
# name the commit).
|
||||
# 2. Toolchain: Go, pinned, SHA-256 as published by go.dev, checked before use.
|
||||
# 3. AWS's own build (GOPATH mode over the vendored deps, -ldflags "-s -w"),
|
||||
# version stamped to the tag, made reproducible (-trimpath, no VCS stamp,
|
||||
# empty build id, CGO off, GOAMD64=v1, nothing inherited).
|
||||
# 4. The output must equal the pinned SHA-256.
|
||||
#
|
||||
# The result is UNSIGNED: in a release build Tauri presents it to the sign
|
||||
# command (windows-sign.ps1 signs it with our certificate), and
|
||||
# windows-verify-signatures.ps1 requires our signature on it in both installers.
|
||||
#
|
||||
# Needs tar.exe (bsdtar, in every Windows 10+). Idempotent.
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
|
||||
$PluginVersion = '1.2.896.0'
|
||||
$PluginCommit = '6430675a44032a551be1937fb27a2d3fdfeb27f7'
|
||||
$SourceUrl = "https://codeload.github.com/aws/session-manager-plugin/tar.gz/$PluginCommit"
|
||||
$SourceSha = '7C95BE411AD5F43D14D01460500BFD5A5AA0E28BA94815F8B049AF33A2C381B0'
|
||||
$GoVersion = '1.26.11'
|
||||
$GoSha = '71AE086F0137E665F855A811CC119152B6A783E0BBC1B906E709F46D80141EB0' # go1.26.11.windows-amd64.zip, go.dev
|
||||
$BinarySha = '6D428E5FD77E76D9713F0C42B8EC39F2DE1031E5F3C567FEB73C7FE11B14B226'
|
||||
$Triple = 'x86_64-pc-windows-msvc'
|
||||
|
||||
$repoRoot = Split-Path -Parent $PSScriptRoot
|
||||
$destDir = Join-Path $repoRoot 'app\src-tauri\binaries'
|
||||
$dest = Join-Path $destDir "session-manager-plugin-$Triple.exe"
|
||||
$notices = Join-Path $repoRoot 'app\src-tauri\THIRD_PARTY_NOTICES'
|
||||
|
||||
function Get-Sha256([string]$Path) { (Get-FileHash -LiteralPath $Path -Algorithm SHA256).Hash.ToUpperInvariant() }
|
||||
|
||||
if (-not ((Select-String -LiteralPath $notices -SimpleMatch "Version: $PluginVersion" -Quiet) -and
|
||||
(Select-String -LiteralPath $notices -SimpleMatch "Commit: $PluginCommit" -Quiet))) {
|
||||
throw "$notices does not name plugin $PluginVersion at $PluginCommit - update it with the bump"
|
||||
}
|
||||
|
||||
if ((Test-Path -LiteralPath $dest) -and ((Get-Sha256 $dest) -eq $BinarySha)) {
|
||||
Write-Host "session-manager-plugin-$Triple.exe: already the pinned $PluginVersion build"
|
||||
exit 0
|
||||
}
|
||||
|
||||
# A short work root, not %TEMP% (on the runner that is deep under
|
||||
# systemprofile): the longest extracted path is ~200 characters, and MAX_PATH
|
||||
# is 260 for Windows PowerShell 5.1, tar.exe and the Go build alike.
|
||||
$work = Join-Path "$env:SystemDrive\" ('ssm-' + [guid]::NewGuid().ToString('N').Substring(0, 8))
|
||||
New-Item -ItemType Directory -Path $work | Out-Null
|
||||
# A directory at the drive root inherits C:\'s ACL, where Authenticated Users
|
||||
# may create and modify files - another local user could swap the source, the
|
||||
# toolchain or the output between our checks and their use. So before anything
|
||||
# lands in it: no inheritance, full control for SYSTEM, Administrators and this
|
||||
# process's own user only. Mandatory on Windows; skipped only where there is no
|
||||
# Windows ACL (the Linux pwsh test path).
|
||||
if ($env:OS -eq 'Windows_NT') {
|
||||
$me = [Security.Principal.WindowsIdentity]::GetCurrent().User.Value
|
||||
& icacls.exe $work /inheritance:r /grant:r '*S-1-5-18:(OI)(CI)F' '*S-1-5-32-544:(OI)(CI)F' "*${me}:(OI)(CI)F" | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Remove-Item -LiteralPath $work -Recurse -Force -ErrorAction SilentlyContinue
|
||||
throw "icacls could not restrict $work ($LASTEXITCODE)"
|
||||
}
|
||||
}
|
||||
$ProgressPreference = 'SilentlyContinue'
|
||||
try {
|
||||
$goZip = Join-Path $work 'go.zip'
|
||||
Write-Host "Downloading Go $GoVersion (windows-amd64)"
|
||||
Invoke-WebRequest -Uri "https://go.dev/dl/go$GoVersion.windows-amd64.zip" -OutFile $goZip -UseBasicParsing
|
||||
$actual = Get-Sha256 $goZip
|
||||
if ($actual -ne $GoSha) { throw "SHA-256 mismatch for the Go toolchain: got $actual, pinned $GoSha" }
|
||||
[IO.Compression.ZipFile]::ExtractToDirectory($goZip, (Join-Path $work 'toolchain'))
|
||||
$go = Join-Path $work 'toolchain\go\bin\go.exe'
|
||||
|
||||
$srcTgz = Join-Path $work 'source.tar.gz'
|
||||
Write-Host "Downloading session-manager-plugin $PluginVersion source ($PluginCommit)"
|
||||
Invoke-WebRequest -Uri $SourceUrl -OutFile $srcTgz -UseBasicParsing
|
||||
$actual = Get-Sha256 $srcTgz
|
||||
if ($actual -ne $SourceSha) { throw "SHA-256 mismatch for the plugin source: got $actual, pinned $SourceSha" }
|
||||
$srcDir = Join-Path $work 'src'
|
||||
New-Item -ItemType Directory -Path $srcDir | Out-Null
|
||||
# Only what the build reads, as build-ssm-plugin.sh does: the vendored SDK's
|
||||
# Java codegen/ tree reaches 258 characters inside the archive, past
|
||||
# MAX_PATH, and its snapshot/ files are test data.
|
||||
& tar.exe --exclude='*/codegen/*' --exclude='*/snapshot/*' -xzf $srcTgz -C $srcDir
|
||||
if ($LASTEXITCODE -ne 0) { throw "tar.exe could not extract the source ($LASTEXITCODE)" }
|
||||
$goSpace = Join-Path $srcDir "session-manager-plugin-$PluginCommit"
|
||||
if (-not (Test-Path -LiteralPath (Join-Path $goSpace 'src\sessionmanagerplugin-main'))) {
|
||||
throw "the source archive is not the pinned commit's tree"
|
||||
}
|
||||
|
||||
# A clean, fully specified Go environment for everything below.
|
||||
foreach ($v in 'GOFLAGS', 'GOROOT', 'GOBIN', 'GOEXPERIMENT', 'GOTMPDIR') { Remove-Item "env:$v" -ErrorAction SilentlyContinue }
|
||||
$gopath = Join-Path $work 'gopath'
|
||||
$env:GOENV = 'off'; $env:GOTOOLCHAIN = 'local'; $env:GO111MODULE = 'off'; $env:GOPROXY = 'off'; $env:GOWORK = 'off'
|
||||
$env:GOPATH = "$gopath;$(Join-Path $goSpace 'vendor')"
|
||||
$env:GOCACHE = Join-Path $work 'cache'; $env:GOMODCACHE = Join-Path $work 'modcache'
|
||||
$env:CGO_ENABLED = '0'; $env:GOAMD64 = 'v1'; $env:GOARM64 = 'v8.0'
|
||||
|
||||
# makefile pre-build: stamp the version with AWS's own generator.
|
||||
[IO.File]::WriteAllText((Join-Path $goSpace 'VERSION'), $PluginVersion)
|
||||
# version-gen runs on this host, so no GOOS/GOARCH yet.
|
||||
Remove-Item env:GOOS, env:GOARCH -ErrorAction SilentlyContinue
|
||||
Push-Location $goSpace
|
||||
try { & $go run ./src/version/versiongenerator/version-gen.go | Out-Null } finally { Pop-Location }
|
||||
if ($LASTEXITCODE -ne 0) { throw "version-gen failed ($LASTEXITCODE)" }
|
||||
if (-not (Select-String -LiteralPath (Join-Path $goSpace 'src\version\version.go') -SimpleMatch "const Version = `"$PluginVersion`"" -Quiet)) {
|
||||
throw 'the version stamp did not take'
|
||||
}
|
||||
|
||||
# makefile copy-src: GOPATH mode, from a copy at the import path.
|
||||
$pkgRoot = Join-Path $gopath 'src\github.com\aws\session-manager-plugin'
|
||||
New-Item -ItemType Directory -Force -Path $pkgRoot | Out-Null
|
||||
Copy-Item -Recurse -LiteralPath (Join-Path $goSpace 'src') -Destination $pkgRoot
|
||||
|
||||
$out = Join-Path $work 'session-manager-plugin.exe'
|
||||
Write-Host "Building session-manager-plugin $PluginVersion for windows/amd64"
|
||||
$env:GOOS = 'windows'; $env:GOARCH = 'amd64'
|
||||
Push-Location $pkgRoot
|
||||
try {
|
||||
& $go build -trimpath -buildvcs=false -ldflags '-s -w -buildid=' -o $out `
|
||||
github.com/aws/session-manager-plugin/src/sessionmanagerplugin-main
|
||||
} finally { Pop-Location }
|
||||
if ($LASTEXITCODE -ne 0) { throw "go build failed ($LASTEXITCODE)" }
|
||||
$actual = Get-Sha256 $out
|
||||
if ($actual -ne $BinarySha) {
|
||||
throw "the windows/amd64 build is not the pinned binary: got $actual, pinned $BinarySha (source, toolchain or build flags changed)"
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $destDir | Out-Null
|
||||
Move-Item -LiteralPath $out -Destination $dest -Force
|
||||
# And what landed is still what was checked.
|
||||
$actual = Get-Sha256 $dest
|
||||
if ($actual -ne $BinarySha) {
|
||||
Remove-Item -LiteralPath $dest -Force -ErrorAction SilentlyContinue
|
||||
throw "$dest changed after it was verified: got $actual, pinned $BinarySha"
|
||||
}
|
||||
Write-Host "session-manager-plugin-$Triple.exe: session-manager-plugin $PluginVersion (unsigned; signed by the release build)"
|
||||
} finally {
|
||||
Remove-Item -LiteralPath $work -Recurse -Force -ErrorAction SilentlyContinue
|
||||
# PS 5.1's Remove-Item can give up on read-only files and deep trees;
|
||||
# rd /s /q is the fallback.
|
||||
if (Test-Path -LiteralPath $work) { cmd /c rd /s /q "`"$work`"" | Out-Null }
|
||||
if (Test-Path -LiteralPath $work) { Write-Warning "could not remove $work" }
|
||||
}
|
||||
@@ -1,233 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# build-ssm-plugin.sh [target-triple ...] - build AWS's session-manager-plugin
|
||||
# FROM SOURCE and put it where Tauri's `bundle.externalBin` expects it:
|
||||
#
|
||||
# app/src-tauri/binaries/session-manager-plugin-<target-triple>[.exe]
|
||||
#
|
||||
# The app runs the plugin to connect to workspaces on AWS; bundling it means
|
||||
# users do not have to install it. We build it ourselves from AWS's Apache-2.0
|
||||
# source (github.com/aws/session-manager-plugin) rather than redistributing
|
||||
# AWS's prebuilt binaries, which AWS ships as "AWS Content" under the AWS
|
||||
# Customer Agreement.
|
||||
#
|
||||
# With no argument the host's triple is used (`rustc -vV`). Every target is a
|
||||
# pure-Go cross-compile (CGO_ENABLED=0), so any host can build any of them; CI
|
||||
# builds each platform's own targets in its own job. scripts/build-ssm-plugin.ps1
|
||||
# is the same build for the Windows runner, which has no bash.
|
||||
#
|
||||
# Supported triples:
|
||||
# x86_64-unknown-linux-gnu linux/amd64
|
||||
# aarch64-unknown-linux-gnu linux/arm64
|
||||
# x86_64-apple-darwin darwin/amd64
|
||||
# aarch64-apple-darwin darwin/arm64
|
||||
# universal-apple-darwin both darwin slices plus the two thin files,
|
||||
# joined with lipo (`tauri build --target
|
||||
# universal-apple-darwin` compiles each arch and
|
||||
# tauri-build wants each arch's sidecar; the
|
||||
# bundler then wants the universal one)
|
||||
# x86_64-pc-windows-msvc windows/amd64 (for local cross-builds; CI uses
|
||||
# the .ps1)
|
||||
#
|
||||
# Trust and reproducibility - the build fails on any miss:
|
||||
# 1. The source is AWS's tag 1.2.896.0, pinned by COMMIT, downloaded as
|
||||
# GitHub's archive of that commit and checked against a pinned SHA-256
|
||||
# BEFORE extraction (the SHA-256 is the check; the archive's top
|
||||
# directory, which names the commit, must also be there). Only what the
|
||||
# build reads is extracted: the vendored SDK's Java `codegen/` tree and its
|
||||
# test `snapshot/` files are skipped, which also keeps every path under
|
||||
# Windows' MAX_PATH (the .ps1 extracts the same way, so both build the
|
||||
# same tree).
|
||||
# 2. The Go toolchain is a pinned release from go.dev, checked against the
|
||||
# SHA-256 go.dev publishes (https://go.dev/dl/?mode=json), before use.
|
||||
# 3. The build is AWS's own (its makefile: GOPATH mode over the vendored
|
||||
# dependencies, `-ldflags "-s -w"`, package sessionmanagerplugin-main),
|
||||
# with VERSION set to the tag so `--version` prints 1.2.896.0 (AWS's
|
||||
# release pipeline stamps it; the repo's VERSION file says 1.3.0.0), plus
|
||||
# what makes it reproducible: -trimpath, no VCS stamping, an empty build
|
||||
# id, CGO off, explicit GOAMD64/GOARM64, no inherited GOFLAGS.
|
||||
# 4. The output must equal a PINNED SHA-256 per target. Go builds are
|
||||
# bit-for-bit reproducible across hosts, so every CI runner must produce
|
||||
# exactly the binary recorded here; a mismatch means the source, the
|
||||
# toolchain or the build changed.
|
||||
#
|
||||
# To bump the plugin or Go: change the pins in this script and in
|
||||
# build-ssm-plugin.ps1, rebuild every target, record the new output hashes
|
||||
# (both scripts), and update the version/commit lines in
|
||||
# app/src-tauri/THIRD_PARTY_NOTICES (checked below) and its dependency licences.
|
||||
#
|
||||
# Idempotent: a destination that already holds the pinned binary is left alone.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
PLUGIN_VERSION="1.2.896.0"
|
||||
PLUGIN_COMMIT="6430675a44032a551be1937fb27a2d3fdfeb27f7"
|
||||
SOURCE_URL="https://codeload.github.com/aws/session-manager-plugin/tar.gz/${PLUGIN_COMMIT}"
|
||||
SOURCE_SHA256="7c95be411ad5f43d14d01460500bfd5a5aa0e28ba94815f8b049af33a2c381b0"
|
||||
|
||||
GO_VERSION="1.26.11"
|
||||
go_pin() { # <goos-goarch of the build host> -> SHA-256 published by go.dev
|
||||
case "$1" in
|
||||
linux-amd64) echo 9849f4e04ee35303714e34fbc3ac8ab44ea3e448a95aa182f91e3b9b79c710ec ;;
|
||||
linux-arm64) echo 6c2f29b458b5add0835f18b776f69c8881a6d88428f1484a6da55755e620757e ;;
|
||||
darwin-amd64) echo 394baae971332f2bc783d6e2004ae57101479bd3b06ed8209a3fe3570d4ce498 ;;
|
||||
darwin-arm64) echo e3a42e67a7a8acf450ebada2b074c7ca863000ca514907b7185b45e8f5cdff57 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# target triple -> GOOS GOARCH SHA-256 of the binary we build
|
||||
target_pin() {
|
||||
case "$1" in
|
||||
x86_64-unknown-linux-gnu) echo "linux amd64 414dafe49a90428cb4271a28ea964ad9242a26cb08a38d9679d808470c3b6b62" ;;
|
||||
aarch64-unknown-linux-gnu) echo "linux arm64 79f00cd41536611e2906a9ea703175ab4f06f9b81107a0357b2304c8bfac61dd" ;;
|
||||
x86_64-apple-darwin) echo "darwin amd64 fc61cd7e30bef3524a3681dc6b1a0f472506d9c98bccf62a67865067c9f2f059" ;;
|
||||
aarch64-apple-darwin) echo "darwin arm64 9f3857f85cbcdc88e3ca686f84ac2a794e19e1778ad47ac3294c39e700de08f8" ;;
|
||||
x86_64-pc-windows-msvc) echo "windows amd64 6d428e5fd77e76d9713f0c42b8ec39f2de1031e5f3c567feb73c7fe11b14b226" ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
dest_dir="$repo_root/app/src-tauri/binaries"
|
||||
notices="$repo_root/app/src-tauri/THIRD_PARTY_NOTICES"
|
||||
|
||||
die() { echo "build-ssm-plugin: $*" >&2; exit 1; }
|
||||
|
||||
sha256() {
|
||||
if command -v sha256sum >/dev/null 2>&1; then
|
||||
sha256sum "$1" | cut -d' ' -f1
|
||||
else
|
||||
shasum -a 256 "$1" | cut -d' ' -f1
|
||||
fi
|
||||
}
|
||||
|
||||
# The notices name the version and commit they describe; a bump updates both.
|
||||
grep -qF "Version: ${PLUGIN_VERSION}" "$notices" && grep -qF "Commit: ${PLUGIN_COMMIT}" "$notices" \
|
||||
|| die "$notices does not name plugin ${PLUGIN_VERSION} at ${PLUGIN_COMMIT} - update it with the bump"
|
||||
|
||||
work="$(mktemp -d)"
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
prepared=false
|
||||
|
||||
download() { # <url> <out>
|
||||
curl -fsSL --proto '=https' --tlsv1.2 --retry 3 --retry-delay 5 -o "$2" "$1" \
|
||||
|| die "download failed: $1"
|
||||
}
|
||||
|
||||
# Toolchain and source, once per run, both verified before they are unpacked.
|
||||
prepare() {
|
||||
[ "$prepared" = true ] && return 0
|
||||
|
||||
local host_os host_arch go_sha go_tgz
|
||||
case "$(uname -s)" in Linux) host_os=linux ;; Darwin) host_os=darwin ;; *) die "unsupported build host $(uname -s)" ;; esac
|
||||
case "$(uname -m)" in x86_64|amd64) host_arch=amd64 ;; arm64|aarch64) host_arch=arm64 ;; *) die "unsupported build host arch $(uname -m)" ;; esac
|
||||
go_sha="$(go_pin "$host_os-$host_arch")" || die "no pinned Go for $host_os-$host_arch"
|
||||
go_tgz="$work/go.tar.gz"
|
||||
echo "Downloading Go ${GO_VERSION} (${host_os}-${host_arch})"
|
||||
download "https://go.dev/dl/go${GO_VERSION}.${host_os}-${host_arch}.tar.gz" "$go_tgz"
|
||||
[ "$(sha256 "$go_tgz")" = "$go_sha" ] \
|
||||
|| die "SHA-256 mismatch for the Go toolchain: got $(sha256 "$go_tgz"), pinned $go_sha"
|
||||
mkdir -p "$work/toolchain"
|
||||
tar -xzf "$go_tgz" -C "$work/toolchain"
|
||||
GO="$work/toolchain/go/bin/go"
|
||||
|
||||
local src_tgz="$work/source.tar.gz"
|
||||
echo "Downloading session-manager-plugin ${PLUGIN_VERSION} source (${PLUGIN_COMMIT})"
|
||||
download "$SOURCE_URL" "$src_tgz"
|
||||
[ "$(sha256 "$src_tgz")" = "$SOURCE_SHA256" ] \
|
||||
|| die "SHA-256 mismatch for the plugin source: got $(sha256 "$src_tgz"), pinned $SOURCE_SHA256"
|
||||
mkdir -p "$work/src"
|
||||
tar --exclude='*/codegen/*' --exclude='*/snapshot/*' -xzf "$src_tgz" -C "$work/src"
|
||||
GO_SPACE="$work/src/session-manager-plugin-${PLUGIN_COMMIT}"
|
||||
[ -d "$GO_SPACE/src/sessionmanagerplugin-main" ] || die "the source archive is not the pinned commit's tree"
|
||||
|
||||
# makefile `pre-build`: stamp the version with AWS's own generator.
|
||||
printf '%s' "$PLUGIN_VERSION" >"$GO_SPACE/VERSION"
|
||||
( cd "$GO_SPACE" && go_env "$(go_host_os)" "$(go_host_arch)" "$GO" run ./src/version/versiongenerator/version-gen.go >/dev/null )
|
||||
grep -qF "const Version = \"${PLUGIN_VERSION}\"" "$GO_SPACE/src/version/version.go" \
|
||||
|| die "the version stamp did not take"
|
||||
|
||||
# makefile `copy-src`: the code builds in GOPATH mode, from a copy at its
|
||||
# import path, with the vendored dependencies as a second GOPATH entry.
|
||||
GOPATH_DIR="$work/gopath"
|
||||
mkdir -p "$GOPATH_DIR/src/github.com/aws/session-manager-plugin"
|
||||
cp -R "$GO_SPACE/src" "$GOPATH_DIR/src/github.com/aws/session-manager-plugin/"
|
||||
prepared=true
|
||||
}
|
||||
|
||||
go_host_os() { "$GO" env GOHOSTOS; }
|
||||
go_host_arch() { "$GO" env GOHOSTARCH; }
|
||||
|
||||
# Run with a clean, fully specified Go environment (nothing inherited).
|
||||
go_env() { # <goos> <goarch> <cmd...>
|
||||
local goos="$1" goarch="$2"; shift 2
|
||||
env -u GOFLAGS -u GOROOT -u GOBIN -u GOEXPERIMENT \
|
||||
GOENV=off GOTOOLCHAIN=local GO111MODULE=off GOPROXY=off GOWORK=off \
|
||||
GOPATH="${GOPATH_DIR:-$work/gopath}:${GO_SPACE}/vendor" \
|
||||
GOCACHE="$work/cache" GOMODCACHE="$work/modcache" GOTMPDIR= \
|
||||
CGO_ENABLED=0 GOOS="$goos" GOARCH="$goarch" GOAMD64=v1 GOARM64=v8.0 \
|
||||
"$@"
|
||||
}
|
||||
|
||||
build_thin() { # <triple> <out>
|
||||
local triple="$1" out="$2" pin goos goarch want
|
||||
pin="$(target_pin "$triple")" || die "unsupported target $triple"
|
||||
read -r goos goarch want <<<"$pin"
|
||||
|
||||
if [ -f "$out" ] && [ "$(sha256 "$out")" = "$want" ]; then
|
||||
echo "$(basename "$out"): already the pinned ${PLUGIN_VERSION} build"
|
||||
return 0
|
||||
fi
|
||||
prepare
|
||||
echo "Building session-manager-plugin ${PLUGIN_VERSION} for ${goos}/${goarch}"
|
||||
( cd "$GOPATH_DIR/src/github.com/aws/session-manager-plugin" && \
|
||||
go_env "$goos" "$goarch" "$GO" build -trimpath -buildvcs=false \
|
||||
-ldflags "-s -w -buildid=" -o "$work/out-$triple" \
|
||||
github.com/aws/session-manager-plugin/src/sessionmanagerplugin-main )
|
||||
local got
|
||||
got="$(sha256 "$work/out-$triple")"
|
||||
[ "$got" = "$want" ] || die "the ${goos}/${goarch} build is not the pinned binary: got $got, pinned $want (source, toolchain or build flags changed)"
|
||||
mkdir -p "$(dirname "$out")"
|
||||
chmod 0755 "$work/out-$triple"
|
||||
mv -f "$work/out-$triple" "$out"
|
||||
echo "$(basename "$out"): session-manager-plugin ${PLUGIN_VERSION}"
|
||||
}
|
||||
|
||||
build_universal() {
|
||||
local lipo
|
||||
lipo="$(command -v lipo || command -v llvm-lipo || true)"
|
||||
[ -n "$lipo" ] || die "universal-apple-darwin needs lipo (Xcode command line tools) or llvm-lipo"
|
||||
local x86="$dest_dir/session-manager-plugin-x86_64-apple-darwin"
|
||||
local arm="$dest_dir/session-manager-plugin-aarch64-apple-darwin"
|
||||
local uni="$dest_dir/session-manager-plugin-universal-apple-darwin"
|
||||
build_thin x86_64-apple-darwin "$x86"
|
||||
build_thin aarch64-apple-darwin "$arm"
|
||||
"$lipo" -create "$x86" "$arm" -output "$work/universal"
|
||||
# Each slice must come back out byte-identical to its pinned thin binary.
|
||||
local pair arch triple
|
||||
for pair in x86_64:x86_64-apple-darwin arm64:aarch64-apple-darwin; do
|
||||
arch="${pair%%:*}" triple="${pair#*:}"
|
||||
"$lipo" "$work/universal" -thin "$arch" -output "$work/slice-$arch"
|
||||
[ "$(sha256 "$work/slice-$arch")" = "$(target_pin "$triple" | cut -d' ' -f3)" ] \
|
||||
|| die "the $arch slice of the universal binary is not the pinned binary"
|
||||
done
|
||||
chmod 0755 "$work/universal"
|
||||
mv -f "$work/universal" "$uni"
|
||||
echo "$(basename "$uni"): session-manager-plugin ${PLUGIN_VERSION} (x86_64 + arm64)"
|
||||
}
|
||||
|
||||
targets=("$@")
|
||||
if [ ${#targets[@]} -eq 0 ]; then
|
||||
host="$(rustc -vV 2>/dev/null | sed -n 's/^host: //p')"
|
||||
[ -n "$host" ] || die "no target given and rustc is not available to name the host's"
|
||||
targets=("$host")
|
||||
fi
|
||||
|
||||
for t in "${targets[@]}"; do
|
||||
case "$t" in
|
||||
universal-apple-darwin) build_universal ;;
|
||||
*-windows-*) build_thin "$t" "$dest_dir/session-manager-plugin-$t.exe" ;;
|
||||
*) build_thin "$t" "$dest_dir/session-manager-plugin-$t" ;;
|
||||
esac
|
||||
done
|
||||
@@ -317,22 +317,6 @@ if [ "$pw_removed" = true ]; then
|
||||
fi
|
||||
[ -x "$out/usr/bin/triple-c" ] || fail "no executable usr/bin/triple-c."
|
||||
|
||||
# The bundled AWS Session Manager plugin (bundle.externalBin, built from
|
||||
# source by build-ssm-plugin.sh) is what AWS workspaces connect through. Tauri copies it
|
||||
# beside the app binary with the target triple stripped, which is where
|
||||
# `host::ssm::find_plugin` looks. It must be the real plugin: an ELF, not the
|
||||
# placeholder a debug build writes (build.rs refuses that for release, and this
|
||||
# is the check on what actually shipped).
|
||||
plugin="$out/usr/bin/session-manager-plugin"
|
||||
[ -x "$plugin" ] || fail "no executable usr/bin/session-manager-plugin (the bundled AWS plugin)."
|
||||
[ "$(head -c 4 "$plugin" | od -An -c | tr -d ' ')" = "177ELF" ] \
|
||||
|| fail "usr/bin/session-manager-plugin is not an ELF binary (a placeholder?)."
|
||||
"$plugin" --version >/dev/null 2>&1 \
|
||||
|| fail "usr/bin/session-manager-plugin does not run (--version)."
|
||||
# Its license and notices travel with it (bundle.resources).
|
||||
notices=("$out"/usr/lib/*/THIRD_PARTY_NOTICES)
|
||||
[ -f "${notices[0]}" ] || fail "THIRD_PARTY_NOTICES is not in the image."
|
||||
|
||||
# Every file readable by all, every program executable by all — what the
|
||||
# `chmod -R a+rX` before the repack promised (AppRun.wrapped used to ship 0770).
|
||||
# Files only: the AppImage runtime's --appimage-extract creates every
|
||||
|
||||
@@ -10,10 +10,9 @@
|
||||
# extension DLLs candle/light load, the NSIS plugins makensis embeds - and
|
||||
# each signature is metered (about 1000 a month), so those are skipped. The
|
||||
# allowlist below is the whole of what reaches users: the app binary, the MSI,
|
||||
# the NSIS installer, the uninstaller makensis writes to the job's temp
|
||||
# directory, and the session-manager-plugin sidecar we build from source. A
|
||||
# file that already carries a valid signature is skipped too: Tauri presents
|
||||
# the app binary once per bundle type.
|
||||
# the NSIS installer, and the uninstaller makensis writes to the job's temp
|
||||
# directory. A file that already carries a valid signature is skipped too:
|
||||
# Tauri presents the app binary once per bundle type.
|
||||
#
|
||||
# This may run as 32-bit PowerShell: the NSIS uninstaller is signed from inside
|
||||
# makensis, which is 32-bit and resolves `powershell` to the SysWOW64 copy. So
|
||||
@@ -47,12 +46,7 @@ try {
|
||||
$full = (Resolve-Path -LiteralPath $Path).ProviderPath
|
||||
Write-Log "== $full"
|
||||
|
||||
# The bundled session-manager-plugin sidecar (bundle.externalBin), which we
|
||||
# build from AWS's source (scripts/build-ssm-plugin.ps1) and so ship unsigned
|
||||
# unless signed here. Tauri presents a sidecar to the sign command, in place
|
||||
# under app\src-tauri\binaries, only when `signtool verify /pa` rejects it.
|
||||
$ships = ($full -match '\\src-tauri\\binaries\\session-manager-plugin-x86_64-pc-windows-msvc\.exe$') -or
|
||||
($full -match '\\target\\release\\[^\\]+\.exe$') -or
|
||||
$ships = ($full -match '\\target\\release\\[^\\]+\.exe$') -or
|
||||
($full -match '\\target\\release\\bundle\\(msi|nsis)\\[^\\]+\.(msi|exe)$') -or
|
||||
$full.StartsWith($env:TRIPLE_C_SIGN_TMP.TrimEnd('\') + '\', [StringComparison]::OrdinalIgnoreCase)
|
||||
if (-not $ships) {
|
||||
|
||||
@@ -14,10 +14,6 @@
|
||||
# unpacked with an administrative install and its binaries checked directly;
|
||||
# the NSIS installer cannot be unpacked that way, so for it the signing log
|
||||
# must show the app binary and the uninstaller were signed.
|
||||
#
|
||||
# The bundled session-manager-plugin (built from source, signed by us) is
|
||||
# checked too: present in the MSI, and in both installers validly signed,
|
||||
# timestamped, and by the same signing identity as the installer itself.
|
||||
|
||||
param([Parameter(Mandatory = $true, ValueFromRemainingArguments = $true)][string[]]$Patterns)
|
||||
|
||||
@@ -51,24 +47,6 @@ function Test-Signature([IO.FileInfo]$File, [string]$Label) {
|
||||
return $false
|
||||
}
|
||||
|
||||
# The session-manager-plugin sidecar is built from AWS's source
|
||||
# (build-ssm-plugin.ps1), so it is unsigned until windows-sign.ps1 signs it. It
|
||||
# must carry OUR signature: valid, timestamped, and from the same signing
|
||||
# identity (subject and issuer) as the installer that ships it.
|
||||
$sidecarName = 'session-manager-plugin.exe'
|
||||
$sidecarSource = Join-Path (Split-Path -Parent $PSScriptRoot) 'app\src-tauri\binaries\session-manager-plugin-x86_64-pc-windows-msvc.exe'
|
||||
function Test-OurSigner([IO.FileInfo]$File, [string]$Label, [IO.FileInfo]$Installer) {
|
||||
if (-not (Test-Signature $File $Label)) { return $false }
|
||||
$ours = (Get-AuthenticodeSignature -FilePath $Installer.FullName).SignerCertificate
|
||||
$theirs = (Get-AuthenticodeSignature -FilePath $File.FullName).SignerCertificate
|
||||
# Subject + Issuer, not the thumbprint: Azure Artifact Signing issues a
|
||||
# fresh short-lived certificate (daily), so the plugin and the installer
|
||||
# can legitimately carry different thumbprints within one build.
|
||||
if ($ours -and $theirs -and $ours.Subject -eq $theirs.Subject -and $ours.Issuer -eq $theirs.Issuer) { return $true }
|
||||
Write-Host "FAIL $Label - signed by '$($theirs.Subject)' (issuer '$($theirs.Issuer)'), not the identity that signed $($Installer.Name)"
|
||||
return $false
|
||||
}
|
||||
|
||||
function Get-SignedLog {
|
||||
if ($env:TRIPLE_C_SIGN_LOG -and (Test-Path $env:TRIPLE_C_SIGN_LOG)) { return @(Get-Content $env:TRIPLE_C_SIGN_LOG) }
|
||||
return @()
|
||||
@@ -78,7 +56,7 @@ $failed = @()
|
||||
$nsisBuilt = $false
|
||||
foreach ($file in $files) {
|
||||
if (-not (Test-Signature $file $file.Name)) { $failed += $file.Name }
|
||||
if ($file.FullName -match '\\bundle\\nsis\\') { $nsisBuilt = $true; $nsisInstaller = $file }
|
||||
if ($file.FullName -match '\\bundle\\nsis\\') { $nsisBuilt = $true }
|
||||
|
||||
if ($file.Extension -eq '.msi') {
|
||||
$extract = Join-Path ([IO.Path]::GetTempPath()) ('msi-verify-' + [guid]::NewGuid().ToString('N'))
|
||||
@@ -96,21 +74,6 @@ foreach ($file in $files) {
|
||||
foreach ($f in $inner) {
|
||||
if (-not (Test-Signature $f "$($file.Name) > $($f.Name)")) { $failed += "$($file.Name) > $($f.Name)" }
|
||||
}
|
||||
# Its licence notices travel with it (bundle.resources).
|
||||
if ($proc.ExitCode -eq 0 -and -not @(Get-ChildItem -Path $extract -Recurse -File -Filter 'THIRD_PARTY_NOTICES').Count) {
|
||||
Write-Host "FAIL $($file.Name) - carries no THIRD_PARTY_NOTICES"
|
||||
$failed += "$($file.Name) > THIRD_PARTY_NOTICES (missing)"
|
||||
}
|
||||
# The bundled plugin must be in there, under our signature.
|
||||
if ($proc.ExitCode -eq 0) {
|
||||
$plugin = @($inner | Where-Object { $_.Name -eq $sidecarName })
|
||||
if ($plugin.Count -ne 1) {
|
||||
Write-Host "FAIL $($file.Name) - carries $($plugin.Count) $sidecarName, expected 1"
|
||||
$failed += "$($file.Name) > $sidecarName (missing)"
|
||||
} elseif (-not (Test-OurSigner $plugin[0] "$($file.Name) > $sidecarName" $file)) {
|
||||
$failed += "$($file.Name) > $sidecarName (signer)"
|
||||
}
|
||||
}
|
||||
Remove-Item -Recurse -Force $extract -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
@@ -129,18 +92,6 @@ if ($nsisBuilt) {
|
||||
} else {
|
||||
Write-Host "OK app binary - signed before packaging ($($appSigned.Count)x)"
|
||||
}
|
||||
# makensis packs the sidecar straight from app\src-tauri\binaries, where
|
||||
# Tauri had it signed in place before any bundle: so that file, and a
|
||||
# logged signature for it, are what NSIS shipped.
|
||||
if (-not (Test-Path -LiteralPath $sidecarSource)) {
|
||||
Write-Host "FAIL $sidecarName - $sidecarSource is missing"
|
||||
$failed += "NSIS > $sidecarName (missing)"
|
||||
} elseif (-not (Test-OurSigner (Get-Item -LiteralPath $sidecarSource) "NSIS > $sidecarName (as packed)" $nsisInstaller)) {
|
||||
$failed += "NSIS > $sidecarName (signer)"
|
||||
} elseif (-not @($log | Where-Object { $_ -match '\\src-tauri\\binaries\\session-manager-plugin-x86_64-pc-windows-msvc\.exe$' }).Count) {
|
||||
Write-Host "FAIL $sidecarName - no signature was logged for it"
|
||||
$failed += "NSIS > $sidecarName (not logged)"
|
||||
}
|
||||
$tmp = $env:TRIPLE_C_SIGN_TMP
|
||||
$uninstaller = @()
|
||||
if ($tmp) { $uninstaller = @($log | Where-Object { $_.StartsWith($tmp, [StringComparison]::OrdinalIgnoreCase) }) }
|
||||
|
||||
Reference in new issue
Block a user