oxsecurity / megalinter

🦙 MegaLinter analyzes 50 languages, 22 formats, 21 tooling formats, excessive copy-pastes, spelling mistakes and security issues in your repository sources with a GitHub Action, other CI tools or locally.
https://megalinter.io
GNU Affero General Public License v3.0
1.88k stars 223 forks source link

Making outbound network requests by default is very surprising behavior #3737

Closed mbyio closed 1 month ago

mbyio commented 1 month ago

Describe the bug

I was testing out megalinter on a project for the first time. I got it running correctly in GitHub Actions... and then when "lychee" ran, I was shocked to see it making what look like real HTTP requests to any links it finds in the codebase.

I think it misinterpreted the contents of some integration tests, which use recorded HTTP sessions with some private APIs. Fortunately, the APIs do require authentication, and the keys aren't stored in the codebase, so all the requests failed with 403.

This is shocking default behavior for a linter. Typically a linter is only checking your code, maybe downloading a few extra dependencies to help it check. It is not typical for a linter to make HTTP requests like this.

I really think this is a mistake that could cause big problems for some people. What if they are logged into a VPN, run MegaLinter locally, and it makes requests to some internal service? Even if the requests are blocked due to missing credentials, if there are a lot of links then it could slam the service with requests, or it could trigger rate limiting.

To Reproduce Steps to reproduce the behavior:

  1. Use the default settings (except for setting the env vars VALIDATE_ALL_CODEBASE=true and APPLY_FIXES=all)
  2. Run mega linter
  3. See your life flash before your eyes when it makes requests to internal APIs

Expected behavior Don't follow external links, or ask the user before following them, or warn the user that the link checker is "opt in".

nvuillam commented 1 month ago

hi @mbyio ,

Don't be shocked for so little, it's bad for your heart :)

Checking urls is indeed the default behavior of lychee lnter

If you want to skip some checks, you can:

Lychee doc in MegaLinter: https://megalinter.io/latest/descriptors/spell_lychee/