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

feat: add --enable-api-filtering-logging command-line switch #20335

Merged
merged 1 commit into from Oct 4, 2019

Conversation

miniak
Copy link
Contributor

@miniak miniak commented Sep 24, 2019

Description of Change

Add --enable-api-filtering-logging command-line switch, which enables caller stack logging for the following APIs (filtering events):

  • desktopCapturer.getSources() / desktop-capturer-get-sources
  • remote.require() / remote-require
  • remote.getGlobal() / remote-get-builtin
  • remote.getBuiltin() / remote-get-global
  • remote.getCurrentWindow() / remote-get-current-window
  • remote.getCurrentWebContents() / remote-get-current-web-contents
  • remote.getGuestWebContents() / remote-get-guest-web-contents

Checklist

Release Notes

Notes: Added --enable-api-filtering-logging command-line switch, which enables caller stack logging for desktopCapturer and remote APIs that can be blocked or filtered.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Sep 24, 2019
@miniak miniak force-pushed the miniak/filtering-event-stacks branch 3 times, most recently from 2bac259 to 6f6b515 Compare September 24, 2019 15:01
@miniak miniak changed the title feat: add ELECTRON_ENABLE_FILTERING_EVENT_STACKS environment variable feat: add ELECTRON_ENABLE_API_FILTERING_STACKS environment variable Sep 24, 2019
@miniak miniak force-pushed the miniak/filtering-event-stacks branch from 6f6b515 to 39c0d15 Compare September 24, 2019 15:15
@miniak miniak marked this pull request as ready for review September 24, 2019 15:17
@miniak miniak self-assigned this Sep 24, 2019
@miniak miniak force-pushed the miniak/filtering-event-stacks branch from 39c0d15 to a24ba9c Compare September 24, 2019 15:34
@MarshallOfSound
Copy link
Member

I feel as though there is a cleaner and less impactful implementation out there for this.

What if we captures the trace inside ipcRenderer.send and attached it to the event object itself. I.e. event.senderStackTrace?

@miniak
Copy link
Contributor Author

miniak commented Sep 24, 2019

@MarshallOfSound that seems quite intrusive as well, @nornagon what do you think?

Copy link
Member

@nornagon nornagon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An environment variable doesn't seem like the right way to expose this functionality.

What problem are you trying to solve?

@miniak
Copy link
Contributor Author

miniak commented Sep 25, 2019

@nornagon when blocking the remote module, sometimes it's hard to figure out where it's being used from. especially when the renderer process is sandboxed, the preload script cannot be debugged easily to see where the exception is thrown.

I didn't want to make the stack available by default as I was concerned about the performance impact.

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Sep 25, 2019
@zcbenz
Copy link
Member

zcbenz commented Oct 1, 2019

From past experience it is generally bad idea to change API's behavior with environment variables.

@miniak
Copy link
Contributor Author

miniak commented Oct 1, 2019

@zcbenz I agree with that. My concern is the performance impact of always capturing the stack traces if it's not optional.

@miniak
Copy link
Contributor Author

miniak commented Oct 1, 2019

@zcbenz what about not changing the API, but just logging the call stacks when the variable is set?

@miniak miniak force-pushed the miniak/filtering-event-stacks branch from a24ba9c to bb07519 Compare October 1, 2019 16:49
@miniak miniak changed the title feat: add ELECTRON_ENABLE_API_FILTERING_STACKS environment variable feat: add ELECTRON_ENABLE_API_FILTERING_LOGGING environment variable Oct 1, 2019
@miniak miniak requested a review from nornagon October 1, 2019 16:54
@miniak miniak force-pushed the miniak/filtering-event-stacks branch 3 times, most recently from 1d68619 to c549bb1 Compare October 1, 2019 17:24
@miniak miniak changed the title feat: add ELECTRON_ENABLE_API_FILTERING_LOGGING environment variable feat: add --enable-api-filtering-logging commandline switch Oct 1, 2019
@miniak miniak changed the title feat: add --enable-api-filtering-logging commandline switch feat: add --enable-api-filtering-logging command-line switch Oct 1, 2019
@miniak miniak force-pushed the miniak/filtering-event-stacks branch from c549bb1 to 1c75a40 Compare October 1, 2019 17:33
Copy link
Member

@zcbenz zcbenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good with current approach.

lib/renderer/api/remote.js Outdated Show resolved Hide resolved
@miniak miniak force-pushed the miniak/filtering-event-stacks branch 3 times, most recently from 94b34f1 to c052cea Compare October 3, 2019 15:10
@miniak miniak force-pushed the miniak/filtering-event-stacks branch from c052cea to d6823d6 Compare October 4, 2019 16:21
@miniak
Copy link
Contributor Author

miniak commented Oct 4, 2019

@nornagon modified getCurrentStack as suggested, should be ready to land

@nornagon nornagon merged commit ccff140 into master Oct 4, 2019
@release-clerk
Copy link

release-clerk bot commented Oct 4, 2019

Release Notes Persisted

Added --enable-api-filtering-logging command-line switch, which enables caller stack logging for desktopCapturer and remote APIs that can be blocked or filtered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants