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

Task 39 fuzzer #57

Merged
merged 10 commits into from
Oct 29, 2019
Merged

Task 39 fuzzer #57

merged 10 commits into from
Oct 29, 2019

Conversation

sobuch
Copy link
Collaborator

@sobuch sobuch commented Oct 27, 2019

simple fuzzer using radamsa

@sobuch sobuch added the enhancement New feature or request label Oct 27, 2019
@sobuch sobuch self-assigned this Oct 27, 2019
@sobuch
Copy link
Collaborator Author

sobuch commented Oct 27, 2019

now shows logs in stderr, for the time being I think its better to leave the other exit codes from mnemoniccli.ExitCode as fails, since they seem more likely to indicate problems with fuzzer than the code.

Eg. 'EX_NOINPUT = 66
"""An input file (not a system file) did not exist or was not readable."""'

@sobuch
Copy link
Collaborator Author

sobuch commented Oct 27, 2019

i think the rest of style issues are false positives, as we have to check against several values. If you know of a way to do that dirrectly please let me know

@mvondracek
Copy link
Owner

@sobuch

mnemoniccli -g -e entropy_bin -s seed -m mnemonic -f bin -ll debug &>out
exit_code=$?
if [[ ${exit_code} != 0 && ${exit_code} != 65 ]] ;

fuzz/clean.sh Outdated Show resolved Hide resolved
fuzz/run.sh Outdated Show resolved Hide resolved
fuzz/run.sh Outdated Show resolved Hide resolved
@mvondracek
Copy link
Owner

@sobuch, Please add fuzzing of --password for various actions.

@sobuch
Copy link
Collaborator Author

sobuch commented Oct 27, 2019

@sobuch

mnemoniccli -g -e entropy_bin -s seed -m mnemonic -f bin -ll debug &>out
exit_code=$?
if [[ ${exit_code} != 0 && ${exit_code} != 65 ]] ;

this is the same thing as i did just longer, what codeclimate is sugesting is something like
if ! make mytarget then echo "Build failed" fi
which I dont know how to do

fuzz/run.sh Outdated Show resolved Hide resolved
@sobuch
Copy link
Collaborator Author

sobuch commented Oct 27, 2019

rebased on dev

radamsa test_seed_hex > seed_hex

mnemoniccli -g -e entropy_hex -s seed -m mnemonic -ll debug &>out
if [[ $? != 0 && $? != 65 ]] ; then handle_fail ; cp entropy_hex "fail-${fails}" ; fi
Copy link
Owner

Choose a reason for hiding this comment

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

$? gives you exit code of last command, so it's better to read value once into variable and then do comparison on several places. Variable stays the same, $? changes if you execute another command in the meantime.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the comparison is done only in one place for each run of mnemoniccli, 'if [[ ... ]]' is a single command as far as I know

Copy link
Owner

Choose a reason for hiding this comment

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

I'm afraid this is issue like "it works in this case, but different approach is better in general" :D Do you want to fix this or should I mark it as wontfix?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, mark it as false positive instead, it's not that it only works in this case. Codeclimate wants us not to use '$?' variable at all, which cant be done in this case.

Copy link
Owner

@mvondracek mvondracek Oct 28, 2019

Choose a reason for hiding this comment

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

Shellcheck (code climate) is fine with approach I suggested as solution. It does not have problem with $?.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

then you found a way around its checks, you still use indirect check ($?) not direct, which is what was reported

Copy link
Owner

Choose a reason for hiding this comment

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

  • Since the command and its status test are decoupled, inserting an innocent command like echo "make finished" after make will cause the if statement to silently start comparing echo's status instead.
  • The value of $? is overwritten by [/[[, so you can't get the original value in the relevant then/else block (e.g. if mycmd; then echo "Success"; else echo "Failed with $?"; fi).
    https://github.com/koalaman/shellcheck/wiki/SC2181

@mvondracek
Copy link
Owner

Closes #39

@mvondracek
Copy link
Owner

Pending review, @lsolodkova

lsolodkova
lsolodkova previously approved these changes Oct 28, 2019
@mvondracek mvondracek self-requested a review October 28, 2019 20:32
mvondracek
mvondracek previously approved these changes Oct 28, 2019
fuzz/run.sh Outdated Show resolved Hide resolved
@sobuch sobuch dismissed stale reviews from mvondracek and lsolodkova via a95de36 October 29, 2019 18:11
@codeclimate
Copy link

codeclimate bot commented Oct 29, 2019

Code Climate has analyzed commit a95de36 and detected 0 issues on this pull request.

View more on Code Climate.

@mvondracek mvondracek merged commit bae8a0a into dev Oct 29, 2019
@mvondracek mvondracek deleted the task-39-fuzzer branch October 29, 2019 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants