Documentation
¶
Index ¶
- func AskForConfirmation(s string) bool
- func CheckConfigDir(path string) (bool, error)
- func CheckPath(cmd string) bool
- func CheckYamlExists(path string)
- func Contains(slice []string, target string) bool
- func DirExists(path string) bool
- func DownloadDockerComposeFiles()
- func DownloadFile(url string, filepath string) error
- func EvaluateDockerComposeStatus()
- func EvaluateEnvironment()
- func FetchLogs(containerName string, lines string) []string
- func FileExists(path string) bool
- func GenerateRandomPassword(pwLength int, safe bool) string
- func GetBloodHoundDir() string
- func GetConfigAll() []byte
- func GetCwdFromExe() string
- func GetDefaultConfigDir() string
- func GetRemoteBloodHoundCliVersion() (string, string, error)
- func GetYamlFilePath(override string) string
- func MakeConfigDir() error
- func ParseBloodHoundEnvironmentVariables()
- func ResetAdminPassword(yaml string)
- func RunBasicCmd(name string, args []string) (string, error)
- func RunCmd(name string, args []string) error
- func RunDockerComposeDown(yaml string, volumes bool)
- func RunDockerComposeInstall(yaml string)
- func RunDockerComposePull(yaml string)
- func RunDockerComposeRestart(yaml string)
- func RunDockerComposeStart(yaml string)
- func RunDockerComposeStop(yaml string)
- func RunDockerComposeUninstall(yaml string)
- func RunDockerComposeUp(yaml string)
- func RunDockerComposeUpgrade(yaml string)
- func SetConfig(key string, value string)
- func WriteBloodHoundEnvironmentVariables()
- type Configuration
- type Configurations
- type Container
- type Containers
- type HealthIssue
- type HealthIssues
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AskForConfirmation ¶
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 CheckConfigDir ¶ added in v0.1.7
CheckConfigDir checks if the config directory's permissions are at least 0600. This ensures the current user has R/W access and BloodHound CLI can function. A more permissive mode won't trigger any errors. It returns true if the permissions are sufficient, along with any error encountered during the stat operation.
func CheckYamlExists ¶ added in v0.1.7
func CheckYamlExists(path string)
CheckYamlExists verifies that a YAML file exists at the specified path. If the file does not exist, it logs a fatal error with instructions for obtaining the required YAML file.
func Contains ¶
Contains checks if a slice of strings ("slice" parameter) contains a given string ("search" parameter).
func DirExists ¶
DirExists reports whether the specified path exists and is a directory. Returns false if the path does not exist.
func DownloadDockerComposeFiles ¶ added in v0.1.6
func DownloadDockerComposeFiles()
DownloadDockerComposeFiles downloads the production and development Docker Compose YAML files into the BloodHound directory. If either file already exists, prompts the user for confirmation before overwriting. Exits fatally on download failure.
func DownloadFile ¶
DownloadFile downloads a file from the specified URL and saves it to the provided filepath.
func EvaluateDockerComposeStatus ¶
func EvaluateDockerComposeStatus()
EvaluateDockerComposeStatus checks if Docker (or Podman in Docker compatibility mode) and the Docker Compose plugin are installed and operational. It verifies the presence of the CLI, ensures the daemon is running, and sets the global dockerCmd variable to either `docker` or `podman`. The function exits fatally via log.Fatal* if any requirement is not met; otherwise it returns normally.
func EvaluateEnvironment ¶ added in v0.1.6
func EvaluateEnvironment()
EvaluateEnvironment checks for the presence of Docker YAML files and initiates their download if necessary.
func FetchLogs ¶
FetchLogs fetches logs from the container with the specified "name" label ("containerName" parameter).
func FileExists ¶
FileExists determines if a given string is a valid filepath. Reference: https://golangcode.com/check-if-a-file-exists/
func GenerateRandomPassword ¶
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 GetBloodHoundDir ¶ added in v0.1.7
func GetBloodHoundDir() string
GetBloodHoundDir returns the configured BloodHound config directory path from the environment variable "config_directory".
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 GetDefaultConfigDir ¶ added in v0.1.7
func GetDefaultConfigDir() string
GetDefaultConfigDir returns the default BloodHound config directory path as a `bloodhound` folder inside the current user's data directory. Logs a fatal error if the user's config directory cannot be determined.
func GetRemoteBloodHoundCliVersion ¶ added in v0.1.8
GetRemoteBloodHoundCliVersion fetches the latest BloodHound CLI version from GitHub's API.
func GetYamlFilePath ¶ added in v0.1.7
GetYamlFilePath joins and returns the directory path of the BloodHound config directory with the Docker Compose YAML file. If a user has provided the `-f` or `--file` flag with a string value, the function will return that filepath.
func MakeConfigDir ¶ added in v0.1.7
func MakeConfigDir() error
MakeConfigDir ensures the configured BloodHound config directory exists, creating it if necessary. Returns an error if directory creation fails.
func ParseBloodHoundEnvironmentVariables ¶
func ParseBloodHoundEnvironmentVariables()
ParseBloodHoundEnvironmentVariables initializes default configuration values, ensures the BloodHound config file and directory exist with correct permissions, loads configuration from the JSON file and environment variables, and writes the final configuration back to the file. The function terminates the program on critical errors.
func ResetAdminPassword ¶ added in v0.1.4
func ResetAdminPassword(yaml string)
ResetAdminPassword executes the "docker compose" commands to brings containers down and back up to reset the default admin account for the specified YAML file ("yaml" parameter).
func RunBasicCmd ¶
RunBasicCmd executes a given command ("name") with a list of arguments ("args") and returns a "string" with the output.
func RunCmd ¶
RunCmd executes a given command ("name") with a list of arguments ("args") and return stdout and stderr buffers.
func RunDockerComposeDown ¶
RunDockerComposeDown stops and removes containers defined in the specified Docker Compose YAML file. If volumes is true, associated Docker volumes are also removed. Exits fatally on failure.
func RunDockerComposeInstall ¶
func RunDockerComposeInstall(yaml string)
RunDockerComposeInstall performs a first-time installation of BloodHound containers using the specified Docker Compose YAML file. It ensures required YAML files are present, pulls container images, and starts the environment in detached mode. Prints login credentials and UI access information upon successful setup. Exits fatally on errors.
func RunDockerComposePull ¶ added in v0.1.4
func RunDockerComposePull(yaml string)
RunDockerComposePull pulls the latest container images defined in the specified Docker Compose YAML file. Exits fatally if the YAML file does not exist or if the pull operation fails.
func RunDockerComposeRestart ¶
func RunDockerComposeRestart(yaml string)
RunDockerComposeRestart restarts all containers defined in the specified Docker Compose YAML file. Exits fatally if the YAML file does not exist or if the restart operation fails.
func RunDockerComposeStart ¶
func RunDockerComposeStart(yaml string)
RunDockerComposeStart starts all services defined in the specified Docker Compose YAML file. Exits fatally if the YAML file does not exist or if starting the containers fails.
func RunDockerComposeStop ¶
func RunDockerComposeStop(yaml string)
RunDockerComposeStop stops all services defined in the specified Docker Compose YAML file. Exits the program if stopping services fails.
func RunDockerComposeUninstall ¶ added in v0.1.3
func RunDockerComposeUninstall(yaml string)
RunDockerComposeUninstall removes all BloodHound containers, images, and volumes defined in the specified Docker Compose YAML file, then optionally deletes the BloodHound config directory after user confirmation. The process is interactive and exits if the user declines any confirmation prompt. Fatal errors are logged if uninstallation or directory deletion fails.
func RunDockerComposeUp ¶
func RunDockerComposeUp(yaml string)
RunDockerComposeUp brings up Docker containers in detached mode using the specified Docker Compose YAML file. Exits fatally if the YAML file does not exist or if the command fails.
func RunDockerComposeUpgrade ¶
func RunDockerComposeUpgrade(yaml string)
RunDockerComposeUpgrade rebuilds and restarts all containers defined in the specified Docker Compose YAML file. It brings down any running containers, rebuilds images, and brings the environment back up in detached mode. Exits fatally if any Docker command fails.
func WriteBloodHoundEnvironmentVariables ¶
func WriteBloodHoundEnvironmentVariables()
WriteBloodHoundEnvironmentVariables writes the current BloodHound configuration to the JSON config file, ensuring the file exists before writing. Logs a fatal error and exits if writing fails.
Types ¶
type Configuration ¶
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 []container.PortSummary
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) 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 ¶
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)