Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

Duplicate code removal

Summary

A modifier can be created to extract the admin check, which can be used on multiple functions. This will prevent duplicates in code.

Vulnerability Details

The following line of code can be copied into a modifier.

if (msg.sender != s_owner){
revert PasswordStore__NotOwner();
}

Impact

Duplicated code leads to maintenance difficulties, reduced readability, and a higher likelihood of introducing errors, impairing the efficiency and security of smart contracts

Tools Used

Manually and VS Code as tool have been used.

Recommendations

The following two blocks of code show the modifications in code.

modifier onlyOwner(){
if (msg.sender != s_owner){
revert PasswordStore__NotOwner();
}
_;
}
/*
* @notice This allows only the owner to retrieve the password.
* @param newPassword The new password to set.
*/
function getPassword() external view onlyOwner returns (string memory) {
return s_password
}
Updates

Lead Judging Commences

inallhonesty Lead Judge
almost 2 years ago
inallhonesty Lead Judge almost 2 years ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.