Open thaining opened 1 year ago
Check out this dump utility. I'm sure you can tweak the logic for your needs. Buttercup 'a' format is a little messy, but 'b' format is just nested JSON: https://github.com/fkasler/butterbrute/blob/main/dump_vault.mjs
Code in the README.md to read Vault content does not work as suggested in NodeJS.
The README suggests that following code sample should work:
This hits two problems. The first problem is with the integrity of the
datasourceCredentials
. Running the above snippet withnode
and a valid buttercup file produces the following error duringload()
:This appears to be cause of imprecise use of copy-by-sharing in the
TextDatasource
constructor:restrictPurposes()
modifies an object called by reference, not a private copy. The object only has a 'secure-export' purpose, which causesfileDatasource.load()
to fail.An ugly workaround is to create another copy of the object.
This reveals a second error:
This occurs because of how
TextDataSource.load()
eventually returns theVault()
history:It's returning an anonymous object, not a DatasourceLoadedData. The compiled javascript sees this as single returned object with
history
andFormat
members. Theundefined
Format member passed back byload()
is tolerated bycreateFromHistory()
, but the object passed in is not a valid History. Execution fails as soon as that non-History object is used.vault.format
in my case resolves to VaultFormatA, and_executeCommand()
does not know what to do with it.I'm not much of a typescript writer, but I tried compiling a typescript version of the snippet. The compiler recognized the same problem immediately:
Doing this resolves the issue for NodeJS: