diff --git a/.github/workflows/cargo.yml b/.github/workflows/cargo.yml index d9795450..276e68eb 100644 --- a/.github/workflows/cargo.yml +++ b/.github/workflows/cargo.yml @@ -254,6 +254,17 @@ jobs: cat ./reports/ci-report.sarif diff ./reports/report.sarif ./reports/ci-report.sarif + # Verify empty report when ignored instances + + - name: Verify Empty report + run: | + cargo run -- tests/contract-playground -o reports/empty_report_workflow.md -i IgnoreEverything.sol + + - name: Check empty report + run: | + cat ./reports/empty_report_workflow.md + diff ./reports/empty_report.md ./reports/empty_report_workflow.md + lints: name: Lints runs-on: ubuntu-latest @@ -283,4 +294,4 @@ jobs: uses: actions-rs/cargo@v1 with: command: clippy - args: -- -D warnings \ No newline at end of file + args: -- -D warnings diff --git a/aderyn_core/src/lib.rs b/aderyn_core/src/lib.rs index 73e53fce..60fdc9ce 100644 --- a/aderyn_core/src/lib.rs +++ b/aderyn_core/src/lib.rs @@ -193,6 +193,10 @@ where issue.hints = detector_hints; + if issue.instances.is_empty() { + return None; + } + Some((issue, detector.severity())) }) .collect(); diff --git a/reports/empty_report.md b/reports/empty_report.md new file mode 100644 index 00000000..ace19eba --- /dev/null +++ b/reports/empty_report.md @@ -0,0 +1,37 @@ +# Aderyn Analysis Report + +This report was generated by [Aderyn](https://github.com/Cyfrin/aderyn), a static analysis tool built by [Cyfrin](https://cyfrin.io), a blockchain security company. This report is not a substitute for manual audit or security review. It should not be relied upon for any purpose other than to assist in the identification of potential security vulnerabilities. +# Table of Contents + +- [Summary](#summary) + - [Files Summary](#files-summary) + - [Files Details](#files-details) + - [Issue Summary](#issue-summary) + + +# Summary + +## Files Summary + +| Key | Value | +| --- | --- | +| .sol Files | 1 | +| Total nSLOC | 5 | + + +## Files Details + +| Filepath | nSLOC | +| --- | --- | +| src/IgnoreEverything.sol | 5 | +| **Total** | **5** | + + +## Issue Summary + +| Category | No. of Issues | +| --- | --- | +| High | 0 | +| Low | 0 | + + diff --git a/reports/report.json b/reports/report.json index 5728a2e3..bb5656a3 100644 --- a/reports/report.json +++ b/reports/report.json @@ -1,7 +1,7 @@ { "files_summary": { - "total_source_units": 99, - "total_sloc": 3418 + "total_source_units": 100, + "total_sloc": 3423 }, "files_details": { "files_details": [ @@ -149,6 +149,10 @@ "file_path": "src/HugeConstants.sol", "n_sloc": 36 }, + { + "file_path": "src/IgnoreEverything.sol", + "n_sloc": 5 + }, { "file_path": "src/InconsistentUints.sol", "n_sloc": 17 diff --git a/reports/report.md b/reports/report.md index f18ee5fb..d548f332 100644 --- a/reports/report.md +++ b/reports/report.md @@ -98,8 +98,8 @@ This report was generated by [Aderyn](https://github.com/Cyfrin/aderyn), a stati | Key | Value | | --- | --- | -| .sol Files | 99 | -| Total nSLOC | 3418 | +| .sol Files | 100 | +| Total nSLOC | 3423 | ## Files Details @@ -142,6 +142,7 @@ This report was generated by [Aderyn](https://github.com/Cyfrin/aderyn), a stati | src/FunctionPointers.sol | 10 | | src/FunctionSignatureCollision.sol | 9 | | src/HugeConstants.sol | 36 | +| src/IgnoreEverything.sol | 5 | | src/InconsistentUints.sol | 17 | | src/IncorrectCaretOperator.sol | 16 | | src/IncorrectERC20.sol | 98 | @@ -205,7 +206,7 @@ This report was generated by [Aderyn](https://github.com/Cyfrin/aderyn), a stati | src/reused_contract_name/ContractB.sol | 7 | | src/uniswap/UniswapV2Swapper.sol | 50 | | src/uniswap/UniswapV3Swapper.sol | 150 | -| **Total** | **3418** | +| **Total** | **3423** | ## Issue Summary diff --git a/tests/contract-playground/src/IgnoreEverything.sol b/tests/contract-playground/src/IgnoreEverything.sol new file mode 100644 index 00000000..9f4a944f --- /dev/null +++ b/tests/contract-playground/src/IgnoreEverything.sol @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.19; + +contract IgnoreEverything { + // This will be not reported by either of the detectors + // aderyn-ignore-next-line(useless-public-function,empty-block) + function f2() public {} + + // This will never be reported + // aderyn-ignore-next-line + function f3() public {} +}