Ejemplo n.º 1
0
    def test_osquery_info_with_attrs(self):
        '''
        Test the results returned from the kernel_modules function
        with attributes
        '''
        _table_attrs_results = [
            'pid', 'uuid', 'instance_id', 'version', 'config_hash',
            'config_valid', 'extensions', 'build_platform', 'build_distro',
            'start_time', 'watcher'
        ]

        _os_query_results = {
            'data': [{
                'build_platform': 'ubuntu',
                'start_time': '1514484833'
            }],
            'result': True
        }

        with patch.object(osquery, '_table_attrs',
                          MagicMock(return_value=_table_attrs_results)):
            with patch.object(osquery, '_osquery',
                              MagicMock(return_value=_os_query_results)):
                with patch.dict(osquery.__grains__, {'os_family': 'Debian'}):
                    self.assertEqual(
                        osquery.osquery_info(
                            attrs=['build_platform', 'start_time']),
                        _os_query_results)
Ejemplo n.º 2
0
    def test_osquery_info_with_attrs(self):
        """
        Test the results returned from the kernel_modules function
        with attributes
        """
        _table_attrs_results = [
            "pid",
            "uuid",
            "instance_id",
            "version",
            "config_hash",
            "config_valid",
            "extensions",
            "build_platform",
            "build_distro",
            "start_time",
            "watcher",
        ]

        _os_query_results = {
            "data": [{"build_platform": "ubuntu", "start_time": "1514484833"}],
            "result": True,
        }

        with patch.object(
            osquery, "_table_attrs", MagicMock(return_value=_table_attrs_results)
        ):
            with patch.object(
                osquery, "_osquery", MagicMock(return_value=_os_query_results)
            ):
                with patch.dict(osquery.__grains__, {"os_family": "Debian"}):
                    self.assertEqual(
                        osquery.osquery_info(attrs=["build_platform", "start_time"]),
                        _os_query_results,
                    )
Ejemplo n.º 3
0
    def test_osquery_info(self):
        '''
        Test the results returned from the kernel_modules function
        with attributes
        '''
        _table_attrs_results = [
            'pid', 'uuid', 'instance_id', 'version', 'config_hash',
            'config_valid', 'extensions', 'build_platform', 'build_distro',
            'start_time', 'watcher'
        ]

        _os_query_results = {
            'data': [{
                'build_platform': 'ubuntu',
                'start_time': '1514484833',
                'uuid': 'D31FD400-7277-11E3-ABA6-B8AEED7E173B',
                'build_distro': 'xenial',
                'pid': '24288',
                'watcher': '-1',
                'instance_id': 'dff196b0-5c91-4105-962b-28660d7aa282',
                'version': '2.6.1',
                'extensions': 'inactive',
                'config_valid': '0',
                'config_hash': ''
            }],
            'result':
            True
        }

        with patch.object(osquery, '_table_attrs',
                          MagicMock(return_value=_table_attrs_results)):
            with patch.object(osquery, '_osquery',
                              MagicMock(return_value=_os_query_results)):
                with patch.dict(osquery.__grains__, {'os_family': 'Debian'}):
                    self.assertEqual(osquery.osquery_info(), _os_query_results)
Ejemplo n.º 4
0
    def test_osquery_info(self):
        """
        Test the results returned from the kernel_modules function
        with attributes
        """
        _table_attrs_results = [
            "pid",
            "uuid",
            "instance_id",
            "version",
            "config_hash",
            "config_valid",
            "extensions",
            "build_platform",
            "build_distro",
            "start_time",
            "watcher",
        ]

        _os_query_results = {
            "data": [
                {
                    "build_platform": "ubuntu",
                    "start_time": "1514484833",
                    "uuid": "D31FD400-7277-11E3-ABA6-B8AEED7E173B",
                    "build_distro": "xenial",
                    "pid": "24288",
                    "watcher": "-1",
                    "instance_id": "dff196b0-5c91-4105-962b-28660d7aa282",
                    "version": "2.6.1",
                    "extensions": "inactive",
                    "config_valid": "0",
                    "config_hash": "",
                }
            ],
            "result": True,
        }

        with patch.object(
            osquery, "_table_attrs", MagicMock(return_value=_table_attrs_results)
        ):
            with patch.object(
                osquery, "_osquery", MagicMock(return_value=_os_query_results)
            ):
                with patch.dict(osquery.__grains__, {"os_family": "Debian"}):
                    self.assertEqual(osquery.osquery_info(), _os_query_results)