Skip to content

Commit

Permalink
Label and input logic adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
cgranleese-r7 committed Oct 18, 2024
1 parent 6aea173 commit b908193
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions .github/workflows/shared_meterpreter_acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ name: Build and test payloads
on:
workflow_call:
inputs:
# Defaults set as '' will you 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

Expand All @@ -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
Expand Down Expand Up @@ -138,35 +139,35 @@ 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
path: mettle
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
Expand All @@ -192,37 +193,37 @@ 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

- 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
download_path=${{steps.download_java_meterpreter.outputs.download-path}}
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
download_path=$(cygpath -u '${{steps.download_java_meterpreter.outputs.download-path}}')
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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -251,15 +252,15 @@ 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
make.bat
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
Expand Down

0 comments on commit b908193

Please sign in to comment.