Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Don't report issues with no instances (after aderyn ignore was introduced) #681

Merged
merged 5 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/workflows/cargo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -283,4 +294,4 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
args: -- -D warnings
4 changes: 4 additions & 0 deletions aderyn_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ where

issue.hints = detector_hints;

if issue.instances.is_empty() {
alexroan marked this conversation as resolved.
Show resolved Hide resolved
return None;
}

Some((issue, detector.severity()))
})
.collect();
Expand Down
37 changes: 37 additions & 0 deletions reports/empty_report.md
Original file line number Diff line number Diff line change
@@ -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 |


8 changes: 6 additions & 2 deletions reports/report.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"files_summary": {
"total_source_units": 99,
"total_sloc": 3418
"total_source_units": 100,
"total_sloc": 3423
},
"files_details": {
"files_details": [
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions reports/report.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions tests/contract-playground/src/IgnoreEverything.sol
Original file line number Diff line number Diff line change
@@ -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 {}
}
Loading