Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calls for getting CDB lists #301

Merged
merged 12 commits into from
Feb 1, 2019
Merged

Calls for getting CDB lists #301

merged 12 commits into from
Feb 1, 2019

Conversation

druizz90
Copy link
Contributor

Hi team,

This PR is for adding new calls for getting CDB lists (issue #298). Below there are some examples of these new calls.

  • curl -u foo:bar -k -X GET "http://127.0.0.1:55000/lists:
# curl -u foo:bar -k -X GET "http://127.0.0.1:55000/lists?pretty&offset=1&limit=3"
{
   "error": 0,
   "data": {
      "totalItems": 3,
      "items": [
         {
            "path": "etc/lists/amazon/aws-test",
            "items": [
               {
                  "key": "AttachLoadBalancers",
                  "value": "Autoscaling"
               },
               {
                  "key": "DetachLoadBalancers",
                  "value": "Autoscaling"
               },
               {
                  "key": "CreateSubnet",
                  "value": "Legacy Wazuh CDB"
               },
               {
                  "key": "CreateTags",
                  "value": "Legacy Wazuh CDB"
               },
               {
                  "key": "CreateVolume",
                  "value": "Legacy Wazuh CDB"
               },
               {
                  "key": "DeletePlacementGroup",
                  "value": "Legacy Wazuh CDB"
               }
            ]
         },
         {
            "path": "etc/lists/audit-keys",
            "items": [
               {
                  "key": "audit-wazuh-w",
                  "value": "write"
               },
               {
                  "key": "audit-wazuh-r",
                  "value": "read"
               },
               {
                  "key": "audit-wazuh-a",
                  "value": "attribute"
               },
               {
                  "key": "audit-wazuh-x",
                  "value": "execute"
               },
               {
                  "key": "audit-wazuh-c",
                  "value": "command"
               }
            ]
         },
         {
            "path": "etc/lists/aa-test-list",
            "items": [
               {
                  "key": "test-wazuh-w",
                  "value": "write"
               },
               {
                  "key": "test-wazuh-r",
                  "value": "read"
               },
               {
                  "key": "test-wazuh-a",
                  "value": "attribute"
               },
               {
                  "key": "test-wazuh-x",
                  "value": "execute"
               },
               {
                  "key": "test-wazuh-c",
                  "value": "command"
               }
            ]
         }
      ]
   }
}
# curl -u foo:bar -k -X GET "http://127.0.0.1:55000/lists?pretty&search=audit"
{
   "error": 0,
   "data": {
      "totalItems": 1,
      "items": [
         {
            "path": "etc/lists/audit-keys",
            "items": [
               {
                  "key": "audit-wazuh-w",
                  "value": "write"
               },
               {
                  "key": "audit-wazuh-r",
                  "value": "read"
               },
               {
                  "key": "audit-wazuh-a",
                  "value": "attribute"
               },
               {
                  "key": "audit-wazuh-x",
                  "value": "execute"
               },
               {
                  "key": "audit-wazuh-c",
                  "value": "command"
               }
            ]
         }
      ]
   }
}
# curl -u foo:bar -k -X GET "http://127.0.0.1:55000/lists?pretty&search=aws&offset=1"
{
   "error": 0,
   "data": {
      "totalItems": 1,
      "items": [
         {
            "path": "etc/lists/amazon/aws-test",
            "items": [
               {
                  "key": "AttachLoadBalancers",
                  "value": "Autoscaling"
               },
               {
                  "key": "DetachLoadBalancers",
                  "value": "Autoscaling"
               },
               {
                  "key": "CreateSubnet",
                  "value": "Legacy Wazuh CDB"
               },
               {
                  "key": "CreateTags",
                  "value": "Legacy Wazuh CDB"
               },
               {
                  "key": "CreateVolume",
                  "value": "Legacy Wazuh CDB"
               },
               {
                  "key": "DeletePlacementGroup",
                  "value": "Legacy Wazuh CDB"
               }
            ]
         }
      ]
   }
}
# curl -u foo:bar -k -X GET "http://127.0.0.1:55000/lists?pretty&offset=2" 
{
   "error": 0,
   "data": {
      "totalItems": 2,
      "items": [
         {
            "path": "etc/lists/audit-keys",
            "items": [
               {
                  "key": "audit-wazuh-w",
                  "value": "write"
               },
               {
                  "key": "audit-wazuh-r",
                  "value": "read"
               },
               {
                  "key": "audit-wazuh-a",
                  "value": "attribute"
               },
               {
                  "key": "audit-wazuh-x",
                  "value": "execute"
               },
               {
                  "key": "audit-wazuh-c",
                  "value": "command"
               }
            ]
         },
         {
            "path": "etc/lists/aa-test-list",
            "items": [
               {
                  "key": "test-wazuh-w",
                  "value": "write"
               },
               {
                  "key": "test-wazuh-r",
                  "value": "read"
               },
               {
                  "key": "test-wazuh-a",
                  "value": "attribute"
               },
               {
                  "key": "test-wazuh-x",
                  "value": "execute"
               },
               {
                  "key": "test-wazuh-c",
                  "value": "command"
               }
            ]
         }
      ]
   }
}
# curl -u foo:bar -k -X GET "http://127.0.0.1:55000/lists?pretty&offset=2&limit=1"
{
   "error": 0,
   "data": {
      "totalItems": 1,
      "items": [
         {
            "path": "etc/lists/audit-keys",
            "items": [
               {
                  "key": "audit-wazuh-w",
                  "value": "write"
               },
               {
                  "key": "audit-wazuh-r",
                  "value": "read"
               },
               {
                  "key": "audit-wazuh-a",
                  "value": "attribute"
               },
               {
                  "key": "audit-wazuh-x",
                  "value": "execute"
               },
               {
                  "key": "audit-wazuh-c",
                  "value": "command"
               }
            ]
         }
      ]
   }
}
# curl -u foo:bar -k -X GET "http://127.0.0.1:55000/lists?pretty&offset=2&limit=2&sort=path" 
{
   "error": 0,
   "data": {
      "totalItems": 2,
      "items": [
         {
            "path": "etc/lists/aa-test-list",
            "items": [
               {
                  "key": "test-wazuh-w",
                  "value": "write"
               },
               {
                  "key": "test-wazuh-r",
                  "value": "read"
               },
               {
                  "key": "test-wazuh-a",
                  "value": "attribute"
               },
               {
                  "key": "test-wazuh-x",
                  "value": "execute"
               },
               {
                  "key": "test-wazuh-c",
                  "value": "command"
               }
            ]
         },
         {
            "path": "etc/lists/audit-keys",
            "items": [
               {
                  "key": "audit-wazuh-w",
                  "value": "write"
               },
               {
                  "key": "audit-wazuh-r",
                  "value": "read"
               },
               {
                  "key": "audit-wazuh-a",
                  "value": "attribute"
               },
               {
                  "key": "audit-wazuh-x",
                  "value": "execute"
               },
               {
                  "key": "audit-wazuh-c",
                  "value": "command"
               }
            ]
         }
      ]
   }
}
curl -u foo:bar -k -X GET "http://127.0.0.1:55000/lists?pretty&offset=2&limit=2&sort=-path"
{
   "error": 0,
   "data": {
      "totalItems": 2,
      "items": [
         {
            "path": "etc/lists/audit-keys",
            "items": [
               {
                  "key": "audit-wazuh-w",
                  "value": "write"
               },
               {
                  "key": "audit-wazuh-r",
                  "value": "read"
               },
               {
                  "key": "audit-wazuh-a",
                  "value": "attribute"
               },
               {
                  "key": "audit-wazuh-x",
                  "value": "execute"
               },
               {
                  "key": "audit-wazuh-c",
                  "value": "command"
               }
            ]
         },
         {
            "path": "etc/lists/aa-test-list",
            "items": [
               {
                  "key": "test-wazuh-w",
                  "value": "write"
               },
               {
                  "key": "test-wazuh-r",
                  "value": "read"
               },
               {
                  "key": "test-wazuh-a",
                  "value": "attribute"
               },
               {
                  "key": "test-wazuh-x",
                  "value": "execute"
               },
               {
                  "key": "test-wazuh-c",
                  "value": "command"
               }
            ]
         }
      ]
   }
}
  • curl -u foo:bar -k -X GET "http://127.0.0.1:55000/lists/files:
# curl -u foo:bar -k -X GET "http://127.0.0.1:55000/lists/files?pretty"
{
   "error": 0,
   "data": [
      {
         "path": "/var/ossec/etc/lists/amazon",
         "name": "aws-eventnames"
      },
      {
         "path": "/var/ossec/etc/lists/amazon",
         "name": "aws-test"
      },
      {
         "path": "/var/ossec/etc/lists",
         "name": "audit-keys"
      },
      {
         "path": "/var/ossec/etc/lists",
         "name": "aa-test-list"
      }
   ]
}

Best regards,

Demetrio.

@crd1985
Copy link
Contributor

crd1985 commented Jan 29, 2019

Hi!
In the last example, I would prefer not to show the full paths.
Thx!

@druizz90
Copy link
Contributor Author

Hi,

I made changes for showing relative paths in the output:

# curl -u foo:bar -k -X GET "http://127.0.0.1:55000/lists?pretty&offset=1&limit=2&sort=-path"
{
   "error": 0,
   "data": {
      "totalItems": 2,
      "items": [
         {
            "path": "etc/lists/audit-keys",
            "items": [
               {
                  "key": "audit-wazuh-w",
                  "value": "write"
               },
               {
                  "key": "audit-wazuh-r",
                  "value": "read"
               },
               {
                  "key": "audit-wazuh-a",
                  "value": "attribute"
               },
               {
                  "key": "audit-wazuh-x",
                  "value": "execute"
               },
               {
                  "key": "audit-wazuh-c",
                  "value": "command"
               }
            ]
         },
         {
            "path": "etc/lists/amazon/aws-test",
            "items": [
               {
                  "key": "AttachLoadBalancers",
                  "value": "Autoscaling"
               },
               {
                  "key": "DetachLoadBalancers",
                  "value": "Autoscaling"
               },
               {
                  "key": "CreateSubnet",
                  "value": "Legacy Wazuh CDB"
               },
               {
                  "key": "CreateTags",
                  "value": "Legacy Wazuh CDB"
               },
               {
                  "key": "CreateVolume",
                  "value": "Legacy Wazuh CDB"
               },
               {
                  "key": "DeletePlacementGroup",
                  "value": "Legacy Wazuh CDB"
               }
            ]
         }
      ]
   }
}
curl -u foo:bar -k -X GET "http://127.0.0.1:55000/lists/files?pretty"                         
{
   "error": 0,
   "data": [
      {
         "path": "etc/lists/amazon",
         "name": "aws-eventnames"
      },
      {
         "path": "etc/lists/amazon",
         "name": "aws-test"
      },
      {
         "path": "etc/lists",
         "name": "audit-keys"
      },
      {
         "path": "etc/lists",
         "name": "aa-test-list"
      }
   ]
}

@crd1985
Copy link
Contributor

crd1985 commented Jan 29, 2019

I miss this new endpoint to be added to mocha tests.

@druizz90
Copy link
Contributor Author

Mocha tests were added @crd1985!

Copy link
Contributor

@crd1985 crd1985 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me everything is ok.
Thx!

@crd1985
Copy link
Contributor

crd1985 commented Jan 31, 2019

Merging blocked by wazuh/wazuh#2481

@crd1985 crd1985 merged commit 9b0bdc1 into 3.9 Feb 1, 2019
@crd1985 crd1985 deleted the dev-api-cdb-lists branch February 1, 2019 16:22
@crd1985 crd1985 mentioned this pull request Feb 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants