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

add ember-no-implicit-this-codemod #20

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kellyselden
Copy link
Member

@kellyselden kellyselden commented Aug 18, 2019

Closes #19

cc @NullVoxPopuli

@kellyselden kellyselden changed the title add ember-no-implicit-this-codemod WIP add ember-no-implicit-this-codemod Aug 18, 2019
manifest.json Outdated
},
"projectOptions": ["app", "addon"],
"nodeVersion": "8.0.0",
"script": "const cp = require('child_process'); let ps = cp.spawn('ember', ['s']); let url = await new Promise(resolve => { ps.stdout.on('data', data => { let str = data.toString(); let matches = str.match(/^Build successful \\(\\d+ms\\) – Serving on (.*)$/m); if (matches) { resolve(matches[1]); } }); }); cp.execSync(`npx ember-no-implicit-this-codemod ${url} app/`); ps.kill(); await new Promise(resolve => { ps.on('exit', resolve); });"
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems risky :-\

Copy link
Member Author

Choose a reason for hiding this comment

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

elaborate please

Copy link
Contributor

Choose a reason for hiding this comment

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

just that having a bunch of node stored as a string implies that this'll be eval'd somewhere, and I know that eval can lead to vulnerabilities.

Makes me wonder if the codemods should distribute interactive bins that ember-cli-update invokes -- that way each codemod could be responsible for instructing the user how to set things up. idk

Copy link
Member Author

Choose a reason for hiding this comment

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

I did this to help protect kellyselden/boilerplate-update#125

But in the long run, there isn't too much difference between eval and npx, both download code and execute.

Copy link
Member

Choose a reason for hiding this comment

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

Well, in this case it is embedding eval and npx 😸. Two semi-risky things seems strictly worse than one no?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm torn. I know there is risk associated with eval, but I don't think there is much additional risk here. My thoughts:

  • The dangers of eval are mostly for people concatenating strings from user input, much like SQL injection. The strings in this case are under our control and don't take user input.
  • I use the Function contructor instead of eval described here.
  • So the attack vector seems to be a compromised GitHub account, which seems as likely as a compromised NPM account.

Please correct me if I'm wrong. Am I naive?

@kellyselden kellyselden force-pushed the ember-no-implicit-this-codemod branch 3 times, most recently from 26a97ce to 1df5c06 Compare August 24, 2019 12:34
@rwjblue
Copy link
Member

rwjblue commented Oct 10, 2019

I think we should refactor how this works in general, each codemod booting the app is going to get bonkers pretty quickly. The list of codemods that want telemetry data is going to continue growing (its very important for a number of the current/pressing use cases). Imagine your app has a boot time of ~45seconds, you are incurring that cost for each codemod, the overall runtime quickly gets high.

We should probably consider grouping the codemods that need a running app in this manifest file, and having the host process that runs through them boot the app for us. Then the only thing that would be needed is to interpolate the port number for invocation.

@kellyselden kellyselden mentioned this pull request Oct 10, 2019
2 tasks
@kellyselden kellyselden force-pushed the ember-no-implicit-this-codemod branch 3 times, most recently from 447599c to 2cfa118 Compare November 18, 2019 13:45
@kellyselden kellyselden changed the title WIP add ember-no-implicit-this-codemod add ember-no-implicit-this-codemod Nov 18, 2019
@kellyselden
Copy link
Member Author

@kellyselden kellyselden force-pushed the ember-no-implicit-this-codemod branch 2 times, most recently from 46e5122 to 00ff5ee Compare December 17, 2019 15:24
@kellyselden kellyselden changed the base branch from v3 to v4 January 11, 2020 16:09
@kellyselden kellyselden force-pushed the ember-no-implicit-this-codemod branch 2 times, most recently from 5a0dec5 to 6db120c Compare January 11, 2020 17:39
@kellyselden kellyselden changed the base branch from v4 to master January 14, 2020 11:16
@kellyselden kellyselden force-pushed the ember-no-implicit-this-codemod branch 4 times, most recently from 89e1ba2 to 91d8cae Compare January 14, 2020 18:25
@kellyselden kellyselden force-pushed the ember-no-implicit-this-codemod branch 2 times, most recently from 557d7c8 to 24e787a Compare January 14, 2020 22:00
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

3 participants