Add installer hashes to info.json - #1327
Conversation
| "build_outputs": { | ||
| "default": [], | ||
| "description": "Additional artifacts to be produced after building the installer. It expects either a list of strings or single-key dictionaries.\nAllowed strings / keys: `hash`, `info.json`, `licenses`, `lockfile`, `pkgs_list`.", | ||
| "description": "Additional artifacts to be produced after building the installer. It expects either a list of strings or single-key dictionaries.\nRequesting `info.json` adds an `_installer_hashes` property containing the SHA256 digest of the generated installer. Hash algorithms requested through a `hash` build output are also included in this property.\nFor example:\n```json\n\"_installer_hashes\": {\n \"sha256\": \"...\",\n \"md5\": \"...\"\n}\n```\nThe `hash` output continues to create separate checksum files.\nAllowed strings / keys: `hash`, `info.json`, `licenses`, `lockfile`, `pkgs_list`.", |
There was a problem hiding this comment.
I wonder if we should not mention this here. I do think the information per say is good but as far as I can see we dont have any place right now explaining the contents of info.json - because of this it seems out of place.
There was a problem hiding this comment.
Should I remove the whole thing or just the hardcoded example? I thought this was a good place because we do list info.json as an option in the schema here. However, I could see how my addition could be a little too detailed.
There was a problem hiding this comment.
I'd say remove the whole thing.
| algorithms = set(algorithms) | ||
| invalid = algorithms.difference(hashlib.algorithms_available) | ||
| if invalid: | ||
| raise ValueError(f"Invalid algorithm: {', '.join(sorted(invalid))}") |
There was a problem hiding this comment.
These needs to be singular/plural based on len(invalid).
| if invalid: | ||
| raise ValueError(f"Invalid algorithm: {', '.join(sorted(invalid))}") | ||
|
|
||
| BUFFER_SIZE = 65536 |
There was a problem hiding this comment.
Whats the rationale here for changing to 64KB instead of 256KB (262144 below)?
There was a problem hiding this comment.
I didn't change it. I only copied over what was already in build_outputs.py here. With that being said, if it should be changed to 262144 instead, then just let me know. 😃
| @@ -0,0 +1,19 @@ | |||
| ### Enhancements | |||
|
|
|||
| * Add installer hashes to `info.json` making it the single source of truth for installer checksums used in SBOM generation. (#1327) | |||
There was a problem hiding this comment.
| * Add installer hashes to `info.json` making it the single source of truth for installer checksums used in SBOM generation. (#1327) | |
| * Add installer hashes to `info.json` making it the single source of truth for installer checksums. (#1327) |
I propose that we skip the last part since in theory users don't need to know the connection to SBOM generation.
| if isinstance(algorithm, str): | ||
| algorithms.add(algorithm) | ||
| elif algorithm: | ||
| algorithms.update(algorithm) |
There was a problem hiding this comment.
We need to validate that the hash algorithms are valid. It looks like that part of the code got removed.
There was a problem hiding this comment.
It didn't get removed completely. It got moved here.
There was a problem hiding this comment.
Ah, yes, thanks for pointing that out! It looks like the test catching that ValueError got removed though, so we are missing some test coverage.
| outpath = Path(f"{installer}.{algo}") | ||
|
|
||
| with open(outpath, "w", newline="\n") as f: | ||
| f.write(f"{info['_installer_hashes'][algo]} {installer.name}\n") |
There was a problem hiding this comment.
This should have a guard to make sure we don't have an uncaught exception here. That way, we can have a more meaningful error message.
Co-authored-by: Robin <34315751+lrandersson@users.noreply.github.com>
Description
Adds installer hashes to info.json so downstream tooling can use it as a single source of truth for installer checksums.
Changes:
Test expectations:
Checklist - did you ...
newsdirectory (using the template) for the next release's release notes?