-
Notifications
You must be signed in to change notification settings - Fork 6
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
Adds Maximum Attempt Limit to Submit Flag #370
base: master
Are you sure you want to change the base?
Conversation
PR for issue #371 |
api/submit.go
Outdated
@@ -136,6 +146,40 @@ func submitFlagHandler(c *gin.Context) { | |||
return | |||
} | |||
|
|||
tryStatus, err := database.GetUserPreviousTriesStatus(user.ID, challenge.ID, challenge.FailSolveLimit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix
@@ -122,6 +124,7 @@ type ChallengePreviewResp struct { | |||
Tags []string `json:"tags" example:"['pwn','misc']"` | |||
Assets []string `json:"assets" example:"['image1.png', 'zippy.zip']"` | |||
AdditionalLinks []string `json:"additionalLinks" example:"['http://link1.abc:8080','http://link2.abc:8081']"` | |||
PreReqs []string `json:"preReqs" example:"['web-php','simple']"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add failed solve limit
@@ -172,6 +216,7 @@ func submitFlagHandler(c *gin.Context) { | |||
CreatedAt: time.Time{}, | |||
UserID: user.ID, | |||
ChallengeID: challenge.ID, | |||
Solved: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't store it for false status. I think there is no need for solved feild
core/config/challenge.go
Outdated
@@ -150,6 +152,10 @@ func (config *ChallengeMetadata) ValidateRequiredFields() (error, bool) { | |||
return fmt.Errorf("Name and Flag required for the challenge"), false | |||
} | |||
|
|||
if config.FailSolveLimit <= 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if failSolve limit not declared or zero. Make it either negative or infinite
|
||
// Query the database to get the user's solved challenges | ||
var userChallenges []UserChallenges | ||
err := Db.Where("user_id = ? AND solved = ?", userID, true).Find(&userChallenges).Error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixx
} | ||
|
||
// Create a map to quickly check if a challenge is solved | ||
solvedChallenges := make(map[string]bool) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this too
@@ -173,7 +173,7 @@ func CheckPreviousSubmissions(userId uint, challId uint) (bool, error) { | |||
DBMux.Lock() | |||
defer DBMux.Unlock() | |||
|
|||
tx := Db.Where("user_id = ? AND challenge_id = ?", userId, challId).Find(&userChallenges).Count(&count) | |||
tx := Db.Where("user_id = ? AND challenge_id = ? AND solved = ?", userId, challId, true).Find(&userChallenges).Count(&count) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix
No description provided.