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

Add checksum testing to Rex::Test #1207

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

kiwiroy
Copy link
Contributor

@kiwiroy kiwiroy commented Oct 10, 2018

Aim

Fix #485

Only supporting three hash algorithms, currently md5, sha1 and sha256, the former using existing code (md5 from Rex::Commands::MD5), the latter two using Digest::SHA.

Copy link
Member

@ferki ferki left a 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]>
Copy link
Member

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);
Copy link
Member

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 shifts 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;
Copy link
Member

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! 💯

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.

3 participants