Open bep opened 1 year ago
just store version information + file hashes and then download the correct architecture when needed.
Agree. This is what the Scoop, Chocolatey, and Snap packages for Embedded Dart Sass do.
@jmooring can I borrow your attention for a minute. I have a working prototype of this running and, as usual, I'm a little paranoid about security. After a little testing I have concluded that having the user do PATH fiddling to make this work, isn't ... great. So with what I have now I use abs paths to the "imported" binaries, and this should be enough to get Dart Sass:
[[module.imports]]
path="github.com/gohugoio/hugo-mod-bin-dartsass"
The SHA56 of the downloaded archive (stored in the Hugo Module) is checked on installation.
The one thing I'm a little worried about then is someone creating a fake Hugo Module with a fake dartsass binary. A little far fetched, perhaps, but to improve on this I have added a new whitelist to the security config: AllowBinFromModules: "^github.com/gohugoio/"
-- thinking that most such binaries will be hosted by us, and we can be trusted.
What do you think?
Some links:
Thoughts, in no particular order...
AllowBinFromModules: "^github.com/gohugoio/"
, without the ability to override via site configuration or env vars? You and I export env vars from our .bashrc
files or whatever to make sure that, when we clone a project, we're not exposed when the cloned project overrides the default security config. But I think this is rare; I would be surprised if more than a handful of users have configured their systems this way.Finally, and please be don't be offended, but it seems like installing Go is a little more complicated than using a package manager, assuming they've already installed the package manager, which many have not, so maybe requiring Go is OK.
And a couple of FYI's:
The Sass team changed the Embedded Dart Sass packaging for Linux. So manual installation is now like Windows:
dart-sass-embedded (script) --> dart (exec) --> dart-sass-embedded.snapshot
This change can break existing CI/CD deployments. I've updated the Netlify instructions in this forum post.
There's also this: https://www.npmjs.com/package/sass-embedded
npm i sass-embedded
It is platform aware. Not sure you want to go down that path, but we do have precedence with POSTCSS.
HUGO_CACHEDIR
-- the installation of these should be both fast and reproducible and it would be great if it could join the same --gc
regime of the file cache etc.I'm not totally sure I'm able to land this issue anytime soon, but I appreciate your feedback.
Thinking a little more on this, I'll let this be as it is for now:
npm i
; we could probably get by this with a hugo install
command or something.)The way 0.114.0 works with the new Dart Sass packaging is truly outstanding; kudos! Does this in any way suggest a path to resolving this particular issue (and/or https://github.com/gohugoio/hugo/issues/8299), or is it of no value in that regard?
Edit, 2023-06-23: Actually, on the other hand, @jmooring has now made an excellent argument against further worrying about this.
Dart Sass with Hugo is incredibly powerful, but it's also a pain to install. #8299 has been stranded because 1. Go doesn't have a way of doing this built-in and 2. Building a custom solution would be a challenge to do securely.
This proposal outlines a way to do this. This is deliberately a little vague about the details.
HUGOBIN
env var. The user (or installation script) would be responsible to add this folder to thePATH
.binary
component type which would allow mounting of files into thisHUGOBIN
folder.Since GitHub releases is separated from the Git repo, we need to somehow wrap these binaries in a module somehow:
The above should