Exemple #1
0
def bash_affected(rpms):
    rpm = rpms.get_max("bash")
    if rpm and rpm >= LOWER and rpm < UPPER:
        return make_response("BASH_AFFECTED", version=rpm.nvr)
    elif rpm:
        return make_response("BASH_UNAFFECTED", version=rpm.nvr)
    else:
        return make_response("NO_BASH")
Exemple #2
0
def report():
    meta = get_metadata(report)
    foo = meta["foo"]

    if foo < 5:
        return make_response("LESS_THAN_5", foo=foo)
    else:
        return make_response("GREATER_EQUAL_5", foo=foo)
Exemple #3
0
def report(shas, meta):
    num_members = meta.num_members
    uniq = shas.sha.unique()
    if len(shas) != num_members or len(uniq) != 1:
        return make_response("DISTINCT_NTP_CONFS",
                             confs=len(uniq),
                             nodes=num_members)
def infra_nodes(info, meta, max_pod_cluster, label, key):
    """ Function used to create the response for all infra node types """
    nodes = meta.get(label, []) or []
    infos = info[info["machine_id"].isin(nodes)]
    if infos.empty:
        return
    return make_response(key, max_pod_cluster=max_pod_cluster, infos=infos,
                         GREEN=Fore.GREEN, RED=Fore.RED, YELLOW=Fore.YELLOW, NC=Style.RESET_ALL)
def report(hp, rhr):
    """
    Rule reports a response if there is more than 1 host
    entry defined in the /etc/hosts file.

    Arguments:
        hp (HostParser): Parser object for the custom parser in this
            module.
        rhr (RedhatRelease): Parser object for the /etc/redhat-release
            file.
    """
    if len(hp.hosts) > 1:
        return make_response("TOO_MANY_HOSTS", num=len(hp.hosts))
def master_etcd(info, meta, max_pod_cluster, label):
    """ Function used to create the response for all master node types """
    nodes = meta.get(label, []) or []
    info = info[info["machine_id"].isin(nodes)]
    if info.empty:
        return

    cpu_factor = max_pod_cluster / 1000.0
    nocpu_expected = MASTER_MIN_CORE + (max_pod_cluster / 1000.0)
    bad = info[info["cpu_count"] < nocpu_expected]
    good = info[info["cpu_count"] >= nocpu_expected]
    return make_response("MASTER_ETCD",
                         nocpu_expected=nocpu_expected, cpu_factor=cpu_factor,
                         bad=bad, good=good, max_pod_cluster=max_pod_cluster,
                         GREEN=Fore.GREEN, RED=Fore.RED, YELLOW=Fore.YELLOW, NC=Style.RESET_ALL)
def report(sestatus, selinuxconfig, installedrpms):
    selinux_enabled = sestatus.data['selinux_status'] == 'enabled'
    selinux_enforcing = sestatus.data['current_mode'] == 'enforcing'
    selinux_type = selinuxconfig.data.get('SELINUXTYPE')

    if selinux_type is None:
        return

    policy_rpm = installedrpms.get_max('selinux-policy')
    policy_type_rpm = installedrpms.get_max(
        'selinux-policy-{}'.format(selinux_type))

    if policy_rpm is None or policy_type_rpm is None:
        return

    mismatching_policies = (policy_rpm.version != policy_type_rpm.version
                            or policy_rpm.release != policy_type_rpm.release)

    if selinux_enabled and selinux_enforcing and mismatching_policies:
        return make_response(ERROR_KEY,
                             policy_rpm=policy_rpm.nvr,
                             policy_type_rpm=policy_type_rpm.nvr,
                             policy_type=selinux_type)
Exemple #8
0
def report2(cfg):
    return make_response("SOMETHING_ELSE_HAPPENED")
Exemple #9
0
def report(log, cfg):
    return make_response("SOMETHING_HAPPENED")
def report(hp, rhr):
    if len(hp.hosts) > 1:
        return make_response("TOO_MANY_HOSTS", num=len(hp.hosts))
Exemple #11
0
def report():
    return make_response("ERROR", foo="bar")
Exemple #12
0
def report(hp, rhr):
    if len(hp.hosts) > 1:
        return make_response("ERROR_KEY_TOO_MANY_HOSTS",
                             number=len(hp.hosts),
                             product=rhr.product)
Exemple #13
0
def bash_installed(rpms):
    rpm = rpms.get_max("bash")
    if rpm:
        return make_response("BASH_INSTALLED", version=rpm.nvr)
    return make_response("BASH_NOT_INSTALLED")