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 ¶
- func ComputeFileChecksum(filePath string) ([]byte, error)
- func FileInfo(filePath string) (string, string, string, error)
- func GetDownloadPath(log *ipfsLog.ZapEventLogger) string
- func LoadKeyFromFile(filename, storagePath string) ([]byte, error)
- func SanitizePath(path string) (string, error)
- func WaitForTermSignal()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeFileChecksum ¶
func FileInfo ¶
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 ¶
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 ¶
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.