Skip to content

Commit

Permalink
Merge pull request #411 from art-dsit/art/rootless_2
Browse files Browse the repository at this point in the history
Prevent root-owned files ending up on the filesystem during CLI build
  • Loading branch information
its-a-feature authored Oct 8, 2024
2 parents e58eead + 033ce4f commit 63a6d5e
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions Mythic_CLI/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,33 @@ default: build_linux ;
export

copy_binary_linux:
docker run -v ${LOCAL_PATH}/copy_file/:/copy_file/ --rm ${BUILDER_IMAGE} sh -c "cp /mythic-cli_linux /copy_file/mythic-cli"
mv ./copy_file/${BINARY_NAME} . && rm -rf ./copy_file && chmod +x ${BINARY_NAME}
docker create --name mythic-cli-tmp ${BUILDER_IMAGE} /bin/sh
docker cp mythic-cli-tmp:/mythic-cli_linux ./${BINARY_NAME}
docker rm mythic-cli-tmp
chmod +x ${BINARY_NAME}

copy_binary_macos:
docker run -v ${LOCAL_PATH}/copy_file/:/copy_file/ --rm ${BUILDER_IMAGE} sh -c "cp /mythic-cli_macos /copy_file/mythic-cli"
mv ./copy_file/${BINARY_NAME} . && rm -rf ./copy_file && chmod +x ${BINARY_NAME}
docker create --name mythic-cli-tmp ${BUILDER_IMAGE} /bin/sh
docker cp mythic-cli-tmp:/mythic-cli_macos ./${BINARY_NAME}
docker rm mythic-cli-tmp
chmod +x ${BINARY_NAME}

build_local:
cd src && go build -o ../../mythic-cli .

build_linux_docker:
docker build -t mythic-cli-builder -f Dockerfile .
docker run -v ${LOCAL_PATH}/copy_file/:/copy_file/ --rm mythic-cli-builder sh -c "cp /mythic-cli_linux /copy_file/mythic-cli"
mv ./copy_file/${BINARY_NAME} . && rm -rf ./copy_file && chmod +x ${BINARY_NAME}
docker create --name mythic-cli-tmp mythic-cli-builder /bin/sh
docker cp mythic-cli-tmp:/mythic-cli_linux ./${BINARY_NAME}
docker rm mythic-cli-tmp
chmod +x ${BINARY_NAME}

build_macos_docker:
docker build -t mythic-cli-builder -f Dockerfile .
docker run -v ${LOCAL_PATH}/copy_file/:/copy_file/ --rm mythic-cli-builder sh -c "cp /mythic-cli_macos /copy_file/mythic-cli"
mv ./copy_file/${BINARY_NAME} . && rm -rf ./copy_file && chmod +x ${BINARY_NAME}
docker create --name mythic-cli-tmp mythic-cli-builder /bin/sh
docker cp mythic-cli-tmp:/mythic-cli_macos ./${BINARY_NAME}
docker rm mythic-cli-tmp
chmod +x ${BINARY_NAME}

build_linux: copy_binary_linux
build_macos: copy_binary_macos

0 comments on commit 63a6d5e

Please sign in to comment.