fix(security): fix file_tools.py validate_path startswith bypass #7478 #11180

Closed
freemo wants to merge 35 commits from fix/security-file-tools-path-traversal-7478 into master

35 Commits

Author SHA1 Message Date
HAL9000 36e2da6e82 fix(lint): resolve ruff check and format violations on PR changes
CI / helm (pull_request) Successful in 55s
CI / build (pull_request) Successful in 2m34s
CI / push-validation (pull_request) Successful in 3m13s
CI / quality (pull_request) Successful in 4m18s
CI / lint (pull_request) Successful in 4m23s
CI / security (pull_request) Successful in 4m27s
CI / typecheck (pull_request) Successful in 4m29s
CI / unit_tests (pull_request) Failing after 4m45s
CI / coverage (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / integration_tests (pull_request) Successful in 9m25s
CI / status-check (pull_request) Failing after 11s
2026-05-13 22:57:53 +00:00
freemo 290345d9d3 fix(security): fix startswith bypass in file_ops.py and inline_executor.py #7478
CI / helm (pull_request) Successful in 1m4s
CI / build (pull_request) Successful in 2m13s
CI / lint (pull_request) Failing after 2m25s
CI / push-validation (pull_request) Successful in 2m18s
CI / quality (pull_request) Successful in 2m59s
CI / typecheck (pull_request) Successful in 3m10s
CI / security (pull_request) Successful in 3m11s
CI / unit_tests (pull_request) Failing after 3m32s
CI / docker (pull_request) Has been skipped
CI / coverage (pull_request) Has been skipped
CI / integration_tests (pull_request) Successful in 5m10s
CI / status-check (pull_request) Failing after 8s
2026-05-13 21:20:20 +00:00
freemo f3ee171ef7 fix(security): fix file_tools.py validate_path startswith bypass #7478
Replace insecure str.startswith() path check in validate_path() with
Path.resolve()/Path.relative_to() for proper canonicalisation before
sandbox containment verification.

Added comprehensive unit tests covering sibling-prefix collision, symlink
resolution, and normalisation edge cases. Updated CHANGELOG and contributors.

ISSUES CLOSED: #7478
ISSUES CLOSED: #7549
2026-05-13 21:20:20 +00:00
freemo b86f067bfb fix: parallel pre-fetch, timeouts, newline-safe prompts, verbose logging
opencode-builder.sh: major reliability and correctness fixes:

- Parallel pre-fetch per pool: ALL list_prs_*.ts scripts for a pool now
  launch in parallel (background jobs), results cached to temp files. Each
  pool iteration fetches all work-group data in ONE parallel batch (~90s)
  instead of 11 sequential ~90s calls (~990s). The bottleneck is Forgejo
  API speed, not sequential script execution.

- Timeouts everywhere: SCRIPT_TIMEOUT_SEC raised 60s→300s (Forgejo is slow).
  find_sessions_by_prefix and other session_* scripts get 30s timeout via
  the timeout(1) utility. fetch_list_script catches timeout exit codes
  (124, 137, 139, 143) and returns [] gracefully.

- Prompt builders fixed: build_impl_prompt, build_merge_prompt,
  build_review_prompt now collapse newlines in title/body via tr+sed so
  the prompt file stays valid as plain text. Full item JSON embedded as
  compact single-line (jq -c .) at end of prompt.

- Verbose step logging: [step2], [pool:NAME] prefixes throughout main
  loop show exactly which stage is running and where any hang occurs.

- BUILDER_DEBUG=1 env var enables bash -x tracing for deep debugging.

Note: find_sessions_by_prefix --status busy returns empty (OpenCode
/session/status only reports the supervisor session). busy_count=0 when
all session status fields are empty, making all slots available. The
total session count is logged alongside active count for visibility.
2026-05-13 21:20:20 +00:00
freemo ebce3ae4a7 fix: rewrite opencode-builder.sh cleanly — parallel workers, correct status, better output 2026-05-13 21:20:20 +00:00
freemo 7b80485375 fix: count workers by last_active timestamp, not status API
The OpenCode /session/status endpoint reports all async workers as
"idle" even while they are actively processing — making the previous
--status busy filter always return empty and workers count as 0.

Fixes across the board:

- get_active_worker_tags() and count_active_workers(): new functions
  that filter by last_active >= (now - 2 min) instead of status field.

- Pool launcher: use count_active_workers() for the busy count, and
  extract exclude_numbers from active sessions' tags.

- Health cycle idle check: was using --status idle (returns all sessions
  since everything is "idle"). Now uses --status all + last_active
  threshold to find genuinely idle workers.

- Doom loop check: was using --status busy (returns nothing). Now uses
  --status all + last_active < (now - 30 min) to find abandoned sessions.

- fetch_list_script: guard against corrupted JSON when stderr messages
  from the script contaminate stdout — only accept output starting with
  "[" as valid JSON.

- Worker launch: add --restart so stale sessions are always replaced
  with fresh workers.

- Add IDLE_THRESHOLD_MS (3 min) constant for the health cycle.
2026-05-13 21:20:20 +00:00
freemo 90e7492051 build: parallel worker launch in opencode-builder.sh
Previously workers were launched sequentially (2-3s each), causing
30+ second delays per pool in iteration #1 and making the health
check cycle stall. Now:

- Collect all work items for a pool into an array first
- Launch all workers in parallel with background jobs (&)
- Wait for each job in sequence, tracking results

Also removed dead code: launch_worker() and launch_pool_workers()
functions (replaced by inline parallel launch), and get_work_number()
and get_work_type() helpers (no longer needed).
2026-05-13 21:20:20 +00:00
freemo 3b2b47a3f2 build: fix opencode-builder.sh crash and work-item discovery
- resolve_forgejo_config: fall back to git remote origin when
  FORGEJO_OWNER/FORGEJO_REPO are not set in env vars
- busy_count: count directly in the tag loop instead of a broken
  grep-pipeline that caused '0: syntax error' when count was zero
- Remove the now-dead launch_supervisor function and SUPERVISOR_TIMEOUT
  (already removed from loop in prior commit)
2026-05-13 21:20:20 +00:00
freemo 7afcba22e7 build: eliminated supervisors and uses the script directly now to launch 2026-05-13 21:20:20 +00:00
freemo b2666b7461 build: increaased implementation supervisor timeout 2026-05-13 21:20:20 +00:00
freemo 1cbe33a97b build: fixed max_worker passing and added minimax to tiers 2026-05-13 21:20:20 +00:00
freemo 4cad32b036 build: added 2 new working minimax endpoints 2026-05-13 21:20:20 +00:00
freemo e71abde2fc build: fixed some issues with opencode-builder.sh 2026-05-13 21:20:20 +00:00
freemo bdbb6b3fe4 build: enforcing impelementors to never give out of scope errors 2026-05-13 21:20:20 +00:00
freemo 3b541ac555 build: fixed broken script 2026-05-13 21:20:20 +00:00
freemo 28314c76fb build: first attempt to move more of the pool management into the script 2026-05-13 21:20:20 +00:00
HAL9000 0b52b4d2a2 fix(tui): extract @token text correctly in on_input_submitted suggestions query 2026-05-13 21:20:20 +00:00
HAL9000 9ed1223474 fix(langgraph): store and dispose RxPy subscription Disposables in stop() 2026-05-13 21:20:20 +00:00
HAL9000 d395f262f3 fix(cli): add Invariants and Validations panels to project show rich output
Enhance the  command's Rich display with dedicated tables
for project-level invariants (read from ns_projects.invariants_json) and
validation attachments on linked resources (resolved via tool registry).

Also refactor the main panel to a cleaner 'Project Details' title showing
resource count and remote status.

ISSUES CLOSED: #9460
2026-05-13 21:20:20 +00:00
HAL9000 f9a7b61993 feat(cli): implement context list and context add CLI format support for ACMS
Add --format json, --format yaml, --format plain, and --format table options to
`agents actor context list`, `agents actor context add`, and `agents actor context show`.
Machine-readable JSON/YAML output includes a spec-compliant envelope with
command, status, exit_code, data, timing, and messages fields for integration with
automation pipelines.

Added full BDD test coverage in features/context_cli_format_support.feature with
step definitions in features/steps/context_cli_format_support_steps.py.

Updated CHANGELOG.md and CONTRIBUTORS.md to document this contribution.

ISSUES CLOSED: #9672
2026-05-13 21:20:20 +00:00
clever-agent 4bbb1c8519 build: restricted bash to durther prevent force merges or sudo escalation 2026-05-13 21:20:20 +00:00
clever-agent 01d86e3489 build: Had to re-restrict the permissions on the agents, they were misbehaving 2026-05-13 21:20:19 +00:00
clever-agent 7ef7e3f86c Fixed a bad/old escalation table 2026-05-13 21:20:19 +00:00
HAL9000 3f10e44ec4 docs(spec): clarify layer boundary DI exception, ULID scope, TUI/ACMS gap-fill [AUTO-ARCH-1]
Add targeted clarifications to docs/specification.md to fill identified gaps:

1. Layer boundary DI Container Exception (Cross-Milestone Architectural Invariants)
2. ULID Scope Clarification - domain vs internal identifiers
3. ACMS Pipeline Protocol Contracts with storage tiers and budget protocol
4. TUI Component Interfaces with verifiable checks

Co-authored-by: CleverAgents Bot <bot@cleveragents.com>

ISSUES CLOSED: #10451
2026-05-13 21:20:19 +00:00
clever-agent 04ebeeb8d3 build: testing agents with allow first permissions 2026-05-13 21:20:19 +00:00
clever-agent 2eaf43ddcd build: fixed the tiers to now only use qwen and kimi 2026-05-13 21:20:19 +00:00
clever-agent df931641f0 build: improved the startup script for auto-agents 2026-05-13 21:20:19 +00:00
clever-agent 211df163cc build: opened up echo and cat perms to help smooth over some tool calls 2026-05-13 21:20:19 +00:00
clever-agent 23b57c8332 build: changed permission on auto-agents script 2026-05-13 21:20:19 +00:00
clever-agent ef89539d0c build: added deny permission for sudo calls 2026-05-13 21:20:19 +00:00
clever-agent 083c4b95ef build: implement explicit-vs-fetched variable propagation across all agents
All agents now track which variables were explicitly present in their prompt
versus fetched from environment variables or git remote. When constructing
subagent prompts, only explicitly-present variables are included. Fetched
variables are omitted, allowing each subagent to fetch them independently.

This prevents credentials and other fetched values from being garbled as they
propagate through multiple LLM prompt layers.

Affected agents:
- auto-agents (primary orchestrator)
- implementation-supervisor, pr-merge-supervisor, pr-review-supervisor
- supervisor (generic)
- implementation-worker, pr-merge-worker, pr-review-worker
- task-implementor, tier-dispatcher
- work-group-util, git-clone-util, git-push-util, git-checkout-util
2026-05-13 21:20:19 +00:00
clever-agent fb81804a20 build: added critical rule clearly stating no question asking 2026-05-13 21:20:19 +00:00
clever-agent 4874b19172 build: improved some of the standard bash permissions to access fetchable variables at every level 2026-05-13 21:20:19 +00:00
clever-agent f096cfc50a build: Fixed models being used to align with new endpoints 2026-05-13 21:20:19 +00:00
clever-agent b9ecb48edd build: pulled in new endpoints and fixing permission from experimental branch 2026-05-13 21:20:19 +00:00