mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:00:42 +00:00
perf(test): trim hotspot coverage duplication
This commit is contained in:
@@ -1275,6 +1275,8 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
|
||||
});
|
||||
|
||||
it("requires explicit approval for strict inline-eval carriers", async () => {
|
||||
// The full carrier matrix lives in exec-inline-eval.test.ts; this is the
|
||||
// handle-level smoke for strictInlineEval denial wiring.
|
||||
const cases = [
|
||||
{
|
||||
command: ["python3", "-c", "print('hi')"],
|
||||
@@ -1284,22 +1286,6 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
|
||||
command: ["awk", 'BEGIN{system("id")}', "/dev/null"],
|
||||
expected: "awk inline program requires explicit approval in strictInlineEval mode",
|
||||
},
|
||||
{
|
||||
command: ["find", ".", "-exec", "id", "{}", ";"],
|
||||
expected: "find -exec requires explicit approval in strictInlineEval mode",
|
||||
},
|
||||
{
|
||||
command: ["xargs", "id"],
|
||||
expected: "xargs inline command requires explicit approval in strictInlineEval mode",
|
||||
},
|
||||
{
|
||||
command: ["make", "-f", "evil.mk"],
|
||||
expected: "make -f requires explicit approval in strictInlineEval mode",
|
||||
},
|
||||
{
|
||||
command: ["sed", "s/.*/id/e", "/dev/null"],
|
||||
expected: "sed inline program requires explicit approval in strictInlineEval mode",
|
||||
},
|
||||
] as const;
|
||||
setRuntimeConfigSnapshot({
|
||||
tools: {
|
||||
@@ -1363,12 +1349,11 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
|
||||
});
|
||||
|
||||
it("does not persist allow-always approvals for strict inline-eval carriers", async () => {
|
||||
// Persistence behavior is covered generically in exec-approvals tests; keep
|
||||
// one flag carrier and one inline-program carrier wired through the handler.
|
||||
const cases = [
|
||||
{ executable: "python3", args: ["-c", "print('hi')"] },
|
||||
{ executable: "awk", args: ['BEGIN{system("id")}', "/dev/null"] },
|
||||
{ executable: "find", args: [".", "-exec", "id", "{}", ";"] },
|
||||
{ executable: "xargs", args: ["id"] },
|
||||
{ executable: "sed", args: ["s/.*/id/e", "/dev/null"] },
|
||||
] as const;
|
||||
setRuntimeConfigSnapshot({
|
||||
tools: {
|
||||
|
||||
@@ -332,9 +332,9 @@ function buildLocalSlashCommands(): SlashCommandDef[] {
|
||||
return [...builtins, ...UI_ONLY_COMMANDS];
|
||||
}
|
||||
|
||||
function buildReservedLocalSlashNames(): Set<string> {
|
||||
function buildReservedLocalSlashNames(localCommands = buildLocalSlashCommands()): Set<string> {
|
||||
const reserved = new Set<string>();
|
||||
for (const command of buildLocalSlashCommands()) {
|
||||
for (const command of localCommands) {
|
||||
reserved.add(normalizeLowercaseStringOrEmpty(command.name));
|
||||
for (const alias of command.aliases ?? []) {
|
||||
const normalized = normalizeSlashIdentifier(alias);
|
||||
@@ -392,7 +392,7 @@ function replaceSlashCommands(next: SlashCommandDef[]) {
|
||||
|
||||
function buildSlashCommandsFromEntries(entries: CommandEntry[]): SlashCommandDef[] {
|
||||
const local = buildLocalSlashCommands();
|
||||
const reservedLocalNames = buildReservedLocalSlashNames();
|
||||
const reservedLocalNames = buildReservedLocalSlashNames(local);
|
||||
const mapped = entries
|
||||
.slice(0, MAX_REMOTE_COMMANDS)
|
||||
.map((entry) => normalizeCommandEntry(entry, reservedLocalNames))
|
||||
|
||||
Reference in New Issue
Block a user