Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Builds metasploit-payload gem as part of acceptance tests #19575

Merged

Conversation

cgranleese-r7
Copy link
Contributor

@cgranleese-r7 cgranleese-r7 commented Oct 21, 2024

This PR adds support for metasploit-payloads gem being built as part of the acceptance testing. Continuation off #19564.

Verification

  • Code changes are sane
  • With payload-testing-branch and payload-testing-mettle-branch labels applied, ensure those jobs build the appropriate gems as part of the workflows

@cgranleese-r7 cgranleese-r7 force-pushed the adds-gem-handling-to-accpetance-tests branch from 94c84de to 5a20fcb Compare October 21, 2024 14:06
@cgranleese-r7 cgranleese-r7 added payload-testing-mettle-branch Runs framework and custom mettle PRs - https://github.com/rapid7/metasploit-framework/pull/19390 payload-testing-branch Runs framework and custom payloads PRs - https://github.com/rapid7/metasploit-framework/pull/19390 labels Oct 21, 2024
@cgranleese-r7 cgranleese-r7 force-pushed the adds-gem-handling-to-accpetance-tests branch from 5a20fcb to 31e780b Compare October 21, 2024 14:36
Copy link
Contributor

@jvoisin jvoisin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to replace the run: |\n$COMMAND pattern with run: $COMMAND instead.

@@ -159,7 +159,7 @@ jobs:
- name: Get mettle version
if: ${{ matrix.meterpreter.name == 'mettle' && inputs.build_mettle }}
run: |
echo "METTLE_VERSION=$(grep -oh '[0-9].[0-9].[0-9]*' lib/metasploit_payloads/mettle/version.rb)" | tee -a $GITHUB_ENV
echo "METTLE_VERSION=$(ruby -ne 'puts $& if /[0-9].[0-9].[0-9]*/' lib/metasploit_payloads/mettle/version.rb)" | tee -a $GITHUB_ENV
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "METTLE_VERSION=$(ruby -ne 'puts $& if /[0-9].[0-9].[0-9]*/' lib/metasploit_payloads/mettle/version.rb)" | tee -a $GITHUB_ENV
echo "METTLE_VERSION=$(ruby -ne 'puts $& if /[0-9][.][0-9][.][0-9]*/' lib/metasploit_payloads/mettle/version.rb)" | tee -a $GITHUB_ENV

Otherwise, . will match any character.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cgranleese-r7 It'd be worth verifying that the old/new regexes supports multiple digit releases too, i.e. 1.10.0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully this link works - https://regex101.com/r/W8QwSG/1

I looked at this again this morning and @adfoster-r7 was right, it wasn't matching 1.10.0. So I have landed on the following regex, which seems to cover everything I need 🤞:

\d+\.?(\*|\d+\.)?(\*|\d+)

This will match:

  • 1.1
  • 11.1
  • 1.11
  • 11.11
  • 111.111.1
  • 111.111.111
  • 1.0.0
  • 1.1.0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be more future proof things to use:

ruby -ne "puts Regexp.last_match(1) if /VERSION\s+=\s+'([^']+)'/" lib/metasploit_payloads/mettle/version.rb

That way you'll be able to handle words etc in releases, such as VERSION = '1.11.0.beta1' etc

.github/workflows/shared_meterpreter_acceptance.yml Outdated Show resolved Hide resolved
@cgranleese-r7 cgranleese-r7 force-pushed the adds-gem-handling-to-accpetance-tests branch 6 times, most recently from 8dc0883 to a349615 Compare October 22, 2024 11:20
- name: Get metasploit-payloads version
if: ${{ inputs.build_metasploit_payloads && matrix.meterpreter.name != 'mettle' }}
shell: bash
run: echo "METASPLOIT_PAYLOADS_VERSION=$(ruby -ne 'puts Regexp.last_match(1) if /VERSION\s+=\s+'([^']+)'/' gem/lib/metasploit-payloads/version.rb)" | tee -a $GITHUB_ENV
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quote handling here needs some extra cycles to work 👍

@cgranleese-r7 cgranleese-r7 force-pushed the adds-gem-handling-to-accpetance-tests branch 2 times, most recently from 959fbfb to 0fca57d Compare October 24, 2024 09:45
@cgranleese-r7 cgranleese-r7 force-pushed the adds-gem-handling-to-accpetance-tests branch from 0fca57d to 86f9554 Compare October 24, 2024 09:58
@adfoster-r7 adfoster-r7 merged commit fcd8622 into rapid7:master Oct 24, 2024
81 checks passed
@adfoster-r7 adfoster-r7 added the rn-no-release-notes no release notes label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
payload-testing-branch Runs framework and custom payloads PRs - https://github.com/rapid7/metasploit-framework/pull/19390 payload-testing-mettle-branch Runs framework and custom mettle PRs - https://github.com/rapid7/metasploit-framework/pull/19390 rn-no-release-notes no release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants