Example #1
0
def get_help(format, tool_name, rule_id, test_name, issue_dict):
    """
    Constructs a full description for the rule

    :param format: text or markdown
    :param tool_name:
    :param rule_id:
    :param test_name:
    :param issue_dict:
    :return: Help text
    """
    if rule_id and rule_id.upper().startswith("CWE"):
        return get_description(rule_id, True)
    if issue_dict.get("cwe_category"):
        return get_description(issue_dict.get("cwe_category"), True)
    issue_text = issue_dict.get("issue_text", "")
    return issue_text
Example #2
0
def get_rule_full_description(tool_name, rule_id, test_name, issue_dict):
    """
    Constructs a full description for the rule

    :param tool_name:
    :param rule_id:
    :param test_name:
    :param issue_dict:
    :return:
    """
    if rule_id and rule_id.upper().startswith("CWE"):
        return get_description(rule_id, False)
    if issue_dict.get("cwe_category"):
        return get_description(issue_dict.get("cwe_category"), False)
    issue_text = issue_dict.get("issue_text", "")
    # Extract just the first line alone
    if issue_text:
        issue_text = issue_text.split("\n")[0]
    if not issue_text.endswith("."):
        issue_text = issue_text + "."
    return issue_text
Example #3
0
def test_cwe_get_desc():
    data = get_description("cwe-78")
    assert data