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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Explain literal agent token-file formats without exposing credentials
pulse-triage[bot]9c5100128366
diff --git a/docs/UNIFIED_AGENT.md b/docs/UNIFIED_AGENT.mdindex 5ad68125e4..ac340dc91a 100644--- a/docs/UNIFIED_AGENT.md+++ b/docs/UNIFIED_AGENT.md@@ -132,6 +132,11 @@ optional for host-local data.)```+ This is a plain token file, **not a shell script or `.env` file**. Do not+ include `PULSE_TOKEN=`, `export`, comments or surrounding quotes. For an+ existing authentication failure, use the [token-file format guidance](#token-file-format-is-not-shell-syntax)+ before changing the saved credential or running another installation.+2. Replace `https://pulse.example.com` with your Pulse server's HTTPS addressin both the download and installation commands. Download to a new privatefile. This ignores local curl settings, accepts only HTTP **200** over HTTPS,@@ -1156,6 +1161,37 @@ credential hand-off or accepted host reports. Retain the existing installationwhile those remaining distinctions are investigated. A listed record with`Never` is not, by itself, a reason to mint a replacement.+#### Token-file format is not shell syntax++If the intended record exists with the host scopes but lookup and reporting+still return 401, keep credential selection separate from file contents.+`--token-file` names a file; it does not establish which credential reached+Pulse. An environment or explicit-token override is a separate possibility,+not a diagnosis from `Never`.++The agent trims whitespace at the beginning and end of a token file. It does+**not** interpret shell syntax, strip quotes or extract a value from an+assignment. These file forms therefore mean different things:++| File form | What the agent reads |+| --- | --- |+| Bare token, possibly followed by a newline | The token value; this does not prove it matches the intended record or Pulse instance. |+| Token surrounded by single or double quotes | The quotes remain part of the credential. |+| Assignment prefix such as `PULSE_TOKEN=` or `export` | The prefix remains part of the credential; this is not an environment-file parser. |+| Unknown | The format and cause remain unknown; no new installation is needed to complete a report. |++Quotes or a prefix can cause rejection even when the intended record has the+right scopes. A rejected credential can leave that record showing `Never`;+this does not identify the cause of a particular installation's failure.++Use how the file was saved or an existing private observation. If you cannot+safely tell, say **unknown**. If asked, report only **bare**, **quoted**,+**prefixed** or **unknown**, not the value, length, hint, screenshot or file.+Do not print, source, upload or edit the installed token file, restart the+service, generate a replacement or reinstall merely to classify it. A bare+value still leaves credential selection, server record and instance matching+to investigate; it is not proof of accepted reporting.+If asked about the inventory, report only whether the record exists and therelevant metadata; do not share the token or its hint. Keep service environments,token files and connection files private; do not paste a credential into adiff --git a/frontend-modern/browser-tests/agent-token-file-guidance.cjs b/frontend-modern/browser-tests/agent-token-file-guidance.cjsnew file mode 100644index 0000000000..28a4ecc94f--- /dev/null+++ b/frontend-modern/browser-tests/agent-token-file-guidance.cjs@@ -0,0 +1,95 @@+// Real Docs/router/Markdown/CSS, with no backend or credential access.+const assert = require('node:assert/strict');+const fs = require('node:fs');+const path = require('node:path');+const crypto = require('node:crypto');+const { chromium, webkit } = require('playwright');++(async () => {+ const root = '/workspace/frontend-modern';+ process.chdir(root);+ const artifacts = path.join(root, 'node_modules', 'agent-token-file-guidance-browser');+ fs.mkdirSync(artifacts, { recursive: true });+ const { createServer } = await import(path.join(root, 'node_modules/vite/dist/node/index.js'));+ const server = await createServer({+ root,+ configFile: path.join(root, 'vite.config.ts'),+ cacheDir: path.join(root, 'node_modules', '.vite-agent-token-file-guidance'),+ server: { host: '127.0.0.1', port: 5251, strictPort: true },+ optimizeDeps: { noDiscovery: true, include: [] },+ });+ let browser;+ const results = [];+ try {+ await server.listen();+ for (const [engine, width, dark] of [['chromium', 1280, false], ['webkit', 390, true]]) {+ browser = await { chromium, webkit }[engine].launch(engine === 'chromium'+ ? { headless: true, channel: 'chromium', args: ['--no-sandbox'] }+ : { headless: true });+ const page = await browser.newPage({ viewport: { width, height: 900 },+ ...(engine === 'webkit' ? { isMobile: true, hasTouch: true } : {}) });+ const errors = [];+ const backendRequests = [];+ page.on('pageerror', (error) => errors.push(error.message));+ page.on('console', (message) => {+ if (message.type() === 'error') errors.push(message.text());+ });+ await page.route('**/api/**', async (route) => {+ backendRequests.push({ method: route.request().method(), pathname: new URL(route.request().url()).pathname });+ await route.abort();+ });+ await page.goto('http://127.0.0.1:5251/browser-tests/docs-fragment-navigation.html', {+ waitUntil: 'domcontentloaded', timeout: 60000,+ });+ await page.evaluate(() => {+ history.pushState({}, '', '/docs/UNIFIED_AGENT#private-file-installation-linux-macos-and-nas');+ dispatchEvent(new PopStateEvent('popstate'));+ });+ if (dark) await page.evaluate(() => document.documentElement.classList.add('dark'));+ const waitForHeading = async (id) => {+ await page.waitForFunction((target) => {+ const heading = document.getElementById(target);+ const rect = heading?.getBoundingClientRect();+ return heading && document.activeElement === heading && rect.top >= 0 && rect.top < innerHeight;+ }, id);+ };+ await waitForHeading('private-file-installation-linux-macos-and-nas');+ const link = page.getByRole('link', { name: 'token-file format guidance', exact: true });+ await link.focus();+ await page.keyboard.press('Enter');+ await waitForHeading('token-file-format-is-not-shell-syntax');+ assert.ok(page.url().endsWith('/docs/UNIFIED_AGENT#token-file-format-is-not-shell-syntax'));+ await page.waitForFunction(() => document.getAnimations().length === 0);+ const table = page.getByRole('table').filter({ has: page.getByRole('columnheader', { name: 'File form', exact: true }) });+ assert.equal(await table.getByRole('row').count(), 5);+ assert.deepEqual(await table.getByRole('columnheader').allTextContents(), ['File form', 'What the agent reads']);+ for (const phrase of ['The quotes remain part', 'The prefix remains part', 'format and cause remain unknown']) {+ assert.ok((await table.innerText()).includes(phrase), phrase);+ }+ assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1));+ await page.screenshot({ path: path.join(artifacts, `${engine}-file-form.png`) });+ const safeguard = page.getByText('Use how the file was saved or an existing private observation.', { exact: false });+ await safeguard.scrollIntoViewIfNeeded();+ const text = (await safeguard.innerText()).replace(/\s+/g, ' ');+ assert.ok(text.includes('not the value, length, hint, screenshot or file'));+ assert.ok(text.includes('Do not print, source, upload or edit'));+ assert.ok(text.includes('not proof of accepted reporting'));+ await page.screenshot({ path: path.join(artifacts, `${engine}-private-evidence.png`) });+ assert.deepEqual(backendRequests, []);+ assert.deepEqual(errors, []);+ results.push({ engine, version: browser.version(), width, dark,+ keyboardFormatLink: true, focusedVisibleHeading: true, fourFormsAndHeaders: true,+ privateUnknownEvidence: true, noHorizontalPageOverflow: true, backendRequests, errors });+ await browser.close();+ browser = undefined;+ }+ const result = { result: 'passed', playwright: require('playwright/package.json').version,+ document_sha256: crypto.createHash('sha256').update(fs.readFileSync(path.join(root, 'public/docs/UNIFIED_AGENT.md'))).digest('hex'),+ scope: 'shipped help and keyboard navigation; not credential hand-off, authentication or installed reporting', results };+ fs.writeFileSync(path.join(artifacts, 'result.json'), JSON.stringify(result, null, 2) + '\n');+ console.log(JSON.stringify(result));+ } finally {+ if (browser) await browser.close();+ await server.close();+ }+})().catch((error) => { console.error(error); process.exitCode = 1; });diff --git a/frontend-modern/public/docs/UNIFIED_AGENT.md b/frontend-modern/public/docs/UNIFIED_AGENT.mdindex 5ad68125e4..ac340dc91a 100644--- a/frontend-modern/public/docs/UNIFIED_AGENT.md+++ b/frontend-modern/public/docs/UNIFIED_AGENT.md@@ -132,6 +132,11 @@ optional for host-local data.)```+ This is a plain token file, **not a shell script or `.env` file**. Do not+ include `PULSE_TOKEN=`, `export`, comments or surrounding quotes. For an+ existing authentication failure, use the [token-file format guidance](#token-file-format-is-not-shell-syntax)+ before changing the saved credential or running another installation.+2. Replace `https://pulse.example.com` with your Pulse server's HTTPS addressin both the download and installation commands. Download to a new privatefile. This ignores local curl settings, accepts only HTTP **200** over HTTPS,@@ -1156,6 +1161,37 @@ credential hand-off or accepted host reports. Retain the existing installationwhile those remaining distinctions are investigated. A listed record with`Never` is not, by itself, a reason to mint a replacement.+#### Token-file format is not shell syntax++If the intended record exists with the host scopes but lookup and reporting+still return 401, keep credential selection separate from file contents.+`--token-file` names a file; it does not establish which credential reached+Pulse. An environment or explicit-token override is a separate possibility,+not a diagnosis from `Never`.++The agent trims whitespace at the beginning and end of a token file. It does+**not** interpret shell syntax, strip quotes or extract a value from an+assignment. These file forms therefore mean different things:++| File form | What the agent reads |+| --- | --- |+| Bare token, possibly followed by a newline | The token value; this does not prove it matches the intended record or Pulse instance. |+| Token surrounded by single or double quotes | The quotes remain part of the credential. |+| Assignment prefix such as `PULSE_TOKEN=` or `export` | The prefix remains part of the credential; this is not an environment-file parser. |+| Unknown | The format and cause remain unknown; no new installation is needed to complete a report. |++Quotes or a prefix can cause rejection even when the intended record has the+right scopes. A rejected credential can leave that record showing `Never`;+this does not identify the cause of a particular installation's failure.++Use how the file was saved or an existing private observation. If you cannot+safely tell, say **unknown**. If asked, report only **bare**, **quoted**,+**prefixed** or **unknown**, not the value, length, hint, screenshot or file.+Do not print, source, upload or edit the installed token file, restart the+service, generate a replacement or reinstall merely to classify it. A bare+value still leaves credential selection, server record and instance matching+to investigate; it is not proof of accepted reporting.+If asked about the inventory, report only whether the record exists and therelevant metadata; do not share the token or its hint. Keep service environments,token files and connection files private; do not paste a credential into adiff --git a/frontend-modern/src/features/docs/__tests__/agentTokenFileGuide.test.ts b/frontend-modern/src/features/docs/__tests__/agentTokenFileGuide.test.tsnew file mode 100644index 0000000000..81c40f387c--- /dev/null+++ b/frontend-modern/src/features/docs/__tests__/agentTokenFileGuide.test.ts@@ -0,0 +1,62 @@+import { readFileSync } from 'node:fs';+import path from 'node:path';+import { fileURLToPath } from 'node:url';+import { describe, expect, it } from 'vitest';+import { renderDocMarkdown } from '../docMarkdown';++const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../..');+const guide = readFileSync(path.join(repoRoot, 'docs/UNIFIED_AGENT.md'), 'utf8');+const id = 'token-file-format-is-not-shell-syntax';++function renderGuide(): HTMLElement {+ const article = document.createElement('article');+ article.innerHTML = renderDocMarkdown(guide, 'UNIFIED_AGENT');+ return article;+}++describe('agent token-file help in the shipped Markdown renderer', () => {+ it('makes the preparation link reach the local format heading, not an external page', () => {+ const article = renderGuide();+ const link = Array.from(article.querySelectorAll('a')).find(+ (anchor) => anchor.textContent === 'token-file format guidance',+ );+ expect(link?.getAttribute('href')).toBe(`/docs/UNIFIED_AGENT#${id}`);+ expect(link?.hasAttribute('data-doc-link')).toBe(true);+ expect(link?.hasAttribute('target')).toBe(false);+ expect(article.querySelector(`#${id}`)?.textContent).toBe('Token-file format is not shell syntax');+ expect(guide).toBe(+ readFileSync(path.join(repoRoot, 'frontend-modern/public/docs/UNIFIED_AGENT.md'), 'utf8'),+ );+ });++ it('renders all four forms as a table with headers and keeps private, unknown evidence valid', () => {+ const article = renderGuide();+ const heading = article.querySelector(`#${id}`)!;+ const parts: Element[] = [];+ for (let element = heading.nextElementSibling; element; element = element.nextElementSibling) {+ if (/^H[1-4]$/.test(element.tagName)) break;+ parts.push(element);+ }+ const table = parts.flatMap((element) => [...element.querySelectorAll('table')])[0];+ expect(table).toBeDefined();+ expect([...table.querySelectorAll('th')].map((cell) => cell.textContent)).toEqual([+ 'File form',+ 'What the agent reads',+ ]);+ const rows = [...table.querySelectorAll('tbody tr')];+ expect(rows).toHaveLength(4);+ for (const [index, phrase] of [+ 'does not prove it matches',+ 'The quotes remain part',+ 'The prefix remains part',+ 'format and cause remain unknown',+ ].entries()) {+ expect(rows[index].textContent).toContain(phrase);+ }+ const text = parts.map((element) => element.textContent).join(' ').replace(/\s+/g, ' ');+ expect(text).toContain('not the value, length, hint, screenshot or file');+ expect(text).toContain('Do not print, source, upload or edit the installed token file');+ expect(text).toContain('not proof of accepted reporting');+ expect(parts.some((element) => element.matches('pre') || element.querySelector('pre'))).toBe(false);+ });+});diff --git a/scripts/tests/test_agent_auth_docs.py b/scripts/tests/test_agent_auth_docs.pyindex 9ace3488fd..e205865aa1 100644--- a/scripts/tests/test_agent_auth_docs.py+++ b/scripts/tests/test_agent_auth_docs.py@@ -163,6 +163,31 @@ class AgentAuthDocsTest(unittest.TestCase):"broaden its permissions, reinstall or probe the agent"):self.assertIn(fact, text)+ def test_file_format_guidance_matches_the_literal_reader_without_requesting_a_secret(self):+ text = " ".join(section().split())+ source = (ROOT / "cmd/pulse-agent/main.go").read_text()+ reader = source.split("func resolveTokenInternal(", 1)[1].split(+ "// 3. PULSE_TOKEN", 1)[0]+ self.assertIn("readFile(tokenFileFlag)", reader)+ self.assertIn("strings.TrimSpace(string(content))", reader)+ self.assertNotIn("strings.Trim(", reader)+ self.assertNotIn("strings.TrimPrefix(", reader)+ validator = (ROOT / "internal/config/api_tokens.go").read_text().split(+ "func (c *Config) ValidateAPIToken(", 1)[1].split(+ "// IsValidAPIToken", 1)[0]+ self.assertIn("auth.CompareAPIToken(rawToken, record.Hash)", validator)+ self.assertLess(validator.index("auth.CompareAPIToken"), validator.index("LastUsedAt = &now"))+ for fact in ("Token-file format is not shell syntax", "not a diagnosis from `Never`",+ "not** interpret shell syntax, strip quotes", "The quotes remain part",+ "The prefix remains part", "does not prove it matches",+ "rejected credential can leave that record showing `Never`",+ "Use how the file was saved or an existing private observation",+ "say **unknown**", "not the value, length, hint, screenshot or file",+ "Do not print, source, upload or edit", "merely to classify it",+ "not proof of accepted reporting"):+ self.assertIn(fact, text)+ self.assertIn("#token-file-format-is-not-shell-syntax", DOC.read_text())+if __name__ == "__main__":unittest.main()