diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5d4fc18d8..eab23793c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,3 +43,7 @@ repos: files: "monkey/" exclude: "monkey/monkey_island/cc/ui" stages: [push] + - repo: https://github.com/swimmio/pre-commit + rev: v0.2 + hooks: + - id: swimm-verify diff --git a/deployment_scripts/README.md b/deployment_scripts/README.md index 7f4e414bd..aed00ae58 100644 --- a/deployment_scripts/README.md +++ b/deployment_scripts/README.md @@ -85,3 +85,9 @@ been run or all issues have not been resolved. To install and configure pre-commit manually, run `pip install --user pre-commit`. Next, go to the top level directory of this repository and run `pre-commit install -t pre-commit -t pre-push` Now, pre-commit will automatically run whenever you `git commit`. + +## Swimm + +Infection Monkey has development tutorials that use [`swimm.io`](https://swimm.io/) to help teach new developers how to perform common code tasks in the Infection Monkey codebase and accelerate the ramp-up process. The tutorials include adding new configuration values, new system info collectors and more. + +In order to pass the pre-commit checks, you'll have to [install Swimm successfully](https://www.guardicore.com/infectionmonkey/docs/development/swimm/). Both the Linux and Windows deployment scrips will install [Swimm](https://swimm.io/), but you'll have to sign up [here](https://swimm.io/sign-beta) to complete the process. diff --git a/deployment_scripts/config b/deployment_scripts/config index cad04a01c..101dadd0f 100644 --- a/deployment_scripts/config +++ b/deployment_scripts/config @@ -43,3 +43,6 @@ export TRACEROUTE_32_BINARY_URL="https://github.com/guardicore/monkey/releases/d export SAMBACRY_64_BINARY_URL="https://github.com/guardicore/monkey/releases/download/$MONKEY_LATEST_RELEASE/sc_monkey_runner64.so" export SAMBACRY_32_BINARY_URL="https://github.com/guardicore/monkey/releases/download/$MONKEY_LATEST_RELEASE/sc_monkey_runner32.so" + +# Swimm +export SWIMM_URL=https://github.com/swimmio/SwimmReleases/releases/download/v0.4.4-0/Swimm_0.4.4-0_Setup.deb diff --git a/deployment_scripts/config.ps1 b/deployment_scripts/config.ps1 index d140eb711..54ad20be9 100644 --- a/deployment_scripts/config.ps1 +++ b/deployment_scripts/config.ps1 @@ -46,3 +46,4 @@ $OPEN_SSL_URL = "https://indy.fulgan.com/SSL/openssl-1.0.2u-x64_86-win64.zip" $CPP_URL = "https://go.microsoft.com/fwlink/?LinkId=746572" $NPM_URL = "https://nodejs.org/dist/v12.14.1/node-v12.14.1-x64.msi" $UPX_URL = "https://github.com/upx/upx/releases/download/v3.96/upx-3.96-win64.zip" +$SWIMM_URL="https://github.com/swimmio/SwimmReleases/releases/download/v0.4.4-0/Swimm-Setup-0.4.4-0.exe" diff --git a/deployment_scripts/deploy_linux.sh b/deployment_scripts/deploy_linux.sh index c003dd278..0aa018534 100755 --- a/deployment_scripts/deploy_linux.sh +++ b/deployment_scripts/deploy_linux.sh @@ -239,6 +239,18 @@ else curl -o ${MONKEY_BIN_DIR}/traceroute32 ${TRACEROUTE_32_BINARY_URL} fi +# Download Swimm +log_message "Downloading swimm" +if exists wget; then + wget ${SWIMM_URL} -O $HOME/swimm +else + curl ${SWIMM_URL} -o $HOME/swimm +fi + +log_message "Installing swimm" +sudo dpkg -i $HOME/swimm || (sudo apt-get update && sudo apt-get -f install) +rm $HOME/swimm + sudo chmod +x "${INFECTION_MONKEY_DIR}/build_linux.sh" configure_precommit ${python_cmd} ${monkey_home} diff --git a/deployment_scripts/deploy_windows.ps1 b/deployment_scripts/deploy_windows.ps1 index 20f600f51..46f2fb0f4 100644 --- a/deployment_scripts/deploy_windows.ps1 +++ b/deployment_scripts/deploy_windows.ps1 @@ -23,6 +23,18 @@ function Configure-precommit([String] $git_repo_dir) exit } Pop-Location + + # Set env variable to skip Swimm verification during pre-commit, Windows not supported yet + $skipValue = [System.Environment]::GetEnvironmentVariable('SKIP', [System.EnvironmentVariableTarget]::User) + if ($skipValue) { # if `SKIP` is not empty + if (-Not ($skipValue -split ',' -contains 'swimm-verify')) { # if `SKIP` doesn't already have "swimm-verify" + [System.Environment]::SetEnvironmentVariable('SKIP', $env:SKIP + ',swimm-verify', [System.EnvironmentVariableTarget]::User) + } + } + else { + [System.Environment]::SetEnvironmentVariable('SKIP', 'swimm-verify', [System.EnvironmentVariableTarget]::User) + } + Write-Output "Pre-commit successfully installed" } @@ -267,6 +279,13 @@ function Deploy-Windows([String] $monkey_home = (Get-Item -Path ".\").FullName, $webClient.DownloadFile($SAMBA_64_BINARY_URL, $samba64_path) } + # Get Swimm + "Downloading Swimm..." + $swimm_filename = Join-Path -Path $HOME -ChildPath "swimm.exe" + $webClient.DownloadFile($SWIMM_URL, $swimm_filename) + Start-Process $swimm_filename + + "Script finished" } diff --git a/docs/content/development/setup-development-environment.md b/docs/content/development/setup-development-environment.md index b7d122778..ad9a4675b 100644 --- a/docs/content/development/setup-development-environment.md +++ b/docs/content/development/setup-development-environment.md @@ -31,3 +31,9 @@ Pre-commit is a multi-language package manager for pre-commit hooks. It will run Our CI system runs the same checks when pull requests are submitted. This system may report that the build has failed if the pre-commit hooks have not been run or all issues have not been resolved. To install and configure pre-commit, run `pip install --user pre-commit`. Next, go to the top level directory of this repository and run `pre-commit install -t pre-commit -t pre-push`. Pre-commit will now run automatically whenever you `git commit`. + +## Swimm + +Infection Monkey has development tutorials that use [`swimm.io`](https://swimm.io/) to help teach new developers how to perform common code tasks in the Infection Monkey codebase and accelerate the ramp-up process. The tutorials include adding new configuration values, new system info collectors and more. + +In order to pass the pre-commit checks, you'll have to [install Swimm successfully](https://www.guardicore.com/infectionmonkey/docs/development/swimm/). Both the Linux and Windows deployment scrips will install [Swimm](https://swimm.io/), but you'll have to sign up [here](https://swimm.io/sign-beta) to complete the process.