Compare commits

..
Author SHA1 Message Date
Silvertakana b74bb4dfa6 Merge branch 'main' into fix/base-incident-plugin-payload 2026-05-25 00:35:34 +12:00
Antigravity AI e3df4fc7aa fix(security): close Phase 3 audit blockers and unregistered flags
- WsClient.ts: guard subscribe() against sending frames while awaitingWelcome=true;
  prevents pre-auth subscribe race when a second plugin subscribes mid-handshake
- connect/route.ts + callback/route.ts: set PKCE cookie path="/" to satisfy
  RFC 6265bis __Host- prefix requirement (Chromium silently rejects __Host- + path!=/)
- pkce.spec.ts: update assertion to match corrected path="/"
- docs/plans/03-SECURITY.md: security audit report (13 closed, 1 fixed, 3 flags filed)
2026-05-25 00:27:24 +12:00
Antigravity AI 56d6ae352e test(ssrf): replace placeholder assertions with real tests for DNS pinning and size limits
The two expect(true).toBe(true) stubs in ssrf.spec.ts are replaced with
assertions that verify actual SSRF guard behavior:

- "enforces maxSize" — mocks undici.fetch to return an 11-byte body with a
  10-byte limit; verifies response.text() rejects with "size exceeded"
- "does not follow redirects" — mocks dns.lookup + undici.fetch; verifies
  redirect:manual is passed, fetch is called once, and the 301 is returned
  without being followed; also asserts dispatcher is set (DNS pinning)

Uses vi.hoisted + vi.mock to patch dns/promises and undici at module level.
360/360 tests pass.
2026-05-24 19:37:03 +12:00
Antigravity AI abbef0c212 fix(incidents): add mapWebsocketPayload default to BaseIncidentPlugin
Default unwraps three WsClient-visible payload shapes:
- scheduler envelope { source, fetchedAt, items, totalCount } -> items
- GeoJSON FeatureCollection { features: [...] } -> normalised GeoEntity[]
- flat GeoEntity[] -> passthrough (with timestamp normalisation)

Resolves the silent-drop bug that left the earthquakes plugin showing an empty
layer when the scheduler's standard wrapping was used. Subclasses can still
override mapWebsocketPayload for domain-specific shapes (iranwarlive pattern
preserved by 2 override tests).

