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): keep pet lookups inside their folders and strip HTML comments fully
rubenluetke10-beepfbbe96302664
diff --git a/jarvis/ui/pets/loader.py b/jarvis/ui/pets/loader.pyindex 903822dd65..2dd8c4f861 100644--- a/jarvis/ui/pets/loader.py+++ b/jarvis/ui/pets/loader.py@@ -13,6 +13,7 @@ from __future__ import annotationsimport jsonimport logging+import osfrom collections.abc import Mappingfrom dataclasses import dataclass, fieldfrom pathlib import Path@@ -89,16 +90,29 @@ def find_pet_dir(pet_id: str, *, data_dir: Path | None = None) -> tuple[Path, boif not isinstance(pet_id, str) or pet_id == NO_PET_ID:return Noneif BUILTIN_ID_RE.match(pet_id) and not USER_ID_RE.match(pet_id):- folder = builtin_root() / pet_id- if (folder / MANIFEST_NAME).is_file():+ folder = _child_folder(builtin_root(), pet_id)+ if folder is not None and (folder / MANIFEST_NAME).is_file():return folder, Trueif USER_ID_RE.match(pet_id):- folder = custom_root(data_dir) / pet_id- if (folder / MANIFEST_NAME).is_file():+ folder = _child_folder(custom_root(data_dir), pet_id)+ if folder is not None and (folder / MANIFEST_NAME).is_file():return folder, Falsereturn None+def _child_folder(root: Path, name: str) -> Path | None:+ """``root / name`` when it stays a direct child of ``root``, else ``None``.++ The id patterns already rule out separators and dots; this second check+ keeps the guarantee local to the one place a request value becomes a path.+ """+ base = os.path.normpath(os.path.abspath(root))+ full = os.path.normpath(os.path.join(base, name))+ if not full.startswith(base + os.sep) or os.path.dirname(full) != base:+ return None+ return Path(full)++def read_manifest(pet_dir: Path, *, builtin: bool) -> PetManifest:"""Parse ``pet.json`` in ``pet_dir`` and check it against its sheet's size.diff --git a/jarvis/ui/web/frontend/src/views/assistant/FilesSection.tsx b/jarvis/ui/web/frontend/src/views/assistant/FilesSection.tsxindex 2d467eef56..3129f3a557 100644--- a/jarvis/ui/web/frontend/src/views/assistant/FilesSection.tsx+++ b/jarvis/ui/web/frontend/src/views/assistant/FilesSection.tsx@@ -30,10 +30,19 @@ export function useFileMeta(): (file: SoulFile) => string {};}+/** Drops HTML comments, including nested leftovers and an unclosed opener. */+function withoutComments(text: string): string {+ let previous: string;+ do {+ previous = text;+ text = text.replace(/<!--[\s\S]*?-->/g, "");+ } while (text !== previous);+ return text.replace(/<!--|-->/g, "");+}+/** Inline Markdown made readable: emphasis markers and comments dropped. */function clean(line: string): string {- return line- .replace(/<!--.*?-->/g, "")+ return withoutComments(line).replace(/\*\*(.+?)\*\*/g, "$1").replace(/(^|\s)_([^_]+)_(?=[\s.,;:!?]|$)/g, "$1$2").replace(/^_|_$/g, "")@@ -57,7 +66,7 @@ export function previewLines(file: SoulFile, max = 4): string[] {};for (const raw of file.content.split("\n")) {const trimmed = raw.trim();- if (!trimmed || trimmed.startsWith("#") || /^<!--.*-->$/.test(trimmed)) {+ if (!trimmed || trimmed.startsWith("#") || (trimmed.startsWith("<!--") && trimmed.endsWith("-->"))) {flush();} else if (/^[-*]\s+/.test(trimmed)) {flush();