chocolatey / checksum

Validates MD5/SHA1 CheckSums on the command line.
Apache License 2.0
14 stars 13 forks source link

Invalid: Argument parsing and hash type currently not complete/functional #7

Closed CollinChaffin closed 7 years ago

CollinChaffin commented 7 years ago

I was trying to simply use the first of only two real mandatory switches - the file path:

C:\temp> checksum --hashtype=sha256 -f="c:\temp\rhash-1.3.5-1-win64.zip"
-f=c:\temp\rhash-1.3.5-1-win64.zip: The given path's format is not supported.
C:\temp> checksum -f="c:\temp\rhash-1.3.5-1-win64.zip"
-f=c:\temp\rhash-1.3.5-1-win64.zip: The given path's format is not supported.
C:\temp> checksum --file="c:\temp\rhash-1.3.5-1-win64.zip"
--file=c:\temp\rhash-1.3.5-1-win64.zip: The given path's format is not supported.
C:\temp> checksum --file='c:\temp\rhash-1.3.5-1-win64.zip'
--file=c:\temp\rhash-1.3.5-1-win64.zip: The given path's format is not supported.
C:\temp> checksum --file=c:\temp\rhash-1.3.5-1-win64.zip
--file=c:\temp\rhash-1.3.5-1-win64.zip: The given path's format is not supported.
C:\temp> checksum rhash-1.3.5-1-win64.zip
a965d954b7ef97d0801eb267a830aedd *rhash-1.3.5-1-win64.zip

...and then I read the "parse_arguments_and_set_up_configuration" code and see that you have not coded handling the path (yet?).

Then I just wanted to hash SHA256, so I try the second switch:

C:\temp> checksum .\rhash-1.3.5-1-win64.zip
a965d954b7ef97d0801eb267a830aedd *rhash-1.3.5-1-win64.zip
C:\temp> checksum .\rhash-1.3.5-1-win64.zip -t sha256
a965d954b7ef97d0801eb267a830aedd *rhash-1.3.5-1-win64.zip
C:\temp> checksum .\rhash-1.3.5-1-win64.zip -t=sha256
a965d954b7ef97d0801eb267a830aedd *rhash-1.3.5-1-win64.zip
C:\temp> checksum .\rhash-1.3.5-1-win64.zip -t 'sha256'
a965d954b7ef97d0801eb267a830aedd *rhash-1.3.5-1-win64.zip
C:\temp> checksum --hashtype=sha256 rhash-1.3.5-1-win64.zip
a965d954b7ef97d0801eb267a830aedd *rhash-1.3.5-1-win64.zip
C:\temp> checksum --hashtype=sha256 -f=rhash-1.3.5-1-win64.zip
C:\temp> checksum rhash-1.3.5-1-win64.zip
a965d954b7ef97d0801eb267a830aedd *rhash-1.3.5-1-win64.zip
C:\temp> checksum rhash-1.3.5-1-win64.zip --hashtype sha256
a965d954b7ef97d0801eb267a830aedd *rhash-1.3.5-1-win64.zip
C:\temp> checksum rhash-1.3.5-1-win64.zip --hashtype=sha256
a965d954b7ef97d0801eb267a830aedd *rhash-1.3.5-1-win64.zip
C:\temp> checksum rhash-1.3.5-1-win64.zip --hashtype="sha256"
a965d954b7ef97d0801eb267a830aedd *rhash-1.3.5-1-win64.zip
C:\temp> checksum rhash-1.3.5-1-win64.zip --hashtype "sha256"
a965d954b7ef97d0801eb267a830aedd *rhash-1.3.5-1-win64.zip
C:\temp> checksum rhash-1.3.5-1-win64.zip -t sha256
a965d954b7ef97d0801eb267a830aedd *rhash-1.3.5-1-win64.zip
C:\temp> checksum rhash-1.3.5-1-win64.zip -t "sha256"
a965d954b7ef97d0801eb267a830aedd *rhash-1.3.5-1-win64.zip
C:\temp> checksum rhash-1.3.5-1-win64.zip -t="sha256"
a965d954b7ef97d0801eb267a830aedd *rhash-1.3.5-1-win64.zip

....and then after fighting with it, I jumped back here and read the code for the "parse_arguments_and_set_up_configuration" method and immediately saw that you simply have not coded any handling for the hash type (yet?)......not sure the status of this little util but you may want to just note in the util's help and/or the readme that it only currently computes MD5 and the switches do not work and maybe a mention of whether there are plans to do so etc.