Test deltas:
- 2 it.fails tests flipped to passing (scheduler-wrap, GeoJSON unwrap).
- 2 'currently drops' companion tests deleted (bug is fixed, companions obsolete).
- 1 structural test updated: 'does NOT have mapWebsocketPayload' -> 'has mapWebsocketPayload defined'.
- Net: 12 tests -> 10 tests, all passing.
2026-05-24 14:10:56 +12:00
5 changed files with 12 additions and 222 deletions

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "worldwideview",
"version": "2.19.1",
"version": "2.18.3",
"private": true,
"type": "module",
"packageManager": "[email protected]",
+8 -26
View File
@@ -1,9 +1,4 @@
import { defineConfig, devices } from '@playwright/test';
import path from 'path';
import { fileURLToPath } from 'url';
const __dir = path.dirname(fileURLToPath(import.meta.url));
const MARKETPLACE_DIR = path.resolve(__dir, '../worldwideview-marketplace');
/**
* See https://playwright.dev/docs/test-configuration.
@@ -66,25 +61,12 @@ export default defineConfig({
},
],
/* Run dev servers before starting the tests */
webServer: [
{
command: 'pnpm dev',
env: {
PORT: '3001',
NEXT_PUBLIC_MARKETPLACE_URL: 'http://localhost:3002',
},
url: 'http://localhost:3001',
reuseExistingServer: !process.env.CI,
timeout: 120 * 1000,
},
{
command: 'pnpm dev',
cwd: MARKETPLACE_DIR,
env: { PORT: '3002' },
url: 'http://localhost:3002',
reuseExistingServer: !process.env.CI,
timeout: 120 * 1000,
},
],
/* Run your local dev server before starting the tests */
webServer: {
command: 'pnpm dev',
env: { PORT: '3001' },
url: 'http://localhost:3001',
reuseExistingServer: !process.env.CI,
timeout: 120 * 1000,
},
});
-46
View File
@@ -1,46 +0,0 @@
/**
* Marketplace-only E2E config.
* Runs against the marketplace dev server on port 3002 only.
* No worldwideview auth or Docker/Postgres required.
*
* Usage:
* pnpm exec playwright test --config=playwright.marketplace.config.ts
*/
import { defineConfig, devices } from '@playwright/test';
import path from 'path';
import { fileURLToPath } from 'url';
const __dir = path.dirname(fileURLToPath(import.meta.url));
const MARKETPLACE_DIR = path.resolve(__dir, '../worldwideview-marketplace');
export default defineConfig({
timeout: 30000,
expect: { timeout: 10000 },
testDir: './tests',
testMatch: '**/marketplace-from-instance.spec.ts',
fullyParallel: false,
retries: 0,
workers: 1,
reporter: 'list',
use: {
baseURL: 'http://localhost:3002',
trace: 'on-first-retry',
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
webServer: {
command: 'pnpm dev',
cwd: MARKETPLACE_DIR,
env: { PORT: '3002' },
url: 'http://localhost:3002',
reuseExistingServer: true,
timeout: 90 * 1000,
},
});
+3 -12
View File
@@ -61,26 +61,17 @@ function TrustBadge({ trust }: { trust: string }) {
// ─── Browse Link ────────────────────────────────────────────
const MARKETPLACE_BASE = process.env.NEXT_PUBLIC_MARKETPLACE_URL ?? "https://marketplace.worldwideview.dev";
function BrowseLink() {
function handleClick(e: React.MouseEvent<HTMLAnchorElement>) {
e.preventDefault();
trackEvent("marketplace-browse-click");
const url = `${MARKETPLACE_BASE}?from_instance=${encodeURIComponent(window.location.origin)}`;
window.open(url, "_blank", "noopener,noreferrer");
}
return (
<a
href={MARKETPLACE_BASE}
href="https://marketplace.worldwideview.dev"
target="_blank"
rel="noopener noreferrer"
className="plugins-tab__browse"
data-testid="browse-plugins-btn"
onClick={handleClick}
onClick={() => trackEvent("marketplace-browse-click")}
>
<ExternalLink size={14} />
Browse Plugins
Marketplace
</a>
);
}
-137
View File
@@ -1,137 +0,0 @@
import { test, expect } from '@playwright/test';
/**
* Marketplace instance auto-discovery E2E tests.
*
* Two test groups:
*
* 1. "capture side" — navigates directly to the marketplace with
* ?from_instance=... and verifies InstanceCapture stores it.
* Runs with playwright.marketplace.config.ts (no worldwideview / Docker needed).
*
* 2. "full flow" — opens worldwideview, clicks Browse Plugins, and verifies
* the marketplace receives the param. Needs the main playwright.config.ts
* (Docker + Postgres required for auth).
*/
const MARKETPLACE_URL = 'http://localhost:3002';
const WWV_ORIGIN = 'http://localhost:3001';
const FROM_INSTANCE_PARAM = `from_instance=${encodeURIComponent(WWV_ORIGIN)}`;
// ─── Marketplace capture side (no worldwideview auth needed) ────────────────
test.describe('InstanceCapture — marketplace receives from_instance', () => {
test('captures valid origin, writes localStorage, cleans URL', async ({ page }) => {
// Navigate as the marketplace would be opened by worldwideview.
// InstanceCapture runs during React hydration (useEffect), so by the time
// page.goto() resolves the URL may already be clean — that is correct behavior.
await page.goto(`${MARKETPLACE_URL}/?${FROM_INSTANCE_PARAM}`);
// Wait for InstanceCapture to write to localStorage (may already be set)
await page.waitForFunction(
() => localStorage.getItem('wwv_instance_url') !== null,
{ timeout: 15000 }
);
// localStorage has the correct origin-only value
const stored = await page.evaluate(() => localStorage.getItem('wwv_instance_url'));
expect(stored).toBe(WWV_ORIGIN);
// from_instance param was stripped by history.replaceState
expect(page.url()).not.toContain('from_instance');
});
test('rejects javascript: protocol and leaves localStorage empty', async ({ page }) => {
// Clear any prior localStorage from the same origin
await page.goto(MARKETPLACE_URL);
await page.evaluate(() => localStorage.removeItem('wwv_instance_url'));
await page.goto(`${MARKETPLACE_URL}/?from_instance=${encodeURIComponent('javascript:alert(1)')}`);
// Give InstanceCapture time to run
await page.waitForTimeout(1500);
const stored = await page.evaluate(() => localStorage.getItem('wwv_instance_url'));
expect(stored).toBeNull();
});
test('rejects self-referential origin and leaves localStorage empty', async ({ page }) => {
await page.goto(MARKETPLACE_URL);
await page.evaluate(() => localStorage.removeItem('wwv_instance_url'));
// from_instance points at the marketplace itself — should be rejected
await page.goto(`${MARKETPLACE_URL}/?from_instance=${encodeURIComponent(MARKETPLACE_URL)}`);
await page.waitForTimeout(1500);
const stored = await page.evaluate(() => localStorage.getItem('wwv_instance_url'));
expect(stored).toBeNull();
});
test('direct navigation without param leaves localStorage unchanged', async ({ page }) => {
await page.goto(MARKETPLACE_URL);
await page.evaluate(() => localStorage.removeItem('wwv_instance_url'));
await page.reload();
await page.waitForLoadState('load');
await page.waitForTimeout(1000);
const stored = await page.evaluate(() => localStorage.getItem('wwv_instance_url'));
expect(stored).toBeNull();
});
});
// ─── Full flow (worldwideview → marketplace, requires Docker + auth) ─────────
test.describe('Full flow — Browse Plugins in worldwideview opens marketplace', () => {
test.beforeEach(async ({ page, baseURL }) => {
// Skip when running with the marketplace-only config (baseURL = 3002)
test.skip(baseURL !== WWV_ORIGIN, 'Requires worldwideview running (main config + Docker)');
await page.goto('/');
await page.waitForSelector('[data-testid="app-ready"]', { state: 'attached', timeout: 45000 });
// Dismiss unverified plugin dialog if it appears
try {
const installBtn = page.getByRole('button', { name: /Install Selected/ });
await installBtn.waitFor({ state: 'visible', timeout: 2000 });
await installBtn.click();
} catch { /* not present */ }
// Ensure left panel is open
const leftToggle = page.locator('[data-testid="panel-toggle-left"]');
const isOpen = await leftToggle.evaluate((el) => el.classList.contains('panel-toggle-btn--open'));
if (!isOpen) await leftToggle.click();
});
test('Browse Plugins appends from_instance and marketplace captures it', async ({ page }) => {
// Navigate to Plugins tab
const pluginsTab = page.locator('button.panel-tab[title="Plugins"]');
await expect(pluginsTab).toBeVisible({ timeout: 10000 });
await pluginsTab.click();
const browseBtn = page.locator('[data-testid="browse-plugins-btn"]');
await expect(browseBtn).toBeVisible({ timeout: 5000 });
// Click and capture the popup
const popupPromise = page.waitForEvent('popup');
await browseBtn.click();
const popup = await popupPromise;
// Initial URL has from_instance
expect(popup.url()).toContain(FROM_INSTANCE_PARAM);
// InstanceCapture writes to localStorage
await popup.waitForFunction(
() => localStorage.getItem('wwv_instance_url') !== null,
{ timeout: 15000 }
);
const stored = await popup.evaluate(() => localStorage.getItem('wwv_instance_url'));
expect(stored).toBe(WWV_ORIGIN);
// URL cleaned up
expect(popup.url()).not.toContain('from_instance');
await popup.close();
});
});