示例#1
0
def read_policy(name=None, file=None, version=default_bundle_version):
    if not name or not file:
        raise Exception("input error")

    if not os.path.exists(file):
        raise Exception("input file does not exist: " + str(file))

    pdata = anchore_utils.read_plainfile_tolist(file)
    if not verify_policy(policydata=pdata, version=version):
        raise Exception("cannot verify policy data read from file as valid")

    ret = {}
    ret[name] = pdata

    return (ret)
示例#2
0
def read_policy(name=None, file=None, version=default_bundle_version):
    if not name or not file:
        raise Exception("input error")

    if not os.path.exists(file):
        raise Exception("input file does not exist: " + str(file))

    pdata = anchore_utils.read_plainfile_tolist(file)
    if not verify_policy(policydata=pdata, version=version):
        raise Exception("cannot verify policy data read from file as valid")

    ret = {}
    ret[name] = pdata

    return(ret)
示例#3
0
def read_whitelist(name=None, file=None, version=default_whitelist_version):
    if not name:
        raise Exception("bad input: " + str(name) + " : " + str(file))

    if file:
        if not os.path.exists(file):
            raise Exception("input file does not exist: " + str(file))

        wdata = anchore_utils.read_plainfile_tolist(file)
        if not verify_whitelist(whitelistdata=wdata, version=version):
            raise Exception("cannot verify whitelist data read from file as valid")
    else:
        wdata = []

    ret = {}
    ret[name] = wdata

    return(ret)
示例#4
0
def read_whitelist(name=None, file=None, version=default_whitelist_version):
    if not name:
        raise Exception("bad input: " + str(name) + " : " + str(file))

    if file:
        if not os.path.exists(file):
            raise Exception("input file does not exist: " + str(file))

        wdata = anchore_utils.read_plainfile_tolist(file)
        if not verify_whitelist(whitelistdata=wdata, version=version):
            raise Exception(
                "cannot verify whitelist data read from file as valid")
    else:
        wdata = []

    ret = {}
    ret[name] = wdata

    return (ret)
示例#5
0
 def load_gate_whitelist(self, imageId):
     thefile = os.path.join(self.imagerootdir, imageId,
                            'anchore_gate.whitelist')
     return (anchore_utils.read_plainfile_tolist(thefile))
示例#6
0
 def load_gate_output(self, imageId, gate_name):
     thedir = os.path.join(self.imagerootdir, imageId, 'gates_output')
     thefile = os.path.join(thedir, gate_name)
     return (anchore_utils.read_plainfile_tolist(thefile))