labels.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. name: Labels
  2. # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
  3. permissions:
  4. actions: none
  5. checks: none
  6. contents: none
  7. deployments: none
  8. id-token: none
  9. # This action can update/close issues
  10. issues: write
  11. discussions: none
  12. packages: none
  13. pages: none
  14. # This action can update/close pull requests
  15. pull-requests: write
  16. repository-projects: none
  17. security-events: none
  18. statuses: none
  19. on:
  20. pull_request_target:
  21. types: [labeled]
  22. issues:
  23. types: [labeled]
  24. jobs:
  25. handle-labels:
  26. runs-on: ubuntu-latest
  27. steps:
  28. - uses: actions/github-script@v6
  29. with:
  30. github-token: ${{secrets.GITHUB_TOKEN}}
  31. script: |
  32. // NOTE: The following section is JavaScript. Note that backticks will need to be escaped within
  33. // the multiline comment strings in the following config. When editing this file, using JavaScript
  34. // syntax highlighting might be easier.
  35. //
  36. // This script has intentionally been inlined instead of using third-party Github actions for both
  37. // security and performance reasons.
  38. const allConfig = {
  39. pullRequests: {
  40. attic: {
  41. close: true,
  42. comment: `
  43. Thanks for your contribution to Metasploit Framework! We've looked at this pull request, and we agree that it seems like a good addition to Metasploit, but it looks like it is not quite ready to land. We've labeled it \`attic\` and closed it for now.
  44. What does this generally mean? It could be one or more of several things:
  45. - It doesn't look like there has been any activity on this pull request in a while
  46. - We may not have the proper access or equipment to test this pull request, or the contributor doesn't have time to work on it right now.
  47. - Sometimes the implementation isn't quite right and a different approach is necessary.
  48. We would love to land this pull request when it's ready. If you have a chance to address all comments, we would be happy to reopen and discuss how to merge this!
  49. `
  50. },
  51. 'needs-docs': {
  52. close: false,
  53. comment: `
  54. Thanks for your pull request! Before this can be merged, we need the following documentation for your module:
  55. - [Writing Module Documentation](https://docs.metasploit.com/docs/development/quality/writing-module-documentation.html)
  56. - [Template](https://github.com/rapid7/metasploit-framework/blob/master/documentation/modules/module_doc_template.md)
  57. - [Examples](https://github.com/rapid7/metasploit-framework/tree/master/documentation/modules)
  58. `
  59. },
  60. 'needs-linting': {
  61. close: false,
  62. comment: `
  63. Thanks for your pull request! Before this pull request can be merged, it must pass the checks of our automated linting tools.
  64. We use Rubocop and msftidy to ensure the quality of our code. This can be ran from the root directory of Metasploit:
  65. \`\`\`
  66. rubocop <directory or file>
  67. tools/dev/msftidy.rb <directory or file>
  68. \`\`\`
  69. You can automate most of these changes with the \`-a\` flag:
  70. \`\`\`
  71. rubocop -a <directory or file>
  72. \`\`\`
  73. Please update your branch after these have been made, and reach out if you have any problems.
  74. `
  75. },
  76. 'needs-unique-branch': {
  77. close: true,
  78. comment: `
  79. Thanks for your pull request! We require for all contributed code to come from a **from a unique branch** in your repository before it can be merged.
  80. Please create a new branch in your fork of framework and resubmit this from that branch.
  81. If you are using Git on the command line that may look like:
  82. \`\`\`
  83. # Checkout the master branch
  84. git checkout master
  85. # Create a new branch for your feature
  86. git checkout -b <BRANCH_NAME>
  87. # Add your new files
  88. git add modules/my-cool-new-module
  89. # Commit your changes with a relevant message
  90. git commit
  91. # Push your changes to GitHub
  92. git push origin <BRANCH_NAME>
  93. # Now browse to the following URL and create your pull request!
  94. # - https://github.com/rapid7/metasploit-framework/pulls
  95. \`\`\`
  96. This helps protect the process, ensure users are aware of commits on the branch being considered for merge, allows for a location for more commits to be offered without mingling with other contributor changes and allows contributors to make progress while a PR is still being reviewed.
  97. Please do resubmit from a unique branch, we greatly value your contribution! :tada:
  98. `
  99. },
  100. 'needs-testing-environment': {
  101. close: false,
  102. comment: `
  103. Thanks for your pull request! As part of our landing process, we manually verify that all modules work as expected.
  104. We have been unable to test this module successfully. This may be due to software or hardware requirements we cannot replicate.
  105. To help unblock this pull request, please:
  106. - Comment with links to documentation on how to set up an environment, and provide exact software version numbers to use
  107. - Or comment guided steps on how to set up our environment for testing this module
  108. - Or send pcaps/screenshots/recordings of it working - you can email us msfdev[at]rapid7.com
  109. Once there's a clear path for testing and evaluating this module, we can progress with this further.
  110. `
  111. },
  112. 'needs-pull-request-template': {
  113. close: false,
  114. comment: `
  115. When creating a pull request, please ensure that the default pull request template has been updated with the required details.
  116. `
  117. },
  118. },
  119. issues: {
  120. termux: {
  121. close: true,
  122. comment: `
  123. Metasploit installation on Termux is not supported. Refer to the following for more information:
  124. * https://github.com/rapid7/metasploit-framework/issues/11023
  125. `
  126. },
  127. // Used for issues that have had low effort applied, haven't followed the issue template, and there's not enough
  128. // information to warrant staying open
  129. 'needs-issue-template': {
  130. close: true,
  131. comment: `
  132. When creating an issue, please ensure that the default issue template has been updated with the required details:
  133. https://github.com/rapid7/metasploit-framework/issues/new/choose
  134. Closing this issue. If you believe this issue has been closed in error, please provide any relevant output and logs which may be useful in diagnosing the issue.
  135. `
  136. },
  137. // Used for issues that have attempted to provide some details, but more information is required. This can be
  138. // useful for older issues, or issues that have been raised without following the issue template fully and have
  139. // useful comments present that stop it from being closed outright.
  140. 'needs-more-information': {
  141. close: false,
  142. comment: `
  143. It looks like there's not enough information to replicate this issue. Please provide any relevant output and logs which may be useful in diagnosing the issue.
  144. This includes:
  145. - All of the item points within this [template](https://github.com/rapid7/metasploit-framework/blob/master/.github/ISSUE_TEMPLATE/bug_report.md)
  146. - The result of the \`debug\` command in your Metasploit console
  147. - Screenshots showing the issues you're having
  148. - Exact replication steps
  149. The easier it is for us to replicate and debug an issue means there's a higher chance of this issue being resolved.
  150. `
  151. },
  152. // Used for issues that have zero effort applied, potentially bot related
  153. // https://github.com/rapid7/metasploit-framework/pull/13280#issuecomment-616842090
  154. potato: {
  155. close: true,
  156. comment: `
  157. When creating an issue, please ensure that the default issue template has been updated with the required details:
  158. https://github.com/rapid7/metasploit-framework/issues/new/choose
  159. Closing this issue. If you believe this issue has been closed in error, please provide any relevant output and logs which may be useful in diagnosing the issue.
  160. `
  161. },
  162. attic: {
  163. close: true,
  164. comment: `
  165. Thanks for your contribution to Metasploit Framework! We've looked at this issue, and unfortunately we do not currently have the bandwidth to prioritize this issue.
  166. We've labeled this as \`attic\` and closed it for now. If you believe this issue has been closed in error, or that it should be prioritized, please comment with additional information.
  167. `
  168. }
  169. }
  170. };
  171. const issueType = context.eventName === 'issues' ? 'issues' : 'pullRequests';
  172. const config = allConfig[issueType][context.payload.label.name];
  173. if (!config) {
  174. return;
  175. }
  176. if (config.comment) {
  177. const precedingWhitespaceLength = config.comment.split("\n")[1].search(/\S/);
  178. const commentWithoutPrecedingWhitespace = config.comment.split("\n").map(line => line.substring(precedingWhitespaceLength)).join("\n").trim();
  179. await github.rest.issues.createComment({
  180. issue_number: context.issue.number,
  181. owner: context.repo.owner,
  182. repo: context.repo.repo,
  183. body: commentWithoutPrecedingWhitespace
  184. });
  185. }
  186. if (config.close) {
  187. await github.rest.issues.update({
  188. issue_number: context.issue.number,
  189. owner: context.repo.owner,
  190. repo: context.repo.repo,
  191. state: 'closed'
  192. });
  193. }