| 1435 | return dimensions |
| 1436 | |
| 1437 | def execute(self, params, **kwargs): |
| 1438 | load_syslog_templates(params) |
| 1439 | |
| 1440 | def normalize_param(param_value): |
| 1441 | """Convert single values to lists to maintain consistent processing""" |
| 1442 | if param_value is None: |
| 1443 | return None |
| 1444 | if isinstance(param_value, str): |
| 1445 | return [param_value] |
| 1446 | elif isinstance(param_value, list): |
| 1447 | return param_value |
| 1448 | else: |
| 1449 | return [param_value] |
| 1450 | |
| 1451 | list_params = ['event_type', 'username', 'to_username', 'record_uid', 'shared_folder_uid', 'ip_address', 'aggregate'] |
| 1452 | for param in list_params: |
| 1453 | if param in kwargs and kwargs[param] is not None: |
| 1454 | kwargs[param] = normalize_param(kwargs[param]) |
| 1455 | |
| 1456 | if kwargs.get('syntax_help'): |
| 1457 | logging.info(audit_report_description) |
| 1458 | if kwargs.get('syntax_help'): |
| 1459 | events = AuditReportCommand.load_audit_dimension(params, 'audit_event_type') |
| 1460 | event_types = [(et['id'], et['name']) for et in events] |
| 1461 | logging.info('The following are possible event type id and event type name values:') |
| 1462 | for event_id, event_name in event_types: |
| 1463 | logging.info('{0:>10d}: {1}'.format(event_id, event_name)) |
| 1464 | return |
| 1465 | |
| 1466 | has_aram = True |
| 1467 | licenses = params.enterprise.get('licenses') |
| 1468 | if isinstance(licenses, list) and licenses: |
| 1469 | has_aram = any((True for x in licenses[0].get('add_ons', []) |
| 1470 | if x.get('name') == 'enterprise_audit_and_reporting')) |
| 1471 | |
| 1472 | patterns = kwargs.get('pattern', '') |
| 1473 | use_regex = kwargs.get('regex', False) |
| 1474 | match_all = kwargs.get('match_all', False) |
| 1475 | report_type = kwargs.get('report_type', 'raw') |
| 1476 | if report_type == 'dim': |
| 1477 | columns = kwargs['columns'] |
| 1478 | if not isinstance(columns, list): |
| 1479 | raise CommandError('audit-report', "'columns' parameter is missing") |
| 1480 | for column in columns: |
| 1481 | dimension = AuditReportCommand.load_audit_dimension(params, column) |
| 1482 | if dimension: |
| 1483 | table = [] |
| 1484 | if column == 'audit_event_type': |
| 1485 | fields = ['id', 'name', 'category', 'syslog'] |
| 1486 | elif column == 'keeper_version': |
| 1487 | fields = ['version_id', 'type_name', 'version', 'type_category'] |
| 1488 | elif column == 'ip_address': |
| 1489 | fields = ['ip_address', 'city', 'region', 'country_code'] |
| 1490 | elif column == 'geo_location': |
| 1491 | fields = ['geo_location', 'city', 'region', 'country_code', 'ip_count'] |
| 1492 | elif column == 'device_type': |
| 1493 | fields = ['type_name', 'type_category'] |
| 1494 | else: |