utilities

package
v0.0.0-...-b2b9887 Latest Latest
Warning

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

Go to latest
Published: May 15, 2025 License: AGPL-3.0 Imports: 14 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustParseRsaPublicKey

func MustParseRsaPublicKey(key []byte) *rsa.PublicKey

MustParseRsaPublicKey parses a public key in PEM format and returns the rsa.PublicKey object. Panics if the key is invalid.

func ParseRsaPublicKey

func ParseRsaPublicKey(key []byte) (*rsa.PublicKey, error)

ParseRsaPublicKey parses a public key in PEM format and returns the rsa.PublicKey object. Returns an error if the key is invalid.

func PipeCommands

func PipeCommands(commands ...*exec.Cmd) ([]byte, error)

PipeCommands executes the commands received as input by feeding the output of one to the input of the other, exactly like Unix Pipe (|). Returns the output of the final command and the eventual error.

code inspired by https://gist.github.com/tyndyll/89fbb2c2273f83a074dc

func SafeJoin

func SafeJoin(parent, subdir string) (string, error)

SafeJoin performs a filepath.Join of 'parent' and 'subdir' but returns an error if the resulting path points outside of 'parent'.

func SaveFileonTempDir

func SaveFileonTempDir(filename string, data io.Reader) (string, error)

SaveFileonTempDir creates a temp directory and saves the file data as the filename in that directory. Returns an error if the agent doesn't have permission to create the folder. Returns an error if the filename doesn't form a valid path.

Note that path could be defined and still there could be an error.

func TellCommandNotToSpawnShell

func TellCommandNotToSpawnShell(_ *exec.Cmd)

TellCommandNotToSpawnShell will now spawn a shell

func UserPrompt

func UserPrompt(dialog string, buttons string, defaultButton string, toPress string, title string) bool

UserPrompt executes an osascript and returns the pressed button

func VerifyInput

func VerifyInput(input string, signature string, pubKey *rsa.PublicKey) error

VerifyInput will verify an input against a signature using the public key. A valid signature is indicated by returning a nil error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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