wazuh / wazuh-api

Wazuh - RESTful API
https://wazuh.com
GNU General Public License v2.0
69 stars 57 forks source link

Fix bad input validation regex for q param #359

Closed crd1985 closed 5 years ago

crd1985 commented 5 years ago

This PR closes #358 .

After applying the patch, now the behaviour is the expected one:

root@00dfc6dbc0ec:/wazuh-api# curl -u foo:bar "localhost:55000/agents?q=(status=Active,status=Disconnected);os.platform=ubuntu&pretty"
{
   "error": 0,
   "data": {
      "items": [
         {
            "os": {
               "arch": "x86_64",
               "codename": "Bionic Beaver",
               "major": "18",
               "minor": "04",
               "name": "Ubuntu",
               "platform": "ubuntu",
               "uname": "Linux |00dfc6dbc0ec |4.15.0-43-generic |#46-Ubuntu SMP Thu Dec 6 14:45:28 UTC 2018 |x86_64",
               "version": "18.04.1 LTS"
            },
            "id": "000",
            "node_name": "master-node",
            "dateAdd": "2019-03-27 15:48:25",
            "status": "Active",
            "lastKeepAlive": "9999-12-31 23:59:59",
            "ip": "127.0.0.1",
            "name": "00dfc6dbc0ec",
            "version": "Wazuh v3.9.0",
            "manager": "00dfc6dbc0ec",
            "registerIP": "127.0.0.1"
         },
         {
            "os": {
               "arch": "x86_64",
               "codename": "Bionic Beaver",
               "major": "18",
               "minor": "04",
               "name": "Ubuntu",
               "platform": "ubuntu",
               "uname": "Linux |fed867ff3505 |4.15.0-43-generic |#46-Ubuntu SMP Thu Dec 6 14:45:28 UTC 2018 |x86_64",
               "version": "18.04.1 LTS"
            },
            "id": "001",
            "node_name": "master-node",
            "dateAdd": "2019-03-27 15:53:51",
            "configSum": "ab73af41699f13fdd81903b5f23d8d00",
            "status": "Active",
            "lastKeepAlive": "2019-03-27 15:57:23",
            "ip": "172.20.0.3",
            "group": [
               "default"
            ],
            "mergedSum": "c6309ff81a74781f6b55b68129a76738",
            "name": "fed867ff3505",
            "version": "Wazuh v3.8.2",
            "manager": "00dfc6dbc0ec",
            "registerIP": "172.20.0.3"
         },
         {
            "os": {
               "arch": "x86_64",
               "codename": "Bionic Beaver",
               "major": "18",
               "minor": "04",
               "name": "Ubuntu",
               "platform": "ubuntu",
               "uname": "Linux |ec56b8232d01 |4.15.0-43-generic |#46-Ubuntu SMP Thu Dec 6 14:45:28 UTC 2018 |x86_64",
               "version": "18.04.1 LTS"
            },
            "id": "002",
            "node_name": "worker2",
            "dateAdd": "2019-03-27 15:53:58",
            "configSum": "ab73af41699f13fdd81903b5f23d8d00",
            "status": "Active",
            "lastKeepAlive": "2019-03-27 15:57:20",
            "ip": "172.20.0.6",
            "group": [
               "default"
            ],
            "mergedSum": "c6309ff81a74781f6b55b68129a76738",
            "name": "ec56b8232d01",
            "version": "Wazuh v3.8.2",
            "manager": "90ee1ec46762",
            "registerIP": "172.20.0.6"
         },
         {
            "os": {
               "arch": "x86_64",
               "codename": "Bionic Beaver",
               "major": "18",
               "minor": "04",
               "name": "Ubuntu",
               "platform": "ubuntu",
               "uname": "Linux |684893c9f9b9 |4.15.0-43-generic |#46-Ubuntu SMP Thu Dec 6 14:45:28 UTC 2018 |x86_64",
               "version": "18.04.1 LTS"
            },
            "id": "003",
            "node_name": "worker1",
            "dateAdd": "2019-03-27 15:53:58",
            "configSum": "ab73af41699f13fdd81903b5f23d8d00",
            "status": "Active",
            "lastKeepAlive": "2019-03-27 15:57:11",
            "ip": "172.20.0.7",
            "group": [
               "default"
            ],
            "mergedSum": "c6309ff81a74781f6b55b68129a76738",
            "name": "684893c9f9b9",
            "version": "Wazuh v3.8.2",
            "manager": "38733ec7c51b",
            "registerIP": "172.20.0.7"
         }
      ],
      "totalItems": 4
   }
}