Ejemplo n.º 1
0
def test_list_paginated(app, create_cwes):
    old = app.config["CWES_PER_PAGE"]
    app.config["CWES_PER_PAGE"] = 3

    create_cwes(["CWE-1", "CWE-2", "CWE-3", "CWE-4"])

    with app.test_request_context():
        cwes = CweController.list_items()
        assert sorted([c.cwe_id for c in cwes]) == ["CWE-2", "CWE-3", "CWE-4"]
        cwes = CweController.list_items({"page": 2})
        assert sorted([c.cwe_id for c in cwes]) == ["CWE-1"]

    app.config["CWES_PER_PAGE"] = old
Ejemplo n.º 2
0
def test_list(app, create_cwes):
    create_cwes(["CWE-1", "CWE-2"])

    with app.test_request_context():
        cwes = CweController.list_items()
    assert len(cwes) == 2
    assert sorted([c.cwe_id for c in cwes]) == ["CWE-1", "CWE-2"]
Ejemplo n.º 3
0
def test_by_search(app, create_cwes, create_cwe, args, result):
    create_cwes(["CWE-1", "CWE-2"])
    create_cwe(
        "CWE-522",
        "Insufficiently Protected Credentials",
        "The product transmits...",
    )

    with app.test_request_context():
        cwes = CweController.list_items(args)
    assert sorted([c.cwe_id for c in cwes]) == result
Ejemplo n.º 4
0
def cwes():
    objects, _, pagination = CweController.list(request.args)
    return render_template("cwes.html", cwes=objects, pagination=pagination)
Ejemplo n.º 5
0
def test_metas(app):
    with app.test_request_context():
        _, metas, _ = CweController.list()
    assert metas == {}
Ejemplo n.º 6
0
 def get(self, id):
     CweController.get({"cwe_id": id})
     return CveController.list_items({**request.args, "cwe": id})
Ejemplo n.º 7
0
 def get(self, id):
     return CweController.get({"cwe_id": id})
Ejemplo n.º 8
0
 def get(self):
     return CweController.list_items(request.args)