endojs / endo

Endo is a distributed secure JavaScript sandbox, based on SES
Apache License 2.0
829 stars 72 forks source link

Implement an `isPassable` that does not rely on try/catch. #2096

Open erights opened 8 months ago

erights commented 8 months ago

@agoric/base-zone has an implementation of isPassable that emulates the proper behavior using a try/catch to turn the thrown failure of passStyleOf into a return false;.

As of https://github.com/endojs/endo/pull/2042 , that is duplicated into @endo/pass-style , as a first step of migrating isPassable from @agoric/base-zone into @endo/pass-style. Once synced, we should also delete the one in @agoric/base-zone and change its users to import from @endo/pass-style instead.

passStyleOf should be rewritten into the form of our other checkFoo functions to take a Checker argument, so it can be used to create either an assertPassable that throws or an isPassable that never throws but rather returns false iff assertPassable would have thrown. passStyleOf would then be like assertPassable except that the success case also returns a string.

This will require a significant refactoring of passStyleOf, which is already performance critical, so we'll need to be careful.