Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/JAVA/Openclaw/src/infra/   (Openclaw AI Version 22©)  Datei vom 26.3.2026 mit Größe 2 kB image not shown  

Quelle  scp-host.test.ts

  Sprache: JAVA
 

import { describe, expect, it } from "vitest";
import {
  isSafeScpRemoteHost,
  isSafeScpRemotePath,
  normalizeScpRemoteHost,
  normalizeScpRemotePath,
} from "./scp-host.js";

describe("scp remote host", () => {
  it.each([
    { value: "gateway-host", expected: "gateway-host" },
    { value: " bot@gateway-host ", expected: "bot@gateway-host" },
    { value: "bot@192.168.64.3", expected: "bot@192.168.64.3" },
    { value: "bot@[fe80::1]", expected: "bot@[fe80::1]" },
  ])("normalizes safe hosts for %j", ({ value, expected }) => {
    expect(normalizeScpRemoteHost(value)).toBe(expected);
  });

  it.each([
    null,
    undefined,
    "",
    "   ",
    "-oProxyCommand=whoami",
    "bot@gateway-host -oStrictHostKeyChecking=no",
    "bot@host:22",
    "bot@/tmp/host",
    "bot@@host",
    "@host",
    "bot@",
    "bot@host\\name",
    "bot@-gateway-host",
    "bot@fe80::1",
    "bot@[fe80::1%en0]",
    "bot name@gateway-host",
  ])("rejects unsafe host tokens: %j", (value) => {
    expect(normalizeScpRemoteHost(value)).toBeUndefined();
    expect(isSafeScpRemoteHost(value)).toBe(false);
  });
});

describe("scp remote path", () => {
  it.each(
    [
      {
        value: "/Users/demo/Library/Messages/Attachments/ab/cd/photo.jpg",
        normalized: "/Users/demo/Library/Messages/Attachments/ab/cd/photo.jpg",
        safe: true,
      },
      {
        value: " /Users/demo/Library/Messages/Attachments/ab/cd/IMG 1234 (1).jpg ",
        normalized: "/Users/demo/Library/Messages/Attachments/ab/cd/IMG 1234 (1).jpg",
        safe: true,
      },
      null,
      undefined,
      "",
      "   ",
      "relative/path.jpg",
      "/Users/demo/Library/Messages/Attachments/ab/cd/bad$path.jpg",
      "/Users/demo/Library/Messages/Attachments/ab/cd/bad`path`.jpg",
      "/Users/demo/Library/Messages/Attachments/ab/cd/bad;path.jpg",
      "/Users/demo/Library/Messages/Attachments/ab/cd/bad|path.jpg",
      "/Users/demo/Library/Messages/Attachments/ab/cd/bad&path.jpg",
      "/Users/demo/Library/Messages/Attachments/ab/cd/bad<path.jpg",
      "/Users/demo/Library/Messages/Attachments/ab/cd/bad>path.jpg",
      '/Users/demo/Library/Messages/Attachments/ab/cd/bad"path.jpg',
      "/Users/demo/Library/Messages/Attachments/ab/cd/bad'path.jpg",
      "/Users/demo/Library/Messages/Attachments/ab/cd/bad\\path.jpg",
    ].map((entry) =>
      typeof entry === "object" && entry !== null && "value" in entry
        ? entry
        : { value: entry, normalized: undefined, safe: false },
    ),
  )("classifies path token %j", ({ value, normalized, safe }) => {
    expect(normalizeScpRemotePath(value)).toBe(normalized);
    expect(isSafeScpRemotePath(value)).toBe(safe);
  });
});

Messung V0.5 in Prozent
C=100 H=100 G=100

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet am  2026-06-09) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

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.