tenable / terrascan

Detect compliance and security violations across Infrastructure as Code to mitigate risk before provisioning cloud native infrastructure.
https://runterrascan.io
Apache License 2.0
4.69k stars 496 forks source link

Failed to initialize terrascan. error : could not connect to github.com #1241

Open SayaliMane05 opened 2 years ago

SayaliMane05 commented 2 years ago

Description

Running 'terrascan init' or 'terrascan scan' command yields following error - 2022-05-09T07:55:24.311+0300 error cli/init.go:42 failed to initialize terrascan. error : could not connect to github.com

What I Did

Downloaded and installed terrascan in a Dockerfile. Then while running scan or running terrascan init in a pipeline job, getting this error - 2022-05-09T07:55:24.311+0300 error cli/init.go:42 failed to initialize terrascan. error : could not connect to github.com

patilpankaj212 commented 2 years ago

Hello @SayaliMane05, I couldn't reproduce this issue with the latest version. It is possible that GitHub wasn't reachable at the time you performed init. Could you please try to reproduce again? Let us know if you are still facing this issue.

SayaliMane05 commented 2 years ago

Hello @patilpankaj212 , I tried this multiple times. Still getting the same error. What could be the reason for this error? Do we need to install anything (any packages etc) along with Terrascan?

patilpankaj212 commented 2 years ago

No, we don't need to install anything for terrascan to perform the init operation. When the init command is run, it clones the terrascan github repo to $USER_HOME/.terrascan on the users machine. So, when init is run, the machine should be connected to internet and github should be reachable.

SayaliMane05 commented 2 years ago

Okay @patilpankaj212 Thanks for the help. I'll check again why it's failing

sydneyscoffield commented 2 years ago

I am getting the same error. I am attempting to use the tenable/terrascan docker image from hub.docker.com in my gitlab-ci.yml file and whenever I run any of the terrascan commands, I get this error:

Screen Shot 2022-08-25 at 8 49 55 AM

This is what my .gitlab-ci.yml file looks like. I got this method from the documentation. Screen Shot 2022-08-25 at 8 52 39 AM

I am using a GitLab shared runner and its a kubernetes executor. I'm not sure if that's the problem or a bug with the container but I would really like to be able to use this image with my GitLab job.

kverstr commented 1 year ago

Does anyone know where it tries to connect to on github.com? For us github.com will only be opened on certain context-paths but terrascan is not logging the specifics.

Kr

ana-cdc commented 11 months ago

Commenting to say I am also having this issue.

terrascan version: v1.18.3 OS: MacOS Ventura 13.6

mmraz commented 1 week ago

I had this problem because our corporate firewall blocks SSH on port 22. The git@github.com: urls use SSH and we're required to use https git urls instead. Added the following configuration step in our CI job before running terrascan init

git config --global url."https://github.com/".insteadOf git@github.com: