46 lines
1.0 KiB
Plaintext
46 lines
1.0 KiB
Plaintext
include::../description.adoc[]
|
|
|
|
== Noncompliant Code Example
|
|
|
|
[source,python]
|
|
----
|
|
import ldap
|
|
|
|
def init_ldap():
|
|
connect = ldap.initialize('ldap://example:1389')
|
|
|
|
connect.simple_bind('cn=root') # Noncompliant
|
|
connect.simple_bind_s('cn=root') # Noncompliant
|
|
connect.bind_s('cn=root', None) # Noncompliant
|
|
connect.bind('cn=root', None) # Noncompliant
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
[source,python]
|
|
----
|
|
import ldap
|
|
import os
|
|
|
|
def init_ldap():
|
|
connect = ldap.initialize('ldap://example:1389')
|
|
|
|
connect.simple_bind('cn=root', os.environ.get('LDAP_PASSWORD')) # Compliant
|
|
connect.simple_bind_s('cn=root', os.environ.get('LDAP_PASSWORD')) # Compliant
|
|
connect.bind_s('cn=root', os.environ.get('LDAP_PASSWORD')) # Compliant
|
|
connect.bind('cn=root', os.environ.get('LDAP_PASSWORD')) # Compliant
|
|
----
|
|
|
|
include::../see.adoc[]
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::message.adoc[]
|
|
|
|
include::../highlighting.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|