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)
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)
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)
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)
def load_gate_whitelist(self, imageId): thefile = os.path.join(self.imagerootdir, imageId, 'anchore_gate.whitelist') return (anchore_utils.read_plainfile_tolist(thefile))
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))