@@ -443,6 +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 {
466+ /**
467+ * A data-flow node that executes an LDAP query.
468+ *
469+ * Extend this class to model new APIs. If you want to refine existing API models,
470+ * extend `LDAPQuery` instead.
471+ */
472+ abstract class Range extends DataFlow:: Node {
473+ /** Gets the argument containing the filter string. */
474+ abstract DataFlow:: Node getFilter ( ) ;
475+
476+ /** Gets the argument containing the base DN. */
477+ abstract DataFlow:: Node getBaseDn ( ) ;
478+ }
479+ }
480+
446481/**
447482 * A data-flow node that escapes meta-characters, which could be used to prevent
448483 * injection attacks.
@@ -500,8 +535,20 @@ module Escaping {
500535 /** Gets the escape-kind for escaping a string so it can safely be included in HTML. */
501536 string getHtmlKind ( ) { result = "html" }
502537
503- /** Gets the escape-kind for escaping a string so it can safely be included in HTML . */
538+ /** Gets the escape-kind for escaping a string so it can safely be included in a regular expression . */
504539 string getRegexKind ( ) { result = "regex" }
540+
541+ /**
542+ * Gets the escape-kind for escaping a string so it can safely be used as a
543+ * distinguished name (DN) in an LDAP search.
544+ */
545+ string getLdapDnKind ( ) { result = "ldap_dn" }
546+
547+ /**
548+ * Gets the escape-kind for escaping a string so it can safely be used as a
549+ * filter in an LDAP search.
550+ */
551+ string getLdapFilterKind ( ) { result = "ldap_filter" }
505552 // TODO: If adding an XML kind, update the modeling of the `MarkupSafe` PyPI package.
506553 //
507554 // Technically it claims to escape for both HTML and XML, but for now we don't have
@@ -526,6 +573,21 @@ class RegexEscaping extends Escaping {
526573 RegexEscaping ( ) { range .getKind ( ) = Escaping:: getRegexKind ( ) }
527574}
528575
576+ /**
577+ * An escape of a string so it can be safely used as a distinguished name (DN)
578+ * in an LDAP search.
579+ */
580+ class LdapDnEscaping extends Escaping {
581+ LdapDnEscaping ( ) { range .getKind ( ) = Escaping:: getLdapDnKind ( ) }
582+ }
583+
584+ /**
585+ * An escape of a string so it can be safely used as a filter in an LDAP search.
586+ */
587+ class LdapFilterEscaping extends Escaping {
588+ LdapFilterEscaping ( ) { range .getKind ( ) = Escaping:: getLdapFilterKind ( ) }
589+ }
590+
529591/** Provides classes for modeling HTTP-related APIs. */
530592module HTTP {
531593 import semmle.python.web.HttpConstants
0 commit comments