Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a2e8d88

Browse files
committed
Write documentation
1 parent cd75433 commit a2e8d88

3 files changed

Lines changed: 79 additions & 1 deletion

File tree

python/ql/src/experimental/semmle/python/Concepts.qll

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,28 @@ private import semmle.python.dataflow.new.RemoteFlowSources
1414
private import semmle.python.dataflow.new.TaintTracking
1515
private import experimental.semmle.python.Frameworks
1616

17+
/** Provides classes for modeling LDAP-related APIs. */
1718
module LDAPQuery {
19+
/**
20+
* A data-flow node that collects methods executing a LDAP query.
21+
*
22+
* Extend this class to model new APIs. If you want to refine existing API models,
23+
* extend `LDAPQuery` instead.
24+
*/
1825
abstract class Range extends DataFlow::Node {
26+
/**
27+
* Gets the argument containing the executed expression.
28+
*/
1929
abstract DataFlow::Node getLDAPNode();
2030
}
2131
}
2232

33+
/**
34+
* A data-flow node that collect methods executing a LDAP query.
35+
*
36+
* Extend this class to refine existing API models. If you want to model new APIs,
37+
* extend `LDAPQuery::Range` instead.
38+
*/
2339
class LDAPQuery extends DataFlow::Node {
2440
LDAPQuery::Range range;
2541

@@ -28,12 +44,28 @@ class LDAPQuery extends DataFlow::Node {
2844
DataFlow::Node getLDAPNode() { result = range.getLDAPNode() }
2945
}
3046

47+
/** Provides classes for modeling LDAP components escape-related APIs. */
3148
module LDAPEscape {
49+
/**
50+
* A data-flow node that collects functions escaping LDAP components.
51+
*
52+
* Extend this class to model new APIs. If you want to refine existing API models,
53+
* extend `LDAPEscape` instead.
54+
*/
3255
abstract class Range extends DataFlow::Node {
56+
/**
57+
* Gets the argument containing the escaped expression.
58+
*/
3359
abstract DataFlow::Node getEscapeNode();
3460
}
3561
}
3662

63+
/**
64+
* A data-flow node that collects functions escaping LDAP components.
65+
*
66+
* Extend this class to refine existing API models. If you want to model new APIs,
67+
* extend `RegexEscape::Range` instead.
68+
*/
3769
class LDAPEscape extends DataFlow::Node {
3870
LDAPEscape::Range range;
3971

python/ql/src/experimental/semmle/python/frameworks/Stdlib.qll

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,32 @@ private import semmle.python.dataflow.new.RemoteFlowSources
1010
private import experimental.semmle.python.Concepts
1111
private import semmle.python.ApiGraphs
1212

13+
/**
14+
* Provides models for Python's ldap-related libraries.
15+
*/
1316
private module LDAP {
17+
/**
18+
* Provides models for Python's `ldap` library.
19+
*
20+
* See https://www.python-ldap.org/en/python-ldap-3.3.0/index.html
21+
*/
1422
private module LDAP2 {
23+
/**
24+
* List of `ldap` methods used to execute a query.
25+
*
26+
* See https://www.python-ldap.org/en/python-ldap-3.3.0/reference/ldap.html#functions
27+
*/
1528
private class LDAP2QueryMethods extends string {
1629
LDAP2QueryMethods() {
1730
this in ["search", "search_s", "search_st", "search_ext", "search_ext_s"]
1831
}
1932
}
2033

34+
/**
35+
* A class to find `ldap` methods executing a query.
36+
*
37+
* See `LDAP2QueryMethods`
38+
*/
2139
private class LDAP2Query extends DataFlow::CallCfgNode, LDAPQuery::Range {
2240
DataFlow::Node ldapNode;
2341

@@ -41,6 +59,11 @@ private module LDAP {
4159
override DataFlow::Node getLDAPNode() { result = ldapNode }
4260
}
4361

62+
/**
63+
* A class to find calls to `ldap.dn.escape_dn_chars`.
64+
*
65+
* See https://github.com/python-ldap/python-ldap/blob/7ce471e238cdd9a4dd8d17baccd1c9e05e6f894a/Lib/ldap/dn.py#L17
66+
*/
4467
private class LDAP2EscapeDNCall extends DataFlow::CallCfgNode, LDAPEscape::Range {
4568
LDAP2EscapeDNCall() {
4669
this = API::moduleImport("ldap").getMember("dn").getMember("escape_dn_chars").getACall()
@@ -49,6 +72,11 @@ private module LDAP {
4972
override DataFlow::Node getEscapeNode() { result = this.getArg(0) }
5073
}
5174

75+
/**
76+
* A class to find calls to `ldap.filter.escape_filter_chars`.
77+
*
78+
* See https://www.python-ldap.org/en/python-ldap-3.3.0/reference/ldap-filter.html#ldap.filter.escape_filter_chars
79+
*/
5280
private class LDAP2EscapeFilterCall extends DataFlow::CallCfgNode, LDAPEscape::Range {
5381
LDAP2EscapeFilterCall() {
5482
this =
@@ -59,7 +87,15 @@ private module LDAP {
5987
}
6088
}
6189

90+
/**
91+
* Provides models for Python's `ldap3` library.
92+
*
93+
* See https://pypi.org/project/ldap3/
94+
*/
6295
private module LDAP3 {
96+
/**
97+
* A class to find `ldap3` methods executing a query.
98+
*/
6399
private class LDAP3Query extends DataFlow::CallCfgNode, LDAPQuery::Range {
64100
DataFlow::Node ldapNode;
65101

@@ -79,6 +115,11 @@ private module LDAP {
79115
override DataFlow::Node getLDAPNode() { result = ldapNode }
80116
}
81117

118+
/**
119+
* A class to find calls to `ldap3.utils.dn.escape_rdn`.
120+
*
121+
* See https://github.com/cannatag/ldap3/blob/4d33166f0869b929f59c6e6825a1b9505eb99967/ldap3/utils/dn.py#L390
122+
*/
82123
private class LDAP3EscapeDNCall extends DataFlow::CallCfgNode, LDAPEscape::Range {
83124
LDAP3EscapeDNCall() {
84125
this =
@@ -92,6 +133,11 @@ private module LDAP {
92133
override DataFlow::Node getEscapeNode() { result = this.getArg(0) }
93134
}
94135

136+
/**
137+
* A class to find calls to `ldap3.utils.conv.escape_filter_chars`.
138+
*
139+
* See https://github.com/cannatag/ldap3/blob/4d33166f0869b929f59c6e6825a1b9505eb99967/ldap3/utils/conv.py#L91
140+
*/
95141
private class LDAP3EscapeFilterCall extends DataFlow::CallCfgNode, LDAPEscape::Range {
96142
LDAP3EscapeFilterCall() {
97143
this =

python/ql/src/experimental/semmle/python/security/injection/LDAP.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import semmle.python.dataflow.new.TaintTracking
99
import semmle.python.dataflow.new.RemoteFlowSources
1010

1111
/**
12-
* A taint-tracking configuration for detecting regular expression injections.
12+
* A taint-tracking configuration for detecting LDAP injections.
1313
*/
1414
class LDAPInjectionFlowConfig extends TaintTracking::Configuration {
1515
LDAPInjectionFlowConfig() { this = "LDAPInjectionFlowConfig" }

0 commit comments

Comments
 (0)