diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 622c475..759235d 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -30,230 +30,230 @@ jobs: # ├── metasploit-omnibus # └── metasploit-framework (Only if ARM or Windows builds) # - # docker_arm: - # runs-on: ${{ matrix.os }} - # timeout-minutes: 600 - - # strategy: - # fail-fast: false - # matrix: - # os: - # - ubuntu-latest - # # From: 'ls ./docker/' - # docker: - # # Skipped as not working - # # - { dockerfile: 'debian-aarch64', previousImage: '' } - # - { name: 'debian-armv7', previousDockerhubImage: 'rapid7/msf-debian-armv7-omnibus:2020_03' } - - # name: ${{ matrix.os }} - ${{ matrix.docker.name }} - # steps: - # - name: Checkout omnibus - # uses: actions/checkout@v4 - # with: - # path: metasploit-omnibus - - # - uses: dorny/paths-filter@4067d885736b84de7c414f582ac45897079b0a78 - # id: changes - # with: - # filters: | - # docker: - # - 'docker/**' - # working-directory: metasploit-omnibus - - # # Set the env vars for either a new build, or a previously successful build - # - name: Set docker build metadata - # run: | - # export BUILD_DATE=$(date "+%Y_%m") - # echo "BUILD_DATE=$BUILD_DATE" >> "$GITHUB_ENV" - # if test "${HAS_MODIFIED_DOCKERFILES}" = 'true'; then - # echo 'New build required' - # echo "DOCKER_IMAGE=rapid7/${DOCKER_NAME}-omnibus:${BUILD_DATE}" >> "$GITHUB_ENV" - # else - # echo 'Reusing old image' - # echo "DOCKER_IMAGE=${PREVIOUS_DOCKERHUB_IMAGE}" >> "$GITHUB_ENV" - # fi - # env: - # HAS_MODIFIED_DOCKERFILES: ${{ steps.changes.outputs.docker }} - # DOCKER_NAME: ${{ matrix.docker.name }} - # PREVIOUS_DOCKERHUB_IMAGE: ${{ matrix.docker.previousDockerhubImage }} - - # - name: Build Docker image - # if: steps.changes.outputs.docker == 'true' - # run: | - # /bin/bash -x -c "cd metasploit-omnibus && docker build --tag ${DOCKER_IMAGE} -f ./docker/${DOCKER_NAME}/Dockerfile ./docker/${DOCKER_NAME}" - # env: - # DOCKER_NAME: ${{ matrix.docker.name }} - - # # Checkout again - but with the submodules enabled to start a real build - # - name: Checkout omnibus and submodules - # uses: actions/checkout@v4 - # with: - # submodules: true - # path: metasploit-omnibus - - # # Checkout framework - # - name: Checkout metasploit-framework code - # uses: actions/checkout@v4 - # with: - # repository: rapid7/metasploit-framework - # path: metasploit-framework - - # - name: Run omnibus - # run: | - # echo "Building new image from ${DOCKER_IMAGE}" - # mkdir -p metasploit-omnibus/certs - # curl -L -o metasploit-omnibus/certs/ca-certificates.crt https://curl.haxx.se/ca/cacert.pem - # cat > Dockerfile_temp < Dockerfile_temp.dockerignore <> "$GITHUB_ENV" - # if test "${HAS_MODIFIED_DOCKERFILES}" = 'true'; then - # echo 'New build required' - # echo "DOCKER_IMAGE=rapid7/${DOCKER_NAME}-omnibus:${BUILD_DATE}" >> "$GITHUB_ENV" - # else - # echo 'Reusing old image' - # echo "DOCKER_IMAGE=${PREVIOUS_DOCKERHUB_IMAGE}" >> "$GITHUB_ENV" - # fi - # env: - # HAS_MODIFIED_DOCKERFILES: ${{ steps.changes.outputs.docker }} - # DOCKER_NAME: ${{ matrix.docker.name }} - # PREVIOUS_DOCKERHUB_IMAGE: ${{ matrix.docker.previousDockerhubImage }} - - # - name: Build Docker image - # if: steps.changes.outputs.docker == 'true' - # run: | - # /bin/bash -x -c "cd metasploit-omnibus && docker build --tag ${DOCKER_IMAGE} -f ./docker/${IMAGE_NAME}/Dockerfile ./docker/${IMAGE_NAME}" - # env: - # IMAGE_NAME: ${{ matrix.docker.name }} - - # # Checkout again - but with the submodules enabled to start a real build - # - name: Checkout omnibus and submodules - # uses: actions/checkout@v4 - # with: - # submodules: true - # path: metasploit-omnibus - - # - name: Run omnibus - # run: | - # mkdir -p metasploit-omnibus/certs - # curl -L -o metasploit-omnibus/certs/ca-certificates.crt https://curl.haxx.se/ca/cacert.pem - - # # If required, change reported architecture in new program environment and set personality flags - # if [ ! -z "${LINUX32}" ] ; then - # echo 'setting linux32' - # /bin/bash -x -c "docker run --rm --volume $(pwd):$(pwd) --workdir $(pwd) --user jenkins ${DOCKER_IMAGE} linux32 /bin/bash -l -c 'cd metasploit-omnibus && ARCH=x86_64 make'" - # else - # /bin/bash -x -c "docker run --rm --volume $(pwd):$(pwd) --workdir $(pwd) --user jenkins ${DOCKER_IMAGE} /bin/bash -l -c 'cd metasploit-omnibus && make'" - # fi - # env: - # LINUX32: ${{ matrix.docker.linux32 }} - - # osx: - # runs-on: ${{ matrix.os }} - # timeout-minutes: 180 - - # strategy: - # fail-fast: false - # matrix: - # os: - # - macos-11 - # ruby: - # - 3.0.6 - - # name: ${{ matrix.os }} - # steps: - # - name: Checkout omnibus - # uses: actions/checkout@v4 - # with: - # submodules: true - # path: metasploit-omnibus - - # - name: Setup Ruby - # env: - # BUNDLE_FORCE_RUBY_PLATFORM: true - # uses: ruby/setup-ruby@v1 - # with: - # ruby-version: ${{ matrix.ruby }} - # bundler-cache: true - # cache-version: 4 - # working-directory: metasploit-omnibus - - # - name: Run omnibus - # run: | - # sudo mkdir -p /var/cache/omnibus - # sudo mkdir -p /opt/metasploit-framework - # sudo chown `whoami` /var/cache/omnibus - # sudo chown `whoami` /opt/metasploit-framework - - # cd metasploit-omnibus - # make + docker_arm: + runs-on: ${{ matrix.os }} + timeout-minutes: 600 + + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + # From: 'ls ./docker/' + docker: + # Skipped as not working + # - { dockerfile: 'debian-aarch64', previousImage: '' } + - { name: 'debian-armv7', previousDockerhubImage: 'rapid7/msf-debian-armv7-omnibus:2020_03' } + + name: ${{ matrix.os }} - ${{ matrix.docker.name }} + steps: + - name: Checkout omnibus + uses: actions/checkout@v4 + with: + path: metasploit-omnibus + + - uses: dorny/paths-filter@4067d885736b84de7c414f582ac45897079b0a78 + id: changes + with: + filters: | + docker: + - 'docker/**' + working-directory: metasploit-omnibus + + # Set the env vars for either a new build, or a previously successful build + - name: Set docker build metadata + run: | + export BUILD_DATE=$(date "+%Y_%m") + echo "BUILD_DATE=$BUILD_DATE" >> "$GITHUB_ENV" + if test "${HAS_MODIFIED_DOCKERFILES}" = 'true'; then + echo 'New build required' + echo "DOCKER_IMAGE=rapid7/${DOCKER_NAME}-omnibus:${BUILD_DATE}" >> "$GITHUB_ENV" + else + echo 'Reusing old image' + echo "DOCKER_IMAGE=${PREVIOUS_DOCKERHUB_IMAGE}" >> "$GITHUB_ENV" + fi + env: + HAS_MODIFIED_DOCKERFILES: ${{ steps.changes.outputs.docker }} + DOCKER_NAME: ${{ matrix.docker.name }} + PREVIOUS_DOCKERHUB_IMAGE: ${{ matrix.docker.previousDockerhubImage }} + + - name: Build Docker image + if: steps.changes.outputs.docker == 'true' + run: | + /bin/bash -x -c "cd metasploit-omnibus && docker build --tag ${DOCKER_IMAGE} -f ./docker/${DOCKER_NAME}/Dockerfile ./docker/${DOCKER_NAME}" + env: + DOCKER_NAME: ${{ matrix.docker.name }} + + # Checkout again - but with the submodules enabled to start a real build + - name: Checkout omnibus and submodules + uses: actions/checkout@v4 + with: + submodules: true + path: metasploit-omnibus + + # Checkout framework + - name: Checkout metasploit-framework code + uses: actions/checkout@v4 + with: + repository: rapid7/metasploit-framework + path: metasploit-framework + + - name: Run omnibus + run: | + echo "Building new image from ${DOCKER_IMAGE}" + mkdir -p metasploit-omnibus/certs + curl -L -o metasploit-omnibus/certs/ca-certificates.crt https://curl.haxx.se/ca/cacert.pem + cat > Dockerfile_temp < Dockerfile_temp.dockerignore <> "$GITHUB_ENV" + if test "${HAS_MODIFIED_DOCKERFILES}" = 'true'; then + echo 'New build required' + echo "DOCKER_IMAGE=rapid7/${DOCKER_NAME}-omnibus:${BUILD_DATE}" >> "$GITHUB_ENV" + else + echo 'Reusing old image' + echo "DOCKER_IMAGE=${PREVIOUS_DOCKERHUB_IMAGE}" >> "$GITHUB_ENV" + fi + env: + HAS_MODIFIED_DOCKERFILES: ${{ steps.changes.outputs.docker }} + DOCKER_NAME: ${{ matrix.docker.name }} + PREVIOUS_DOCKERHUB_IMAGE: ${{ matrix.docker.previousDockerhubImage }} + + - name: Build Docker image + if: steps.changes.outputs.docker == 'true' + run: | + /bin/bash -x -c "cd metasploit-omnibus && docker build --tag ${DOCKER_IMAGE} -f ./docker/${IMAGE_NAME}/Dockerfile ./docker/${IMAGE_NAME}" + env: + IMAGE_NAME: ${{ matrix.docker.name }} + + # Checkout again - but with the submodules enabled to start a real build + - name: Checkout omnibus and submodules + uses: actions/checkout@v4 + with: + submodules: true + path: metasploit-omnibus + + - name: Run omnibus + run: | + mkdir -p metasploit-omnibus/certs + curl -L -o metasploit-omnibus/certs/ca-certificates.crt https://curl.haxx.se/ca/cacert.pem + + # If required, change reported architecture in new program environment and set personality flags + if [ ! -z "${LINUX32}" ] ; then + echo 'setting linux32' + /bin/bash -x -c "docker run --rm --volume $(pwd):$(pwd) --workdir $(pwd) --user jenkins ${DOCKER_IMAGE} linux32 /bin/bash -l -c 'cd metasploit-omnibus && ARCH=x86_64 make'" + else + /bin/bash -x -c "docker run --rm --volume $(pwd):$(pwd) --workdir $(pwd) --user jenkins ${DOCKER_IMAGE} /bin/bash -l -c 'cd metasploit-omnibus && make'" + fi + env: + LINUX32: ${{ matrix.docker.linux32 }} + + osx: + runs-on: ${{ matrix.os }} + timeout-minutes: 180 + + strategy: + fail-fast: false + matrix: + os: + - macos-11 + ruby: + - 3.0.6 + + name: ${{ matrix.os }} + steps: + - name: Checkout omnibus + uses: actions/checkout@v4 + with: + submodules: true + path: metasploit-omnibus + + - name: Setup Ruby + env: + BUNDLE_FORCE_RUBY_PLATFORM: true + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + cache-version: 4 + working-directory: metasploit-omnibus + + - name: Run omnibus + run: | + sudo mkdir -p /var/cache/omnibus + sudo mkdir -p /opt/metasploit-framework + sudo chown `whoami` /var/cache/omnibus + sudo chown `whoami` /opt/metasploit-framework + + cd metasploit-omnibus + make windows: runs-on: ${{ matrix.os }} @@ -336,10 +336,8 @@ jobs: MSYSTEM: MINGW64 run: | cd metasploit-omnibus - - rem Don't run via `make`, as the process will be spawned under msys2 - and the ridk.cmd - rem ruby installer will forcibly kill the msys2 process before attempting to install ruby make dependencies - rem build the metasploit-framework package + rem Don't run the main build itslef under `make`, as the process will be spawned under msys2 + rem and the ridk.cmd Ruby installer will forcibly kill the msys2 process before attempting to install ruby ruby bin/omnibus build metasploit-framework diff --git a/config/software/metasploit-framework.rb b/config/software/metasploit-framework.rb index 9cb7dea..438c2f5 100644 --- a/config/software/metasploit-framework.rb +++ b/config/software/metasploit-framework.rb @@ -81,8 +81,8 @@ bundle "config set force_ruby_platform true", env: env bundle_env = with_standard_compiler_flags(with_embedded_path) - # bundle_env['MAKE'] = 'make -j4' - bundle "install", env: bundle_env + bundle_env['MAKE'] = 'make -j4' + bundle "install --jobs=4", env: bundle_env if windows? delete "#{install_dir}/embedded/msys64"