Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(security): contain Downloads writes and parse skill headings in linear time
rubenluetke10-beep4d35f020f706
diff --git a/jarvis/agentic_ide/skill_library.py b/jarvis/agentic_ide/skill_library.pyindex 76d661245e..e57b09a724 100644--- a/jarvis/agentic_ide/skill_library.py+++ b/jarvis/agentic_ide/skill_library.py@@ -76,7 +76,20 @@ ICONS: tuple[str, ...] = (_LEGACY_ICONS: dict[str, str] = {"sparkles": "auto", "wand": "refactor", "brain": "plan"}_FRONTMATTER_RE = re.compile(r"\A\ufeff?---[ \t]*\r?\n(.*?)\r?\n---[ \t]*(?:\r?\n|\Z)", re.DOTALL)-_HEADING_RE = re.compile(r"^\s{0,3}#{1,6}\s+(.+?)\s*#*\s*$")+def _heading_text(line: str) -> str | None:+ """The text of a Markdown ATX heading line (``## Title ##``), else ``None``.++ Parsed by hand rather than with a regex: a lazy group between optional+ whitespace runs backtracks quadratically on a long line of spaces.+ """+ rest = line.lstrip(" ")+ if len(line) - len(rest) > 3:+ return None+ marks = len(rest) - len(rest.lstrip("#"))+ if not 1 <= marks <= 6 or len(rest) == marks or not rest[marks].isspace():+ return None+ text = rest[marks:].strip().rstrip("#").rstrip()+ return text or Nonedef skill_library_path() -> Path:@@ -132,9 +145,9 @@ def derive_title(content: str, fallback: str = "") -> str:else:body = contentfor line in body.splitlines():- heading = _HEADING_RE.match(line)+ heading = _heading_text(line)if heading:- return _clean_line(heading.group(1), MAX_TITLE_LEN)+ return _clean_line(heading, MAX_TITLE_LEN)if fallback.strip():return _clean_line(fallback, MAX_TITLE_LEN)for line in body.splitlines():@@ -159,7 +172,7 @@ def derive_description(content: str) -> str:if stripped.startswith(("```", "~~~")):in_fence = not in_fencecontinue- if in_fence or not stripped or _HEADING_RE.match(line):+ if in_fence or not stripped or _heading_text(line) is not None:continueif stripped.startswith(("|", "---", "<!--")):continuediff --git a/jarvis/ui/web/downloads_routes.py b/jarvis/ui/web/downloads_routes.pyindex 1637e70bf5..aa276040e8 100644--- a/jarvis/ui/web/downloads_routes.py+++ b/jarvis/ui/web/downloads_routes.py@@ -45,6 +45,7 @@ from typing import Anyfrom fastapi import APIRouter, HTTPException, Requestfrom pydantic import BaseModel, Field+from jarvis.core.path_safety import contained_pathfrom jarvis.platform import detect_platform, user_dirs# Reuse the proven collision-avoidance helper from the sessions save path@@ -136,7 +137,7 @@ async def save_to_downloads(filename = _safe_basename(body.filename)downloads = user_dirs.downloads_dir()downloads.mkdir(parents=True, exist_ok=True)- target = _avoid_collision(downloads / filename)+ target = _avoid_collision(contained_path(downloads, filename))target.write_bytes(data)log.info("DownloadSave: %s (%d bytes)", target, len(data))diff --git a/jarvis/ui/web/sessions_routes.py b/jarvis/ui/web/sessions_routes.pyindex dd0d856470..6e5c5e9a8f 100644--- a/jarvis/ui/web/sessions_routes.py+++ b/jarvis/ui/web/sessions_routes.py@@ -32,6 +32,7 @@ from fastapi import APIRouter, HTTPException, Query, Requestfrom fastapi.responses import PlainTextResponse, Responsefrom pydantic import BaseModel+from jarvis.core.path_safety import contained_pathfrom jarvis.sessions.formatter import format_session_markdown, format_session_plainfrom jarvis.sessions.models import (SessionDetail,@@ -213,7 +214,9 @@ async def save_session_to_downloads(# Target path: %USERPROFILE%\Downloads\.downloads = Path.home() / "Downloads"downloads.mkdir(parents=True, exist_ok=True)- target = _avoid_collision(downloads / filename)+ # contained_path refuses a name that would leave Downloads (defence in depth:+ # the name is already built from a slug or the session id).+ target = _avoid_collision(contained_path(downloads, filename))# Write — UTF-8 with a BOM only for plain text so Notepad detects it# correctly; Markdown + JSON stay pure UTF-8.