Attributes of None
values should never be accessed. Doing so will cause an AttributeError
to be thrown. At best, such an
exception will cause abrupt program termination. At worse, it could expose debugging information that would be useful to an attacker, or it could
allow an attacker to bypass security measures.
Noncompliant Code Example
def myfunc(param):
if param is None:
print(param.test()) # Noncompliant
if param == None:
print(param.test()) # Noncompliant
if param is not None:
pass
else:
print(param.test()) # Noncompliant
if param != None:
pass
else:
print(param.test()) # Noncompliant
See