Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Fix hosted mobile approval proof runtime setup

rcourtman410590c2e18d
diff --git a/internal/relay/encryption_test.go b/internal/relay/encryption_test.go
index 7cca9b86da..8628a6a605 100644
--- a/internal/relay/encryption_test.go
+++ b/internal/relay/encryption_test.go
@@ -4,6 +4,7 @@ import (
"bytes"
"crypto/ecdh"
"crypto/sha256"
+ "encoding/hex"
"testing"
"io"
@@ -77,6 +78,47 @@ func TestDeriveChannelKeys_Roundtrip(t *testing.T) {
}
}
+func TestDeriveChannelKeys_DecryptsMobileAppVector(t *testing.T) {
+ decodeHex := func(label, value string) []byte {
+ t.Helper()
+ decoded, err := hex.DecodeString(value)
+ if err != nil {
+ t.Fatalf("decode %s: %v", label, err)
+ }
+ return decoded
+ }
+
+ // Generated by repos/pulse-mobile/src/relay/encryption.ts using Node's
+ // x25519 + HKDF path. This catches cross-runtime drift that Go-only and
+ // TypeScript-only round trips cannot see.
+ appPublic := decodeHex("app public key", "16f4f6574e7084c8f08edac52f124517131eb584bb7cd702b04c9a77c740e456")
+ instancePrivate := decodeHex("instance private key", "e0fb8da5158b2076eb81c323708b9389516293c1739ea2a437bf144251df7173")
+ ciphertext := decodeHex("ciphertext", "0000000000000000000000004e09ba88aed1fe11117dc092027a1d3981ec25ab3abe758d04c76a7fa4486668ca3a444a3bb9d7387c6444a3e179d8c9283911551ab164d8b80aec607c2668396d57d41867f8b6058b9b3af5e5")
+ wantPlaintext := []byte(`{"id":"req_vector","method":"GET","path":"/api/ai/approvals"}`)
+
+ instancePriv, err := ecdh.X25519().NewPrivateKey(instancePrivate)
+ if err != nil {
+ t.Fatalf("parse instance private key: %v", err)
+ }
+ appPub, err := ecdh.X25519().NewPublicKey(appPublic)
+ if err != nil {
+ t.Fatalf("parse app public key: %v", err)
+ }
+
+ instanceEnc, err := DeriveChannelKeys(instancePriv, appPub, true)
+ if err != nil {
+ t.Fatalf("derive instance channel keys: %v", err)
+ }
+
+ got, err := instanceEnc.Decrypt(ciphertext)
+ if err != nil {
+ t.Fatalf("decrypt mobile vector: %v", err)
+ }
+ if !bytes.Equal(got, wantPlaintext) {
+ t.Fatalf("mobile vector plaintext = %q, want %q", got, wantPlaintext)
+ }
+}
+
func TestDeriveKeyUsesRelayDomainSalt(t *testing.T) {
secret := []byte("shared-secret-for-relay-kdf")
info := hkdfInfoAppToInstance
diff --git a/tests/integration/scripts/hosted-tenant-approval-store.mjs b/tests/integration/scripts/hosted-tenant-approval-store.mjs
index 7ccce76e1b..5212aa15b2 100644
--- a/tests/integration/scripts/hosted-tenant-approval-store.mjs
+++ b/tests/integration/scripts/hosted-tenant-approval-store.mjs
@@ -9,7 +9,7 @@ import { pathToFileURL } from 'node:url';
import {
assertHostedTenantRuntimeExists,
- resolveHostedTenantOrgDataDir,
+ resolveHostedTenantRootDataDir,
restartHostedTenantRuntime,
runRemote,
shellQuote,
@@ -83,6 +83,10 @@ export function parseArgs(argv) {
return parsed;
}
+export function resolveHostedTenantApprovalStoreDataDir(tenantId) {
+ return resolveHostedTenantRootDataDir(tenantId);
+}
+
function buildLocalHelper(tempDir) {
const binaryPath = path.join(tempDir, 'approval-store-helper');
execFileSync('go', [
@@ -115,7 +119,7 @@ function main() {
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'pulse-hosted-approval-helper-'));
const localBinaryPath = buildLocalHelper(tempDir);
const remoteBinaryPath = `/tmp/approval-store-helper-${process.pid}-${Date.now()}`;
- const tenantDataDir = resolveHostedTenantOrgDataDir(args.tenantId, args.orgId);
+ const tenantDataDir = resolveHostedTenantApprovalStoreDataDir(args.tenantId);
try {
execFileSync('scp', [localBinaryPath, `${args.cloudHost}:${remoteBinaryPath}`], {
diff --git a/tests/integration/scripts/hosted-tenant-runtime.test.mjs b/tests/integration/scripts/hosted-tenant-runtime.test.mjs
index f318ff2261..86f0200735 100644
--- a/tests/integration/scripts/hosted-tenant-runtime.test.mjs
+++ b/tests/integration/scripts/hosted-tenant-runtime.test.mjs
@@ -7,7 +7,10 @@ import {
hostedTenantRuntimeExistsScript,
restartHostedTenantRuntime,
} from './hosted-tenant-runtime.mjs';
-import { parseArgs as parseApprovalStoreArgs } from './hosted-tenant-approval-store.mjs';
+import {
+ parseArgs as parseApprovalStoreArgs,
+ resolveHostedTenantApprovalStoreDataDir,
+} from './hosted-tenant-approval-store.mjs';
import { parseArgs as parseRuntimeCheckArgs } from './hosted-tenant-runtime-check.mjs';
import { parseArgs as parseRuntimeRestartArgs } from './hosted-tenant-runtime-restart.mjs';
@@ -113,3 +116,10 @@ test('hosted approval seeding can defer runtime restart for transactional proof
assert.equal(parsed.restartAfterCreate, false);
assert.deepEqual(parsed.passthrough, ['--approval-id', 'approval-123']);
});
+
+test('hosted approval seeding targets the runtime approval store root', () => {
+ assert.equal(
+ resolveHostedTenantApprovalStoreDataDir('t-canary'),
+ '/data/tenants/t-canary',
+ );
+});