Merge pull request #1544 from guardicore/1524-broken-updates

AppImage and Docker deployment renaming
This commit is contained in:
ilija-lazoroski 2021-10-22 09:19:41 +02:00 committed by GitHub
commit 3b9eaf34c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 47 additions and 34 deletions

View File

@ -59,6 +59,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/).
- Bug that periodically cleared the telemetry table's filter. #1392
- Crashes, stack traces, and other malfunctions when data from older versions of Infection Monkey is
present in the data directory. #1114
- Broken update links. #1524
### Security
- Generate a random password when creating a new user for CommunicateAsNewUser

View File

@ -104,11 +104,16 @@ remove_python_appdir_artifacts() {
}
build_package() {
local version=$1
local dist_dir=$2
local commit_id=$2
local dist_dir=$3
log_message "Building AppImage"
set_version "$version"
if [ -n "$1" ]; then
local version="v$1"
else
local version="$commit_id"
fi
pushd "$APPIMAGE_DIR"
ARCH="x86_64" linuxdeploy \
@ -119,21 +124,12 @@ build_package() {
--deploy-deps-only="$MONGO_PATH/bin/mongod"\
--output appimage
move_package_to_dist_dir $dist_dir
dst_name="InfectionMonkey-$version.AppImage"
move_package_to_dist_dir $dist_dir $dst_name
popd
}
set_version() {
# The linuxdeploy and appimage-builder tools will use the commit hash of the
# repo to name the AppImage, which is preferable to using "dev". If the
# version was specified in a command-line argument (i.e. not "dev"), then
# setting the VERSION environment variable will change this behavior.
if [ $1 != "dev" ]; then
export VERSION=$1
fi
}
move_package_to_dist_dir() {
mv Infection_Monkey*.AppImage "$1/"
mv Infection*Monkey*.AppImage "$1/$2"
}

View File

@ -8,5 +8,5 @@ APPIMAGE_DIR="$(realpath $(dirname $BASH_SOURCE[0]))"
rm -rf "$HOME/git/monkey"
rm -rf "$HOME/.monkey_island"
rm -rf "$APPIMAGE_DIR/squashfs-root"
rm "$APPIMAGE_DIR"/Infection_Monkey*x86_64.AppImage
rm "$APPIMAGE_DIR/../dist/Infection_Monkey*x86_64.AppImage"
rm "$APPIMAGE_DIR"/Infection_Monkey*.AppImage
rm "$APPIMAGE_DIR/../dist/InfectionMonkey*.AppImage"

View File

@ -1,6 +1,6 @@
[Desktop Entry]
Type=Application
Name=Infection Monkey
Name=InfectionMonkey
Exec=bash
Comment=An automated breach and attack simulation platform
Icon=monkey-icon

View File

@ -44,7 +44,6 @@ echo_help() {
echo " (Default: $DEFAULT_REPO_MONKEY_HOME)"
echo ""
echo "--version A version number for the package."
echo " (Default: dev)"
echo ""
echo "--deployment A deployment type for the package."
echo " (Default: develop)"
@ -110,7 +109,7 @@ agent_binary_dir=""
as_root=false
branch="develop"
monkey_repo="$DEFAULT_REPO_MONKEY_HOME"
monkey_version="dev"
monkey_version=""
package=""
deployment_type=""
@ -199,7 +198,8 @@ install_package_specific_build_prereqs "$WORKSPACE"
setup_build_dir "$agent_binary_dir" "$monkey_repo" "$deployment_type"
build_package "$monkey_version" "$DIST_DIR"
commit_id=$(get_commit_id "$monkey_repo")
build_package "$monkey_version" "$commit_id" "$DIST_DIR"
log_message "Finished building package: $package"
exit 0

View File

@ -93,3 +93,8 @@ remove_node_modules() {
rm -rf "$1/node_modules"
rm -rf "$1/.npm"
}
get_commit_id() {
local monkey_repo=$1
echo $(git -C "$monkey_repo" rev-parse --short HEAD)
}

View File

@ -1,5 +1,4 @@
DOCKER_DIR="$(realpath $(dirname $BASH_SOURCE[0]))"
OUTPUT_NAME_TGZ="$DOCKER_DIR/infection_monkey_docker_$(date +%Y%m%d_%H%M%S).tgz"
source "$DOCKER_DIR/../common.sh"
@ -37,16 +36,25 @@ copy_server_config_to_build_dir() {
build_package() {
local version=$1
local dist_dir=$2
local commit_id=$2
local dist_dir=$3
pushd ./docker
if [ -n "$1" ]; then
version="v$version"
else
version="$commit_id"
fi
docker_image_name="guardicore/monkey-island:$version"
tar_name="$DOCKER_DIR/dk.monkeyisland.$version.tar"
tar_name="$DOCKER_DIR/InfectionMonkey-docker-$version.tar"
build_docker_image_tar "$docker_image_name" "$tar_name"
build_docker_image_tgz "$tar_name" "$version"
move_package_to_dist_dir $dist_dir
tgz_name="$DOCKER_DIR/InfectionMonkey-docker-$version.tgz"
build_docker_image_tgz "$tar_name" "$tgz_name"
move_package_to_dist_dir $tgz_name $dist_dir
popd
}
@ -60,9 +68,9 @@ build_docker_image_tgz() {
mkdir tgz
mv "$1" ./tgz
cp ./DOCKER_README.md ./tgz/README.md
tar -C ./tgz -cvf "$OUTPUT_NAME_TGZ" --gzip .
tar -C ./tgz -cvf "$2" --gzip .
}
move_package_to_dist_dir() {
mv $OUTPUT_NAME_TGZ "$1/"
mv "$1" "$2/"
}

View File

@ -23,13 +23,13 @@ The Infection Monkey Docker container works on Linux only. It is not compatible
1. Extract the Monkey Island Docker tarball:
```bash
tar -xvzf monkey-island-docker.tar.gz
tar -xvzf InfectionMonkey-docker-v1.12.0.tgz
```
1. Load the Monkey Island Docker image:
```bash
sudo docker load -i dk.monkeyisland.VERSION.tar
sudo docker load -i InfectionMonkey-docker-v1.12.0.tar
```
### 2. Start MongoDB

View File

@ -23,15 +23,18 @@ installed, but the ones that we've tested are:
- Ubuntu Focal 20.04
- Ubuntu Hirsute 21.04
On Windows, AppImage can be run in WSL.
## Deployment
1. Make the AppImage package executable:
```bash
chmod u+x Infection_Monkey_v1.11.0.AppImage
chmod u+x InfectionMonkey-v1.12.0.AppImage
```
1. Start Monkey Island by running the Infection Monkey AppImage package:
```bash
./Infection_Monkey_v1.11.0.AppImage
./InfectionMonkey-v1.12.0.AppImage
```
1. Access the Monkey Island web UI by pointing your browser at
`https://localhost:5000`.
@ -56,7 +59,7 @@ private certificate authority.
`server_config.json` file.
```bash
./Infection_Monkey_v1.11.0.AppImage --setup-only
./InfectionMonkey-v1.12.0.AppImage --setup-only
```
1. (Optional but recommended) Move your `.crt` and `.key` files to
@ -92,7 +95,7 @@ private certificate authority.
1. Start Monkey Island by running the Infection Monkey AppImage package:
```bash
./Infection_Monkey_v1.11.0.AppImage
./InfectionMonkey-v1.12.0.AppImage
```
1. Access the Monkey Island web UI by pointing your browser at