openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
27 lines (26 loc) • 1.13 kB
JavaScript
import { c as normalizeOptionalLowercaseString } from "./string-coerce-CCIiB4H7.mjs";
//#region src/agents/sandbox/network-mode.ts
/**
* Docker network mode safety helpers.
*
* Flags host networking and container namespace joins because they bypass normal sandbox network isolation.
*/
/** Normalizes optional Docker network mode strings for policy checks. */
function normalizeNetworkMode(e) {
return normalizeOptionalLowercaseString(e) || void 0;
}
/** Returns the concrete block reason for dangerous network modes, if blocked. */
function getBlockedNetworkModeReason(e) {
const t = normalizeNetworkMode(e.network);
if (!t) return null;
if (t === "host") return "host";
if (t.startsWith("container:") && e.allowContainerNamespaceJoin !== true) return "container_namespace_join";
return null;
}
/** Returns whether a network mode weakens sandbox network isolation. */
function isDangerousNetworkMode(e) {
const t = normalizeNetworkMode(e);
return t === "host" || t?.startsWith("container:") === true;
}
//#endregion
export { isDangerousNetworkMode as n, normalizeNetworkMode as r, getBlockedNetworkModeReason as t };