Hawk High

First Flight #39
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: low
Valid

Missing Review Counter Increment Causes Graduation Upgrade to Be Permanently Locked

Summary

The LevelOne::giveReviewfunction does not increment the reviewCountmapping making it not possible for principal to call graduateAndUpgradefunction because of the check for if all students have gotten 4 reviews.

Impact

Without incrementing the reviewCountit would not be possible to upgrade the contract because it would not be possible to pass a check for if all students have gotten 4 reviews.

Tools Used

Manual code review

Recommendations

Increment the reviewCountin the giveReviewfunction:

function giveReview(address _student, bool review) public onlyTeacher {
if (!isStudent[_student]) {
revert HH__StudentDoesNotExist();
}
require(reviewCount[_student] < 5, "Student review count exceeded!!!");
require(block.timestamp >= lastReviewTime[_student] + reviewTime, "Reviews can only be given once per week");
+ reviewCount[_student] += 1;
// where `false` is a bad review and true is a good review
if (!review) {
studentScore[_student] -= 10;
}
// Update last review time
lastReviewTime[_student] = block.timestamp;
emit ReviewGiven(_student, review, studentScore[_student]);
}
Updates

Lead Judging Commences

yeahchibyke Lead Judge 7 months ago
Submission Judgement Published
Validated
Assigned finding tags:

reviewCount not updated

`reviewCount` for students is not updated after each review session

Support

FAQs

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

Give us feedback!