arch

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package arch provides architecture-specific functionality for Linux systems. It includes utilities for device detection, platform identification, and execution of system-specific commands like hashcat and 7z.

Package arch provides architecture-specific functionality. This file contains cross-platform path validation for exec.CommandContext calls.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRelativePath indicates a path is not absolute.
	ErrRelativePath = errors.New("path must be absolute")
	// ErrPathNotFound indicates a path does not exist on disk.
	ErrPathNotFound = errors.New("path does not exist")
	// ErrPathIsDirectory indicates a path points to a directory, not a file.
	ErrPathIsDirectory = errors.New("path is a directory, expected a file")
	// ErrPathNotDirectory indicates a path does not point to a directory.
	ErrPathNotDirectory = errors.New("path is not a directory")
)

Functions

func Extract7z

func Extract7z(ctx context.Context, srcFile, destDir string) error

Extract7z extracts the contents of a 7z archive to a specified directory. It takes the source file path of the 7z archive and the destination directory where the contents should be extracted.

Parameters:

  • ctx: A context for cancellation and deadlines. The command will be cancelled if ctx is cancelled.
  • srcFile: The path to the 7z archive file.
  • destDir: The directory where the contents of the archive will be extracted.

Returns:

  • error: An error object if the extraction fails, otherwise nil.

func GetAdditionalHashcatArgs

func GetAdditionalHashcatArgs() []string

GetAdditionalHashcatArgs returns a slice of additional arguments to be passed to Hashcat. Currently, it returns an empty slice, but it can be extended to include more arguments as needed.

func GetDefaultHashcatBinaryName

func GetDefaultHashcatBinaryName() string

GetDefaultHashcatBinaryName returns the default binary name for the Hashcat tool on Linux systems. This function is useful for determining the standard executable name used by Hashcat.

func GetHashcatVersion

func GetHashcatVersion(ctx context.Context, hashcatPath string) (string, error)

GetHashcatVersion retrieves the version of Hashcat installed at the specified path. It runs the Hashcat executable with the "--version" and "--quiet" flags and returns the version as a string. If an error occurs during execution, it returns "0.0.0" and the error.

Parameters:

  • ctx: A context for cancellation and deadlines. The command will be cancelled if ctx is cancelled.
  • hashcatPath: The file path to the Hashcat executable.

Returns:

  • A string representing the Hashcat version.
  • An error if the command execution fails.

func ValidateArchivePaths added in v0.6.2

func ValidateArchivePaths(srcFile, destDir string) error

ValidateArchivePaths checks that srcFile exists and is a regular file, and that destDir exists and is a directory.

func ValidateExecutablePath added in v0.6.2

func ValidateExecutablePath(path string) error

ValidateExecutablePath checks that a binary path is absolute, exists, and is not a directory. This is a defense-in-depth check before passing paths to exec.CommandContext.

Types

This section is empty.

Jump to

Keyboard shortcuts

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