diff --git a/.github/workflows/shared_meterpreter_acceptance.yml b/.github/workflows/shared_meterpreter_acceptance.yml index 3f1413d918466..d725b4f019e21 100644 --- a/.github/workflows/shared_meterpreter_acceptance.yml +++ b/.github/workflows/shared_meterpreter_acceptance.yml @@ -1,20 +1,21 @@ -name: Build and test payloads +name: Shared Meterpreter Acceptance on: workflow_call: inputs: + # Defaults set as '' will use the current branch as their commit metasploit-framework_commit: description: "metasploit-framework commit to build with" - default: "" + default: '' required: false type: string metasploit-payloads_commit: description: "metasploit-payloads commit to build with" - default: "master" + default: '' required: false type: string mettle_commit: description: "mettle commit to build with" - default: "master" + default: '' required: false type: string @@ -25,7 +26,7 @@ jobs: java_meterpreter_compilation: name: Compile Java Meterpreter runs-on: ubuntu-latest - if: ${{ contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') && inputs.metasploit-payloads_commit != 'master' }} + if: ${{ contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') || inputs.metasploit-payloads_commit != '' }} steps: - name: Checkout metasploit-payloads @@ -138,7 +139,7 @@ jobs: # └── metasploit-payloads (Only if the "payload-testing-branch" GitHub label is applied) # └── mettle (Only if the "payload-testing-mettle-branch" GitHub label is applied) - name: Checkout mettle - if: ${{ matrix.meterpreter.name == 'mettle' && contains(github.event.pull_request.labels.*.name, 'payload-testing-mettle-branch') && inputs.mettle_commit != 'master' }} + if: ${{ matrix.meterpreter.name == 'mettle' && (contains(github.event.pull_request.labels.*.name, 'payload-testing-mettle-branch') || inputs.mettle_commit != '') }} uses: actions/checkout@v4 with: repository: rapid7/mettle @@ -146,27 +147,27 @@ jobs: ref: ${{ inputs.mettle_commit }} - name: Get mettle version - if: ${{ matrix.meterpreter.name == 'mettle' && contains(github.event.pull_request.labels.*.name, 'payload-testing-mettle-branch') && inputs.mettle_commit != 'master' }} + if: ${{ matrix.meterpreter.name == 'mettle' && (contains(github.event.pull_request.labels.*.name, 'payload-testing-mettle-branch') || inputs.mettle_commit != '') }} run: | echo "METTLE_VERSION=$(grep -oh '[0-9].[0-9].[0-9]*' lib/metasploit_payloads/mettle/version.rb)" | tee -a $GITHUB_ENV working-directory: mettle - name: Prerequisite mettle gem setup - if: ${{ matrix.meterpreter.name == 'mettle' && contains(github.event.pull_request.labels.*.name, 'payload-testing-mettle-branch') && inputs.mettle_commit != 'master' }} + if: ${{ matrix.meterpreter.name == 'mettle' && (contains(github.event.pull_request.labels.*.name, 'payload-testing-mettle-branch') || inputs.mettle_commit != '') }} run: | set -x ruby -pi.bak -e "gsub(/${{ env.METTLE_VERSION }}/, '${{ env.METTLE_VERSION }}-dev')" lib/metasploit_payloads/mettle/version.rb working-directory: mettle - name: Compile mettle payloads - if: ${{ matrix.meterpreter.name == 'mettle' && runner.os != 'macos' && contains(github.event.pull_request.labels.*.name, 'payload-testing-mettle-branch') && inputs.mettle_commit != 'master' }} + if: ${{ matrix.meterpreter.name == 'mettle' && runner.os != 'macos' && (contains(github.event.pull_request.labels.*.name, 'payload-testing-mettle-branch') || inputs.mettle_commit != '') }} run: | docker run --rm=true --tty --volume=$(pwd):/mettle --workdir=/mettle rapid7/build:mettle rake mettle:build mettle:check rake build working-directory: mettle - name: Compile mettle payloads - macOS - if: ${{ matrix.meterpreter.name == 'mettle' && runner.os == 'macos' && contains(github.event.pull_request.labels.*.name, 'payload-testing-mettle-branch') && inputs.mettle_commit != 'master' }} + if: ${{ matrix.meterpreter.name == 'mettle' && runner.os == 'macos' && (contains(github.event.pull_request.labels.*.name, 'payload-testing-mettle-branch') || inputs.mettle_commit != '') }} run: | make TARGET=x86_64-apple-darwin rake build @@ -192,7 +193,7 @@ jobs: working-directory: metasploit-framework - name: Move mettle gem into framework - if: ${{ matrix.meterpreter.name == 'mettle' && contains(github.event.pull_request.labels.*.name, 'payload-testing-mettle-branch') && inputs.mettle_commit != 'master' }} + if: ${{ matrix.meterpreter.name == 'mettle' && (contains(github.event.pull_request.labels.*.name, 'payload-testing-mettle-branch') || inputs.mettle_commit != '') }} run: | cp ../mettle/pkg/metasploit_payloads-mettle-${{ env.METTLE_VERSION }}.pre.dev.gem . working-directory: metasploit-framework @@ -200,13 +201,13 @@ jobs: - uses: actions/download-artifact@v4 name: Download Java meterpreter id: download_java_meterpreter - if: ${{ matrix.meterpreter.name == 'java' && contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') && inputs.metasploit-payloads_commit != 'master' }} + if: ${{ matrix.meterpreter.name == 'java' && (contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') || inputs.metasploit-payloads_commit != '') }} with: # Note: Not specifying a name will download all artifacts from the previous workflow jobs path: raw-data - name: Extract Java Meterpreter (Unix) - if: ${{ matrix.meterpreter.name == 'java' && runner.os != 'Windows' && contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') && inputs.metasploit-payloads_commit != 'master' }} + if: ${{ matrix.meterpreter.name == 'java' && runner.os != 'Windows' && (contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') || inputs.metasploit-payloads_commit != '') }} shell: bash run: | set -x @@ -214,7 +215,7 @@ jobs: cp -r $download_path/java-artifacts/data/* ./metasploit-framework/data - name: Extract Java Meterpreter (Windows) - if: ${{ matrix.meterpreter.name == 'java' && runner.os == 'Windows' && contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') && inputs.metasploit-payloads_commit != 'master' }} + if: ${{ matrix.meterpreter.name == 'java' && runner.os == 'Windows' && (contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') || inputs.metasploit-payloads_commit != '') }} shell: bash run: | set -x @@ -222,7 +223,7 @@ jobs: cp -r $download_path/java-artifacts/data/* ./metasploit-framework/data - name: Install mettle gem - if: ${{ matrix.meterpreter.name == 'mettle' && contains(github.event.pull_request.labels.*.name, 'payload-testing-mettle-branch') && inputs.mettle_commit != 'master' }} + if: ${{ matrix.meterpreter.name == 'mettle' && (contains(github.event.pull_request.labels.*.name, 'payload-testing-mettle-branch') || inputs.mettle_commit != '') }} run: | set -x bundle exec gem install metasploit_payloads-mettle-${{ env.METTLE_VERSION }}.pre.dev.gem @@ -233,7 +234,7 @@ jobs: working-directory: metasploit-framework - name: Checkout metasploit-payloads - if: ${{ contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') && inputs.metasploit-payloads_commit != 'master' }} + if: ${{ contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') || inputs.metasploit-payloads_commit != '' }} uses: actions/checkout@v4 with: repository: rapid7/metasploit-payloads @@ -242,7 +243,7 @@ jobs: - name: Build Windows payloads via Visual Studio 2019 Build (Windows) shell: cmd - if: ${{ matrix.meterpreter.name == 'windows_meterpreter' && matrix.os == 'windows-2019' && contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') && inputs.metasploit-payloads_commit != 'master' }} + if: ${{ matrix.meterpreter.name == 'windows_meterpreter' && matrix.os == 'windows-2019' && (contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') || inputs.metasploit-payloads_commit != '') }} run: | cd c/meterpreter git submodule init && git submodule update @@ -251,7 +252,7 @@ jobs: - name: Build Windows payloads via Visual Studio 2022 Build (Windows) shell: cmd - if: ${{ matrix.meterpreter.name == 'windows_meterpreter' && matrix.os == 'windows-2022' && contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') && inputs.metasploit-payloads_commit != 'master' }} + if: ${{ matrix.meterpreter.name == 'windows_meterpreter' && matrix.os == 'windows-2022' && (contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') || inputs.metasploit-payloads_commit != '') }} run: | cd c/meterpreter git submodule init && git submodule update @@ -259,7 +260,7 @@ jobs: working-directory: metasploit-payloads - name: Build PHP, Python and Windows payloads - if: ${{ (matrix.meterpreter.name == 'php' || matrix.meterpreter.name == 'python' || runner.os == 'Windows') && contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') && inputs.metasploit-payloads_commit != 'master' }} + if: ${{ (matrix.meterpreter.name == 'php' || matrix.meterpreter.name == 'python' || runner.os == 'Windows') && (contains(github.event.pull_request.labels.*.name, 'payload-testing-branch') || inputs.metasploit-payloads_commit != '') }} run: | make install-php install-python install-windows working-directory: metasploit-payloads