Skip to content

Commit 1e2428c

Browse files
committed
python: create LDAP module in Concepts
1 parent c2cd58e commit 1e2428c

File tree

4 files changed

+32
-29
lines changed

4 files changed

+32
-29
lines changed

python/ql/lib/semmle/python/Concepts.qll

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -443,38 +443,41 @@ module RegexExecution {
443443
}
444444
}
445445

446-
/**
447-
* A data-flow node that executes an LDAP query.
448-
*
449-
* Extend this class to refine existing API models. If you want to model new APIs,
450-
* extend `LDAPQuery::Range` instead.
451-
*/
452-
class LdapExecution extends DataFlow::Node {
453-
LdapExecution::Range range;
454-
455-
LdapExecution() { this = range }
456-
457-
/** Gets the argument containing the filter string. */
458-
DataFlow::Node getFilter() { result = range.getFilter() }
459-
460-
/** Gets the argument containing the base DN. */
461-
DataFlow::Node getBaseDn() { result = range.getBaseDn() }
462-
}
463-
464-
/** Provides classes for modeling new LDAP query execution-related APIs. */
465-
module LdapExecution {
446+
/** Provides classes for modeling LDAP-related APIs. */
447+
module LDAP {
466448
/**
467449
* A data-flow node that executes an LDAP query.
468450
*
469-
* Extend this class to model new APIs. If you want to refine existing API models,
470-
* extend `LDAPQuery` instead.
451+
* Extend this class to refine existing API models. If you want to model new APIs,
452+
* extend `LDAPQuery::Range` instead.
471453
*/
472-
abstract class Range extends DataFlow::Node {
454+
class LdapExecution extends DataFlow::Node {
455+
LdapExecution::Range range;
456+
457+
LdapExecution() { this = range }
458+
473459
/** Gets the argument containing the filter string. */
474-
abstract DataFlow::Node getFilter();
460+
DataFlow::Node getFilter() { result = range.getFilter() }
475461

476462
/** Gets the argument containing the base DN. */
477-
abstract DataFlow::Node getBaseDn();
463+
DataFlow::Node getBaseDn() { result = range.getBaseDn() }
464+
}
465+
466+
/** Provides classes for modeling new LDAP query execution-related APIs. */
467+
module LdapExecution {
468+
/**
469+
* A data-flow node that executes an LDAP query.
470+
*
471+
* Extend this class to model new APIs. If you want to refine existing API models,
472+
* extend `LDAPQuery` instead.
473+
*/
474+
abstract class Range extends DataFlow::Node {
475+
/** Gets the argument containing the filter string. */
476+
abstract DataFlow::Node getFilter();
477+
478+
/** Gets the argument containing the base DN. */
479+
abstract DataFlow::Node getBaseDn();
480+
}
478481
}
479482
}
480483

python/ql/lib/semmle/python/frameworks/Ldap.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ private module Ldap {
1919
*
2020
* See https://www.python-ldap.org/en/python-ldap-3.3.0/reference/ldap.html#functions
2121
*/
22-
private class LdapQueryExecution extends DataFlow::CallCfgNode, LdapExecution::Range {
22+
private class LdapQueryExecution extends DataFlow::CallCfgNode, LDAP::LdapExecution::Range {
2323
LdapQueryExecution() {
2424
this =
2525
API::moduleImport("ldap")

python/ql/lib/semmle/python/frameworks/Ldap3.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ private import semmle.python.ApiGraphs
1515
*/
1616
private module Ldap3 {
1717
/** The execution of an `ldap` query. */
18-
private class LdapQueryExecution extends DataFlow::CallCfgNode, LdapExecution::Range {
18+
private class LdapQueryExecution extends DataFlow::CallCfgNode, LDAP::LdapExecution::Range {
1919
LdapQueryExecution() {
2020
this =
2121
API::moduleImport("ldap3")

python/ql/lib/semmle/python/security/dataflow/LdapInjectionCustomizations.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ module LdapInjection {
6060
* A logging operation, considered as a flow sink.
6161
*/
6262
class LdapExecutionAsDnSink extends DnSink {
63-
LdapExecutionAsDnSink() { this = any(LdapExecution ldap).getBaseDn() }
63+
LdapExecutionAsDnSink() { this = any(LDAP::LdapExecution ldap).getBaseDn() }
6464
}
6565

6666
/**
6767
* A logging operation, considered as a flow sink.
6868
*/
6969
class LdapExecutionAsFilterSink extends FilterSink {
70-
LdapExecutionAsFilterSink() { this = any(LdapExecution ldap).getFilter() }
70+
LdapExecutionAsFilterSink() { this = any(LDAP::LdapExecution ldap).getFilter() }
7171
}
7272

7373
/**

0 commit comments

Comments
 (0)