Documentation
¶
Overview ¶
Package internal contains internal utility functions and types for Ason.
Index ¶
- func CheckTraversalAttack(basePath, targetPath string) error
- func CleanPath(path string) string
- func IsPathSafe(basePath, targetPath string) bool
- func SanitizeError(err error) string
- func SanitizeString(s string) string
- func ValidatePath(path string) error
- func ValidateVariableName(name string) error
- func ValidateVariableValue(name string, value interface{}) error
- func ValidateVariables(variables map[string]interface{}) error
- type EngineError
- type GenerationError
- type InvalidPathError
- type RegistryError
- type TemplateNotFoundError
- type VariableValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckTraversalAttack ¶
CheckTraversalAttack detects and prevents directory traversal attacks. It returns an error if the path attempts to escape its intended directory. basePath is the base directory that should not be escaped. targetPath is the path to validate.
func CleanPath ¶
CleanPath returns a cleaned version of the path that is safe to use. It resolves . and .. elements and removes duplicate slashes.
func IsPathSafe ¶
IsPathSafe checks if a path is safe to use in file operations. It combines path validation and traversal attack checking.
func SanitizeError ¶
SanitizeError removes sensitive information from an error message. It prevents exposing internal paths and system details.
func SanitizeString ¶
SanitizeString removes potentially dangerous characters from a string. This is used for error messages and logging to prevent information leakage.
func ValidatePath ¶
ValidatePath validates that a path is safe to use. It checks for directory traversal attempts and ensures the path is absolute or relative but clean.
func ValidateVariableName ¶
ValidateVariableName validates that a variable name follows naming conventions. Valid names contain alphanumeric characters, underscores, and dots (for nested access).
func ValidateVariableValue ¶
ValidateVariableValue validates that a variable value is safe to use. It ensures the value can be properly serialized and doesn't contain malicious content.
func ValidateVariables ¶
ValidateVariables validates a map of variables.
Types ¶
type EngineError ¶
EngineError is returned when the template engine fails.
func (*EngineError) Error ¶
func (e *EngineError) Error() string
func (*EngineError) Unwrap ¶
func (e *EngineError) Unwrap() error
type GenerationError ¶
type GenerationError struct {
Phase string // e.g., "loading", "rendering", "writing"
Reason string
Cause error
}
GenerationError is returned when project generation fails.
func (*GenerationError) Error ¶
func (e *GenerationError) Error() string
func (*GenerationError) Unwrap ¶
func (e *GenerationError) Unwrap() error
type InvalidPathError ¶
InvalidPathError is returned when a path is invalid or unsafe.
func (*InvalidPathError) Error ¶
func (e *InvalidPathError) Error() string
type RegistryError ¶
type RegistryError struct {
Operation string // e.g., "register", "list", "remove", "load"
Name string
Reason string
Cause error
}
RegistryError is returned when registry operations fail.
func (*RegistryError) Error ¶
func (e *RegistryError) Error() string
func (*RegistryError) Unwrap ¶
func (e *RegistryError) Unwrap() error
type TemplateNotFoundError ¶
TemplateNotFoundError is returned when a template cannot be found.
func (*TemplateNotFoundError) Error ¶
func (e *TemplateNotFoundError) Error() string
type VariableValidationError ¶
VariableValidationError is returned when a variable fails validation.
func (*VariableValidationError) Error ¶
func (e *VariableValidationError) Error() string
Directories
¶
| Path | Synopsis |
|---|---|
|
Package engine provides template rendering functionality and interfaces.
|
Package engine provides template rendering functionality and interfaces. |
|
Package generator provides template generation and rendering functionality.
|
Package generator provides template generation and rendering functionality. |
|
Package prompt provides interactive prompt functionality using Bubble Tea.
|
Package prompt provides interactive prompt functionality using Bubble Tea. |
|
Package registry provides template registry management functionality.
|
Package registry provides template registry management functionality. |
|
Package template provides template configuration and parsing utilities.
|
Package template provides template configuration and parsing utilities. |
|
Package varfile provides utilities for loading variables from files in TOML, YAML, and JSON formats.
|
Package varfile provides utilities for loading variables from files in TOML, YAML, and JSON formats. |
|
Package xdg provides XDG Base Directory specification utilities.
|
Package xdg provides XDG Base Directory specification utilities. |