Skip to content

Commit 57398e8

Browse files
Added update to pull the latest BHCE images
1 parent c2e2722 commit 57398e8

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
### [0.1.4] - 2025-1-31
8+
9+
### Added
10+
11+
* Added an `update` command to pull the latest BloodHound images
12+
713
## [0.1.3] - 2025-1-31
814

915
### Added

cmd/internal/docker.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,16 @@ func RunDockerComposeDown(yaml string, volumes bool) {
232232
}
233233
}
234234

235+
// RunDockerComposePull executes the "docker compose" commands to pull the latest container images for
236+
// the specified YAML file ("yaml" parameter).
237+
func RunDockerComposePull(yaml string) {
238+
fmt.Printf("[+] Running `%s` to pull container imahes with %s...\n", dockerCmd, yaml)
239+
startErr := RunCmd(dockerCmd, []string{"-f", yaml, "pull"})
240+
if startErr != nil {
241+
log.Fatalf("Error trying to pull the container images with %s: %v\n", yaml, startErr)
242+
}
243+
}
244+
235245
// FetchLogs fetches logs from the container with the specified "name" label ("containerName" parameter).
236246
func FetchLogs(containerName string, lines string) []string {
237247
var logs []string

cmd/update.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
docker "github.com/SpecterOps/BloodHound_CLI/cmd/internal"
6+
"github.com/spf13/cobra"
7+
)
8+
9+
// updateCmd represents the update command
10+
var updateCmd = &cobra.Command{
11+
Use: "update",
12+
Short: "Update the BloodHound container images if an update is available",
13+
Long: `Updates the BloodHound container images if an update is available.`,
14+
Run: updateBloodHound,
15+
}
16+
17+
func init() {
18+
rootCmd.AddCommand(updateCmd)
19+
}
20+
21+
func updateBloodHound(cmd *cobra.Command, args []string) {
22+
err := docker.EvaluateDockerComposeStatus()
23+
if err != nil {
24+
return
25+
}
26+
fmt.Println("[+] Checking for BloodHound image updates...")
27+
docker.RunDockerComposePull("docker-compose.yml")
28+
}

0 commit comments

Comments
 (0)