Open gbirman opened 8 months ago
Hi @gbirman thanks for filing the issue! This is a bug in the std
provider. I'll move the the issue to the provider repo
std.filebase64sha256
should have the same behaviour from terraform and this currently is not the case. To repro:
touch test.txt
with content hi
terraform console
to start up an interactive sessionfilebase64sha256("test.txt")
will return j0NDRmSPa5bfid2pAcUXaxCm2Dlh3TwayItZstwyeqQ=
If you have a look at the values that are base64 encoded it becomes obvious what's happening.
$ echo "OGY0MzQzNDY2NDhmNmI5NmRmODlkZGE5MDFjNTE3NmIxMGE2ZDgzOTYxZGQzYzFhYzg4YjU5YjJkYzMyN2FhNA==" | base64 -d
8f434346648f6b96df89dda901c5176b10a6d83961dd3c1ac88b59b2dc327aa4
$ echo "j0NDRmSPa5bfid2pAcUXaxCm2Dlh3TwayItZstwyeqQ=" | base64 -d | xxd -p
8f434346648f6b96df89dda901c5176b10a6d83961dd3c1ac88b59b2dc32
7aa4
So awkwardly filebase64sha256 seems to base64 encode the hex value of the hash, while the others base64 encode the binary value. Probably a bit of a tricky thing to fix as well because of backwards compatibility.
What happened?
I'm noticing some strange behavior with
std.filebase64sha256
where it doesn't seem to be reading the file contents properly, or at least outputs a completely different value than expected. Please see below.Example
To illustrate the differences I created a file named
text
with the contentshi
. Here are three different ways of setting the hash.Here is the output:
As you can see the file hash is different from the content/nodejs hash, which are equivalent. The file hash is also outputting 88 characters instead of the expected 44 characters for a base64 encoded sha256.
Output of
pulumi about
Additional context
No response
Contributing
Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).