def source_rpm_of_file(self, filepath): """ Find source RPM of given filepath """ cmd = ["/bin/rpm", "-qf", filepath] out, _ = scan_lib.run_cmd_out_err(cmd) return out.split("\n")[0].strip()
def run(self): """ Run the RPM verify test """ cmd = self.get_command() out, err = scan_lib.run_cmd_out_err(cmd) return self.process_cmd_output_data(out)
def source_rpm_of_file(self, filepath): """ Find source RPM of given filepath """ cmd = ["/bin/rpm", "-qf", filepath] out, _ = scan_lib.run_cmd_out_err(cmd) return out.split("\n")[0].strip()
def yum_updates(): """ Finds yum updates """ command = ["yum", "-q", "check-update"] out, err = scan_lib.run_cmd_out_err(command) return out, err
def run(self): """ Run the RPM verify test """ cmd = self.get_command() out, err = scan_lib.run_cmd_out_err(cmd) return self.process_cmd_output_data(out)
def yum_updates(): """ Finds yum updates """ command = ["yum", "-q", "check-update"] out, err = scan_lib.run_cmd_out_err(command) return out, err
def get_meta_of_rpm(self, rpm): """ Get metadata of given installed package. Metadata captured: SIGPGP, VENDOR, PACKAGER, BUILDHOST """ qf = "%{SIGPGP:pgpsig}|%{VENDOR}|%{PACKAGER}|%{BUILDHOST}" cmd = ["/bin/rpm", "-q", "--qf", qf, rpm] out, _ = scan_lib.run_cmd_out_err(cmd) out = out.split("|") return {"RPM": rpm, "SIGNATURE": out[0], "VENDOR": out[1], "PACKAGER": out[2], "BUILDHOST": out[3] }
def get_meta_of_rpm(self, rpm): """ Get metadata of given installed package. Metadata captured: SIGPGP, VENDOR, PACKAGER, BUILDHOST """ qf = "%{SIGPGP:pgpsig}|%{VENDOR}|%{PACKAGER}|%{BUILDHOST}" cmd = ["/bin/rpm", "-q", "--qf", qf, rpm] out, _ = scan_lib.run_cmd_out_err(cmd) out = out.split("|") return { "RPM": rpm, "SIGNATURE": out[0], "VENDOR": out[1], "PACKAGER": out[2], "BUILDHOST": out[3] }
def find_gem_updates(executable="/usr/bin/gem"): """ Finds out outdated installed packages of gem """ command = [executable, "outdated"] out, err = [], "" try: out, err = scan_lib.run_cmd_out_err(command) except Exception as e: err = e if err: if binary_does_not_exist(err): return "{0} is not installed".format(executable) else: return "Failed to find the gem updates." else: if out.strip(): return out.strip().split("\n") else: return []
def find_pip_updates(executable="/usr/bin/pip"): """ Finds out outdated installed packages of pip """ command = [executable, "list", "--outdated", "--disable-pip-version-check"] out, err = [], "" try: out, err = scan_lib.run_cmd_out_err(command) except Exception as e: err = e if err: if binary_does_not_exist(err): return "{0} is not installed".format(executable) else: return "Failed to find the pip updates." else: if out.strip(): return out.strip().split("\n") else: return []
def find_gem_updates(executable="/usr/bin/gem"): """ Finds out outdated installed packages of gem """ command = [executable, "outdated"] out, err = [], "" try: out, err = scan_lib.run_cmd_out_err(command) except Exception as e: err = e if err: if binary_does_not_exist(err): return "{0} is not installed".format(executable) else: return "Failed to find the gem updates." else: if out.strip(): return out.strip().split("\n") else: return []
def find_pip_updates(executable="/usr/bin/pip"): """ Finds out outdated installed packages of pip """ command = [executable, "list", "--outdated", "--disable-pip-version-check"] out, err = [], "" try: out, err = scan_lib.run_cmd_out_err(command) except Exception as e: err = e if err: if binary_does_not_exist(err): return "{0} is not installed".format(executable) else: return "Failed to find the pip updates." else: if out.strip(): return out.strip().split("\n") else: return []