Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent root-owned files ending up on the filesystem during CLI build #411

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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