{"record":{"id":"be9cb652d0896c1a","repo":"affaan-m/ECC","slug":"path-path-targets-a-system-directory","errorCode":null,"errorMessage":"Path '{path}' targets a system directory","messagePattern":"Path '(.+?)' targets a system directory","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/continuous-learning-v2/scripts/instinct-cli.py","lineNumber":168,"sourceCode":"    \"\"\"Validate and resolve a file path, guarding against path traversal.\n\n    Raises ValueError if the path is invalid or suspicious.\n    \"\"\"\n    path = Path(path_str).expanduser().resolve()\n\n    # Block paths that escape into system directories\n    # We block specific system paths but allow temp dirs (/var/folders on macOS)\n    blocked_prefixes = [\n        \"/etc\", \"/usr\", \"/bin\", \"/sbin\", \"/proc\", \"/sys\",\n        \"/var/log\", \"/var/run\", \"/var/lib\", \"/var/spool\",\n        # macOS resolves /etc → /private/etc\n        \"/private/etc\",\n        \"/private/var/log\", \"/private/var/run\", \"/private/var/db\",\n    ]\n    path_s = str(path)\n    for prefix in blocked_prefixes:\n        if path_s.startswith(prefix + \"/\") or path_s == prefix:\n            raise ValueError(f\"Path '{path}' targets a system directory\")\n\n    if must_exist and not path.exists():\n        raise ValueError(f\"Path does not exist: {path}\")\n\n    return path\n\n\ndef _validate_instinct_id(instinct_id: str) -> bool:\n    \"\"\"Validate instinct IDs before using them in filenames.\"\"\"\n    if not instinct_id or len(instinct_id) > 128:\n        return False\n    if \"/\" in instinct_id or \"\\\\\" in instinct_id:\n        return False\n    if \"..\" in instinct_id:\n        return False\n    if instinct_id.startswith(\".\"):\n        return False\n    return bool(re.match(r\"^[A-Za-z0-9][A-Za-z0-9._-]*$\", instinct_id))","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/skills/continuous-learning-v2/scripts/instinct-cli.py#L150-L186","documentation":"Error \"Path '{path}' targets a system directory\" thrown in affaan-m/ECC.","triggerScenarios":"Thrown at skills/continuous-learning-v2/scripts/instinct-cli.py:168 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a path outside blocked system directories (/etc, /var/log, /private/etc, etc.); instinct storage must live under a user-writable project or home location.","Point the tool at your project directory instead of a system path."],"exampleFix":"instinct-cli --path \"$HOME/.ecc/instincts/my-project\"  # not /etc or /var/log","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}