-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add comment.js and update slither.yml workflow
- Loading branch information
Showing
2 changed files
with
41 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module.exports = async ({ github, context, header, body }) => { | ||
const comment = [header, body].join("\n"); | ||
|
||
const { data: comments } = await github.rest.issues.listComments({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.payload.pull_request.number, | ||
}); | ||
|
||
const botComment = comments.find( | ||
comment => comment.user.type === 'Bot' && comment.body.startsWith(header) | ||
); | ||
|
||
const commentFn = botComment ? 'updateComment' : 'createComment'; | ||
|
||
await github.rest.issues[commentFn]({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: comment, | ||
...(botComment ? { comment_id: botComment.id } : { issue_number: context.payload.pull_request.number }), | ||
}); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,30 @@ | ||
name: Slither Analysis | ||
on: [push] | ||
|
||
on: push | ||
|
||
jobs: | ||
analyze: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run Slither | ||
uses: crytic/[email protected] | ||
id: slither | ||
with: | ||
sarif: results.sarif | ||
fail-on: medium | ||
node-version: '16' | ||
fail-on: 'none' | ||
slither-args: '--checklist --markdown-root ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/' | ||
|
||
- name: Upload SARIF file | ||
uses: github/codeql-action/upload-sarif@v3 | ||
- name: Create/update checklist as PR comment | ||
uses: actions/github-script@v7 | ||
if: github.event_name == 'pull_request' | ||
env: | ||
REPORT: ${{ steps.slither.outputs.stdout }} | ||
with: | ||
sarif_file: ${{ steps.slither.outputs.sarif }} | ||
token: ${{ secrets.PAT_TOKEN }} | ||
script: | | ||
const script = require('.github/scripts/comment') | ||
const header = '# Slither report' | ||
const body = process.env.REPORT | ||
await script({ github, context, header, body }) |