Skip to content

Commit

Permalink
Implement the short description property (#121)
Browse files Browse the repository at this point in the history
The short description is the subset of the full docstring description
from the title to the first example.

Signed-off-by: Eric Brown <[email protected]>
  • Loading branch information
ericwb authored Aug 4, 2023
1 parent da362d9 commit 1964b33
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 14 deletions.
10 changes: 9 additions & 1 deletion precli/rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,15 @@ def short_descr(self) -> str:
:return: rule short description
:rtype: str
"""
return self._cwe.description
try:
start = self._full_descr.rindex("===\n") + 4
except ValueError:
start = 0
try:
end = self._full_descr.index("\n---")
except ValueError:
end = len(self._full_descr)
return self._full_descr[start:end]

@property
def full_descr(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion precli/rules/python/stdlib/hashlib/hashlib_weak_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Reversible One Way Hash in Hashlib Module
=========================================
The Python module hashlib provides a number of functions for hashing data.
The Python module ``hashlib`` provides a number of functions for hashing data.
However, some of the hash algorithms supported by hashlib are insecure and
should not be used. These insecure hash algorithms include ``MD4``, ``MD5``,
``RIPEMD-160`` and ``SHA-1``.
Expand Down
2 changes: 1 addition & 1 deletion precli/rules/python/stdlib/hmac/hmac_weak_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Reversible One Way Hash in Hmac Module
======================================
The Python module hmac provides a number of functions for creating and
The Python module ``hmac`` provides a number of functions for creating and
verifying message authentication codes (MACs). However, some of the hash
algorithms supported by hmac are insecure and should not be used. These
insecure hash algorithms include `MD4``, ``MD5``, ``RIPEMD-160`` and ``SHA-1``.
Expand Down
2 changes: 1 addition & 1 deletion precli/rules/python/stdlib/json/json_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Deserialization of Untrusted Data in the Json Module
====================================================
The Python json module provides a way to parse and generate JSON data.
The Python ``json`` module provides a way to parse and generate JSON data.
However, it is important to be aware that malicious JSON strings can be used
to attack applications that use the json module. For example, a malicious
JSON string could be used to cause the decoder to consume considerable CPU
Expand Down
2 changes: 1 addition & 1 deletion precli/rules/python/stdlib/marshal/marshal_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Deserialization of Untrusted Data in the Marshal Module
=======================================================
The Python marshal module provides a way to serialize and deserialize
The Python ``marshal`` module provides a way to serialize and deserialize
Python objects. However, it is important to be aware that malicious data
can be used to attack applications that use the marshal module. For example,
a malicious data could be used to cause the decoder to execute arbitrary code.
Expand Down
2 changes: 1 addition & 1 deletion precli/rules/python/stdlib/pickle/pickle_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Deserialization of Untrusted Data in Pickle Module
==================================================
The Python pickle module is a serialization module that can be used to
The Python ``pickle`` module is a serialization module that can be used to
serialize and deserialize Python objects. However, pickle is not a secure
serialization format and should not be used to serialize sensitive data.
Expand Down
2 changes: 1 addition & 1 deletion precli/rules/python/stdlib/shelve/shelve_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Deserialization of Untrusted Data in the Shelve Module
======================================================
The Python shelve module provides a way to store Python objects in a file.
The Python ``shelve`` module provides a way to store Python objects in a file.
It is backed by the pickle module, which is a serialization format that can
be used to store arbitrary Python objects.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
easily impersonate a legitimate server and fool your application into
connecting to it.
If you use ssl._create_unverified_context, you are opening your application
If you use ``ssl._create_unverified_context``, you are opening your application
up to a number of security risks, including:
- Man-in-the-middle attacks
Expand Down
2 changes: 1 addition & 1 deletion precli/rules/python/stdlib/ssl/insecure_tls_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Inadequate Encryption Strength Using Weak SSL Protocols
=======================================================
The Python ssl modules provide a number of different protocols that can be
The Python ``ssl`` modules provide a number of different protocols that can be
used to encrypt data. However, some of these protocols are no longer
considered secure and should not be used.
Expand Down
10 changes: 5 additions & 5 deletions precli/rules/python/stdlib/telnetlib/telnetlib_cleartext.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
Cleartext Transmission of Sensitive Information in the Telnetlib Module
=======================================================================
The Python module telnetlib is a low-level module that provides access to the
telnet protocol. The telnet protocol is a cleartext protocol, which means that
all data transmitted over the connection is visible to anyone who can sniff
the network traffic. This includes passwords, usernames, and other sensitive
data.
The Python module ``telnetlib`` is a low-level module that provides access to
the telnet protocol. The telnet protocol is a cleartext protocol, which means
that all data transmitted over the connection is visible to anyone who can
sniff the network traffic. This includes passwords, usernames, and other
sensitive data.
If you need to access a remote system over a network, you should use a more
secure protocol, such as SSH. SSH is a secure shell protocol that encrypts
Expand Down

0 comments on commit 1964b33

Please sign in to comment.