internal

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package internal contains internal utility functions and types for Ason.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckTraversalAttack

func CheckTraversalAttack(basePath, targetPath string) error

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

func CleanPath(path string) string

CleanPath returns a cleaned version of the path that is safe to use. It resolves . and .. elements and removes duplicate slashes.

func IsPathSafe

func IsPathSafe(basePath, targetPath string) bool

IsPathSafe checks if a path is safe to use in file operations. It combines path validation and traversal attack checking.

func SanitizeError

func SanitizeError(err error) string

SanitizeError removes sensitive information from an error message. It prevents exposing internal paths and system details.

func SanitizeString

func SanitizeString(s string) string

SanitizeString removes potentially dangerous characters from a string. This is used for error messages and logging to prevent information leakage.

func ValidatePath

func ValidatePath(path string) error

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

func ValidateVariableName(name string) error

ValidateVariableName validates that a variable name follows naming conventions. Valid names contain alphanumeric characters, underscores, and dots (for nested access).

func ValidateVariableValue

func ValidateVariableValue(name string, value interface{}) error

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

func ValidateVariables(variables map[string]interface{}) error

ValidateVariables validates a map of variables.

Types

type EngineError

type EngineError struct {
	Operation string // e.g., "render", "compile"
	Reason    string
	Cause     error
}

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

type InvalidPathError struct {
	Path   string
	Reason string
}

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

type TemplateNotFoundError struct {
	TemplateName string
	Path         string
}

TemplateNotFoundError is returned when a template cannot be found.

func (*TemplateNotFoundError) Error

func (e *TemplateNotFoundError) Error() string

type VariableValidationError

type VariableValidationError struct {
	VariableName string
	Value        interface{}
	Reason       string
}

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.

Jump to

Keyboard shortcuts

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