mirror of
https://github.com/apple/pkl.git
synced 2026-01-13 15:13:38 +01:00
[Question/Issue?] Unable to read package: resource when it's included in allowed resources
#248
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @z-jxy on GitHub (Nov 13, 2024).
Version:
Pkl 0.27.0 (macOS 14.3.1, native)I maintain a binding and was requested to support for the default allowed resources from the cli (
env:,prop:,package:,projectpackage:), but ran into issues with reading packages..pkl:
Evaluating this using the cli works, but when trying to evaluate it through my binding it says the resource isn't in the allowlist
allowlist:
I was able to get this working by adding
https:to the allowed resources, but not sure why this happens if the cli's default allowed resources doesn't include it and can read it without issues.Also, in the docs, allowed resources are described as "Comma-separated list of URI patterns that determine which external resources can be read." My impression was that this was only for the
readfunction, or does this extend to other places as well? I ask because the examples I've seen for including packages is through import, so I was wondering what the use case is for the example I'm trying? Not sure if it's intended to be used a different way@bioball commented on GitHub (Nov 13, 2024):
When Pkl evals a package, it will make some HTTPS requests. When it makes these HTTPS requests, it treats them as resource reads.
BTW: it doesn't do this if the package is already cached.
@z-jxy commented on GitHub (Nov 13, 2024):
So
https:is implicitly required in the allowed resources if the package isn't cached? I'm able to read the package with onlypackage:allowed using the cli and I don't think it's cached@bioball commented on GitHub (Nov 13, 2024):
These patterns are simply regexes; you can, for example, set the allowed resource pattern as:
--allowed-resources https://pkl-lang\\.org,package://pkl-lang\\.org,prop:, and this will only allow imports frompkl-lang.org.But, yes, this is an unfortunate coupling; there's currently no easy way to say: "I want to allow packages to be eval'd, but not direct HTTPS imports/reads".
@z-jxy commented on GitHub (Nov 13, 2024):
Makes sense, that clears up my confusion. Thanks!