v0.0.2.35

This commit is contained in:
its-a-feature
2024-01-18 16:10:05 -06:00
parent 2a32829539
commit 0328ea93ef
4 changed files with 149 additions and 82 deletions
+58 -42
View File
@@ -87,48 +87,6 @@ jobs:
org.opencontainers.image.licenses=${{ env.IMAGE_LICENSE }}
platforms: linux/amd64,linux/arm64
mythic_cli:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
# Pull in the repository code
- name: Checkout the repository
uses: actions/checkout@v4 # ref: https://github.com/marketplace/actions/checkout
- name: Log in to the container registry
uses: docker/login-action@v3 # ref: https://github.com/marketplace/actions/docker-login
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: 'arm64,arm'
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
# the following are unique to this job
- name: Lowercase the cli container image name
run: echo "MYTHIC_CLI_IMAGE_NAME=${MYTHIC_CLI_IMAGE_NAME,,}" >> ${GITHUB_ENV}
- name: Build and push the cli container image
uses: docker/build-push-action@v5 # ref: https://github.com/marketplace/actions/build-and-push-docker-images
with:
context: Mythic_CLI
file: Mythic_CLI/.docker/Dockerfile
tags: |
${{ env.REGISTRY }}/${{ env.MYTHIC_CLI_IMAGE_NAME }}:${{ env.VERSION }}
${{ env.REGISTRY }}/${{ env.MYTHIC_CLI_IMAGE_NAME }}:latest
push: true
# These container metadata labels allow configuring the package in Github
# packages. The source will link the package to this Github repository
labels: |
org.opencontainers.image.source=${{ env.IMAGE_SOURCE }}
org.opencontainers.image.description=${{ env.IMAGE_DESCRIPTION }}
org.opencontainers.image.licenses=${{ env.IMAGE_LICENSE }}
platforms: linux/amd64,linux/arm64
mythic_postgres:
runs-on: ubuntu-latest
permissions:
@@ -431,6 +389,64 @@ jobs:
org.opencontainers.image.licenses=${{ env.IMAGE_LICENSE }}
platforms: linux/amd64,linux/arm64
# update mythic-cli latest after we're sure all the others build properly
mythic_cli:
runs-on: ubuntu-latest
needs:
- mythic_server
- mythic_postgres
- mythic_rabbitmq
- mythic_documentation
- mythic_jupyter
- mythic_graphql
- mythic_nginx
- mythic_react
permissions:
contents: write
packages: write
steps:
# Pull in the repository code
- name: Checkout the repository
uses: actions/checkout@v4 # ref: https://github.com/marketplace/actions/checkout
- name: Log in to the container registry
uses: docker/login-action@v3 # ref: https://github.com/marketplace/actions/docker-login
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: 'arm64,arm'
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
# the following are unique to this job
- name: Lowercase the cli container image name
run: echo "MYTHIC_CLI_IMAGE_NAME=${MYTHIC_CLI_IMAGE_NAME,,}" >> ${GITHUB_ENV}
- name: Fix the mythic_docker_latest reference to reference the new release tag
working-directory: Mythic_CLI/src/cmd/config
run: |
sed -i "s|^mythicEnv.Set(\"mythic_docker_latest\", .*$|mythicEnv.Set(\"mythic_docker_latest\", \"${REGISTRY}/${MYTHIC_SERVER_IMAGE_NAME}:${VERSION}\")|" env.go
- name: Build and push the cli container image
uses: docker/build-push-action@v5 # ref: https://github.com/marketplace/actions/build-and-push-docker-images
with:
context: Mythic_CLI
file: Mythic_CLI/.docker/Dockerfile
tags: |
${{ env.REGISTRY }}/${{ env.MYTHIC_CLI_IMAGE_NAME }}:${{ env.VERSION }}
${{ env.REGISTRY }}/${{ env.MYTHIC_CLI_IMAGE_NAME }}:latest
push: true
# These container metadata labels allow configuring the package in Github
# packages. The source will link the package to this Github repository
labels: |
org.opencontainers.image.source=${{ env.IMAGE_SOURCE }}
org.opencontainers.image.description=${{ env.IMAGE_DESCRIPTION }}
org.opencontainers.image.licenses=${{ env.IMAGE_LICENSE }}
platforms: linux/amd64,linux/arm64
update_files:
runs-on: ubuntu-latest
needs:
+17 -7
View File
@@ -99,6 +99,7 @@ func GetMythicEnv() *viper.Viper {
func setMythicConfigDefaultValues() {
// global configuration
mythicEnv.SetDefault("debug_level", "warning")
mythicEnv.SetDefault("server_name", "mythic")
// nginx configuration
mythicEnv.SetDefault("nginx_port", 7443)
mythicEnv.SetDefault("nginx_host", "mythic_nginx")
@@ -106,17 +107,20 @@ func setMythicConfigDefaultValues() {
mythicEnv.SetDefault("nginx_use_ssl", true)
mythicEnv.SetDefault("nginx_use_ipv4", true)
mythicEnv.SetDefault("nginx_use_ipv6", true)
mythicEnv.SetDefault("nginx_bind_use_volume", false)
mythicEnv.SetDefault("nginx_use_volume", false)
mythicEnv.SetDefault("nginx_use_build_context", true)
// mythic react UI configuration
mythicEnv.SetDefault("mythic_react_host", "mythic_react")
mythicEnv.SetDefault("mythic_react_port", 3000)
mythicEnv.SetDefault("mythic_react_bind_localhost_only", true)
mythicEnv.SetDefault("mythic_react_use_volume", false)
mythicEnv.SetDefault("mythic_react_use_build_context", true)
// documentation configuration
mythicEnv.SetDefault("documentation_host", "mythic_documentation")
mythicEnv.SetDefault("documentation_port", 8090)
mythicEnv.SetDefault("documentation_bind_localhost_only", true)
mythicEnv.SetDefault("documentation_bind_use_volume", false)
mythicEnv.SetDefault("documentation_use_volume", false)
mythicEnv.SetDefault("documentation_use_build_context", true)
// mythic server configuration
mythicEnv.SetDefault("mythic_debug_agent_message", false)
mythicEnv.SetDefault("mythic_server_port", 17443)
@@ -127,7 +131,8 @@ func setMythicConfigDefaultValues() {
mythicEnv.SetDefault("mythic_server_mem_limit", "")
mythicEnv.SetDefault("mythic_server_dynamic_ports", "7000-7010")
mythicEnv.SetDefault("mythic_server_dynamic_ports_bind_localhost_only", false)
mythicEnv.SetDefault("mythic_server_bind_use_volume", false)
mythicEnv.SetDefault("mythic_server_use_volume", false)
mythicEnv.SetDefault("mythic_server_use_build_context", true)
mythicEnv.SetDefault("mythic_server_command", "")
mythicEnv.SetDefault("mythic_sync_cpus", "2")
mythicEnv.SetDefault("mythic_sync_mem_limit", "")
@@ -140,7 +145,8 @@ func setMythicConfigDefaultValues() {
mythicEnv.SetDefault("postgres_password", utils.GenerateRandomPassword(30))
mythicEnv.SetDefault("postgres_cpus", "2")
mythicEnv.SetDefault("postgres_mem_limit", "")
mythicEnv.SetDefault("postgres_bind_use_volume", false)
mythicEnv.SetDefault("postgres_use_volume", false)
mythicEnv.SetDefault("postgres_use_build_context", true)
// rabbitmq configuration
mythicEnv.SetDefault("rabbitmq_host", "mythic_rabbitmq")
mythicEnv.SetDefault("rabbitmq_port", 5672)
@@ -150,7 +156,8 @@ func setMythicConfigDefaultValues() {
mythicEnv.SetDefault("rabbitmq_vhost", "mythic_vhost")
mythicEnv.SetDefault("rabbitmq_cpus", "2")
mythicEnv.SetDefault("rabbitmq_mem_limit", "")
mythicEnv.SetDefault("rabbitmq_bind_use_volume", false)
mythicEnv.SetDefault("rabbitmq_use_volume", false)
mythicEnv.SetDefault("rabbitmq_use_build_context", true)
// jwt configuration
mythicEnv.SetDefault("jwt_secret", utils.GenerateRandomPassword(30))
// hasura configuration
@@ -160,7 +167,8 @@ func setMythicConfigDefaultValues() {
mythicEnv.SetDefault("hasura_secret", utils.GenerateRandomPassword(30))
mythicEnv.SetDefault("hasura_cpus", "2")
mythicEnv.SetDefault("hasura_mem_limit", "2gb")
mythicEnv.SetDefault("hasura_bind_use_volume", false)
mythicEnv.SetDefault("hasura_use_volume", false)
mythicEnv.SetDefault("hasura_use_build_context", true)
// docker-compose configuration
mythicEnv.SetDefault("COMPOSE_PROJECT_NAME", "mythic")
mythicEnv.SetDefault("REBUILD_ON_START", true)
@@ -178,7 +186,8 @@ func setMythicConfigDefaultValues() {
mythicEnv.SetDefault("jupyter_cpus", "2")
mythicEnv.SetDefault("jupyter_mem_limit", "")
mythicEnv.SetDefault("jupyter_bind_localhost_only", true)
mythicEnv.SetDefault("jupyter_bind_use_volume", false)
mythicEnv.SetDefault("jupyter_use_volume", false)
mythicEnv.SetDefault("jupyter_use_build_context", true)
// debugging help
mythicEnv.SetDefault("postgres_debug", false)
mythicEnv.SetDefault("mythic_react_debug", false)
@@ -251,6 +260,7 @@ func parseMythicEnvironmentVariables() {
mythicEnv.Set(key, val[1])
}
}
mythicEnv.Set("mythic_docker_latest", "v0.0.2.34")
writeMythicEnvironmentVariables()
}
func writeMythicEnvironmentVariables() {
+73 -33
View File
@@ -22,10 +22,15 @@ func AddMythicService(service string) {
volumes, _ := manager.GetManager().GetVolumes()
switch service {
case "mythic_postgres":
pStruct["build"] = map[string]interface{}{
"context": "./postgres-docker",
"args": config.GetBuildArguments(),
if mythicEnv.GetBool("postgres_use_build_context") {
pStruct["build"] = map[string]interface{}{
"context": "./postgres-docker",
"args": config.GetBuildArguments(),
}
} else {
pStruct["image"] = fmt.Sprintf("ghcr.io/its-a-feature/%s:%s", service, mythicEnv.GetString("mythic_docker_latest"))
}
pStruct["cpus"] = mythicEnv.GetInt("POSTGRES_CPUS")
if mythicEnv.GetString("postgres_mem_limit") != "" {
pStruct["mem_limit"] = mythicEnv.GetString("postgres_mem_limit")
@@ -49,7 +54,7 @@ func AddMythicService(service string) {
} else {
pStruct["environment"] = environment
}
if !mythicEnv.GetBool("postgres_bind_use_volume") {
if !mythicEnv.GetBool("postgres_use_volume") {
pStruct["volumes"] = []string{
"./postgres-docker/database:/var/lib/postgresql/data",
"./postgres-docker/postgres.conf:/etc/postgresql.conf",
@@ -66,11 +71,15 @@ func AddMythicService(service string) {
}
}
case "mythic_documentation":
pStruct["build"] = "./documentation-docker"
pStruct["build"] = map[string]interface{}{
"context": "./documentation-docker",
"args": config.GetBuildArguments(),
if mythicEnv.GetBool("documentation_use_build_context") {
pStruct["build"] = map[string]interface{}{
"context": "./documentation-docker",
"args": config.GetBuildArguments(),
}
} else {
pStruct["image"] = fmt.Sprintf("ghcr.io/its-a-feature/%s:%s", service, mythicEnv.GetString("mythic_docker_latest"))
}
if mythicEnv.GetBool("documentation_bind_localhost_only") {
pStruct["ports"] = []string{
"127.0.0.1:${DOCUMENTATION_PORT}:${DOCUMENTATION_PORT}",
@@ -83,7 +92,7 @@ func AddMythicService(service string) {
pStruct["environment"] = []string{
"DOCUMENTATION_PORT=${DOCUMENTATION_PORT}",
}
if !mythicEnv.GetBool("documentation_bind_use_volume") {
if !mythicEnv.GetBool("documentation_use_volume") {
pStruct["volumes"] = []string{
"./documentation-docker/:/src",
}
@@ -98,10 +107,15 @@ func AddMythicService(service string) {
}
}
case "mythic_graphql":
pStruct["build"] = map[string]interface{}{
"context": "./hasura-docker",
"args": config.GetBuildArguments(),
if mythicEnv.GetBool("hasura_use_build_context") {
pStruct["build"] = map[string]interface{}{
"context": "./hasura-docker",
"args": config.GetBuildArguments(),
}
} else {
pStruct["image"] = fmt.Sprintf("ghcr.io/its-a-feature/%s:%s", service, mythicEnv.GetString("mythic_docker_latest"))
}
pStruct["cpus"] = mythicEnv.GetInt("HASURA_CPUS")
if mythicEnv.GetString("hasura_mem_limit") != "" {
pStruct["mem_limit"] = mythicEnv.GetString("hasura_mem_limit")
@@ -135,7 +149,7 @@ func AddMythicService(service string) {
"${HASURA_PORT}:${HASURA_PORT}",
}
}
if !mythicEnv.GetBool("hasura_bind_use_volume") {
if !mythicEnv.GetBool("hasura_use_volume") {
pStruct["volumes"] = []string{
"./hasura-docker/metadata:/metadata",
}
@@ -150,10 +164,15 @@ func AddMythicService(service string) {
}
}
case "mythic_nginx":
pStruct["build"] = map[string]interface{}{
"context": "./nginx-docker",
"args": config.GetBuildArguments(),
if mythicEnv.GetBool("nginx_use_build_context") {
pStruct["build"] = map[string]interface{}{
"context": "./nginx-docker",
"args": config.GetBuildArguments(),
}
} else {
pStruct["image"] = fmt.Sprintf("ghcr.io/its-a-feature/%s:%s", service, mythicEnv.GetString("mythic_docker_latest"))
}
nginxUseSSL := "ssl"
if !mythicEnv.GetBool("NGINX_USE_SSL") {
nginxUseSSL = ""
@@ -202,7 +221,7 @@ func AddMythicService(service string) {
"${NGINX_PORT}:${NGINX_PORT}",
}
}
if !mythicEnv.GetBool("nginx_bind_use_volume") {
if !mythicEnv.GetBool("nginx_use_volume") {
pStruct["volumes"] = []string{
"./nginx-docker/ssl:/etc/ssl/private",
"./nginx-docker/config:/etc/nginx",
@@ -222,10 +241,15 @@ func AddMythicService(service string) {
}
}
case "mythic_rabbitmq":
pStruct["build"] = map[string]interface{}{
"context": "./rabbitmq-docker",
"args": config.GetBuildArguments(),
if mythicEnv.GetBool("rabbitmq_use_build_context") {
pStruct["build"] = map[string]interface{}{
"context": "./rabbitmq-docker",
"args": config.GetBuildArguments(),
}
} else {
pStruct["image"] = fmt.Sprintf("ghcr.io/its-a-feature/%s:%s", service, mythicEnv.GetString("mythic_docker_latest"))
}
pStruct["cpus"] = mythicEnv.GetInt("RABBITMQ_CPUS")
if mythicEnv.GetString("rabbitmq_mem_limit") != "" {
pStruct["mem_limit"] = mythicEnv.GetString("rabbitmq_mem_limit")
@@ -260,7 +284,7 @@ func AddMythicService(service string) {
}
}
pStruct["environment"] = finalRabbitEnv
if !mythicEnv.GetBool("rabbitmq_bind_use_volume") {
if !mythicEnv.GetBool("rabbitmq_use_volume") {
pStruct["volumes"] = []string{
"./rabbitmq-docker/storage:/var/lib/rabbitmq",
"./rabbitmq-docker/generate_config.sh:/generate_config.sh",
@@ -290,11 +314,16 @@ func AddMythicService(service string) {
"./mythic-react-docker/mythic/public:/app/build",
}
} else {
pStruct["build"] = map[string]interface{}{
"context": "./mythic-react-docker",
"args": config.GetBuildArguments(),
if mythicEnv.GetBool("mythic_react_use_build_context") {
pStruct["build"] = map[string]interface{}{
"context": "./mythic-react-docker",
"args": config.GetBuildArguments(),
}
} else {
pStruct["image"] = fmt.Sprintf("ghcr.io/its-a-feature/%s:%s", service, mythicEnv.GetString("mythic_docker_latest"))
}
if !mythicEnv.GetBool("mythic_react_bind_use_volume") {
if !mythicEnv.GetBool("mythic_react_use_volume") {
pStruct["volumes"] = []string{
"./mythic-react-docker/config:/etc/nginx",
"./mythic-react-docker/mythic/public:/mythic/new",
@@ -327,10 +356,15 @@ func AddMythicService(service string) {
"MYTHIC_REACT_PORT=${MYTHIC_REACT_PORT}",
}
case "mythic_jupyter":
pStruct["build"] = map[string]interface{}{
"context": "./jupyter-docker",
"args": config.GetBuildArguments(),
if mythicEnv.GetBool("jupyter_use_build_context") {
pStruct["build"] = map[string]interface{}{
"context": "./jupyter-docker",
"args": config.GetBuildArguments(),
}
} else {
pStruct["image"] = fmt.Sprintf("ghcr.io/its-a-feature/%s:%s", service, mythicEnv.GetString("mythic_docker_latest"))
}
pStruct["cpus"] = mythicEnv.GetInt("JUPYTER_CPUS")
if mythicEnv.GetString("jupyter_mem_limit") != "" {
pStruct["mem_limit"] = mythicEnv.GetString("jupyter_mem_limit")
@@ -354,7 +388,7 @@ func AddMythicService(service string) {
}
*/
if !mythicEnv.GetBool("jupyter_bind_use_volume") {
if !mythicEnv.GetBool("jupyter_use_volume") {
pStruct["volumes"] = []string{
"./jupyter-docker/jupyter:/projects",
}
@@ -369,10 +403,15 @@ func AddMythicService(service string) {
}
}
case "mythic_server":
pStruct["build"] = map[string]interface{}{
"context": "./mythic-docker",
"args": config.GetBuildArguments(),
if mythicEnv.GetBool("mythic_server_use_build_context") {
pStruct["build"] = map[string]interface{}{
"context": "./mythic-docker",
"args": config.GetBuildArguments(),
}
} else {
pStruct["image"] = fmt.Sprintf("ghcr.io/its-a-feature/%s:%s", service, mythicEnv.GetString("mythic_docker_latest"))
}
pStruct["cpus"] = mythicEnv.GetInt("MYTHIC_SERVER_CPUS")
if mythicEnv.GetString("mythic_server_mem_limit") != "" {
pStruct["mem_limit"] = mythicEnv.GetString("mythic_server_mem_limit")
@@ -425,7 +464,7 @@ func AddMythicService(service string) {
} else {
pStruct["environment"] = environment
}
if !mythicEnv.GetBool("mythic_server_bind_use_volume") {
if !mythicEnv.GetBool("mythic_server_use_volume") {
pStruct["volumes"] = []string{
"./mythic-docker/src:/usr/src/app",
}
@@ -444,6 +483,7 @@ func AddMythicService(service string) {
fmt.Printf("[-] Failed to get abs path for mythic_sync\n")
return
} else {
pStruct["build"] = map[string]interface{}{
"context": absPath,
"args": config.GetBuildArguments(),
@@ -275,6 +275,7 @@ func (d *DockerComposeManager) GetServiceConfiguration(service string) (map[stri
delete(pStruct, "build")
delete(pStruct, "networks")
delete(pStruct, "command")
delete(pStruct, "image")
delete(pStruct, "healthcheck")
} else {
pStruct = map[string]interface{}{