def cli_probe(args): try: disable_log() kwargs = {} if args.type == 'dcp': kwargs['kdm'] = args.kdm kwargs['pkey'] = args.key obj_type = package_type_map[args.type] res = obj_type(args.path, **kwargs).parse() if args.format == "dict": msg = pprint.pformat(res) elif args.format == "json": msg = json.dumps( res, sort_keys=True, indent=2, separators=(',', ': ')) elif args.format == "xml": xml_str = dicttoxml.dicttoxml( res, custom_root='ClairmetaProbe', ids=False, attr_type=False) msg = prettyprint_xml(xml_str) return True, msg except Exception as e: return False, "Error : {}".format(e)
def cli_check(args): try: if args.type == 'dcp': check_profile = DCP_CHECK_PROFILE callback = None if args.profile: path = os.path.abspath(args.profile) check_profile = load_profile(path) if args.log: check_profile['log_level'] = args.log if args.progress: callback = ConsoleProgress() if args.format != 'text': disable_log() status, report = DCP(args.path, kdm=args.kdm, pkey=args.key).check(profile=check_profile, ov_path=args.ov, hash_callback=callback) if args.format == "dict": msg = pprint.pformat(report.to_dict()) elif args.format == "json": msg = json.dumps(report.to_dict(), sort_keys=True, indent=2, separators=(',', ': ')) elif args.format == "xml": xml_str = dicttoxml.dicttoxml(report.to_dict(), custom_root='ClairmetaCheck', ids=False, attr_type=False) msg = prettyprint_xml(xml_str) if args.format != 'text': return True, msg else: obj_type = package_type_map[args.type] setting = package_check_settings[args.type] status = obj_type(args.path).check(setting) except Exception as e: status = False print("Error : {}".format(e)) msg = "{} - {} - Check {}".format(args.type.upper(), args.path, "succeeded" if status else "failed") return status, msg
def cli_probe(args): try: disable_log() obj_type = package_type_map[args.type] res = obj_type(args.path).parse() if args.format == "dict": return pprint.pformat(res) elif args.format == "json": return json.dumps(res, sort_keys=True, indent=2, separators=(',', ': ')) elif args.format == "xml": xml_str = dicttoxml.dicttoxml(res, custom_root='ClairmetaProbe', ids=False, attr_type=False) return prettyprint_xml(xml_str) except Exception as e: print('Error : ' + str(e), file=sys.stderr)
def __init__(self, *args, **kwargs): super(CheckerTestBase, self).__init__(*args, **kwargs) disable_log() self.profile = get_default_profile()
def __init__(self, *args, **kwargs): super(CliTest, self).__init__(*args, **kwargs) disable_log()
def __init__(self, *args, **kwargs): super(SequenceTestBase, self).__init__(*args, **kwargs) disable_log()
def __init__(self, *args, **kwargs): super(ParserTestBase, self).__init__(*args, **kwargs) disable_log()
def __init__(self, *args, **kwargs): super(CheckerTestBase, self).__init__(*args, **kwargs) disable_log() self.profile = get_default_profile() self.profile['bypass'] = ['check_assets_pkl_hash']