Commit Graph
493 Commits
Author SHA1 Message Date
BaaRai 3d79ec9528 fix(goals): fall back to raw goal only when no LLM provider is configured (#585) 2026-11-27 01:39:33 +01:00
BaaRai 01424b685e fix(goals,planner): enforce structured set_goals contract and guard empty planner context (#585) 2026-11-27 01:08:45 +01:00
BaaRai 95af051481 Merge main into chore/migrate-slog-server (resolve CHANGELOG.md) 2026-11-27 00:13:09 +01:00
BaaRai 0d66d6f489 Merge main into fix/skill-db-error (resolve CHANGELOG.md) 2026-11-27 00:13:00 +01:00
BaaRai c63262fd25 Merge main into fix/llm-test-max-completion-tokens (resolve CHANGELOG.md) 2026-11-26 23:40:10 +01:00
BaaRai 1d1471ed42 synthetic main: +#558 2026-11-26 23:40:10 +01:00
BaaRai aadd77ff2d Merge main into fix/render-template (resolve CHANGELOG.md) 2026-11-26 23:24:38 +01:00
BaaRai 1b876de687 synthetic main: +#575 2026-11-26 23:24:38 +01:00
BaaRai a8d0538051 Merge remote-tracking branch 'origin/main' into pr541
# Conflicts:
#	web/src/i18n/locales/tr.json
#	web/src/i18n/locales/zh-CN.json
2026-11-26 22:26:20 +01:00
BaaRai 7766898ce6 Merge pull request #456 from Shiv9993/feat/chat-bridge-core
feat(chatbridge): inbound chat bridge core with a Telegram long-poll transport (#5, part 1 of 3)
2026-11-26 22:25:11 +01:00
BaaRai 9cdd6b7172 Merge pull request #572 from chaitanya0305/fix/report-task-asset-counts
fix(server): count only the task's assets in the task report
2026-11-26 22:24:24 +01:00
BaaRai c203af2f5c fix(agent): keep Auto and MainAgent on orchestration tools, not Bash/WebFetch
Fixes #544
2026-11-26 21:35:20 +01:00
Phantom-IN a9b692f750 fix(llm): keep stored prices when a profile save omits them
Every save rewrites all four price columns, so an API client that sent
the profile without price fields reset them to 0. Decode the prices as
*float64 and keep the stored value for any that are missing.
2026-11-27 00:54:34 +05:30
shivandkrad b6ec42f15a fix(chatbridge): address review notes on the bridge core
- Require https for base_url. The bot token travels in the URL path and
  the responses are the updates the bridge acts on, so plain http is
  accepted only with ARTEX_NOTIFY_ALLOW_LOCAL=1, for a local test server.
- Cut replies by UTF-16 code units, which is how Telegram counts its 4096
  limit, so emoji-heavy text is no longer rejected. A cut never splits a
  character.
- Cap a server-sent retry_after at the backoff ceiling (1 minute).
- Pause one second after an empty poll, so a self-hosted Bot API that
  ignores the long-poll timeout cannot spin the loop.
- When the refused-chat memory is full, start over instead of muting
  every new chat, which also muted the operator's own chat. Saving the
  configuration of the same bot keeps the memory.
- Fix two stale comments that said an empty allowlist keeps the bridge
  off (migration 0015 is unreleased, so editing its comment is safe).

Co-authored-by: krad <222954346+dar1k0@users.noreply.github.com>
2026-11-26 22:24:28 +05:30
Nirlep Makwana 1860781c82 chore: address review feedback on skill hint, triage logging, and archive log level 2026-11-26 20:47:31 +05:30
GabriMarch3andClaude Opus 5.5 8e3d17136e fix(llm): honor max_tokens_field in the connection test
The Test button on System -> LLM always sent the output cap as max_tokens,
because POST /api/llm/test never read the profile's max_tokens_field. OpenAI
reasoning models (o-series, GPT-5) reject max_tokens with
unsupported_parameter, so a profile set to max_completion_tokens failed the
test with HTTP 400 while conversations with the same profile worked.

testLLM now accepts max_tokens_field from the form and falls back to the
stored profile's value when the field is omitted (list-view test). It is
normalized like profile saves: only the openai format with
max_completion_tokens keeps it. The form passes its current selection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 12:54:04 +01:00
Coff0xc 7d880b0674 fix(server): substitute custom-tool placeholders once
renderTemplate walked the param map and replaced into the string so far,
so a value containing {other} could be expanded on a later key. Replace
each {name} in the original template only.
2026-11-26 11:47:42 +00:00
Chaitanya Deshpande 1fceeb3479 fix(server): count only the task's assets in the task report
GET /api/report renders one task's report, but its "Assets:" summary line
was built from QueryByType over the whole asset library, so it reported
every task's and every company's assets as this task's. It also loaded up
to 100000 full rows per type only to count them.

Use CountsByTypeForTask, the per-task count the assets tab already uses.
2026-11-26 17:09:05 +05:30
Coff0xc 8c8407b126 merge origin/main into fix/skill-db-error 2026-11-26 11:22:47 +00:00
Phantom-IN 9be8227535 feat(llm): set profile prices in the settings dialog
The cost ledger (#70) stores four prices per profile and the usage API
turns them into cost_eur, but the UI never got the follow-up: the profile
list did not return the prices and the dialog had no inputs for them.

That also made prices fragile. SaveProfile always rewrites the price
columns, and the dialog's save payload had no price fields, so editing a
profile in the UI reset prices set through the API to zero.

Return the prices in LLMProfileDTO, add the four inputs to the dialog and
send them on save. A negative price is stored as unset.
2026-11-25 20:58:18 +05:30
Nirlep Makwana 7fbe10abed chore: migrate log.Printf to log/slog in server management and control 2026-11-25 17:33:52 +05:30
shivandkrad 58bafdbf76 feat(chatbridge): inbound chat bridge core with a Telegram long-poll transport
First part of #5: the transport-agnostic bridge core, the Telegram
adapter, the mandatory chat allowlist, storage, API and settings page.
Task commands, main-agent routing and remote approvals follow in
separate PRs on top of this one.

- chatbridge: Transport interface and Router. The router enforces the
  allowlist (an unknown chat gets one refusal naming its chat ID, then
  silence, bounded memory), drops updates older than two minutes so a
  backlog is never executed, ignores bot senders and commands addressed
  to another bot, and dispatches commands (/help, /whoami for now).
- Telegram transport: getUpdates long polling (no inbound port),
  plain-text sendMessage truncated to the Bot API limit, getMe for the
  identity. It reuses notify's dial guard and redirect policy through
  small exported wrappers, and its errors never carry the token.
- Storage: migration 0015 adds chat_bridges, one row per kind. config
  is sealed at rest (added to secretColumns) and masked in the API with
  the notification-channel convention. The update cursor is committed
  before a batch is acted on, only moves forward, and is written only
  for the config_version the poller read, so a poll of a replaced token
  can never move the new bot's cursor. A token change clears it.
- Server: one loop per transport started by server.New; it re-reads its
  row each round and Reload interrupts a poll in flight, so saving the
  form applies without a restart. Exponential backoff on errors, honours
  Telegram's retry_after, logs under [tgbot] without message text.
- API: GET /api/chat-bridges, PUT /api/chat-bridges/{kind},
  POST /api/chat-bridges/{kind}/test. A bridge may run with an empty
  allowlist: it then serves no chat and only sends the one-time refusal
  naming the chat ID, which is how an operator finds the ID to add.
- Web: System -> Chat bot page with live status, zh-CN and tr strings.
- Docs: docs/chat-bridge.md; README lists the token among stored secrets.

The migration test lists 0015; the pre-0012 test rolls it back with the
others and it re-applies (the migration is idempotent).

Co-authored-by: krad <222954346+dar1k0@users.noreply.github.com>
2026-11-24 15:11:50 +05:30
BaaRai 6ebb2b3d0a Merge pull request #510 from kalt2212/feat/issue-423-fail-closed-privdrop
fix(server): fail-closed privilege drop and set PR_SET_NO_NEW_PRIVS on linux (#423)
2026-11-23 23:39:58 +01:00
Adrian Martinez Garcia b6748f8ec0 fix(server): lock OS thread and set PR_SET_NO_NEW_PRIVS in shims before exec
PR_SET_NO_NEW_PRIVS is per thread. PrepareExecPrivilege set it on a server thread that never execs, so the flag was not inherited by agent processes. The shims set it in enterExecutor, but runBashShim and runDropShim did not lock their goroutine, so it could migrate between prctl and exec.

Move the prctl out of PrepareExecPrivilege. Lock the thread at the top of runBashShim and runDropShim; the lock is never released because exec replaces the process.

Replace the test with a deterministic one: the drop shim runs as root with GOMAXPROCS=1, and a wrapped setNoNewPrivsFn forces the goroutine off its thread. Without the lock the exec'd program reports NoNewPrivs 0; with it, 1.
2026-11-23 22:28:50 +00:00
BaaRai a37403d1e7 Merge pull request #488 from sresarehumantoo/chore/slog-migration-v2
chore: migrate log.Printf to log/slog in traffic, egress, enrich and evidence
2026-11-23 23:18:08 +01:00
BaaRai 5ce4e1eae9 Merge branch 'main' into chore/slog-migration-v2 2026-11-23 22:58:53 +01:00
BaaRai d2ccabff98 Merge branch 'main' into feat/systemone-profile-format 2026-11-23 22:58:48 +01:00
BaaRai 3112fef438 chore(logs): keep the tags and read the slog level
The slog migration dropped the [traffic], [egress], [enrich] and [evidence]
tags, so the logs view lost the badge and the level was guessed from the
message text. Put the tag back in each message and teach parseLog to read the
slog level word (2026/11/23 13:48:50 WARN [traffic] ...) before the tag.

Adds parseLog tests for the real slog line, the level words and the legacy
no-level shape.
2026-11-23 22:25:32 +01:00
BaaRai c8c6df423c fix(agent): make the triage threshold atomic
The threshold is written by the settings path and read by the report_finding
worker, so a plain float global is a data race. Store the bits in an
atomic.Uint64, restore the default on 0 or negative, and accept 0 in
applyTriageThreshold so a reset takes effect.

Adds a two-goroutine -race test and the Set(0) reset test.
2026-11-23 22:24:53 +01:00
Adrian Martinez Garcia 528e5230cd fix(server): fail-closed privilege drop and set PR_SET_NO_NEW_PRIVS on linux (#423) 2026-11-23 19:27:26 +00:00
Phantom-IN 2efc2aca68 fix(server): seed a goal URL that is followed by punctuation
parseTarget pulls the first URL out of the goal with https?://[^\s'"]+,
which keeps any punctuation that follows it. "Assess http://juiceshop:3000."
matches "http://juiceshop:3000.", url.Parse rejects the port, and the seed
logs "could not parse a target host/IP" even though goalGateCheck accepted
the same goal. A dotted host only survived through the domain fallback,
which takes the scheme from the port, and a sentence-final period stayed
in the host.

Trim trailing punctuation before parsing the URL, including full-width
punctuation from pasted text. A closing bracket is trimmed only when the
URL has no matching opener, so a bracketed IPv6 host like http://[::1]
still parses.
2026-11-23 20:09:03 +05:30
Николай Гусев a3e44d3f05 agent: close the review blockers on the advisory duplicate check
Fixes the three blockers and three shoulds from the review of #470, rebased
onto current main.

Blocker 1 — no way out of a wrong suppression. The suppression note told the
agent to register a distinct defect again, but report_finding had no override:
the retry hit the same check and was suppressed again. report_finding now takes
force_register, which skips the duplicate check for that call and logs the
override. Covered end to end: suppress, then register with the flag.

Blocker 2 — id mismatch. The suppression answer returned duplicate_of_finding_id
(the findings-table id) while update_finding_report addresses the exploration
NODE. The answer now carries duplicate_of_finding_node_id as well, and the note
names the node id to pass. withNodeID resolves it from the candidates the
question offered, so an id the model was never shown maps to nothing.

Blocker 3 — unguarded HTTP client. SystemOneClient.http() returned a bare client,
so a stored triage profile could point the server at an internal host. The client
is now built by the server under the same endpoint guard as the model-list path:
ARTEX_LLM_PRIVATE_ENDPOINTS allow-list, private and metadata addresses refused,
no proxy, redirects not followed. A refused base_url leaves triage off (fail
open, as every other triage failure). TriageHTTPTimeout is exported so the
injected client uses the same budget instead of a second number.

Should 4 — UTF-8 truncation. capText and buildDuplicateState cut by byte index,
splitting a multi-byte rune on CJK or Cyrillic summaries. Both now cut on a rune
boundary.

Should 5 — settings validation. putSettings accepts and stores any
triage_profile_id and any confidence. Both are validated before anything is
written: a negative or unknown profile id and a threshold outside 0..1 are
rejected with 400; 0 still turns the check off.

Should 6 — the threshold is a setting (triage_min_confidence), read on boot and
on change; the description matches the code.

Verification: go build ./... and go vet clean; gofmt clean. go test ./agent/
./db/ ./llmrec/ ./server/ with ARTEX_PG_DSN on a local PostgreSQL — green except
TestManagerSOCKS5UDPOptInAndAssetBlockRuleDropsDatagram (binds 127.0.0.2) and
TestPauseShiftsTaskDeadlineOnResume, which fail the same way on clean main on
macOS. Red/green: with the force_register branch disabled the override test
fails naming the ignored flag; restored, it passes.
2026-11-23 17:22:16 +03:00
BaaRai 6ec01e007e Merge remote-tracking branch 'origin/main' into pr507b
# Conflicts:
#	CHANGELOG.md
2026-11-23 15:10:58 +01:00
Николай Гусев 24cd7da9af agent: advisory duplicate check on report_finding via a decision model
Duplicates are the cheapest way to lose reviewer trust, and the only guard today is
a prompt instruction: the worker is told to check list_findings before registering.
It does not hold — in one run against a deliberately vulnerable app three defect
classes were registered twice each (two SQLi, two IDOR, two admin-endpoint
findings), and one of the pairs differed only in wording.

A decision model answers exactly this kind of closed-list question (same defect as
one of these N findings, or not?) with probabilities and no generated text, so the
judgement costs one small request instead of a main-model turn over a six-figure
context. Measured on our own findings before writing any of this (15 candidates,
hand labels): the correct partner 8/8 on a 27B decider and 7/8 on the flash one,
against 7/15 for the constant "always distinct", at 0.66 s and ~1.7k input tokens
per call with zero output tokens. Repeated calls were stable (30/30 identical).

Changes

- agent/triage.go: TriageClient interface, a /v1/systemone HTTP client, and the pure
  pieces (state builder, criteria builder, answer parser, threshold) so the logic is
  testable without a server.
- report_finding: consults the client before registering. On a duplicate above the
  confidence threshold the finding is not registered again; the caller is told which
  finding_id it matched and to extend it with update_finding_report.
- Wiring: agent.SetTriageClient on the worker/planner ToolSets, a triage_profile_id
  setting (any llm_profiles row whose base_url serves the decision contract; 0 = off),
  exposed through the settings API.

Fail-open, by construction

Triage changes an outcome only when it is confident; every other path behaves exactly
as today: no client, no existing findings, empty summary, transport error, non-200,
malformed body, an id the question never offered, or confidence below the threshold
all fall through to normal registration. A wrong suppression loses evidence, a wrong
registration only costs a row — hence the threshold, and hence "advisory".

Verification

- go test ./agent/ passes, including new tests: request shape (model/state/criteria
  carry every candidate), distinct answer, unknown id reads as distinct, probability
  fallback when confidence is absent, error on 500, no HTTP call without input, state
  cap, threshold boundaries.
- red/green on two independent breakages: forcing the threshold false and accepting
  an unoffered id both fail the suite; restored, it passes.
- go test ./server/ shows one failure,
  TestManagerSOCKS5UDPOptInAndAssetBlockRuleDropsDatagram (bind 127.0.0.2 —
  environment), reproduced on clean main in a separate worktree.
- gofmt -l agent/ server/ clean.

Notes

- The profile must serve /v1/systemone. A chat-only decider endpoint (one that refuses
  /v1/chat/completions) needs a thin adapter; a decision endpoint works directly.
- Off by default: with no triage_profile_id the platform behaves as before.

The cap on offered findings is a SELECTION, not "the newest N": with a wide graph
the true partner falls out of a newest-first list, so candidates are ranked by
relevance (same class, overlapping endpoint, another task on a shared asset) with
recency only breaking ties. Per-entry summary capping replaces the whole-state
truncation, which used to cut mid-line and leave criteria ids whose state line had
been dropped.

Threshold is a knob, not a constant (live acceptance): on a run with the wider
cross-task pool the model named the right partner in 8 of 9 questions, but its
confidence moved with the question's width — 0.73-0.79 on a small pool, 0.30-0.53
with twenty candidates. Six duplicates were suppressed, and exactly the two that
slipped were the 0.30 and 0.47 ones, both with the correct partner named. A fixed
0.5 cannot fit both ends, so the threshold is a setting (triage_min_confidence,
default 0.5); the low end is affordable because the suppression result tells the
agent to re-register explicitly when the finding is in fact distinct.

Cross-task pool (found by re-measuring the live miss): task_relations only links
spawned tasks, so two tasks created independently against the same target never see
each other's findings and a defect registered in both is invisible to the dedup
question. FindingsSharingAssets joins on the candidate's own asset ids (jsonb
containment, GIN-served) and adds those findings to the question, marked with their
task. On three real cross-task duplicates the wider question names the right partner
in all three (confidence 0.58-0.73, above the threshold), where the own-task pool
could only answer "none".

Regression note (found on a live run, not in CI): FindingID is filled from the findings table, so building the candidate list straight from the nodes dropped every entry and triage never fired ("nodes=6, no usable existing findings"). Covered by TestTriageCandidates_SkipsNodesWithoutFindingRow; findings inherited from a directly related task are kept and marked in the question.

---

Found while running the platform against a live target.

limits: triageDupMinConfidence 0.5 - калибровка 538 пар одной цели (stage3_calibrate.py, 2026-11-22): recall 1.00 при FP 0.47 на 75 жёстких негативах; на истинных дублях в живом прогоне 0.30-0.79
limits: triageMaxExisting 10 - ширина вопроса на реальном дубле (stage3_width.py, 2026-11-22): уверенность 0.81-0.91 до 11 кандидатов, 0.64 на 19, 0.56 на 29; латентность 0.44->1.29 с
limits: triageMaxSummaryChars 400 - p90 длины сводки 334, максимум 564 по 53 находкам графа (2026-11-22)
limits: triageMaxStateChars 6000 - арифметика при потолке 10 записей: 10*(400+60)+480 ~= 5.1 КБ, запас 1.17x
limits: triageHTTPTimeout 20s - наблюдаемая латентность decider 0.26-1.29 с, 3.83-3.96 с на 27B; запас ~5x к худшему
limits: findings pool query limit 50 - самый широкий пул по ассету 31 находка (53 в графе, 2026-11-22), запас 1.6x
limits: ответ decider 1 MiB - наблюдаемый ответ 0.3-2 КБ, запас ~500x
2026-11-23 16:59:40 +03:00
BaaRai 410d8fa7f2 Merge remote-tracking branch 'origin/main' into pr507b
# Conflicts:
#	CHANGELOG.md
2026-11-23 14:55:14 +01:00
BaaRai 8040e38faf Merge remote-tracking branch 'origin/main' into pr503b
# Conflicts:
#	CHANGELOG.md
2026-11-23 14:54:03 +01:00
BaaRai ab2a0262b5 Merge pull request #509 from jamesKhor/feat/assessment-identification
Add a per-task scanner User-Agent for approved sites
2026-11-23 14:53:06 +01:00
BaaRai 164e2388ed Merge pull request #480 from jamesKhor/feat/bedrock-gateway
Add bearer-authenticated Bedrock gateway profiles
2026-11-23 14:52:58 +01:00
BaaRai a4276b490f Merge pull request #478 from BaaRai/feat/agent-uid-isolation-rebased
Run agent processes under the executor identity with a sealed environment
2026-11-23 12:59:10 +01:00
BaaRai 60a1ffca62 server: keep only the fixed locale names in the executor environment
The executor environment kept every name starting with LC_, so a secret supplied under an LC_ name crossed the allowlist even though the comment promised a fixed set of names. The POSIX locale categories are now enumerated and the prefix rule is gone.

Found by jamesKhor in the review of #478.
2026-11-23 12:42:43 +01:00
James Khor 1725a44543 Clarify scanner User-Agent settings and verify recorded redirects 2026-11-23 18:29:58 +08:00
James Khor f90db65430 Limit generated assessment labels to configured HTTP origins 2026-11-23 17:55:39 +08:00
James Khor fdd0041529 Verify assessment labels on the wire and document SOC triage 2026-11-23 17:46:27 +08:00
James Khor 6ef25b22b1 Identify approved assessment tasks in native HTTP requests 2026-11-23 17:45:26 +08:00
thejesh23 1aaa7a479b fix(scheduler): fire on_task_timeout for tasks that time out out of id order
The timeout trigger used the task id as a watermark, but tasks time out
in deadline order. When a newer task timed out first, the watermark moved
past every older running task, so their later timeouts were never fired.

Keep fired timeouts in a persisted set, the same way met goals are
tracked. On first start the set is seeded with the tasks already timed
out, so nothing replays.
2026-11-23 01:33:19 -08:00
James Khor c1e17ad934 server: secure executor run-directory sharing 2026-11-23 12:39:32 +08:00
Leo Camus b7e766ffe4 fix(server): skip named pipes and sockets when packing a task archive
writeTaskArchivePackage opened every entry of the staged workspace that is
not a directory. Opening a FIFO blocks until a writer appears, so a named
pipe left by a command (mkfifo backpipe for an nc relay) stopped the single
archive worker in openat for good, with the task files already moved to
staging and every later archive, restore and delete job queued behind it.
A Unix socket failed the archive instead, and a device file was packed but
refused by extractTaskArchivePackage on restore.

Skip every entry that is neither a directory nor a regular file, as is
already done for symlinks.
2026-11-23 04:34:29 +00:00
James Khor 8f16794a97 fix: scrub Bedrock gateway credentials at startup 2026-11-23 11:13:40 +08:00
Coff0xc 7ac5b629f8 fix(server): hide driver errors on the skill visibility endpoints
Skill usage and missing-skill stats already returned a fixed message. Skill
visibility and its toggle still sent err.Error() to the client. Those two
now log the driver text and return a fixed message. A closed pool test
covers all four handlers.
2026-11-23 02:13:03 +00:00
APZN 7e555e86d7 fix(web): reset stream filters and exclude warning rows from counts
Reset the stream panel's filter and request state when the exchange changes.
Keep recording-limit warnings visible while reporting only actual messages
in the header, including first-page and warning-only counts.

Add message_total to the stream page without changing raw pagination totals
or existing Go paging signatures. Cover the count and pagination boundaries
in the stream and HTTP route tests.
2026-11-23 10:26:56 +09:00