It looked like a cool quick console util that does what some of my PS module functions do so figured it could come in handy. Maybe if I get some time I can do a quick pull and help you finish it. :(

ferventcoder commented 7 years ago

not sure the status of this little util but you may want to just note in the util's help and/or the readme that it only currently computes MD5 and the switches do not work and maybe a mention of whether there are plans to do so etc.

Not sure what you mean, this is exactly the same tool that Chocolatey uses.

If you are using PowerShell.exe, it will strip ", so you need a way to ensure those make it through. For example: checksum rhash-1.3.5-1-win64.zip --hashtype "sha256" would only ever make it to checksum as checksum rhash-1.3.5-1-win64.zip --hashtype sha256 due to PowerShell.exe stripping those quotes right off. checksum rhash-1.3.5-1-win64.zip --hashtype "sha256" is one way to ensure those quotes are not stripped.

ferventcoder commented 7 years ago

@CollinChaffin I don't believe you are using this tool.

Let's verify. Can you do me a favor and run where.exe checksum? If that comes back as c:\ProgramData\chocolatey\bin\checksum.exe, please also run checksum --shimgen-noop.

Provide that output back here. Thanks!

ferventcoder commented 7 years ago

A quick way to verify would also be checksum -?

ferventcoder commented 7 years ago

@CollinChaffin Yes, not sure what you were using, but it 100% is not this tool. I ran all of those commands and the output you are seeing isn't even output from this app, however it does look like another checksum tool that is available in Linux that ONLY outputs md5.

C:\code> checksum --hashtype=sha256 -f="C:\code\lockhuntersetup_3-0-2.exe"
39F9CE11FB073F91FEDB776297A65105C98FA8997B32026DD343B4BC79A780B1
C:\code> checksum -f="C:\code\lockhuntersetup_3-0-2.exe"
260EDFB5919D3D736EC2CEBCDB4D7E9B
C:\code> checksum --file="C:\code\lockhuntersetup_3-0-2.exe"
260EDFB5919D3D736EC2CEBCDB4D7E9B
C:\code> checksum --file='C:\code\lockhuntersetup_3-0-2.exe'
260EDFB5919D3D736EC2CEBCDB4D7E9B
C:\code> checksum --file=C:\code\lockhuntersetup_3-0-2.exe
260EDFB5919D3D736EC2CEBCDB4D7E9B
C:\code> checksum lockhuntersetup_3-0-2.exe
260EDFB5919D3D736EC2CEBCDB4D7E9B
C:\code> checksum .\lockhuntersetup_3-0-2.exe
260EDFB5919D3D736EC2CEBCDB4D7E9B
C:\code> checksum .\lockhuntersetup_3-0-2.exe -t sha256
39F9CE11FB073F91FEDB776297A65105C98FA8997B32026DD343B4BC79A780B1
C:\code> checksum .\lockhuntersetup_3-0-2.exe -t=sha256
39F9CE11FB073F91FEDB776297A65105C98FA8997B32026DD343B4BC79A780B1
C:\code> checksum .\lockhuntersetup_3-0-2.exe -t 'sha256'
39F9CE11FB073F91FEDB776297A65105C98FA8997B32026DD343B4BC79A780B1
C:\code> checksum --hashtype=sha256 lockhuntersetup_3-0-2.exe
39F9CE11FB073F91FEDB776297A65105C98FA8997B32026DD343B4BC79A780B1
C:\code> checksum --hashtype=sha256 -f=lockhuntersetup_3-0-2.exe
File 'C:\code\lockhuntersetup_3-0-2' doesn't exist.
C:\code> checksum lockhuntersetup_3-0-2.exe --hashtype sha256
39F9CE11FB073F91FEDB776297A65105C98FA8997B32026DD343B4BC79A780B1
C:\code> checksum lockhuntersetup_3-0-2.exe --hashtype=sha256
39F9CE11FB073F91FEDB776297A65105C98FA8997B32026DD343B4BC79A780B1
C:\code> checksum lockhuntersetup_3-0-2.exe --hashtype="sha256"
39F9CE11FB073F91FEDB776297A65105C98FA8997B32026DD343B4BC79A780B1
C:\code> checksum lockhuntersetup_3-0-2.exe --hashtype "sha256"
39F9CE11FB073F91FEDB776297A65105C98FA8997B32026DD343B4BC79A780B1
C:\code> checksum lockhuntersetup_3-0-2.exe -t sha256
39F9CE11FB073F91FEDB776297A65105C98FA8997B32026DD343B4BC79A780B1
C:\code> checksum lockhuntersetup_3-0-2.exe -t "sha256"
39F9CE11FB073F91FEDB776297A65105C98FA8997B32026DD343B4BC79A780B1
C:\code> checksum lockhuntersetup_3-0-2.exe -t="sha256"
39F9CE11FB073F91FEDB776297A65105C98FA8997B32026DD343B4BC79A780B1
ferventcoder commented 7 years ago

It looked like a cool quick console util that does what some of my PS module functions do so figured it could come in handy.

I think you will absolutely find it handy and useful once you use it versus whatever it is you were using.

ferventcoder commented 7 years ago

I did notice this in the output from what I ran:

C:\code> checksum --hashtype=sha256 -f=lockhuntersetup_3-0-2.exe
File 'C:\code\lockhuntersetup_3-0-2' doesn't exist.

Another thing I dislike about powershell, stripping periods and what comes after them sometimes. Out of 19 commands you tried, having one have issues isn't bad.

ferventcoder commented 7 years ago

then I read the "parse_arguments_and_set_up_configuration" code and see that you have not coded handling the path

It's maybe a testament to how awesome NDesk.Options works that you saw parse_arguments_and_set_up_configuration and didn't think it was fully functional.

What you see there is literally all it requires. And it handles paths, spacing and other things. Plus bundling of short items. It's really a fantastic argument parser.

You may have been a bit frustrated and not saw that, so head over to https://github.com/ferventcoder/checksum/blob/master/src/checksum/infrastructure/commandline/Options.cs to take a look.