-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
In order to simplify m-c code, move some in pdf.js #12689
Conversation
calixteman
commented
Dec 3, 2020
•
edited
Loading
edited
- move set/clear|Timeout/Interval and crackURL code in pdf.js
- remove the "backdoor" in the proxy (used to dispatch event) and so return the dispatch function in the initializer
- remove listeners if an error occured during sandbox initialization
- add support for alert and prompt in the sandbox
- add a function to eval in the global scope
b96f54d
to
f028c88
Compare
3358fe2
to
40a5b73
Compare
Why is this removing the Please keep in mind that the |
9d8fb6b
to
d530836
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a quick skim and seems reasonable. I'll let @Rob--W review the parts he suggested.
d530836
to
976f0d5
Compare
I pointed out that the sandbox destruction logic wasn't called, at https://phabricator.services.mozilla.com/D91746?id=370264#inline-555164 with the ending note:
By this, I meant to call it at least twice: as part of the privileged unload handler (which always runs), and as usual from the destruction logic in PDF.js. @Snuffleupagus has already fixed the latter in #12695, so what remains is only on the m-c side (and also there already). |
976f0d5
to
715ef3d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took a while to review this because the patch is very large, with many more changes than strictly needed to provide the sandboxing functionality. The review was further complicated by the lack of documentation and references to relevant sources.
To support my review task, I composed the following list of locations that are relevant to the feature that I was asked to review (a sandbox mechanism). I also reviewed the other code since examples of actual usage is a good verification of the effectiveness of the API surrounding the sandbox.
- https://phabricator.services.mozilla.com/D91746 - patch for mozilla-central, with Firefox's implementation.
- https://github.com/mozilla/pdf.js.quickjs - PDF.js's bindings/glue for the quickjs sandbox
- In order to simplify m-c code, move some in pdf.js #12689 (this patch)
- https://github.com/mozilla/pdf.js/tree/master/src/scripting_api
- https://github.com/mozilla/pdf.js/blob/master/src/pdf.sandbox.js
There is no clear authorative reference for JavaScript in PDFs. The following are available (with an incomplete changelog).
- April 2007 - Adobe Acrobat SDK version 8.1
https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/js_api_reference.pdf - May 2015 - Adobe Acrobat DC SDK
https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/AcrobatDC_js_api_reference.pdf - HTML version of the 2015 document, e.g. specifically the
util.crackURL
method that you're adding to this patch:
https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/Acro12_MasterBook/JS_API_AcroJS/util_methods.htm
The last published reference is from 5 years ago, so they may be out of date. Interestingly, Chrome's PDF implementation has a README that references the 2007 implementation, at https://source.chromium.org/chromium/chromium/src/+/master:third_party/pdfium/fxjs/README;l=40;drc=d9d3ed281f87f706ecc442c7902abfa8ef5c4928
Could you also add a README.md to the scripting_api
repository, to allow other readers to know what you're using as the definition of the API, and how everything fits together?
68764a7
to
1504cc9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked closely at the interaction of the sandbox and quickjs, a bit at the timer, but didn't look at the rest in detail. Since there is already something actionable, I'm returning it for review now.
1504cc9
to
9a8f831
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's getting in a good shape. I do have a few comments, but the overall structure looks sane sane.
9a8f831
to
e9898ad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r+ with comments addressed.
* move set/clear|Timeout/Interval and crackURL code in pdf.js * remove the "backdoor" in the proxy (used to dispatch event) and so return the dispatch function in the initializer * remove listeners if an error occured during sandbox initialization * add support for alert and prompt in the sandbox * add a function to eval in the global scope
e9898ad
to
8bff4f1
Compare
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @calixteman received. Current queue size: 0 Live output at: http://54.67.70.0:8877/50347eb15a009eb/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @calixteman received. Current queue size: 0 Live output at: http://3.101.106.178:8877/128f561af7695f6/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.67.70.0:8877/50347eb15a009eb/output.txt Total script time: 25.78 mins
Image differences available at: http://54.67.70.0:8877/50347eb15a009eb/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://3.101.106.178:8877/128f561af7695f6/output.txt Total script time: 27.18 mins
Image differences available at: http://3.101.106.178:8877/128f561af7695f6/reftest-analyzer.html#web=eq.log |