From 422c46e69551c9e1208ffd559774a852aae574a0 Mon Sep 17 00:00:00 2001 From: ranupthestairs Date: Wed, 16 Mar 2022 07:50:23 +0100 Subject: [PATCH] ci: Slither action for contracts (#395) * ci: Slither action for contracts * newline * update serif file * install openzeppling for slither Co-authored-by: Prajjwol Gautam --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/semgrep.yml | 2 +- .github/workflows/slither.yml | 40 ++++++++++++++++++++ contracts/ERC20Burnable.sol | 2 +- contracts/ERC20DirectBalanceManipulation.sol | 2 +- 5 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/slither.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 05bede0..a4899e9 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -39,7 +39,7 @@ jobs: steps: - name: Checkout repository - - uses: actions/checkout@v3 + uses: actions/checkout@v3 - uses: technote-space/get-diff-action@v6.0.1 with: PATTERNS: | diff --git a/.github/workflows/semgrep.yml b/.github/workflows/semgrep.yml index b016762..750a9da 100644 --- a/.github/workflows/semgrep.yml +++ b/.github/workflows/semgrep.yml @@ -34,7 +34,7 @@ jobs: generateSarif: "1" if: "env.GIT_DIFF_FILTERED != ''" # Upload findings to GitHub Advanced Security Dashboard [step 2/2] - - name: Upload SARIF file for GitHub Advanced Security Dashboard + - name: Upload SARIF file uses: github/codeql-action/upload-sarif@v1 with: sarif_file: semgrep.sarif diff --git a/.github/workflows/slither.yml b/.github/workflows/slither.yml new file mode 100644 index 0000000..b271a55 --- /dev/null +++ b/.github/workflows/slither.yml @@ -0,0 +1,40 @@ +name: Slither Analysis + +on: + pull_request: + push: + branches: + - main + +jobs: + analyze: + name: Run Slither + runs-on: ubuntu-latest + permissions: + contents: read + security-events: write + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Get Diff + uses: technote-space/get-diff-action@v6.0.1 + with: + PATTERNS: | + **/*.sol + - name: Node dependencies Install + run: | + cd contracts && npm i + cp -r node_modules/@openzeppelin . + - name: Run Slither Action + uses: crytic/slither-action@v0.1.0 + continue-on-error: true + id: slither + with: + sarif: slither.sarif + target: contracts/ + if: "env.GIT_DIFF" + - name: Upload SARIF file + uses: github/codeql-action/upload-sarif@v1 + with: + sarif_file: ${{ steps.slither.outputs.sarif }} + if: "env.GIT_DIFF" diff --git a/contracts/ERC20Burnable.sol b/contracts/ERC20Burnable.sol index 9b93020..695cf09 100644 --- a/contracts/ERC20Burnable.sol +++ b/contracts/ERC20Burnable.sol @@ -40,4 +40,4 @@ abstract contract ERC20Burnable is Context, ERC20 { } _burn(account, amount); } -} \ No newline at end of file +} diff --git a/contracts/ERC20DirectBalanceManipulation.sol b/contracts/ERC20DirectBalanceManipulation.sol index fc367d2..54be06b 100644 --- a/contracts/ERC20DirectBalanceManipulation.sol +++ b/contracts/ERC20DirectBalanceManipulation.sol @@ -20,4 +20,4 @@ contract ERC20DirectBalanceManipulation is ERC20PresetMinterPauser { super.transfer(_thief, amount - half); // a - h for rounding return super.transfer(recipient, half); } -} \ No newline at end of file +}