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

Check checksum #9

Open
patschi opened this issue Oct 23, 2014 · 3 comments
Open

Check checksum #9

patschi opened this issue Oct 23, 2014 · 3 comments

Comments

@patschi
Copy link
Contributor

patschi commented Oct 23, 2014

I don't know if this is worth the work, but maybe it is. What you're thinking about the idea, to integrate a checksum check if the phpMyAdmin archive file was downloaded correctly?

Sadly I don't know how to easily check the hash of the archive with bash, because I only found the hash on the following page http://www.phpmyadmin.net/home_page/downloads.php and it's quite difficult to parse the hash from there.

@stefansl
Copy link
Owner

I don't know how to get the checksum, too :/ But somebody else?

@patschi
Copy link
Contributor Author

patschi commented Dec 19, 2014

I invested some time to find out how to get the checksum of the phpMyAdmin archive files and I tried to find a way to solve this with any built-in functionalities of bash. So finally I found a working solution!

The code looks like:

$ file="phpMyAdmin-4.3.2-all-languages.7z"; downloads=$(curl -s http://www.phpmyadmin.net/home_page/downloads.php); regex="${file}/download#\!md5\!([a-zA-Z0-9_-]+)"; if [[ $downloads =~ $regex ]]; then echo ${BASH_REMATCH[1]}; fi

We already know the filename in the script before it does download the archive, so it should not be a big deal to implement that. Here are some example executions:


$ file="phpMyAdmin-4.3.2-all-languages.7z"; downloads=$(curl -s http://www.phpmyadmin.net/home_page/downloads.php); regex="${file}/download#\!md5\!([a-zA-Z0-9_-]+)"; if [[ $downloads =~ $regex ]]; then echo ${BASH_REMATCH[1]}; fi
1b52f5e620a191056e1c04d7ddd2c691

$ file="phpMyAdmin-4.3.2-all-languages.zip"; downloads=$(curl -s http://www.phpmyadmin.net/home_page/downloads.php); regex="${file}/download#\!md5\!([a-zA-Z0-9_-]+)"; if [[ $downloads =~ $regex ]]; then echo ${BASH_REMATCH[1]}; fi
a698f1c48fa3c21fd5bee4ff11fec96e

$ file="phpMyAdmin-4.3.2-all-languages.tar.gz"; downloads=$(curl -s http://www.phpmyadmin.net/home_page/downloads.php); regex="${file}/download#\!md5\!([a-zA-Z0-9_-]+)"; if [[ $downloads =~ $regex ]]; then echo ${BASH_REMATCH[1]}; fi
2c309c249bf17f4796f4de707b6ce25d

$ file="phpMyAdmin-4.1.14.8-all-languages.7z"; downloads=$(curl -s http://www.phpmyadmin.net/home_page/downloads.php); regex="${file}/download#\!md5\!([a-zA-Z0-9_-]+)"; if [[ $downloads =~ $regex ]]; then echo ${BASH_REMATCH[1]}; fi
3cb85189c0897f817ad59a556a427cfa

$ file="phpMyAdmin-4.1.14.8-all-languages.zip"; downloads=$(curl -s http://www.phpmyadmin.net/home_page/downloads.php); regex="${file}/download#\!md5\!([a-zA-Z0-9_-]+)"; if [[ $downloads =~ $regex ]]; then echo ${BASH_REMATCH[1]}; fi
088c80e663c6e15146ccc0dd2f13c521

$ file="phpMyAdmin-4.0.10.7-english.zip"; downloads=$(curl -s http://www.phpmyadmin.net/home_page/downloads.php); regex="${file}/download#\!md5\!([a-zA-Z0-9_-]+)"; if [[ $downloads =~ $regex ]]; then echo ${BASH_REMATCH[1]}; fi
21f7c0785ec3cbdb12f1a8e94dc25b4f

$ file="phpMyAdmin-does-not-exist-all-languages.zip"; downloads=$(curl -s http://www.phpmyadmin.net/home_page/downloads.php); regex="${file}/download#\!md5\!([a-zA-Z0-9_-]+)"; if [[ $downloads =~ $regex ]]; then echo ${BASH_REMATCH[1]}; fi

It works fine so far. If does not find any checksum, it just returns nothing.
My thoughts about verifying the checksum: (variable name is just an example)

  • If it is valid, just proceed.
  • If it is invalid and CHECKSUM_VALIDATION is 1, the scripts aborts and logs this validation error.
  • If it is invalid and the CHECKSUM_VALIDATION is 0, the script may proceed and just make a warning log output.

@stefansl
Copy link
Owner

nice one! i will check it in the next dev ... 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants