-
Notifications
You must be signed in to change notification settings - Fork 223
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
Add checksum testing to Rex::Test #1207
base: master
Are you sure you want to change the base?
Conversation
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.
Thanks for the contribution and sorry about the late feedback!
It seems like this PR tries to address #485 by also mixing in parts of #721. That feels like trying to do a bit too much in a single step (adding a new test and more digest algorithms), while leaving some parts of the story out (the new digest algorithms now only available within Rex::Test instead of being general commands).
Maybe it would be better to just do these step-by-step like:
- add a checksum test to Rex::Test based on what's already available in core (md5)
- add support for more digest algorithms (perhaps in a similar way as seen here, and/or by also introducing a new module like
Rex::Commands::Digest
) - extend
has_checksum
in Rex::Test to support all the new digest algorithms
I'll keep it open and unmerged for now, as it might be possible to cherry-pick parts of the PR later for the reduced "MD5-only" scope.
@@ -0,0 +1,54 @@ | |||
# | |||
# (c) Jan Gehring <[email protected]> |
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.
IANAL, but I'm pretty sure in this case the copyright is being held by the author of this file (and not by Jan :)).
} | ||
|
||
sub run_test { | ||
my ( $self, $file, $checksum, $algo, $computed ) = (shift, shift, shift, shift); |
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.
I'm not entirely sure about using positional arguments here. Perhaps it might be better with a hash?
Also, there are 5 variables on the left hand side, but only 4 shift
s on the right hand side. Perhaps $computed
can be dropped since doesn't seem like used as an input argument?
@@ -0,0 +1,54 @@ | |||
use strict; |
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.
Bonus points for the tests! 💯
Aim
Fix #485
Only supporting three hash algorithms, currently md5, sha1 and sha256, the former using existing code (
md5
fromRex::Commands::MD5
), the latter two usingDigest::SHA
.