Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect if ses is being transformed #662

Open
Tracked by #12
kumavis opened this issue Apr 9, 2021 · 2 comments
Open
Tracked by #12

Detect if ses is being transformed #662

kumavis opened this issue Apr 9, 2021 · 2 comments
Labels
confinement Pertaining to confinement of guest programs. kriskowal-review-2024-01 Issues that kriskowal wants to bring to the attention of the team for review as of January, 2024

Comments

@kumavis
Copy link
Member

kumavis commented Apr 9, 2021

it would be helpful for debugging if there were some heuristics for checking if the ses dists were being transformed, as in #659

even being woefully imperfect, this check can be useful by logging a warning or error suggesting that a transform might have taken place.

one common thing that is easy to check is if async functions are being transformed to non-async functions.

here is an example of the transformation.

original:

const testResult = Object.getPrototypeOf(async function AsyncFunctionInstance() {}) === Function.prototype
//=> normally false, but true after transformation

after transformation:

var testResult = Object.getPrototypeOf(function AsyncFunctionInstance() {
  return regeneratorRuntime.async(function AsyncFunctionInstance$(_context) {
    while (1) {
      switch (_context.prev = _context.next) {
        case 0:
        case "end":
          return _context.stop();
      }
    }
  }, null, null, null, Promise);
}) === Function.prototype;
//=> true

note that the transformed async function has a prototype of Function.prototype. we could throw an error suggesting that the code might have been transformed.

@dckc
Copy link
Contributor

dckc commented Apr 22, 2021

...

one common thing that is easy to check is if async functions are being transformed to non-async functions.

Any chance you can go back about a month or two and add that before I/we spent umpteen hours debugging that situation?

;-)

That is: yes, let's please do. Good idea.

@erights erights added the confinement Pertaining to confinement of guest programs. label Jun 25, 2021
@erights
Copy link
Contributor

erights commented Jun 25, 2021

Added the security label because such unexpected translation is also a security hazard, and detecting it sometimes would reduce this hazard.

@kriskowal kriskowal added the kriskowal-review-2024-01 Issues that kriskowal wants to bring to the attention of the team for review as of January, 2024 label Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confinement Pertaining to confinement of guest programs. kriskowal-review-2024-01 Issues that kriskowal wants to bring to the attention of the team for review as of January, 2024
Projects
None yet
Development

No branches or pull requests

4 participants