Skip to content

Commit

Permalink
updated mythic-cli
Browse files Browse the repository at this point in the history
better mythic-cli support for mythic_graphql volumes
  • Loading branch information
its-a-feature committed Jan 29, 2024
1 parent 30856d7 commit 96563b2
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 10 deletions.
14 changes: 14 additions & 0 deletions Mythic_CLI/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 0.2.5 - 2024-01-28

### Changed

- Removed the usage of the volume container for `mythic_graphql`
- Existing volumes for mythic_graphql break new updates since the old volume information is used

## 0.2.4 - 2024-01-28

### Changed

- Refactored to allow multiple kinds of managers for Mythic (defaults to `Docker`)
- Added volume support

## 0.2.3 - 2023-12-27

### Changed
Expand Down
2 changes: 1 addition & 1 deletion Mythic_CLI/src/cmd/config/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ package config

var (
// Version Mythic CLI version
Version = "v0.2.4"
Version = "v0.2.5"
)
21 changes: 14 additions & 7 deletions Mythic_CLI/src/cmd/internal/serviceMetadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,22 @@ func AddMythicService(service string) {
"./hasura-docker/metadata:/metadata",
}
} else {
pStruct["volumes"] = []string{
"mythic_graphql_volume:/metadata",
}
delete(pStruct, "volumes")
/*
pStruct["volumes"] = []string{
"mythic_graphql_volume:/metadata",
}
*/
}
if _, ok := volumes["mythic_graphql"]; !ok {
volumes["mythic_graphql_volume"] = map[string]interface{}{
"name": "mythic_graphql_volume",
/*
if _, ok := volumes["mythic_graphql"]; !ok {
volumes["mythic_graphql_volume"] = map[string]interface{}{
"name": "mythic_graphql_volume",
}
}
}
*/
case "mythic_nginx":
if mythicEnv.GetBool("nginx_use_build_context") {
pStruct["build"] = map[string]interface{}{
Expand Down
20 changes: 18 additions & 2 deletions Mythic_CLI/src/cmd/manager/dockerComposeManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -927,12 +927,28 @@ func (d *DockerComposeManager) RemoveVolume(volumeName string) error {
}
for _, currentVolume := range volumes.Volumes {
if currentVolume.Name == volumeName {
err = cli.VolumeRemove(ctx, currentVolume.Name, true)
containers, err := cli.ContainerList(ctx, types.ContainerListOptions{Size: true})
if err != nil {
return err
log.Fatalf("[-] Failed to get container list: %v\n", err)
}
for _, c := range containers {
for _, m := range c.Mounts {
if m.Name == volumeName {
containerName := c.Labels["name"]
err = cli.ContainerRemove(ctx, c.ID, types.ContainerRemoveOptions{Force: true})
if err != nil {
log.Printf(fmt.Sprintf("[!] Failed to remove container that's using the volume: %v\n", err))
} else {
log.Printf("[+] Removed container %s, which was using that container", containerName)
}
}
}
}
err = cli.VolumeRemove(ctx, currentVolume.Name, true)
return err
}
}
log.Printf("[*] Volume not found")
return nil
}
func (d *DockerComposeManager) CopyIntoVolume(sourceFile io.Reader, destinationFileName string, destinationVolume string) {
Expand Down

0 comments on commit 96563b2

Please sign in to comment.