shsprintf

package
v0.0.0-...-5a72de7 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Overview

Package shsprintf is a drop-in-replacement for using sprintf to produce shell scripts, that adds automatic detection for command / argument injection.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidShTemplate error = errors.New("Invalid Shell Template")

ErrInvalidShTemplate indicates the requested template is not a valid script

View Source
var ErrShInjection error = errors.New("Shell Injection Detected")

ErrShInjection indicates the inputs resulted in shell injection.

Functions

func EscapeDefaultContext

func EscapeDefaultContext(in string) string

EscapeDefaultContext escapes special characters in a context where there is no existing quoting, such as --arg=%s

func MustSprintf

func MustSprintf(format string, a ...any) string

MustSprintf is a wrapper to Sprintf that panics upon error.

func Sprintf

func Sprintf(format string, a ...any) (string, error)

Sprintf is a fmt.Sprintf replacement specific for generating bash scripts, with protection against any string substitution from escaping its context, or from injecting new flag arguments.

func SprintfLang

func SprintfLang(format string, lang syntax.LangVariant, a ...any) (string, error)

SprintfLang is a fmt.Sprintf replacement specific for generating shell scripts, with protection against any string substitution from escaping its context, or from injecting new flag arguments.

Types

This section is empty.

Jump to

Keyboard shortcuts

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