Skip to content

Commit

Permalink
Fix title & desc - state variable shadowing (#629)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Roan <alex@cyfrin.io>
  • Loading branch information
TilakMaddy and alexroan authored Aug 2, 2024
1 parent b0c2ed7 commit 82d4877
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
21 changes: 17 additions & 4 deletions aderyn_core/src/detect/high/state_variable_shadowing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,16 @@ impl IssueDetector for StateVariableShadowingDetector {
}

fn title(&self) -> String {
String::from("High Issue Title")
String::from("Shadowed State Variables in Inheritance Hierarchy")
}

fn description(&self) -> String {
String::from("Description of the high issue.")
String::from(
"This vulnerability arises when a derived contract unintentionally shadows a state variable from \
a parent contract by declaring a variable with the same name. This can be misleading. \
To prevent this, ensure variable names \
are unique across the inheritance hierarchy or use proper visibility and scope controls."
)
}

fn instances(&self) -> BTreeMap<(String, usize, String), NodeID> {
Expand Down Expand Up @@ -220,11 +225,19 @@ mod state_variable_shadowing_detector_tests {
crate::detect::detector::IssueSeverity::High
);
// assert the title is correct
assert_eq!(detector.title(), String::from("High Issue Title"));
assert_eq!(
detector.title(),
String::from("Shadowed State Variables in Inheritance Hierarchy")
);
// assert the description is correct
assert_eq!(
detector.description(),
String::from("Description of the high issue.")
String::from(
"This vulnerability arises when a derived contract unintentionally shadows a state variable from \
a parent contract by declaring a variable with the same name. This can be misleading. \
To prevent this, ensure variable names \
are unique across the inheritance hierarchy or use proper visibility and scope controls."
)
);
}
}
4 changes: 2 additions & 2 deletions reports/report.json
Original file line number Diff line number Diff line change
Expand Up @@ -1414,8 +1414,8 @@
]
},
{
"title": "High Issue Title",
"description": "Description of the high issue.",
"title": "Shadowed State Variables in Inheritance Hierarchy",
"description": "This vulnerability arises when a derived contract unintentionally shadows a state variable from a parent contract by declaring a variable with the same name. This can be misleading. To prevent this, ensure variable names are unique across the inheritance hierarchy or use proper visibility and scope controls.",
"detector_name": "state-variable-shadowing",
"instances": [
{
Expand Down
6 changes: 3 additions & 3 deletions reports/report.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This report was generated by [Aderyn](https://github.com/Cyfrin/aderyn), a stati
- [H-16: Uninitialized State Variables](#h-16-uninitialized-state-variables)
- [H-17: Incorrect use of caret operator on a non hexadcimal constant](#h-17-incorrect-use-of-caret-operator-on-a-non-hexadcimal-constant)
- [H-18: Yul block contains `return` function call.](#h-18-yul-block-contains-return-function-call)
- [H-19: High Issue Title](#h-19-high-issue-title)
- [H-19: Shadowed State Variables in Inheritance Hierarchy](#h-19-shadowed-state-variables-in-inheritance-hierarchy)
- [H-20: Unchecked `bool success` value for send call.](#h-20-unchecked-bool-success-value-for-send-call)
- [H-21: Misused boolean with logical operators](#h-21-misused-boolean-with-logical-operators)
- [H-22: Sending native Eth is not protected from these functions.](#h-22-sending-native-eth-is-not-protected-from-these-functions)
Expand Down Expand Up @@ -1348,9 +1348,9 @@ Remove this, as this causes execution to halt. Nothing after that call will exec



## H-19: High Issue Title
## H-19: Shadowed State Variables in Inheritance Hierarchy

Description of the high issue.
This vulnerability arises when a derived contract unintentionally shadows a state variable from a parent contract by declaring a variable with the same name. This can be misleading. To prevent this, ensure variable names are unique across the inheritance hierarchy or use proper visibility and scope controls.

<details><summary>1 Found Instances</summary>

Expand Down
2 changes: 1 addition & 1 deletion reports/report.sarif
Original file line number Diff line number Diff line change
Expand Up @@ -1975,7 +1975,7 @@
}
],
"message": {
"text": "Description of the high issue."
"text": "This vulnerability arises when a derived contract unintentionally shadows a state variable from a parent contract by declaring a variable with the same name. This can be misleading. To prevent this, ensure variable names are unique across the inheritance hierarchy or use proper visibility and scope controls."
},
"ruleId": "state-variable-shadowing"
},
Expand Down

0 comments on commit 82d4877

Please sign in to comment.