Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  sandbox-tool-policy.test.ts

  Sprache: JAVA
 

import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import { resolveEffectiveToolPolicy } from "./pi-tools.policy.js";
import { pickSandboxToolPolicy } from "./sandbox-tool-policy.js";
import { resolveEffectiveToolFsRootExpansionAllowed } from "./tool-fs-policy.js";

describe("pickSandboxToolPolicy", () => {
  it("returns undefined when neither allow nor deny is configured", () => {
    expect(pickSandboxToolPolicy({})).toBeUndefined();
  });

  it("keeps alsoAllow without allow additive", () => {
    expect(
      pickSandboxToolPolicy({
        alsoAllow: ["web_search"],
      }),
    ).toEqual({
      allow: ["*""web_search"],
      deny: undefined,
    });
  });

  it("merges allow and alsoAllow when both are present", () => {
    expect(
      pickSandboxToolPolicy({
        allow: ["read"],
        alsoAllow: ["write"],
      }),
    ).toEqual({
      allow: ["read""write"],
      deny: undefined,
    });
  });

  it("preserves allow-all semantics for allow: [] plus alsoAllow", () => {
    expect(
      pickSandboxToolPolicy({
        allow: [],
        alsoAllow: ["web_search"],
      }),
    ).toEqual({
      allow: ["*""web_search"],
      deny: undefined,
    });
  });

  it("passes deny through unchanged", () => {
    expect(
      pickSandboxToolPolicy({
        deny: ["exec"],
      }),
    ).toEqual({
      allow: undefined,
      deny: ["exec"],
    });
  });

  it("keeps global alsoAllow additive in effective tool policy resolution", () => {
    const cfg: OpenClawConfig = {
      tools: {
        profile: "coding",
        alsoAllow: ["lobster"],
      },
    };

    const resolved = resolveEffectiveToolPolicy({ config: cfg, agentId: "main" });
    expect(resolved.globalPolicy).toEqual({ allow: ["*""lobster"], deny: undefined });
    expect(resolved.profileAlsoAllow).toEqual(["lobster"]);
  });

  it("does not block fs root expansion when only global alsoAllow is configured", () => {
    const cfg: OpenClawConfig = {
      tools: {
        alsoAllow: ["lobster"],
      },
    };

    expect(resolveEffectiveToolFsRootExpansionAllowed({ cfg, agentId: "main" })).toBe(true);
  });
});

Messung V0.5 in Prozent
C=99 H=98 G=98

¤ Dauer der Verarbeitung: 0.12 Sekunden  (vorverarbeitet am  2026-05-26) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge