Example #1
0
    "performance": {
        "type": "BUG",
        "priority": "MINOR"
    },
    "style": {
        "type": "CODE_SMELL",
        "priority": "MINOR"
    },
    "information": {
        "type": "CODE_SMELL",
        "priority": "MINOR"
    },
}

CWE_MAP = None
et = get_cdata_capable_xml_etree()


def message_with_cwe_reference(msg, cwe_nr):
    cwe_msg = CWE_MAP.get(str(cwe_nr), None)
    if cwe_msg is None:
        sys.stderr.write('CWE ID ' + cwe_nr + ' was not found!\n')
    href_text = "CWE-{}".format(
        cwe_nr) if cwe_msg is None else "CWE-{}: {}".format(cwe_nr, cwe_msg)
    msg_wrapped = textwrap.fill(msg)
    return """<p>
{}
</p>
<h2>References</h2>
<p><a href="https://cwe.mitre.org/data/definitions/{}.html" target="_blank">{}</a></p>""".format(
        msg_wrapped.replace("\\012", "\n"), cwe_nr, href_text)
    # VULNERABILITY MINOR

    "android-cloexec-accept4": {"type": "VULNERABILITY", "severity": "MINOR"},
    "android-cloexec-dup": {"type": "VULNERABILITY", "severity": "MINOR"},
    "android-cloexec-epoll-create": {"type": "VULNERABILITY", "severity": "MINOR"},
    "android-cloexec-epoll-create1": {"type": "VULNERABILITY", "severity": "MINOR"},
    "android-cloexec-fopen": {"type": "VULNERABILITY", "severity": "MINOR"},
    "android-cloexec-inotify-init": {"type": "VULNERABILITY", "severity": "MINOR"},
    "android-cloexec-inotify-init1": {"type": "VULNERABILITY", "severity": "MINOR"},
    "android-cloexec-memfd-create": {"type": "VULNERABILITY", "severity": "MINOR"},
    "android-cloexec-open": {"type": "VULNERABILITY", "severity": "MINOR"},
    "android-cloexec-socket": {"type": "VULNERABILITY", "severity": "MINOR"}

}

et = get_cdata_capable_xml_etree()

CLANG_TIDY_DOC_URL_BASE = "http://clang.llvm.org/extra/clang-tidy/checks/"


def fix_local_urls(html, filename):
    # replace local ancors
    html = re.sub("href=\"(?!http)#", "href=\"" +
                  CLANG_TIDY_DOC_URL_BASE + filename + ".html#", html)
    # replace local urls
    html = re.sub("href=\"(?!http)", "href=\"" + CLANG_TIDY_DOC_URL_BASE, html)
    return html


def rstfile_to_description(path, filename, fix_urls):
    html = subprocess.check_output(