Initial commit: hardened DeerFlow factory
Vendored deer-flow upstream (bytedance/deer-flow) plus prompt-injection hardening: - New deerflow.security package: content_delimiter, html_cleaner, sanitizer (8 layers — invisible chars, control chars, symbols, NFC, PUA, tag chars, horizontal whitespace collapse with newline/tab preservation, length cap) - New deerflow.community.searx package: web_search, web_fetch, image_search backed by a private SearX instance, every external string sanitized and wrapped in <<<EXTERNAL_UNTRUSTED_CONTENT>>> delimiters - All native community web providers (ddg_search, tavily, exa, firecrawl, jina_ai, infoquest, image_search) replaced with hard-fail stubs that raise NativeWebToolDisabledError at import time, so a misconfigured tool.use path fails loud rather than silently falling back to unsanitized output - Native client back-doors (jina_client.py, infoquest_client.py) stubbed too - Native-tool tests quarantined under tests/_disabled_native/ (collect_ignore_glob via local conftest.py) - Sanitizer Layer 7 fix: only collapse horizontal whitespace, preserve newlines and tabs so list/table structure survives - Hardened runtime config.yaml references only the searx-backed tools - Factory overlay (backend/) kept in sync with deer-flow tree as a reference / source See HARDENING.md for the full audit trail and verification steps.
This commit is contained in:
61
deer-flow/frontend/scripts/save-demo.js
Normal file
61
deer-flow/frontend/scripts/save-demo.js
Normal file
@@ -0,0 +1,61 @@
|
||||
import { config } from "dotenv";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { env } from "process";
|
||||
|
||||
export async function main() {
|
||||
const url = new URL(process.argv[2]);
|
||||
const threadId = url.pathname.split("/").pop();
|
||||
const host = url.host;
|
||||
const apiURL = new URL(
|
||||
`/api/langgraph/threads/${threadId}/history`,
|
||||
`${url.protocol}//${host}`,
|
||||
);
|
||||
const response = await fetch(apiURL, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
limit: 10,
|
||||
}),
|
||||
});
|
||||
|
||||
const data = (await response.json())[0];
|
||||
if (!data) {
|
||||
console.error("No data found");
|
||||
return;
|
||||
}
|
||||
|
||||
const title = data.values.title;
|
||||
|
||||
const rootPath = path.resolve(process.cwd(), "public/demo/threads", threadId);
|
||||
if (fs.existsSync(rootPath)) {
|
||||
fs.rmSync(rootPath, { recursive: true });
|
||||
}
|
||||
fs.mkdirSync(rootPath, { recursive: true });
|
||||
fs.writeFileSync(
|
||||
path.resolve(rootPath, "thread.json"),
|
||||
JSON.stringify(data, null, 2),
|
||||
);
|
||||
const backendRootPath = path.resolve(
|
||||
process.cwd(),
|
||||
"../backend/.deer-flow/threads",
|
||||
threadId,
|
||||
);
|
||||
copyFolder("user-data/outputs", rootPath, backendRootPath);
|
||||
copyFolder("user-data/uploads", rootPath, backendRootPath);
|
||||
console.info(`Saved demo "${title}" to ${rootPath}`);
|
||||
}
|
||||
|
||||
function copyFolder(relPath, rootPath, backendRootPath) {
|
||||
const outputsPath = path.resolve(backendRootPath, relPath);
|
||||
if (fs.existsSync(outputsPath)) {
|
||||
fs.cpSync(outputsPath, path.resolve(rootPath, relPath), {
|
||||
recursive: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
config();
|
||||
main();
|
||||
Reference in New Issue
Block a user