Table of Contents

Class PathHelper

Namespace
Oscova.Agents.Utilities
Assembly
Oscova.Agents.dll

Path security utilities for containment checks and safe logging.

public static class PathHelper

Inheritance

Inherited Members

Methods

ArePathsEqual(string, string)

Returns true when two paths resolve to the same filesystem location. Uses the platform's default path comparison rules.

HasSymlinkInPath(string, string)

Returns true if any path segment beneath normalizedDirectoryPath is a symlink or reparse point. Inaccessible segments are treated conservatively as unsafe.

IsDirectChildOfAnyDirectory(string, IEnumerable<string>)

Returns true when relativePath is a direct file child of any supplied top-level directory name.

IsPathWithinAnyDirectory(string, IReadOnlyList<string>)

Returns true if fullPath is located inside any of the supplied directory roots.

IsPathWithinDirectory(string, string)

Returns true if fullPath is located inside normalizedDirectoryPath. Uses System.IO.Path.GetRelativePath(System.String,System.String) which is natively case-sensitive on Linux/macOS and case-insensitive on Windows.

SanitizeForLog(string)

Replaces control characters in a file path with '?' to prevent log injection via crafted filenames containing newlines or other control characters.

ToPlatformRelativePath(string)

Converts a slash-separated relative path into the current platform's directory-separator form.

ToSlashSeparatedRelativePath(string)

Converts a relative path to the forward-slash form used by skill files, zip entries, and model-facing paths.

TryGetContainingDirectory(string, IReadOnlyList<AllowedDirectory>, out AllowedDirectory?)

Finds the most specific allowed directory that contains fullPath.