utils

package
v1.0.0-release Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package utils provides utility functions for file operations and other common tasks in the SecuraChain project.package utils

Package utils provides utility functions for file operations and other common tasks in the SecuraChain project.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeFileChecksum

func ComputeFileChecksum(filePath string) ([]byte, error)

func FileInfo

func FileInfo(filePath string) (string, string, string, error)

FileInfo extracts and returns metadata about a given file. It provides the file's name, size, and type.

func GetDownloadPath

func GetDownloadPath(log *ipfsLog.ZapEventLogger) string

func LoadKeyFromFile

func LoadKeyFromFile(filename, storagePath string) ([]byte, error)

LoadKeyFromFile reads a key from a PEM-formatted file and returns its bytes. The function takes the filename without extension and the storage path as arguments. It returns the raw key bytes or an error if the file cannot be read or parsed.

func SanitizePath

func SanitizePath(path string) (string, error)

SanitizePath sanitizes a given file path to prevent potential security vulnerabilities. This function takes a file path as input and returns its absolute and cleaned version. The function ensures the path is absolute and eliminates any ".." or similar patterns that could be a security risk.

Parameters: - path: The file path that needs to be sanitized.

Returns: - A cleaned, absolute path as a string. - An error if the operation fails, for instance, if it fails to convert the path to an absolute path.

func WaitForTermSignal

func WaitForTermSignal()

Types

This section is empty.

Jump to

Keyboard shortcuts

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