コード例 #1
0
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)
コード例 #2
0
ファイル: cli.py プロジェクト: remia/ClairMeta
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
コード例 #3
0
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)
コード例 #4
0
 def __init__(self, *args, **kwargs):
     super(CheckerTestBase, self).__init__(*args, **kwargs)
     disable_log()
     self.profile = get_default_profile()
コード例 #5
0
 def __init__(self, *args, **kwargs):
     super(CliTest, self).__init__(*args, **kwargs)
     disable_log()
コード例 #6
0
ファイル: test_sequence.py プロジェクト: vcancy/ClairMeta
 def __init__(self, *args, **kwargs):
     super(SequenceTestBase, self).__init__(*args, **kwargs)
     disable_log()
コード例 #7
0
ファイル: test_dcp_parse.py プロジェクト: remia/ClairMeta
 def __init__(self, *args, **kwargs):
     super(ParserTestBase, self).__init__(*args, **kwargs)
     disable_log()
コード例 #8
0
ファイル: test_dcp_check.py プロジェクト: remia/ClairMeta
 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']