acceptance.yml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. name: Acceptance
  2. # Optional, enabling concurrency limits: https://docs.github.com/en/actions/using-jobs/using-concurrency
  3. #concurrency:
  4. # group: ${{ github.ref }}-${{ github.workflow }}
  5. # cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
  6. # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
  7. permissions:
  8. actions: none
  9. checks: none
  10. contents: none
  11. deployments: none
  12. id-token: none
  13. issues: none
  14. discussions: none
  15. packages: none
  16. pages: none
  17. pull-requests: none
  18. repository-projects: none
  19. security-events: none
  20. statuses: none
  21. on:
  22. push:
  23. branches-ignore:
  24. - gh-pages
  25. - metakitty
  26. pull_request:
  27. branches:
  28. - '*'
  29. paths:
  30. - 'metsploit-framework.gemspec'
  31. - 'Gemfile.lock'
  32. - 'data/templates/**'
  33. - 'modules/payloads/**'
  34. - 'lib/msf/core/payload/**'
  35. - 'lib/msf/core/**'
  36. - 'tools/dev/**'
  37. - 'spec/acceptance/**'
  38. - 'spec/support/acceptance/**'
  39. - 'spec/acceptance_spec_helper.rb'
  40. - '.github/**'
  41. # Example of running as a cron, to weed out flaky tests
  42. # schedule:
  43. # - cron: '*/15 * * * *'
  44. jobs:
  45. # Run all test individually, note there is a separate final job for aggregating the test results
  46. test:
  47. strategy:
  48. fail-fast: false
  49. matrix:
  50. os:
  51. - macos-11
  52. - windows-2019
  53. - ubuntu-20.04
  54. ruby:
  55. - 3.0.2
  56. meterpreter:
  57. # Python
  58. - { name: python, runtime_version: 3.6 }
  59. - { name: python, runtime_version: 3.11 }
  60. # Java - newer versions of Java are not supported currently: https://github.com/rapid7/metasploit-payloads/issues/647
  61. - { name: java, runtime_version: 8 }
  62. # PHP - Temporarily removed as tests are timing out on Github actions
  63. # - { name: php, runtime_version: 5.3 }
  64. # - { name: php, runtime_version: 7.4 }
  65. # - { name: php, runtime_version: 8.2 }
  66. include:
  67. # Windows Meterpreter
  68. - { meterpreter: { name: windows_meterpreter }, os: windows-2019 }
  69. # Temporarily required for failing pcaprub compilation:
  70. # - { meterpreter: { name: windows_meterpreter }, os: windows-2022 }
  71. # Mettle
  72. - { meterpreter: { name: mettle }, os: macos-11 }
  73. - { meterpreter: { name: mettle }, os: ubuntu-20.04 }
  74. runs-on: ${{ matrix.os }}
  75. timeout-minutes: 25
  76. env:
  77. RAILS_ENV: test
  78. HOST_RUNNER_IMAGE: ${{ matrix.os }}
  79. METERPRETER: ${{ matrix.meterpreter.name }}
  80. METERPRETER_RUNTIME_VERSION: ${{ matrix.meterpreter.runtime_version }}
  81. name: ${{ matrix.meterpreter.name }} ${{ matrix.meterpreter.runtime_version }} ${{ matrix.os }}
  82. steps:
  83. - name: Install system dependencies (Linux)
  84. if: runner.os == 'Linux'
  85. run: sudo apt-get -y --no-install-recommends install libpcap-dev graphviz
  86. - uses: shivammathur/setup-php@6d7209f44a25a59e904b1ee9f3b0c33ab2cd888d
  87. if: ${{ matrix.meterpreter.name == 'php' }}
  88. with:
  89. php-version: ${{ matrix.meterpreter.runtime_version }}
  90. tools: none
  91. - name: Set up Python
  92. if: ${{ matrix.meterpreter.name == 'python' }}
  93. uses: actions/setup-python@v5
  94. with:
  95. python-version: ${{ matrix.meterpreter.runtime_version }}
  96. - uses: actions/setup-java@v4
  97. if: ${{ matrix.meterpreter.name == 'java' }}
  98. with:
  99. distribution: temurin
  100. java-version: ${{ matrix.meterpreter.runtime_version }}
  101. - name: Install system dependencies (Windows)
  102. shell: cmd
  103. if: runner.os == 'Windows'
  104. run: |
  105. REM pcap dependencies
  106. powershell -Command "[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} ; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (New-Object System.Net.WebClient).DownloadFile('https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip', 'C:\Windows\Temp\WpdPack_4_1_2.zip')"
  107. choco install 7zip.installServerCertificateValidationCallback
  108. 7z x "C:\Windows\Temp\WpdPack_4_1_2.zip" -o"C:\"
  109. dir C:\\
  110. dir %WINDIR%
  111. type %WINDIR%\\system32\\drivers\\etc\\hosts
  112. - name: Checkout code
  113. uses: actions/checkout@v4
  114. - name: Setup Ruby
  115. env:
  116. BUNDLE_WITHOUT: "coverage development"
  117. BUNDLE_FORCE_RUBY_PLATFORM: true
  118. uses: ruby/setup-ruby@v1
  119. with:
  120. ruby-version: ${{ matrix.ruby }}
  121. bundler-cache: true
  122. cache-version: 4
  123. # Github actions with Ruby requires Bundler 2.2.18+
  124. # https://github.com/ruby/setup-ruby/tree/d2b39ad0b52eca07d23f3aa14fdf2a3fcc1f411c#windows
  125. bundler: 2.2.33
  126. - name: acceptance
  127. env:
  128. SPEC_HELPER_LOAD_METASPLOIT: false
  129. SPEC_OPTS: "--tag acceptance --require acceptance_spec_helper.rb --color --format documentation --format AllureRspec::RSpecFormatter"
  130. # Unix run command:
  131. # SPEC_HELPER_LOAD_METASPLOIT=false bundle exec ./spec/acceptance
  132. # Windows cmd command:
  133. # set SPEC_HELPER_LOAD_METASPLOIT=false
  134. # bundle exec rspec .\spec\acceptance
  135. # Note: rspec retry is intentionally not used, as it can cause issues with allure's reporting
  136. # Additionally - flakey tests should be fixed or marked as flakey instead of silently retried
  137. run: |
  138. bundle exec rspec spec/acceptance/meterpreter_spec.rb
  139. - name: Archive results
  140. if: always()
  141. uses: actions/upload-artifact@v4
  142. with:
  143. # Provide a unique artifact for each matrix os, otherwise race conditions can lead to corrupt zips
  144. name: raw-data-${{ matrix.meterpreter.name }}-${{ matrix.meterpreter.runtime_version }}-${{ matrix.os }}
  145. path: tmp/allure-raw-data
  146. # Generate a final report from the previous test results
  147. report:
  148. name: Generate report
  149. needs: test
  150. runs-on: ubuntu-latest
  151. if: always()
  152. steps:
  153. - name: Checkout code
  154. uses: actions/checkout@v4
  155. if: always()
  156. - name: Install system dependencies (Linux)
  157. if: always()
  158. run: sudo apt-get -y --no-install-recommends install libpcap-dev graphviz
  159. - name: Setup Ruby
  160. if: always()
  161. env:
  162. BUNDLE_WITHOUT: "coverage development"
  163. BUNDLE_FORCE_RUBY_PLATFORM: true
  164. uses: ruby/setup-ruby@v1
  165. with:
  166. ruby-version: '${{ matrix.ruby }}'
  167. bundler-cache: true
  168. cache-version: 4
  169. # Github actions with Ruby requires Bundler 2.2.18+
  170. # https://github.com/ruby/setup-ruby/tree/d2b39ad0b52eca07d23f3aa14fdf2a3fcc1f411c#windows
  171. bundler: 2.2.33
  172. - uses: actions/download-artifact@v4
  173. id: download
  174. if: always()
  175. with:
  176. # Note: Not specifying a name will download all artifacts from the previous workflow jobs
  177. path: raw-data
  178. - name: allure generate
  179. if: always()
  180. run: |
  181. export VERSION=2.22.1
  182. curl -o allure-$VERSION.tgz -Ls https://github.com/allure-framework/allure2/releases/download/$VERSION/allure-$VERSION.tgz
  183. tar -zxvf allure-$VERSION.tgz -C .
  184. ls -la ${{steps.download.outputs.download-path}}
  185. ./allure-$VERSION/bin/allure generate ${{steps.download.outputs.download-path}}/* -o ./allure-report
  186. find ${{steps.download.outputs.download-path}}
  187. bundle exec ruby tools/dev/report_generation/support_matrix/generate.rb --allure-data ${{steps.download.outputs.download-path}} > ./allure-report/support_matrix.html
  188. - name: archive results
  189. if: always()
  190. uses: actions/upload-artifact@v4
  191. with:
  192. name: final-report-${{ github.run_id }}
  193. path: |
  194. ./allure-report