Secure-Compliance-Solutions-LLC / GVM-Docker

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

[SOLVED] Alert with Send to Host method get Failed to run alert #101

Closed wetrywebhook closed 4 years ago

wetrywebhook commented 4 years ago

In openvas, we possible to send scan report via send to host method. It will send our report to expected IP/address with specified port

this is my alert setting (it's my local docker IP at virtualbox, its ok for example) image

but it always get "Failed to run alert" when triggered the alert.

How to reproduce: get any report for example, and trigger this button image

and we will get this error message after press the OK button image

This is logs from my alert image There's no informative logs for this issue, so I have no clue for this bug

Additional context This is some details from my container with master commit 44cc8d9 from https://github.com/Secure-Compliance-Solutions-LLC/GVM-Docker image

[
    {
        "Id": "ad6d3358e7e62c535bc29c19132f6f3f20eb2473c897f72a521cdd040111c6c9",
        "Created": "2020-10-23T06:35:50.587804604Z",
        "Path": "/bin/sh",
        "Args": [
            "-c",
            "'/start.sh'"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 9609,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2020-10-23T06:35:51.399403935Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:0c1fbc08e582746b504d086f4c568df0e6cdb5c1f9100957fb2373210be1ec0e",
        "ResolvConfPath": "/var/lib/docker/containers/ad6d3358e7e62c535bc29c19132f6f3f20eb2473c897f72a521cdd040111c6c9/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/ad6d3358e7e62c535bc29c19132f6f3f20eb2473c897f72a521cdd040111c6c9/hostname",
        "HostsPath": "/var/lib/docker/containers/ad6d3358e7e62c535bc29c19132f6f3f20eb2473c897f72a521cdd040111c6c9/hosts",
        "LogPath": "/var/lib/docker/containers/ad6d3358e7e62c535bc29c19132f6f3f20eb2473c897f72a521cdd040111c6c9/ad6d3358e7e62c535bc29c19132f6f3f20eb2473c897f72a521cdd040111c6c9-json.log",
        "Name": "/gvm2",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "docker-default",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "gvm-data:/data"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {
                "9392/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "443"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "Capabilities": null,
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": [],
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "KernelMemory": 0,
            "KernelMemoryTCP": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/476a040caceb73e37e1c75939c2efa30b86d7114691cdc413063d3778f76b4ff-init/diff:/var/lib/docker/overlay2/8332407a4da6a7f4be3a7fb7e0c0c302e3b07dad365f285885b0e4b05c6a6984/diff:/var/lib/docker/overlay2/b37e795d3cd7da364755e04508735b59d7d4c5123808fb5e482da4d332127a23/diff:/var/lib/docker/overlay2/5a6a3266a5c990f867edff776f917745d80bb58f30ef98e9c2a000a4fb443a60/diff:/var/lib/docker/overlay2/f3f084015d8784a627c9ccefa360cb5cb91ec7492956c23cca9fe5d6d0cc13f0/diff:/var/lib/docker/overlay2/83e872bc6a6bdc6f4fa12ab8ef37731555246663a76cb2f528737f154ceae4cd/diff:/var/lib/docker/overlay2/389e25f19532c8facaa57ea91aa6d6094ea3963350c1b05b5cef12218b8cc72e/diff:/var/lib/docker/overlay2/7496dff77e54c6d533bb8cabdd33b4214308a80e0fc24f7865180b8320985729/diff:/var/lib/docker/overlay2/cc8e6d6daa178bbde4050b64fc425a3f641b6aeda388248fa5017b4d35049a12/diff:/var/lib/docker/overlay2/253b2db1db64ceb6bb03e6138b228c20da5a6aed3a9061c03f6b06a1270c522f/diff:/var/lib/docker/overlay2/2015a720723c84d43cbe2bf1e297da29a05f6eec073cce2ded20f91c435489ea/diff:/var/lib/docker/overlay2/8169787222ff43f71dda44a7e1c7b6cc5e283dd721430634a3e9352a199ab6be/diff:/var/lib/docker/overlay2/50a55eb83dd906038a52d9d5ae98965688e8d2ba9f7550028bb726d689085b23/diff:/var/lib/docker/overlay2/563cf01ed98b5064e7d50d55d90cc81d35475052020a68c204ec253e278f42e4/diff:/var/lib/docker/overlay2/ba3599506c963d463c39db23fcf50818b86d6e93c1fb6cdf4bb6222abd7a5388/diff:/var/lib/docker/overlay2/03956aa331a17ebc9639f0786c9296cb48fec87650db2d59e19f7ba5602d9d25/diff:/var/lib/docker/overlay2/8929b0460d66afbb939864cd185939592371b48bfc94a07b7f8fcb09132d3e4e/diff:/var/lib/docker/overlay2/c46d4ce835276696feff3cdacc1ec461379faa3bcd0fbdde70958d751936467a/diff:/var/lib/docker/overlay2/30bcc260b80d9f69a02b12d0d72b076d4a749b79e537e0dd4c1d333b5a949afc/diff:/var/lib/docker/overlay2/3a7ba7896e827ad05e461668d67042d5b333d66d524c4f01a6619ed6c18e94b7/diff",
                "MergedDir": "/var/lib/docker/overlay2/476a040caceb73e37e1c75939c2efa30b86d7114691cdc413063d3778f76b4ff/merged",
                "UpperDir": "/var/lib/docker/overlay2/476a040caceb73e37e1c75939c2efa30b86d7114691cdc413063d3778f76b4ff/diff",
                "WorkDir": "/var/lib/docker/overlay2/476a040caceb73e37e1c75939c2efa30b86d7114691cdc413063d3778f76b4ff/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [
            {
                "Type": "volume",
                "Name": "gvm-data",
                "Source": "/var/lib/docker/volumes/gvm-data/_data",
                "Destination": "/data",
                "Driver": "local",
                "Mode": "z",
                "RW": true,
                "Propagation": ""
            }
        ],
        "Config": {
            "Hostname": "ad6d3358e7e6",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "65221/tcp": {},
                "9392/tcp": {}
            },
            "Tty": true,
            "OpenStdin": true,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "DEBIAN_FRONTEND=noninteractive",
                "LANG=C.UTF-8",
                "gvm_libs_version=v20.8.0",
                "openvas_scanner_version=v20.8.0",
                "gvmd_version=v20.8.0",
                "gsa_version=v20.8.0",
                "gvm_tools_version=2.1.0",
                "openvas_smb=v1.0.5",
                "open_scanner_protocol_daemon=v20.8.1",
                "ospd_openvas=v20.8.0",
                "python_gvm_version=1.6.0"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "'/start.sh'"
            ],
            "Image": "securecompliance/gvm:master",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {}
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "f65f73c47844c22755a1d95ae92335a0b144a4ea3e68f5d8dca75cb980f92c46",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "65221/tcp": null,
                "9392/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "443"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/f65f73c47844",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "9731b54f2f1b0ded0f6e68c7859a9de5c51bf3007a59e90ecc0ea970c3a32343",
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.2",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:02",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "cc5f939fd79da59c726b3ba9970b7e9a92812e67c6abd7210115bddd12f12435",
                    "EndpointID": "9731b54f2f1b0ded0f6e68c7859a9de5c51bf3007a59e90ecc0ea970c3a32343",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:**redacted**:02",
                    "DriverOpts": null
                }
            }
        }
    }
]
wetrywebhook commented 4 years ago

[SOLVED] image

Based on https://github.com/greenbone/gvmd/blob/master/src/alert_methods/Send/alert we need to add socat when install the ubuntu package

cat $3 | socat -t 0 - TCP:$1:$2
EXIT_CODE=$?
exit $EXIT_CODE

if you have installed openvas on your device/system, just exec to your container and do: apt-get install update apt-get install socat