benbjohnson / benbjohnson/hashfs

Allow this package to help with populating the integrity attribute

Open
#8 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
385
Forks
15
PR merge metrics
No merged PRs in 30d

Description

Thank you for this open source project, nice and focussed! Though, I would argue that package is in the perfect position to help developers to populate the "integrity" attribute: https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity. But currently it doesn't seem possible to get access to the raw hash to format a string in the way the integrity attribute expects.

If there is interest in this I can contribute an implementation for this, the following approaches would be possible
1. Create a method `fs.Integrity(name)` that simply returns a value for the integrity attribute. It might be too closely tied to this specific use case
2. Create a method that allows arbitrary formatting something like `Sprintf(name, format, ...args)`, "format" argument could be a string with formatting directives and args would always include the hash. But ordering could be awkward, and this seems to magical
3. Simply have a method that returns the raw hash: `fs.HashOf(name)`, the caller can use the hash in whatever way they like.

Let me know what you think

Contributor guide

No contributing guide indexed for this repository

Research direction

No file, test, or entry point is named. First resolve whether the package should expose an SRI-formatted value, a formatting API, or the raw hash, then identify the relevant hashfs implementation and define tests for the selected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.