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.
61 lines
2.1 KiB
JavaScript
61 lines
2.1 KiB
JavaScript
import { createEnv } from "@t3-oss/env-nextjs";
|
|
import { z } from "zod";
|
|
|
|
export const env = createEnv({
|
|
/**
|
|
* Specify your server-side environment variables schema here. This way you can ensure the app
|
|
* isn't built with invalid env vars.
|
|
*/
|
|
server: {
|
|
BETTER_AUTH_SECRET:
|
|
process.env.NODE_ENV === "production"
|
|
? z.string()
|
|
: z.string().optional(),
|
|
BETTER_AUTH_GITHUB_CLIENT_ID: z.string().optional(),
|
|
BETTER_AUTH_GITHUB_CLIENT_SECRET: z.string().optional(),
|
|
GITHUB_OAUTH_TOKEN: z.string().optional(),
|
|
NODE_ENV: z
|
|
.enum(["development", "test", "production"])
|
|
.default("development"),
|
|
},
|
|
|
|
/**
|
|
* Specify your client-side environment variables schema here. This way you can ensure the app
|
|
* isn't built with invalid env vars. To expose them to the client, prefix them with
|
|
* `NEXT_PUBLIC_`.
|
|
*/
|
|
client: {
|
|
NEXT_PUBLIC_BACKEND_BASE_URL: z.string().optional(),
|
|
NEXT_PUBLIC_LANGGRAPH_BASE_URL: z.string().optional(),
|
|
NEXT_PUBLIC_STATIC_WEBSITE_ONLY: z.string().optional(),
|
|
},
|
|
|
|
/**
|
|
* You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
|
|
* middlewares) or client-side so we need to destruct manually.
|
|
*/
|
|
runtimeEnv: {
|
|
BETTER_AUTH_SECRET: process.env.BETTER_AUTH_SECRET,
|
|
BETTER_AUTH_GITHUB_CLIENT_ID: process.env.BETTER_AUTH_GITHUB_CLIENT_ID,
|
|
BETTER_AUTH_GITHUB_CLIENT_SECRET:
|
|
process.env.BETTER_AUTH_GITHUB_CLIENT_SECRET,
|
|
NODE_ENV: process.env.NODE_ENV,
|
|
|
|
NEXT_PUBLIC_BACKEND_BASE_URL: process.env.NEXT_PUBLIC_BACKEND_BASE_URL,
|
|
NEXT_PUBLIC_LANGGRAPH_BASE_URL: process.env.NEXT_PUBLIC_LANGGRAPH_BASE_URL,
|
|
NEXT_PUBLIC_STATIC_WEBSITE_ONLY:
|
|
process.env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY,
|
|
GITHUB_OAUTH_TOKEN: process.env.GITHUB_OAUTH_TOKEN,
|
|
},
|
|
/**
|
|
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
|
|
* useful for Docker builds.
|
|
*/
|
|
skipValidation: !!process.env.SKIP_ENV_VALIDATION,
|
|
/**
|
|
* Makes it so that empty strings are treated as undefined. `SOME_VAR: z.string()` and
|
|
* `SOME_VAR=''` will throw an error.
|
|
*/
|
|
emptyStringAsUndefined: true,
|
|
});
|