From 8b7f3949440daf20ea1cb281e3c60f32e42a7529 Mon Sep 17 00:00:00 2001 From: Chris Lenk Date: Thu, 5 Oct 2023 13:34:09 -0400 Subject: [PATCH] Fix golang in Dockerfile, update min Go version Ubuntu 23.04 is earliest one with golang 1.19+ in its repositories. Ubuntu 23.04 requires running python in virtual env. --- Dockerfile | 15 +++++++++++++-- README.md | 2 +- conf/default.yml | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index f52460d27..446957dda 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:latest +FROM ubuntu:23.04 SHELL ["/bin/bash", "-c"] ARG TZ="UTC" @@ -12,12 +12,18 @@ ADD . . RUN if [ -z "$(ls plugins/stockpile)" ]; then echo "stockpile plugin not downloaded - please ensure you recursively cloned the caldera git repository and try again."; exit 1; fi RUN apt-get update && \ - apt-get -y install python3 python3-pip git curl golang-go + apt-get -y install python3 python3-pip python3-venv git curl golang-go + #WIN_BUILD is used to enable windows build in sandcat plugin ARG WIN_BUILD=false RUN if [ "$WIN_BUILD" = "true" ] ; then apt-get -y install mingw-w64; fi +# Set up python virtualenv +ENV VIRTUAL_ENV=/opt/venv/caldera +RUN python3 -m venv $VIRTUAL_ENV +ENV PATH="$VIRTUAL_ENV/bin:$PATH" + # Install pip requirements RUN pip3 install --no-cache-dir -r requirements.txt @@ -26,6 +32,11 @@ RUN python3 -c "import app; import app.utility.config_generator; app.utility.con sed -i '/\- atomic/d' conf/local.yml; # Compile default sandcat agent binaries, which will download basic golang dependencies. + +# Install Go dependencies +WORKDIR /usr/src/app/plugins/sandcat/gocat +RUN go mod tidy && go mod download + WORKDIR /usr/src/app/plugins/sandcat # Fix line ending error that can be caused by cloning the project in a Windows environment diff --git a/README.md b/README.md index 3d35e1963..ba7512cfe 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ Next, install the PIP requirements: ```Bash pip3 install -r requirements.txt ``` -**Super-power your Caldera server installation! [Install GoLang (1.17+)](https://go.dev/doc/install)** +**Super-power your Caldera server installation! [Install GoLang (1.19+)](https://go.dev/doc/install)** Finally, start the server. ```Bash diff --git a/conf/default.yml b/conf/default.yml index 4a4ba1ce9..5fd4da373 100644 --- a/conf/default.yml +++ b/conf/default.yml @@ -45,7 +45,7 @@ requirements: go: command: go version type: installed_program - version: 1.11 + version: 1.19 python: attr: version module: sys