Ejemplo n.º 1
0
def create_checklist_item(checklistID, checklist_type, data):
    log("User requested create a new checklist item", "LOW", "PASS")
    checklist_content = data.get('content')
    include_always = data.get('include_always')
    question_ID = data.get('question_ID')
    checklist_kbID = data.get('kbID')
    cwe = data.get('cwe')
    val_num(checklist_kbID)
    val_num(checklist_type)
    if validate_duplicate_checklist_item(checklistID, checklist_type) == True:
        checklist_item = checklists_kb(checklistID, checklist_content,
                                       checklist_kbID, checklist_type,
                                       include_always, question_ID, cwe)
        db.session.add(checklist_item)
        db.session.commit()
        return {'message': 'Checklist item successfully created'}
    else:
        return {'message': 'Checklist item was duplicate!'}
Ejemplo n.º 2
0
def order_checklist_items(checklist_items, get_checklist_items_lvl, lvl):
    ordered_checklist_items = []
    for item in checklist_items.items:
        numbers = item.checklistID.split('.')
        category = int(numbers[0])
        category_requirement = int(numbers[1])
        if (len(ordered_checklist_items) == 0):
            ordered_checklist_items.append(item)
        else:
            y = 0
            while y < len(ordered_checklist_items):
                numbers_ordered = ordered_checklist_items[y].checklistID.split(
                    '.')
                category_ordered = int(numbers_ordered[0])
                category_requirement_ordered = int(numbers_ordered[1])
                if (category < category_ordered):
                    ordered_checklist_items.insert(y, item)
                    break
                else:
                    if (category == category_ordered):
                        if (category_requirement <
                                category_requirement_ordered):
                            ordered_checklist_items.insert(y, item)
                            break
                y = y + 1
            if (y == len(ordered_checklist_items)):
                ordered_checklist_items.insert(y, item)

    if (get_checklist_items_lvl):
        if (not (lvl == 6)):
            i = 0
            previousItemLevel = -1
            orderedWithEmpties = []
            for item in ordered_checklist_items:
                if ((item.checklist_items.level == 0
                     and previousItemLevel == 0) or
                    (item.checklist_items.content
                     == "Resiliency Against Reverse Engineering Requirements"
                     and not (lvl == 6))):
                    if (item.checklist_items.content ==
                            "Resiliency Against Reverse Engineering Requirements"
                        ):
                        orderedWithEmpties.append(item)
                        previousItemLevel = item.checklist_items.level
                        checklist_empty = checklists(
                            "0.0",
                            "Requirements of Reverse Engineering can be added to form a level "
                            + str(lvl - 3) + "+R.", -1, 0)
                        checklists_kb_empty = checklists_kb(
                            "0.0", checklist_empty, 0, None)
                        orderedWithEmpties.append(checklists_kb_empty)
                    else:
                        checklist_empty = checklists(
                            "0.0",
                            "No items for this category in this checklist level",
                            -1, 0)
                        checklists_kb_empty = checklists_kb(
                            "0.0", checklist_empty, 0, None)
                        orderedWithEmpties.append(checklists_kb_empty)
                        orderedWithEmpties.append(item)
                        previousItemLevel = item.checklist_items.level
                else:
                    orderedWithEmpties.append(item)
                    previousItemLevel = item.checklist_items.level
                i = i + 1
            checklist_items.items = orderedWithEmpties
        else:
            orderedWithR6 = []
            checklist_empty = checklists(
                "0.0",
                "Using Requirements of Reverse Engineering you can form the levels L1+R or L2+R.",
                -1, 0)
            checklists_kb_empty = checklists_kb("0.0", checklist_empty, 0,
                                                None)
            orderedWithR6.append(checklists_kb_empty)
            for item in ordered_checklist_items:
                if (item.checklist_items.level == 'R'):
                    checklist_modified = checklists(
                        item.checklistID, item.checklist_items.content, 6,
                        item.checklist_items.kbID)
                    modifiedItem = checklists_kb(item.checklistID,
                                                 checklist_modified, item.kbID,
                                                 item.kb_items)
                    orderedWithR6.append(modifiedItem)
                else:
                    orderedWithR6.append(item)
            checklist_items.items = orderedWithR6
    return checklist_items
Ejemplo n.º 3
0
def order_checklist_items(checklist_items, get_checklist_items_lvl, lvl):
    ordered_checklist_items = []
    for item in checklist_items.items:
        numbers = item.checklistID.split('.')
        category = int(numbers[0])
        category_requirement = int(numbers[1])
        if (len(ordered_checklist_items) == 0):
            ordered_checklist_items.append(item)
        else:
            y = 0
            while y < len(ordered_checklist_items):
                numbers_ordered = ordered_checklist_items[y].checklistID.split('.')
                category_ordered = int(numbers_ordered[0])
                category_requirement_ordered = int(numbers_ordered[1])
                if (category < category_ordered):
                    ordered_checklist_items.insert(y, item)
                    break
                else:
                    if (category == category_ordered):
                        if (category_requirement < category_requirement_ordered):
                            ordered_checklist_items.insert(y, item)
                            break
                y = y + 1
            if (y == len(ordered_checklist_items)):
                ordered_checklist_items.insert(y, item)

    if (get_checklist_items_lvl):
        if (not (lvl == 6)):
            i = 0
            previousItemLevel = -1
            orderedWithEmpties = []
            for item in ordered_checklist_items:
                if ((item.checklist_items.level == 0 and previousItemLevel == 0) or (item.checklist_items.content == "Resiliency Against Reverse Engineering Requirements" and not (lvl == 6))):
                    if (item.checklist_items.content == "Resiliency Against Reverse Engineering Requirements"):
                        orderedWithEmpties.append(item)
                        previousItemLevel = item.checklist_items.level
                        checklist_empty = checklists("0.0", "Requirements of Reverse Engineering can be added to form a level " + str(lvl-3) + "+R.", -1, 0)
                        checklists_kb_empty = checklists_kb("0.0", checklist_empty, 0, None)
                        orderedWithEmpties.append(checklists_kb_empty)
                    else:
                        checklist_empty = checklists("0.0", "No items for this category in this checklist level", -1, 0)
                        checklists_kb_empty = checklists_kb("0.0", checklist_empty, 0, None)
                        orderedWithEmpties.append(checklists_kb_empty)
                        orderedWithEmpties.append(item)
                        previousItemLevel = item.checklist_items.level
                else:
                    orderedWithEmpties.append(item)
                    previousItemLevel = item.checklist_items.level
                i = i + 1;
            checklist_items.items = orderedWithEmpties
        else:
            orderedWithR6 = []
            checklist_empty = checklists("0.0", "Using Requirements of Reverse Engineering you can form the levels L1+R or L2+R.", -1, 0)
            checklists_kb_empty = checklists_kb("0.0", checklist_empty, 0, None)
            orderedWithR6.append(checklists_kb_empty)
            for item in ordered_checklist_items:
                if (item.checklist_items.level == 'R'):
                    checklist_modified = checklists(item.checklistID, item.checklist_items.content, 6, item.checklist_items.kbID)
                    modifiedItem = checklists_kb(item.checklistID, checklist_modified, item.kbID, item.kb_items)
                    orderedWithR6.append(modifiedItem)
                else:
                    orderedWithR6.append(item)
            checklist_items.items = orderedWithR6
    return checklist_items