Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ jobs:
- run: npm run test:auth
- run: npm run test:tamper-hooks
- run: npm run test:i18n
- run: npm run test:navigation
- run: npm run test:chat-filter
- run: npm run test:bash
- run: npm run build:static

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All notable changes to this project are documented in this file. The format is b
### Added

- **Opt-in SELinux overlay for bind mounts**: `docker-compose.selinux.yml` layers private `:Z` labels on `./data`, `./keys` and `./skills` for hosts with SELinux enforcing. The base file keeps its unlabelled mounts, so the overlay is opt-in and a shared `:z` label never lets another container read the encryption keys (#632).
- **Browser back and forward across console views** (#641): page navigation is represented in query parameters (`tab`, `view`, `c`, `path`, and the inspector record parameters), so a user action pushes a history entry and back and forward restore the view. The native history API integrates with the Next router and a stable server snapshot keeps the static export working. Inspector payloads stay in memory and are never written to the URL or to browser storage. `npm run test:navigation` covers the history logic and now runs in CI.
- **Remote approvals over a chat bridge** (#642): a bridged chat can now carry an operator approval as one-time buttons instead of waiting for the console. The nonce is stored as a SHA-256 hash in the new `chat_bridge_approvals` table (migration 0019), a button is consumed atomically so a double tap cannot approve twice, and a group chat only sees the approvals of its own bridge.
- **Chat bridge text excerpts are opt-in** (#642): migration 0018 adds `share_text`, default false, so a bridge no longer forwards captured text unless the operator enables it. `SafeText` also strips more secret shapes, including quoted `curl -u` credentials, and the outbound path re-checks that the asker is still a member before delivering.
- **Tampering-hook tests run in CI**: the `web` job now runs `npm run test:tamper-hooks`. The suite existed as a script but no workflow called it, so a regression in the tampering-hook editor's payload and validation handling could merge without failing a check.
Expand All @@ -22,6 +23,7 @@ All notable changes to this project are documented in this file. The format is b
- **Go vulnerability scanning in CI**: every push and pull request runs the official `govulncheck` action against packages reachable from `./...`, using the Go version declared by `go.mod`. Run the same check locally with `./scripts/verify.sh --security`.

### Fixed
- **The chat agent filter no longer keeps a thread from another agent open**: switching the filter left the previously selected conversation in place, so a thread started with one agent could still be read while the filter showed another, and the draft could pick the wrong agent. The selection is now cleared when it does not belong to the new filter, and the draft uses the filtered agent. `npm run test:chat-filter` covers both helpers and now runs in CI.
- **Session tokens are no longer accepted from a URL query string**: the SSE, log and browser endpoints accepted `?token=`, which put a console JWT into browser history, proxy logs and `Referer` headers. Those endpoints now require the same Bearer header as the rest of the API; the console uses a `fetch` based SSE reader, the client-written auth cookie is gone, and the same-origin CORS preflight allows `Authorization` and `Last-Event-ID`. Login and uploads no longer carry a token in the URL either (#660).
- **CORS answers only the console's own origin**: the middleware reflected the request `Origin` without checking it, so any site could read cross-origin responses with a victim's cookie. It now reflects only an exact origin match and sends `Vary: Origin`; a mismatched `Sec-Fetch-Site` no longer causes a foreign origin to be allowed (#633). The one exception is a loopback Origin against a loopback target, so the `next dev` console on another local port keeps its live streams; the check requireAuth applies to cookie writes stays strict.
- **Task text and untrusted fields are quoted in logs**: `createTask` logged the description and goal raw, so a CR/LF in either could forge log lines. They and the sibling reason/URL lines in the engine, timeout, fingerprint and traffic-rewrite logs are now quoted with `%q` (#658).
Expand Down
51 changes: 51 additions & 0 deletions docs/browser-navigation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Browser navigation

Page navigation is represented in query parameters. User actions push a history
entry; restoring an initial saved preference replaces the current entry. Rendering,
polling and back/forward handling never mirror stale component state into the URL.
The native history API integrates with Next's router and preserves other query
parameters and the hash. A stable server snapshot supports the static export.

| View | Query parameter |
| --- | --- |
| Task detail, finding detail, task archive, assets, models, rules, tools, notifications | `tab` |
| Findings grouping | `view` |
| Conversation, including an explicit empty draft | `c` |
| Workspace directory | `path` |
| Traffic / tool execution / LLM record inspector | `exchange` / `command` / `record` |
| Return from a finding opened inside a task | `from_task` |

`context_task` retains its existing meaning for inherited finding access. The new
return parameter does not change which finding data the API supplies.

Inspector payloads remain in memory (at most 100 visited rows). Back/forward can
restore visited rows across client navigations; after a full reload, the selected
record must be in the loaded list. They are not arbitrary-record permalink APIs.
Payloads, credentials, and form contents are not written into the URL or browser
storage. Creation/edit dialogs and filters remain ordinary form state.

## Regression checks

Run `npm run test:navigation` in `web/` for the history logic. The test is included
in CI and the repository verification script.

For the browser checks, use a Python environment with Playwright and its Chromium
browser installed, then start the mock frontend:

```sh
cd web
NEXT_PUBLIC_MOCK=1 npm run dev -- --hostname 127.0.0.1 --port 18791
```

In another terminal:

```sh
ARTEX_TEST_URL=http://127.0.0.1:18791 python3 web/scripts/navigation-browser.py
```

The browser script uses the existing demo fixtures, emits a JSON result and a
screenshot alongside the script, and exits unsuccessfully if a case fails. It
covers back, forward, refresh, repeated tab selection, invalid tabs, task → finding
→ contextual return, chat selection/draft, record inspectors, and workspace
directories. `ARTEX_TEST_FILTER` selects cases whose names contain the given text.
Use this script against the mock frontend, not a production dataset.
1 change: 1 addition & 0 deletions scripts/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ if want_web; then
run_step "npm ci" npm --prefix web ci
fi
run_step "tsc --noEmit" bash -c 'cd web && npx tsc --noEmit'
run_step "web navigation tests" bash -c 'cd web && npm run test:navigation'
run_step "web polling tests" bash -c 'cd web && npm run test:polling'
run_step "web replay tests" bash -c 'cd web && npm run test:replay'
run_step "web upload tests" bash -c 'cd web && npm run test:upload'
Expand Down
4 changes: 3 additions & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
"test:i18n": "node scripts/check-i18n.mjs && node --test scripts/i18n.test.mjs",
"test:bash": "node --test src/lib/bash-exit-status.test.mjs",
"test:sse": "node --test scripts/sse.test.mjs",
"test:auth": "node --test scripts/auth.test.mjs"
"test:auth": "node --test scripts/auth.test.mjs",
"test:navigation": "node --test src/lib/navigation.test.mjs",
"test:chat-filter": "node --test src/lib/chat-agent-filter.test.mjs"
},
"lint-staged": {
"*.{js,ts,jsx,tsx}": [
Expand Down
119 changes: 119 additions & 0 deletions web/scripts/navigation-browser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import json, os, re
from pathlib import Path
from playwright.sync_api import sync_playwright, expect

base=os.environ.get('ARTEX_TEST_URL','http://127.0.0.1:18791')
results=[]
with sync_playwright() as p:
browser=p.chromium.launch(headless=True)
page=browser.new_page(viewport={"width":1440,"height":1000})
page.set_default_timeout(30000)
errors=[]
page.on('pageerror', lambda e: errors.append(str(e)))
def run(name, fn):
if os.environ.get('ARTEX_TEST_FILTER') and os.environ['ARTEX_TEST_FILTER'] not in name: return
try:
fn()
results.append({'name':name,'passed':True})
except Exception as e:
results.append({'name':name,'passed':False,'error':str(e)[:1200]})
print(json.dumps(results[-1]),flush=True)
def tab(name):
return page.get_by_role('tab',name=re.compile('^'+re.escape(name)+r'(\s|\d|$)'))
def selected(name):
expect(tab(name)).to_have_attribute('data-state','active')
def roundtrip(path, first, second, query):
page.goto(base+path,wait_until='domcontentloaded',timeout=90000)
selected(first)
initial=page.evaluate('history.length')
tab(second).click()
selected(second)
expect(page).to_have_url(re.compile(query))
tab(second).click()
assert page.evaluate('history.length')==initial+1
page.go_back()
selected(first)
page.go_forward()
selected(second)
page.reload()
selected(second)
for args in [
('/function/tasks','Current tasks','Archived','tab=archived'),
('/function/tasks/detail?id=t-acme-web','Sessions','Findings','tab=findings'),
('/function/findings/detail?id=f-1','Overview','Exploration graph','tab=lineage'),
('/function/findings','All findings','By task','view=grouped'),
('/function/assets','Companies','Root domains','tab=root_domain'),
('/system/llm','Model profiles','Retry & backoff','tab=retry'),
('/system/intercept','Interception rules','Model config','tab=judge'),
('/system/tools','System tools','Custom tools','tab=custom'),
('/system/notify','Channels','Delivery log','tab=deliveries'),
]:
run(args[0],lambda args=args: roundtrip(*args))
def task_finding():
page.goto(base+'/function/tasks/detail?id=t-acme-web&tab=findings',wait_until='domcontentloaded')
selected('Findings')
page.get_by_role('link',name='Details',exact=True).first.click()
expect(page).to_have_url(re.compile('from_task=t-acme-web'))
selected('Overview')
page.go_back()
selected('Findings')
page.go_forward()
selected('Overview')
back=page.locator('header a[href*="tab=findings"]')
expect(back).to_have_count(1)
back.click()
selected('Findings')
run('task → finding → browser back/forward → contextual return',task_finding)
def invalid_tab():
page.goto(base+'/function/tasks/detail?id=t-acme-web&tab=invalid',wait_until='domcontentloaded')
selected('Sessions')
run('invalid tab fallback', invalid_tab)
def chats():
page.goto(base+'/chat?c=1',wait_until='domcontentloaded')
one=page.locator('button[title="Double-click to rename"]').filter(has_text='Discussion on the acme admin entry point')
two=page.locator('button[title="Double-click to rename"]').filter(has_text='Mapping the API authorization bypass surface')
expect(one.locator('..')).to_have_class(re.compile('bg-accent text-accent-foreground'))
two.click()
expect(page).to_have_url(re.compile('c=2'))
expect(two.locator('..')).to_have_class(re.compile('bg-accent text-accent-foreground'))
page.go_back()
expect(page).to_have_url(re.compile('c=1'))
expect(one.locator('..')).to_have_class(re.compile('bg-accent text-accent-foreground'))
page.go_forward()
expect(two.locator('..')).to_have_class(re.compile('bg-accent text-accent-foreground'))
page.reload()
expect(two.locator('..')).to_have_class(re.compile('bg-accent text-accent-foreground'))
page.get_by_role('button',name='New conversation',exact=True).click()
expect(page).to_have_url(re.compile(r'c=($|&)'))
page.go_back()
expect(two.locator('..')).to_have_class(re.compile('bg-accent text-accent-foreground'))
run('chat selection, draft, back, forward and reload', chats)
def inspector(path,key):
page.goto(base+path,wait_until='domcontentloaded')
row=page.locator('tbody tr.cursor-pointer').first
row.wait_for()
row.click()
expect(page).to_have_url(re.compile(key+'=[^&]+'))
opened=page.url
page.go_back()
assert not re.search(key+'=[^&]+',page.url)
page.go_forward()
expect(page).to_have_url(opened)
expect(row).to_have_class(re.compile('bg-accent'))
for path,key in [('/function/traffic','exchange'),('/function/commands','command'),('/function/llm-records','record')]:
run(path+' inspector back/forward',lambda path=path,key=key: inspector(path,key))
def workspace():
page.goto(base+'/function/workspace',wait_until='domcontentloaded')
page.locator('tbody tr').filter(has_text='t-001').first.get_by_role('button').first.click()
expect(page).to_have_url(re.compile('path=t-001'))
page.go_back()
expect(page.locator('tbody tr').filter(has_text='t-001').first).to_be_visible()
page.go_forward()
expect(page).to_have_url(re.compile('path=t-001'))
run('workspace directories back/forward',workspace)
page.screenshot(path=str(Path(__file__).with_name('mock-navigation.png')))
browser.close()
Path(__file__).with_name('browser-results.json').write_text(json.dumps({'results':results,'page_errors':errors},indent=2))
assert all(r['passed'] for r in results), 'browser regressions failed'

assert not errors, "browser page errors occurred"
Loading
Loading