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

CodeNarcServer should listen on localhost only #56

Closed
maurofaccenda opened this issue Jun 23, 2020 · 12 comments · Fixed by #59
Closed

CodeNarcServer should listen on localhost only #56

maurofaccenda opened this issue Jun 23, 2020 · 12 comments · Fixed by #59
Assignees

Comments

@maurofaccenda
Copy link

Hi, I believe for security reasons, by default the server should listen on localhost only. Listening on any interface could unnecessarily expose the users' system.

@nvuillam
Copy link
Owner

This is totally true, and whereas the risk to have someone force the linting of groovy files from outside is low, this is a problem that should be solved.
npm-groovy-lint v1 was using local socket connection, but it didn't work on mac and linux, that's why i used "open" port so that every computer was compliant.
I see you forked the repo, are you working on it, or should I add that to my todo list ? 😅

@nvuillam
Copy link
Owner

This is the solution i initially implemented but was not mac/linux compliant

https://stackoverflow.com/questions/50770747/how-to-configure-com-sun-net-httpserver-to-accept-only-requests-from-localhost

@maurofaccenda
Copy link
Author

maurofaccenda commented Jun 24, 2020

On my scenario, the computer have policies that doesn't allow any process to listen on any 'external' network interface. So the CodeNarcServer fails to run. To overcome that locally, I've changed the options.js to use http://127.0.0.1 as default serverhost.

That probably would work on any system (I tested on Mac), except if it has IPv4 disabled (if that's the case it should use http://::1). It could work on both cases if we use http://localhost. But I didn't try.

If you want to find a better approach, I am willing to try on both Mac and Linux and make sure it works. :)

@maurofaccenda
Copy link
Author

I see you forked the repo, are you working on it, or should I add that to my todo list ? 😅

I'm no JS dev. But I if the suggestion I've made just before works for you, I can create a PR.

Btw, I forgot to thank you for the projects, I've been looking for something like that for quite some time :)

@nvuillam
Copy link
Owner

I'll try to make such update in a beta version and ask you to try :)

I have CI on Windows & Linux, but for mac CircleCI is paying so your help will be welcome :)

@nvuillam
Copy link
Owner

I tried an update and it seems to be ok on Windows and Linux

Please can you try the following, and confirm that :

  • it works :)
  • CodeNarcServer is called and performances are not impacted compared to current released version
npm install -g npm-groovy-lint@5.2.0-beta.0
npm-groovy-lint --killserver
npm-groovy-lint

Many thanks :)

@nvuillam
Copy link
Owner

@maurofaccenda , any news ? :)

@nvuillam nvuillam self-assigned this Jun 30, 2020
@maurofaccenda
Copy link
Author

@nvuillam hey. i've really busy this week. i'll give it a try as soon as i can get some spare time to try it (my work env -- where i have a mac -- is really strict, so it takes some effort to run stuff like this). i'll give a shout as soon as possible.

@nvuillam
Copy link
Owner

nvuillam commented Jun 30, 2020 via email

@maurofaccenda
Copy link
Author

I've managed to test. It worked out of the box. But it seem to listen on all interfaces (0.0.0.0:7484).

nvuillam added a commit that referenced this issue Jul 1, 2020
@nvuillam
Copy link
Owner

nvuillam commented Jul 1, 2020

Thanks for your test ! It works on Windows & Linux too, so ... let's have a leap of faith :)

I implemented https://stackoverflow.com/questions/50770747/how-to-configure-com-sun-net-httpserver-to-accept-only-requests-from-localhost , 4 likes for the answer, and the author seems to be a java expert and has a very high reputation on stackexchange (best 0.01%) so let's trust him :D

It seems that listen != accept, so even if it listens to maybe more than localhost, it will accept only from localhost

But if you hear of a stronger way, don't hesitate to reopen the issue :)

@nvuillam
Copy link
Owner

nvuillam commented Jul 1, 2020

Published in v5.4.0 :)

nvuillam added a commit to nvuillam/vscode-groovy-lint that referenced this issue Jul 1, 2020
- Upgrade to [npm-groovy-lint](https://www.npmjs.com/package/npm-groovy-lint) v5.4.1
  - CodeNarcServer listens to localhost only [(#59)](nvuillam/npm-groovy-lint#59) solving [(#56)](nvuillam/npm-groovy-lint#56)
nvuillam added a commit to nvuillam/vscode-groovy-lint that referenced this issue Jul 1, 2020
- Upgrade to [npm-groovy-lint](https://www.npmjs.com/package/npm-groovy-lint) v5.4.1
  - CodeNarcServer listens to localhost only [(#59)](nvuillam/npm-groovy-lint#59) solving [(#56)](nvuillam/npm-groovy-lint#56)
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 a pull request may close this issue.

2 participants