You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Node.js has a carve-out for hashbangs/shebangs at the top of an executable file. This is not valid JS syntax, and as such, SES does not approve.
In @lavamoat/node I had to evade this, but it may be applicable to @endo/evasive-transform at some point.
Example transform (naive):
/** * Hashbangs seem to offend SES. * * @param {string} source * @returns {string} */constdecapitateHashbang=(source)=>{// careful with the source mapreturnsource.replace(/^#!(.+?)(?=\r?\n)/,'// $1')}
This replaces the #! with //, essentially. It could be rewritten without a RegExp, assuming that hashbangs must always be #!/path/to/some/executable [args] at position 0 in a file. I don't know if that's true, so, either I will need to do my own research or someone can drop science here. I don't know if [args] is actually just [arg], either.
I do know that Node.js will allow hashbangs in files that are not the "main" module; you can require() such a file.
The text was updated successfully, but these errors were encountered:
I think it's makes more sense to to do an evasive transform like you have, transforming from #! to // in the limited cases where allowed (which I believe is beginning of source text). I would like to avoid different evaluators for Function and eval, which we'd otherwise require if we were to allow it in SES itself.
Node.js has a carve-out for hashbangs/shebangs at the top of an executable file. This is not valid JS syntax, and as such, SES does not approve.
In
@lavamoat/node
I had to evade this, but it may be applicable to@endo/evasive-transform
at some point.Example transform (naive):
This replaces the
#!
with//
, essentially. It could be rewritten without aRegExp
, assuming that hashbangs must always be#!/path/to/some/executable [args]
at position 0 in a file. I don't know if that's true, so, either I will need to do my own research or someone can drop science here. I don't know if[args]
is actually just[arg]
, either.I do know that Node.js will allow hashbangs in files that are not the "main" module; you can
require()
such a file.The text was updated successfully, but these errors were encountered: