internal

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AskForConfirmation

func AskForConfirmation(s string) bool

AskForConfirmation asks the user for confirmation. A user must type in "yes" or "no" and then press enter. It has fuzzy matching, so "y", "Y", "yes", "YES", and "Yes" all count as confirmations. If the input is not recognized, it will ask again. The function does not return until it gets a valid response from the user. Original source: https://gist.github.com/r0l1/3dcbb0c8f6cfe9c66ab8008f55f8f28b

func CheckPath

func CheckPath(cmd string) bool

CheckPath checks the $PATH environment variable for a given "cmd" and return a "bool" indicating if it exists.

func Contains

func Contains(slice []string, target string) bool

Contains checks if a slice of strings ("slice" parameter) contains a given string ("search" parameter).

func DirExists

func DirExists(path string) bool

DirExists determines if a given string is a valid directory. Reference: https://golangcode.com/check-if-a-file-exists/

func DownloadFile

func DownloadFile(url string, filepath string) error

DownloadFile downloads a file from the specified URL and saves it to the provided filepath.

func EvaluateDockerComposeStatus

func EvaluateDockerComposeStatus(install ...bool) error

EvaluateDockerComposeStatus determines if the host has the "docker compose" plugin or the "docker compose" script installed and set the global `dockerCmd` variable.

func FetchLogs

func FetchLogs(containerName string, lines string) []string

FetchLogs fetches logs from the container with the specified "name" label ("containerName" parameter).

func FileExists

func FileExists(path string) bool

FileExists determines if a given string is a valid filepath. Reference: https://golangcode.com/check-if-a-file-exists/

func GenerateRandomPassword

func GenerateRandomPassword(pwLength int, safe bool) string

GenerateRandomPassword generates a random password of the given length The password will be comprised of a-zA-Z0-9 and !@#$%^&*()_-+=/?<>., Special characters exclude the following: '";:`~\/| Exclusions are to help avoid issues with escaping and breaking quotes in env files

func GetConfigAll

func GetConfigAll() []byte

GetConfigAll retrieves all values from the JSON config configuration file.

func GetCwdFromExe

func GetCwdFromExe() string

GetCwdFromExe gets the current working directory based on "bloodhound-cli" location.

func ParseBloodHoundEnvironmentVariables

func ParseBloodHoundEnvironmentVariables()

ParseBloodHoundEnvironmentVariables attempts to find and open an existing JSON config file or create a new one. If a JSON config file is found, load it into the Viper configuration. If a JSON config file is not found, create a new one with default values. Then write the final file with `WriteBloodHoundEnvironmentVariables()`.

func RunBasicCmd

func RunBasicCmd(name string, args []string) (string, error)

RunBasicCmd executes a given command ("name") with a list of arguments ("args") and return a "string" with the output.

func RunCmd

func RunCmd(name string, args []string) error

RunCmd executes a given command ("name") with a list of arguments ("args") and return stdout and stderr buffers.

func RunDockerComposeDown

func RunDockerComposeDown(yaml string, volumes bool)

RunDockerComposeDown executes the "docker compose" commands to bring down the environment with the specified YAML file ("yaml" parameter).

func RunDockerComposeInstall

func RunDockerComposeInstall(yaml string)

RunDockerComposeInstall executes the "docker compose" commands for a first-time installation with the specified YAML file ("yaml" parameter).

func RunDockerComposeRestart

func RunDockerComposeRestart(yaml string)

RunDockerComposeRestart executes the "docker compose" commands to restart the environment with the specified YAML file ("yaml" parameter).

func RunDockerComposeStart

func RunDockerComposeStart(yaml string)

RunDockerComposeStart executes the "docker compose" commands to start the environment with the specified YAML file ("yaml" parameter).

func RunDockerComposeStop

func RunDockerComposeStop(yaml string)

RunDockerComposeStop executes the "docker compose" commands to stop all services in the environment with the specified YAML file ("yaml" parameter).

func RunDockerComposeUninstall added in v0.1.3

func RunDockerComposeUninstall(yaml string)

RunDockerComposeUninstall executes the "docker compose" commands to bring down containers and remove containers, images, and volumes with the specified YAML file ("yaml" parameter).

func RunDockerComposeUp

func RunDockerComposeUp(yaml string)

RunDockerComposeUp executes the "docker compose" commands to bring up the environment with the specified YAML file ("yaml" parameter).

func RunDockerComposeUpgrade

func RunDockerComposeUpgrade(yaml string)

RunDockerComposeUpgrade executes the "docker compose" commands for re-building or upgrading an installation with the specified YAML file ("yaml" parameter).

func SetConfig

func SetConfig(key string, value string)

SetConfig sets the value of the specified key in the JSON config file.

func WriteBloodHoundEnvironmentVariables

func WriteBloodHoundEnvironmentVariables()

WriteBloodHoundEnvironmentVariables writes the environment variables to the JSON config file.

Types

type Configuration

type Configuration struct {
	Key string
	Val string
}

Configuration is a custom type for storing configuration values as Key:Val pairs.

type Configurations

type Configurations []Configuration

Configurations is a custom type for storing `Configuration` values

func GetConfig

func GetConfig(args []string) Configurations

GetConfig retrieves the specified values from the JSON config file.

func (Configurations) Len

func (c Configurations) Len() int

Len returns the length of a Configurations struct

func (Configurations) Less

func (c Configurations) Less(i, j int) bool

Less determines if one Configuration is less than another Configuration

func (Configurations) Swap

func (c Configurations) Swap(i, j int)

Swap exchanges the position of two Configuration values in a Configurations struct

type Container

type Container struct {
	ID     string
	Image  string
	Status string
	Ports  []types.Port
	Name   string
}

Container is a custom type for storing container information similar to output from "docker containers ls".

type Containers

type Containers []Container

Containers is a collection of Container structs

func GetRunning

func GetRunning() Containers

GetRunning determines if the container with the specified "name" label ("containerName" parameter) is running.

func (Containers) Len

func (c Containers) Len() int

Len returns the length of a Containers struct

func (Containers) Less

func (c Containers) Less(i, j int) bool

Less determines if one Container is less than another Container

func (Containers) Swap

func (c Containers) Swap(i, j int)

Swap exchanges the position of two Container values in a Containers struct

type HealthIssue

type HealthIssue struct {
	Type    string
	Service string
	Message string
}

HealthIssue is a custom type for storing healthcheck output.

type HealthIssues

type HealthIssues []HealthIssue

func (HealthIssues) Len

func (c HealthIssues) Len() int

func (HealthIssues) Less

func (c HealthIssues) Less(i, j int) bool

func (HealthIssues) Swap

func (c HealthIssues) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