Fix CWE hyperlinks with trailing ! or /

This fixes SF bug #9.

Thanks to philipp for reporting it!

Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
This commit is contained in:
David A. Wheeler 2018-01-25 23:48:05 -05:00
parent f91e3ea60b
commit 6380038c34
2 changed files with 5 additions and 3 deletions

View File

@ -197,7 +197,8 @@ Examining test2.c <br>
</pre>
<li>test.c:45: <b> [2] </b> (buffer) <i> char:
Statically-sized arrays can be improperly restricted, leading to potential
overflows or other issues (CWE-119!/<a
overflows or other issues (<a
href="http://cwe.mitre.org/data/definitions/119.html">CWE-119</a>!/<a
href="http://cwe.mitre.org/data/definitions/120.html">CWE-120</a>). Perform
bounds checking, use functions that limit length, or ensure that the size
is larger than the maximum possible length. </i>
@ -206,7 +207,8 @@ Examining test2.c <br>
</pre>
<li>test.c:46: <b> [2] </b> (buffer) <i> char:
Statically-sized arrays can be improperly restricted, leading to potential
overflows or other issues (CWE-119!/<a
overflows or other issues (<a
href="http://cwe.mitre.org/data/definitions/119.html">CWE-119</a>!/<a
href="http://cwe.mitre.org/data/definitions/120.html">CWE-120</a>). Perform
bounds checking, use functions that limit length, or ensure that the size
is larger than the maximum possible length. </i>

View File

@ -335,7 +335,7 @@ def print_multi_line(text):
# This matches references to CWE identifiers, so we can HTMLize them.
# We don't refer to CWEs with one digit, so we'll only match on 2+ digits.
link_cwe_pattern = re.compile(r'(CWE-([1-9][0-9]+))([,()])')
link_cwe_pattern = re.compile(r'(CWE-([1-9][0-9]+))([,()!/])')
# This matches the CWE data, including multiple entries.
find_cwe_pattern = re.compile(r'\(CWE-[^)]*\)')