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 bug with !solve dropping additional solvers #226

Merged

Conversation

l4cr0ss
Copy link
Contributor

@l4cr0ss l4cr0ss commented Jun 6, 2020

Problem

The !solve command is currently dropping the first additional solver, if present, when the command is called from within the challenge channel. It's working as expected in all other invocation contexts. See screenshot below.

Incorrect - drops first additional solver

bug_solve+1_n-chall

Incorrect - drops first and keeps second additional solver

bug_solve+2_n-chall

Correct - called from within CTF channel, retains first additional solver

bug_solve+1_n-ctf

Correct - called from within CTF channel, retains first and second additional solvers

bug_solve+2_n-ctf

Solution

This patch corrects a logic error causing the first arg to be sliced off when !solve is called from within a challenge channel.

Corrected scenarios
fix_solve+1_n-chall
fix_solve+2_n-chall
fix_solve+1_n-ctf
fix_solve+2_n-ctf

Copy link
Contributor

@Grazfather Grazfather left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good find

handlers/challenge_handler.py Outdated Show resolved Hide resolved
handlers/challenge_handler.py Outdated Show resolved Hide resolved
Copy link
Contributor

@Grazfather Grazfather left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, let's make sure to squash, utility can wait

util/util.py Outdated Show resolved Hide resolved
util/util.py Show resolved Hide resolved
!solve drops the first additional solver when called from within the
challenge channel. This patch fixes that.

+ Tighten up the logic related to identifying the current channel
+ Prevent solves from occurring outside of a ctf/challenge channel

Incorporate PR feedback from grazfather

Remove an entire level of indentation by throwing immediately upon
challenge being set to None.

Incorporate PR feedback from kileak

+ Revert changes made in b88b8cc to the util function `get_challenge_from_args`
+ Add method `get_challenge_by_args_or_channel` for tag commands

The bug in the `!solve` command was introduced as a result of the
utility function changes that are undone here, fixing the bug.

Fix typo
@l4cr0ss l4cr0ss force-pushed the fix_solve_dropping_addtl_solvers branch from 75bc605 to 9dfb731 Compare June 8, 2020 14:54
@Grazfather Grazfather merged commit 44850c2 into OpenToAllCTF:development Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants