Esempio n. 1
0
def _get_violation_events(sieve, input_auth, attributes, indent):
	try:
		auth = _process_auth_list(input_auth, indent)
	except json.decoder.JSONDecodeError as e:
		raise USBRipError(
			'Failed to decode authorized device list (JSON)',
			errors={'initial_error': str(e)}
		)

	if not attributes:
		attributes = auth.keys()

	ue = USBEvents()
	if not ue:
		return None

	for event in ue._all_events:
		try:
			if any(event[key] not in vals and
                   event[key] is not None
                   for key, vals in zip(attributes, auth.values())):
				ue._violations.append(event)
		except KeyError as e:
			raise USBRipError(
				'No such attribute in authorized device list',
				errors={'initial_error': str(e)}
			)

	return _filter_events(ue._violations, sieve)
Esempio n. 2
0
def _get_history_events(sieve):
	ue = USBEvents()
	if not ue:
		return None

	return _filter_events(ue._all_events, sieve)