Пример #1
0
def get_cwe(cwe_id=None):
    data = getCWEs()
    if cwe_id is None:
        cwes = [x for x in data if x["weaknessabs"].lower() == "class"]
        return render_template("cwe.html", cwes=cwes, capec=None)
    else:
        cwes = {x["id"]: x["name"] for x in data}
        return render_template(
            "cwe.html", cwes=cwes, cwe=cwe_id, capec=getCAPECFor(cwe_id), minimal=True
        )
Пример #2
0
    def get(self, cwe_id):
        """
        CWE from CWE ID

        Outputs a specific CWE (Common Weakness Enumeration).
        """
        cwes = getCWEs(cwe_id)

        if cwes is None:
            api.abort(404, "The requested CWE is not found")
        else:
            return cwes
Пример #3
0
    def get(self):
        """
        List all CWE's

        Outputs a list of all CWEs (Common Weakness Enumeration).
        """
        cwes = getCWEs()

        if cwes is None:
            api.abort(404, "The requested CWE is not found")
        else:
            return cwes
Пример #4
0
def capec(capec_id):
    data = getCWEs()
    cwes = {x["id"]: x["name"] for x in data}

    req_capec = getCAPEC(capec_id)

    rel_capecs = defaultdict(dict)

    if len(req_capec["related_capecs"]) != 0:
        for each in req_capec["related_capecs"]:
            rel_capecs[each] = getCAPEC(each)["summary"]

    return render_template("capec.html",
                           cwes=cwes,
                           capecs=dict(rel_capecs),
                           capec=req_capec)
Пример #5
0
def capec(capec_id):
    data = getCWEs()
    cwes = {x["id"]: x["name"] for x in data}

    req_capec = getCAPEC(capec_id)
    if req_capec is None:
        return render_template(
            "error.html",
            status={"except": "capec-not-found", "info": {"capec": capec_id}},
        )

    rel_capecs = defaultdict(dict)

    if len(req_capec["related_capecs"]) != 0:
        for each in req_capec["related_capecs"]:
            rel_capecs[each] = getCAPEC(each)["summary"]

    return render_template(
        "capec.html", cwes=cwes, capecs=dict(rel_capecs), capec=req_capec
    )
Пример #6
0
 def api_cwe(self, cwe_id=None):
     return getCWEs(cwe_id) if cwe_id else getCWEs()
Пример #7
0
 def api_cwe(self, cwe_id=None):
     return getCAPECFor(str(cwe_id)) if cwe_id else getCWEs()