Validates filesystem path safety, preventing directory traversal attacks. (domain: security, files)
// Source: https://github.com/wonderwhy-er/DesktopCommanderMCP | License: MIT | Copyright 2024-2025 Eduard Ruzga and Desktop Commander Contributors
// Provided via justclaw.it.com; keep this notice with the code.
import fs from "fs/promises";
import path from "path";
import os from 'os';
import fetch from 'cross-fetch';
import { execFile } from 'child_process';
import { promisify } from 'util';
import { capture } from '../utils/capture.js';
import { withTimeout, runWithAbortableTimeout } from '../utils/withTimeout.js';
import { configManager } from '../config-manager.js';
import { getFileHandler, TextFileHandler } from '../utils/files/index.js';
import type { ReadOptions, FileResult, PdfPageItem } from '../utils/files/base.js';
import { isPdfFile } from "./mime-types.js";
import { parsePdf
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key