Secure-Compliance-Solutions-LLC / GVM-Docker

Greenbone Vulnerability Management Docker Image with OpenVAS
https://securecompliance.gitbook.io/projects/
MIT License
249 stars 91 forks source link

[FAQ] How to integrate with CI? #289

Closed tranphuquy19 closed 3 years ago

tranphuquy19 commented 3 years ago

I wanna configure a Gitlab CI pipeline that can run a scheduled job that can launch an OpenVAS container and perform a scan of a subnet or set of subnets that I define.

How can I do that, Is there a guide for that?

Please help me, thanks a lot!

Dexus commented 3 years ago

Sure, this is not a big problem, you only need to build a shell script that checks the feeds and create tasks.

Von meinem iPhone gesendet

Am 13.10.2021 um 11:54 schrieb どら猫-Doraneko @.***>:

 I wanna configure a Gitlab CI pipeline that can run a scheduled job that can launch an OpenVAS container and perform a scan of a subnet or set of subnets that I define.

How can I do that, Is there a guide for that?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

tranphuquy19 commented 3 years ago

Do you have any examples of that? Should I install gvm-tools and run some commands like gvm-cli tls --xml "<create_target><name>Suspect Host</name><hosts>"$IPADDRESS"</hosts>< /create_target>" or something like that in my script?

Dexus commented 3 years ago

That’s right! You need to use the credentials and run the command in the container.

How I would do it:

  1. create the xml in an host temp dir.
  2. start the container with the volume where the xml files are in.
  3. wait for the feeds synced. (Xml)
  4. create the target (xml) and run the CLI in the container
  5. create the task (xml) and run the CLI in the container
  6. create the start task (xml) and run the CLI in the container
  7. check until the task has status 100(%) (xml) and run the CLI in the container
  8. get the report (xml) and run the CLI in the container
  9. stop the Container

Von meinem iPhone gesendet

Am 13.10.2021 um 13:11 schrieb どら猫-Doraneko @.***>:

 Do you have any examples of that? Should I install gvm-tools and run some commands like gvm-cli tls --xml "Suspect Host"$IPADDRESS"< /create_target>" or something like that in my script?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

tranphuquy19 commented 3 years ago

I ran the below command inside the container as user gvm and I got this error. Looks like I didn't use the credentials as you said. How can I fix it?

$ gvm-cli  --gmp-username admin --gmp-password admin tls --hostname=localhost --xml '<get_tasks/>'
ERROR:gvmtools.cli:Response Error 400. Only command GET_VERSION is allowed before AUTHENTICATE
Dexus commented 3 years ago

The question is which image you use and if the container is ready ( all services at running state ). Then the get_feeds xml is the first thing that need to be checked. You can find a example in one of the Tickets that are closed….

Von meinem iPhone gesendet

Am 13.10.2021 um 16:40 schrieb どら猫-Doraneko @.***>:

 I ran the below command inside the container as user gvm and I got this error. Looks like I didn't use the credentials as you said. How can I fix it?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

tranphuquy19 commented 3 years ago

Right, I checked the services managed by supervisord and they are running. I ran the command get_feeds xml, but it returns the same error. Of course, I waited long enough for the data to sync (>5 hours)

$ gvm-cli  --gmp-username admin --gmp-password admin tls --xml '<get_feeds/>'
ERROR:gvmtools.cli:Response Error 400. Only command GET_VERSION is allowed before AUTHENTICATE

I found a similar issue here https://github.com/Secure-Compliance-Solutions-LLC/GVM-Docker/issues/281#issuecomment-932337725

Dexus commented 3 years ago

Which image/tag you are using?

Von meinem iPhone gesendet

Am 13.10.2021 um 17:10 schrieb どら猫-Doraneko @.***>:

 Right, I checked the services managed by supervisord and they are running. I ran the command get_feeds xml, but it returns the same error. Of course, I waited long enough for the data to sync (>5 hours)

$ gvm-cli --gmp-username admin --gmp-password admin tls --xml '' ERROR:gvmtools.cli:Response Error 400. Only command GET_VERSION is allowed before AUTHENTICATE I found a similar issue here #281 (comment)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

tranphuquy19 commented 3 years ago

I just built the image from master branch and copied the apk-builds artifacts from this repo GVM-APK-build.

BTW, I added a target and created a task to scan on the web UI. Everything seems to be working as expected.

Dexus commented 3 years ago

Did you set the password on container run command? If not the default will be adminpassword

Von meinem iPhone gesendet

Am 13.10.2021 um 17:22 schrieb どら猫-Doraneko @.***>:

 I just built the image from master branch and copy the apk-builds artifacts from this repo GVM-APK-build.

BTW, I added a target and created a task to scan on the web UI. Everything seems to be working as expected.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

tranphuquy19 commented 3 years ago

Yes, I did. Here is my run command

docker run -d \
    -p 8080:9392 -p 5432:5432 -p 2222:22 \
    -e DB_PASSWORD="admin" -e PASSWORD="admin" -e SSHD=true \
    --volume ./storage/postgres-db:/opt/database \
    --volume ./storage/openvas-plugins:/var/lib/openvas/plugins \
    --volume ./storage/gvm:/var/lib/gvm \
    --volume ./storage/ssh:/etc/ssh \
    --name gvm \
    securecompliance/gvm
tranphuquy19 commented 3 years ago

I decided to use python-gvm to remote the GVM container over a TLS connection, and it worked. I close this ticket. Thanks for your help!