monero-project / monero-site

https://getmonero.org
BSD 3-Clause "New" or "Revised" License
275 stars 384 forks source link

validate filenames in hashes.txt #2050

Closed plowsof closed 2 years ago

plowsof commented 2 years ago

added "workflows:" to commit title and removed typo from comments

netlify[bot] commented 2 years ago

Deploy Preview for barolo-time-757cf9 ready!

Built without sensitive environment variables

Name Link
Latest commit 37ff97fdf860e7d8d194b88968cb6777fd0ccdfa
Latest deploy log https://app.netlify.com/sites/barolo-time-757cf9/deploys/632f9b28521e580009eee8d8
Deploy Preview https://deploy-preview-2050--barolo-time-757cf9.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

binaryFate commented 2 years ago

Thanks for this! Can you explain the format assumed for hashes.txt? CLI before GUI? Constant number of lines? Order of the binaries in each section? etc. And what would we need to change if we add or remove a certain binary in the future? If we change an extension?

plowsof commented 2 years ago

Apologies for no description @binaryFate , it was late when i submitted (i need to review it myself). After brainstorming with @selsta , the line numbers of filenames are fixed. when the script reads hashes.txt line by line, here is what it sees (what it expects (CLI / GUI) + line number and the value) -> we expect to see CLI lines between lines 2-13

CLI Line Number: 2
Line: monero-android-armv7-v0.18.1.1.tar.bz2
CLI Line Number: 3
Line: monero-android-armv8-v0.18.1.1.tar.bz2
CLI Line Number: 4
Line: monero-freebsd-x64-v0.18.1.1.tar.bz2
CLI Line Number: 5
Line: monero-linux-armv7-v0.18.1.1.tar.bz2
CLI Line Number: 6
Line: monero-linux-armv8-v0.18.1.1.tar.bz2
CLI Line Number: 7
Line: monero-linux-x64-v0.18.1.1.tar.bz2
CLI Line Number: 8
Line: monero-linux-x86-v0.18.1.1.tar.bz2
CLI Line Number: 9
Line: monero-mac-armv8-v0.18.1.1.tar.bz2
CLI Line Number: 10
Line: monero-mac-x64-v0.18.1.1.tar.bz2
CLI Line Number: 11
Line: monero-win-x64-v0.18.1.1.zip
CLI Line Number: 12
Line: monero-win-x86-v0.18.1.1.zip
CLI Line Number: 13
Line: monero-source-v0.18.1.1.tar.bz2
GUI Line Number: 14
Line: monero-gui-install-win-x64-v0.18.1.1.exe
GUI Line Number: 15
Line: monero-gui-linux-x64-v0.18.1.1.tar.bz2
GUI Line Number: 16
Line: monero-gui-mac-x64-v0.18.1.1.dmg
GUI Line Number: 17
Line: monero-gui-win-x64-v0.18.1.1.zip
GUI Line Number: 18

CLI first , then GUI (the line number is deceptive because its not parsing comments) - if a new file is added, then the if loop that checks that the line number is less than / greater than would be expanded by 1.

Specific order (inside the CLI/GUI sections) is not required, the check at the end is just "is this filename in the list of hardcoded values"

A new file or alternate extension will have to be added to the hardcoded list of 'filenames and extensions we expect to see' which is what cli_files and gui_files is.

Let me know if you want specific mistakes to be tested, it catches quite a lot

binaryFate commented 2 years ago

Super, that's clear, thank you.