platformpath

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package platformpath provides OS-specific path safety helpers.

This package centralizes platform-specific path validation that was previously duplicated across multiple packages. It provides:

  • UNC path detection for Windows
  • Local path validation
  • Platform-specific path safety checks

Security Properties

These helpers prevent attacks that exploit platform-specific path semantics:

  • UNC paths (\\server\share) could redirect operations to remote servers
  • Path separators vary by platform
  • Drive letters are Windows-specific

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasDriveLetter

func HasDriveLetter(path string) bool

HasDriveLetter returns true if the path starts with a Windows drive letter (C:, D:, etc.).

func IsLocalWindowsPath

func IsLocalWindowsPath(path string) bool

IsLocalWindowsPath checks if a path is a local Windows path (not UNC or otherwise unsafe). Returns true for paths like "C:\Users\..." and false for UNC paths like "\\server\share".

SECURITY: UNC paths could redirect file operations to remote servers controlled by an attacker. Helps prevent SSRF-like attacks via environment variables like LOCALAPPDATA or user-provided paths.

Safe to call on any platform - checks path string format without filesystem access.

func IsUNCPath

func IsUNCPath(path string) bool

IsUNCPath returns true if the path is a UNC path (\\server\share or //server/share).

SECURITY: UNC paths can be used to:

  • Redirect operations to attacker-controlled SMB servers
  • Leak credentials via NTLM authentication
  • Cause operations to hang waiting for network timeouts

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL