Repository navigation
feat(web): global company switcher in the sidebar - #425
Conversation
BaaRai
left a comment
There was a problem hiding this comment.
Request changes.
- Findings with no anchored asset appear under every company scope.
applyAssetScopesetsIncludeUnanchored = true, andTestFindingCompanyScopeFilterexpects a company that owns no assets, and even a nonexistent company id, to see them. Pick an attribution (exclude them from company views, or keep them only in "all companies") and pin it. - The task list is filtered in the browser (
tasks/page.tsx), not on the server. With paging the counts and the loaded page are wrong. Filter tasks server-side and keep the client to the display. - The switcher is announced as narrowing the dashboard, the asset tabs and the traffic list. Please state which endpoints actually filter server-side today; groups, the stat cards and the asset tree are not in this diff.
- Add a test that a DSL expression with a top-level OR cannot escape the
company_idfilter (server/assets.gowraps it as(company_id=N) AND (dsl)). - CI: gofmt on
traffic/traffic.go, missing i18n keys for the new strings, and the PR conflicts with main inserver/server.go. Rebase and run the web checks.
|
Thanks for this, the switcher itself is a good addition and the sidebar component reads well. I checked the company scope on the current head and it does not hold in the places below, so I am asking for changes before this can go in. How the responses below were obtained: the HTTP handlers of this PR were called directly (not through the router or a logged-in session) against a fresh database holding two companies (ids 1 and 2, one (a) The company filter on the DSL path of
|
The panel had no way to scope it to one target. Companies exist as the ownership layer, but only the task form offered one, so a second engagement mixed into every list. Sidebar header, under the logo: a company picker that defaults to "All companies" and persists per browser. Every asset-backed view follows it — findings (all three views plus the asset tree and export), the dashboard's finding panels, the task list, the traffic list and the assets tabs. Server side the switch rides on the existing ownership column: findings and traffic take a company, and the assets list takes company_id on both the plain and the DSL path. Findings with no live asset anchor stay visible under their company, because they belong to no other one; the strict subtree filter would hide them from every view. Tests: TestFindingCompanyScopeFilter (own assets, another company, a company with none, a nonexistent id) and TestPageHostsAllowlist. Full ./db/ ./traffic/ ./server/ pass. Co-Authored-By: Claude Code <[email protected]> Claude-Session: https://claude.ai/code/session_01BWbhPDnkSEFNzBXG4wDvTj
Co-Authored-By: Claude Code <[email protected]> Claude-Session: https://claude.ai/code/session_01BWbhPDnkSEFNzBXG4wDvTj
- Findings with no live asset belong to a company only through their task's company scope; unknown or non-numeric ids match nothing. - Filter tasks by company on the server (GET /api/tasks?company=). - Scope the grouped findings view, the asset tree and the stat cards. - AND company_id outside the compiled asset DSL so OR cannot escape it. - Add the 7 company switcher keys to tr.json and zh-CN.json. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01BWbhPFZifkVU75uaD5NYj5
0e21c53 to
9734b4b
Compare
|
Thanks for the detailed review. Rebased on
@BaaRai ready for another look. |
BaaRai
left a comment
There was a problem hiding this comment.
LGTM — all five review items verified on 9734b4b against a fresh PostgreSQL 16 database:
- Unanchored findings: scoped strictly by
task_scope(kind = 'company'); never shown under other companies, nonexistent IDs, or non-numeric IDs (verified across paginated findings, bare array findings, and deleted-asset findings). - Server-side task filter:
GET /api/tasks?company=<id>filters server-side and returns empty for unknown/non-numeric IDs. - Server-side filtering across views: findings groups, finding stat cards, finding asset tree, paginated assets, and traffic host allowlist all filter server-side with matching counts.
- DSL top-level
ORsafety:company_idis ANDed outside the compiled DSL inCountDSLForCompany/QueryDSLForCompany, so top-levelORqueries cannot escape the active company. - Formatting / i18n / merge:
gofmtclean,test:i18n(5/5) andtsc --noEmitpass, and clean merge againstmain.
Two minor follow-ups (non-blocking):
GET /api/assets/countsdoes not yet filter bycompany_id, so asset tab badges and the dashboard's "Asset nodes" card still show global counts.- On the dashboard, only findings narrow by the active company (
tasks,traffic, andassetCountsremain global).
|
Thanks @joanrodriguez. Merged. The company scope holds on the server across findings, tasks, groups, stats, the asset tree, assets and traffic; the two remaining global counts are noted as follow-ups. |
…d audit schema (#31) * E5: engagement authorization artifact in the target gate, hash-chained audit schema Migration 0016: audit_chain (append-only, SHA-256 linked, row triggers on intercept_pending/artex_users/engagement_authorizations), artex_users, engagement_authorizations (versioned, immutable rows). The artifact (scope, time window, technique classes) is consulted inside the existing target gate: run() and ungated() check it first, and target-less calls go through authorizeCall from CheckTargets/CheckUngated. Refusals are decided intercept rows. Card c-669406. Co-Authored-By: Claude Opus 5.5 <[email protected]> * E5: authorization and audit-chain endpoints, chain verification with tamper tests GET/POST /api/tasks/{id}/authorization, POST .../revoke; GET /api/intercept/history/chain and /chain/verify. Verification recomputes every hash, checks seq continuity and the head row, and compares each intercept history row with its newest chain entry. Card c-669406. Co-Authored-By: Claude Opus 5.5 <[email protected]> * E5: governance endpoints read the task id from the path, HTTP test Co-Authored-By: Claude Opus 5.5 <[email protected]> * E5: RBAC (admin/operator/reviewer/client_read) over the existing JWT, users API, docs Console users in artex_users; tokens carry uid/uv and are checked against the row on every request (fails closed). The legacy ARTEX login stays admin. requireAuth enforces a declarative route policy (server/rbac_policy.go) matched on the mux pattern; refusals answer 403 and are appended to the audit chain. Logins are audited. Fix: the authorization check no longer claims the call's trace entry unless it refuses (kept exact intercept correlation). docs/GOVERNANCE.md documents roles, the artifact and the chain. Card c-669406. Co-Authored-By: Claude Opus 5.5 <[email protected]> * E5: review fixes — spawn_task inherits the artifact, snapshot/UTC verify, tighter reads - spawn_task: the child inherits the caller's current artifact (read from the call's scope); a revoked/expired artifact refuses the spawn, and the gate keeps window/revocation on spawn_task. - Local tools return before the artifact lookup (never refused, no query). - Verify runs in one repeatable-read UTC snapshot; the row trigger pins UTC. - Reviewers lose raw traffic exchange/blob/HAR/stream and conversation messages. - change-password is limited to the ARTEX session; actor names reserved; control characters stripped from audited usernames. - Docs and CHANGELOG. Card c-669406. Co-Authored-By: Claude Opus 5.5 <[email protected]> * HANDOFF: E5 state, triage, decisions, follow-up cards Co-Authored-By: Claude Opus 5.5 <[email protected]> * HANDOFF: renumber triage Co-Authored-By: Claude Opus 5.5 <[email protected]> * HANDOFF: deltas stamp Co-Authored-By: Claude Opus 5.5 <[email protected]> * db: chain audit row entries at commit (migration 0018) so the head lock no longer stalls gate writes (c-ba9f64) The intercept_pending, artex_users and engagement_authorizations audit triggers become DEFERRABLE INITIALLY DEFERRED constraint triggers. The audit_chain_head lock is now taken only during COMMIT, after every other lock, so a task archive no longer stalls gate decisions, logins and rbac.denied entries, and write-then-lock transactions cannot deadlock on the head. Concurrency tests reproduce both failures without 0018. Co-Authored-By: Claude Opus 5.5 <[email protected]> * HANDOFF: deltas stamp (c-ba9f64) Co-Authored-By: Claude Opus 5.5 <[email protected]> * E5: bind client_read users to their companies (c-5b5421) client_read was global: a client account for company A could read every client's findings, reports and exports. Bindings now live in artex_user_companies (migration 0019, audited at commit like the other governance tables) and are managed at GET/PUT /api/users/{id}/companies. Every route rbacPolicy opens to client_read has a binder (client_scope.go) that runs after the role check: findings routes are narrowed to the bound company through the BaaRai#425 company filter, ids and tasks outside the binding answer 404, an unbound client gets 403, and a route without a binder is refused. Task ownership and the unanchored-finding fallback count only operator-made company scope rows, so an agent cannot widen what a client sees. The client report and stats no longer carry global asset/traffic counts. Live retests across all clients moved to the read permission. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs: client binding (c-5b5421) in GOVERNANCE, CHANGELOG, HANDOFF Co-Authored-By: Claude Opus 5.5 <[email protected]> * HANDOFF: deltas stamp (c-5b5421) Co-Authored-By: Claude Opus 5.5 <[email protected]> * web(E5): session role/permissions context, governance API client, role-filtered sidebar, username login (c-869050) Co-Authored-By: Claude Opus 5.5 <[email protected]> * web(E5): Users page, task Authorization tab, audit Chain tab with Verify; client_read-safe sidebar (c-869050) - /system/users (admin): table with inline role/enabled, set password, delete, client_read company bindings, add-user dialog. - Task detail Authorization tab: current version + status badge, version history table, admin-only new-version form and revoke. - Approval Records: Approvals | Chain tabs; chain table with filters, paging, entry sheet, Verify (head_seq/head_hash, broken_at, rows_mismatched). - client_read sessions skip the company switcher and the global retest poll. - verify.sh runs the governance unit tests and the i18n check; tr/zh-CN strings. Co-Authored-By: Claude Opus 5.5 <[email protected]> * HANDOFF: E5 web UI state, triage, decisions, follow-up cards (c-869050) Co-Authored-By: Claude Opus 5.5 <[email protected]> * HANDOFF: shorten c-869050 current-state entry Co-Authored-By: Claude Opus 5.5 <[email protected]> * HANDOFF: deltas stamp (c-869050) Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Problem
The panel cannot be scoped to one target.
companiesis the ownership layer, but a company could only be attached while creating a task. A second engagement mixed into the dashboard, the findings list, traffic and the asset tabs.Change
A global company switcher in the sidebar header, under the logo, built like a workspace switcher: search, an explicit All companies entry, the asset count per company, and a link to the companies tab. The choice persists per browser.
Endpoints that filter server-side
GET /api/exploration/findings(paged and bare array)company=<id>GET /api/exploration/findings/groups,GET /api/exploration/findings?task_id=company=<id>GET /api/exploration/findings/asset-treecompany=<id>(kept while the picked node is cleared)GET /api/exploration/findings/statscompany=<id>GET /api/exploration/findings/export?scope=filteredcompany=<id>GET /api/taskscompany=<id>GET /api/trafficcompany=<id>, resolved to the hosts the company ownsGET /api/assets(plain and DSL path)company_id=<id>Not filtered:
GET /api/stats(the dashboard's global counters), the globalcountonGET /api/traffic(the traffic stat card), andGET /api/assets/counts.The browser only displays what these endpoints return.
asset_scope=c:<id>still works and means the same ascompany=<id>.Attribution rule
company_id = C.asset_ids, or only deleted asset ids) belongs to C only when its task has atask_scoperow of kindcompanyfor C.Assets DSL
company_idis ANDed as a SQL clause next to the compiled DSL. It is no longer pasted into the DSL text, so)or a top-levelORcannot escape it.Testing
go test -p 1on every package against Postgres 16.gofmtandgo vetclean.TestFindingCompanyScopeFilter(rewritten): own asset, task-scoped unanchored finding, deleted asset, company without assets, nonexistent id, non-numeric id, a company node outside the selected company, the asset tree and the stat cards.TestListAssetsCompanyFilterSurvivesDSLOr: the exact payloadcompany_id=A) OR (company_id=Band a plain top-level OR. It fails on the previous head.TestQueryDSLForCompanyOrDoesNotEscape: the same at the store level.TestListTasksFiltersByCompany: company A, company B, non-numeric id, all companies.TestPageHostsAllowlist: exact host allowlist,MatchNone, no filter.tsc --noEmit,test:i18n,test:polling,test:replay,test:upload,test:bash,build:static.biome lintreports no new errors on the touched files.🤖 Generated with Claude Code
https://claude.ai/code/session_01BWbhPFZifkVU75uaD5NYj5