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

Use of eval is strongly discouraged #112

Open
autoferrit opened this issue Aug 24, 2020 · 4 comments
Open

Use of eval is strongly discouraged #112

autoferrit opened this issue Aug 24, 2020 · 4 comments

Comments

@autoferrit
Copy link

I installed gray-matter to use with svelte/sapper, and once I did, I started getting this error message in my console.

> sapper dev

✔ client (1.0s)
✔ service worker (1.7s)
• server
Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification
41:         str = '(function() {\nreturn ' + str.trim() + ';\n}());';
42:       }
43:       return eval(str) || {};
                 ^
44:     } catch (err) {
45:       if (wrap !== false && /(unexpected|identifier)/i.test(err.message)) {
> Listening on http://localhost:3000

The app still seems to work. But is there a way I can silence this? Or is there a way to do the same thing without using eval? As using it definitely can be a security risk.

@robertmassaioli
Copy link
Collaborator

The only way that a security issue could arise is if:

  1. You used the javascript engine. AND
  2. You let people using your service provide that input into gray-matter.

I'm not sure if there is another way to do what that engine does without eval since the purpose of the engine seems to be "evaluate javascript". I'll let @jonschlinkert comment further.

@jonschlinkert
Copy link
Owner

jonschlinkert commented Aug 25, 2020

@robertmassaioli is correct. This is an opt-in feature. I don’t see how anyone would be able to abuse this unless you intentionally let them.

@ghost
Copy link

ghost commented Aug 25, 2020

@autoferrit, I end up using Front-matter.

@autoferrit
Copy link
Author

Yea, that makes sense. Is there a configuration to be able to hide this?

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

No branches or pull requests

3 participants