Skip to content

Commit 57eee16

Browse files
committed
PY: fix all ql/no-upper-case-variables
1 parent 5d03c22 commit 57eee16

File tree

7 files changed

+126
-83
lines changed

7 files changed

+126
-83
lines changed

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPrivate.qll

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ predicate isArgumentNode(ArgumentNode arg, DataFlowCall c, ArgumentPosition pos)
3939
//--------
4040
predicate isExpressionNode(ControlFlowNode node) { node.getNode() instanceof Expr }
4141

42+
/** DEPRECATED: Alias for `SyntheticPreUpdateNode` */
43+
deprecated module syntheticPreUpdateNode = SyntheticPreUpdateNode;
44+
4245
/** A module collecting the different reasons for synthesising a pre-update node. */
43-
module syntheticPreUpdateNode {
46+
module SyntheticPreUpdateNode {
4447
class SyntheticPreUpdateNode extends Node, TSyntheticPreUpdateNode {
4548
NeedsSyntheticPreUpdateNode post;
4649

@@ -78,10 +81,13 @@ module syntheticPreUpdateNode {
7881
CfgNode objectCreationNode() { result.getNode().(CallNode) = any(ClassCall c).getNode() }
7982
}
8083

81-
import syntheticPreUpdateNode
84+
import SyntheticPreUpdateNode
85+
86+
/** DEPRECATED: Alias for `SyntheticPostUpdateNode` */
87+
deprecated module syntheticPostUpdateNode = SyntheticPostUpdateNode;
8288

8389
/** A module collecting the different reasons for synthesising a post-update node. */
84-
module syntheticPostUpdateNode {
90+
module SyntheticPostUpdateNode {
8591
/** A post-update node is synthesized for all nodes which satisfy `NeedsSyntheticPostUpdateNode`. */
8692
class SyntheticPostUpdateNode extends PostUpdateNode, TSyntheticPostUpdateNode {
8793
NeedsSyntheticPostUpdateNode pre;
@@ -177,7 +183,7 @@ module syntheticPostUpdateNode {
177183
}
178184
}
179185

180-
import syntheticPostUpdateNode
186+
import SyntheticPostUpdateNode
181187

182188
class DataFlowExpr = Expr;
183189

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

Lines changed: 64 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,11 @@ module PrivateDjango {
526526
/** Gets a reference to the `django` module. */
527527
API::Node django() { result = API::moduleImport("django") }
528528

529+
/** DEPRECATED: Alias for `DjangoImpl` */
530+
deprecated module django = DjangoImpl;
531+
529532
/** Provides models for the `django` module. */
530-
module django {
533+
module DjangoImpl {
531534
// -------------------------------------------------------------------------
532535
// django.db
533536
// -------------------------------------------------------------------------
@@ -541,8 +544,11 @@ module PrivateDjango {
541544
DjangoDb() { this = API::moduleImport("django").getMember("db") }
542545
}
543546

547+
/** DEPRECATED: Alias for `DB` */
548+
deprecated module db = DB;
549+
544550
/** Provides models for the `django.db` module. */
545-
module db {
551+
module DB {
546552
/** Gets a reference to the `django.db.connection` object. */
547553
API::Node connection() { result = db().getMember("connection") }
548554

@@ -557,8 +563,11 @@ module PrivateDjango {
557563
/** Gets a reference to the `django.db.models` module. */
558564
API::Node models() { result = db().getMember("models") }
559565

566+
/** DEPRECATED: Alias for `Models` */
567+
deprecated module models = Models;
568+
560569
/** Provides models for the `django.db.models` module. */
561-
module models {
570+
module Models {
562571
/**
563572
* Provides models for the `django.db.models.Model` class and subclasses.
564573
*
@@ -608,8 +617,11 @@ module PrivateDjango {
608617
/** Gets a reference to the `django.db.models.expressions` module. */
609618
API::Node expressions() { result = models().getMember("expressions") }
610619

620+
/** DEPRECATED: Alias for `Expressions` */
621+
deprecated module expressions = Expressions;
622+
611623
/** Provides models for the `django.db.models.expressions` module. */
612-
module expressions {
624+
module Expressions {
613625
/** Provides models for the `django.db.models.expressions.RawSql` class. */
614626
module RawSql {
615627
/**
@@ -662,8 +674,8 @@ module PrivateDjango {
662674
DataFlow::Node sql;
663675

664676
ObjectsAnnotate() {
665-
this = django::db::models::querySetReturningMethod("annotate").getACall() and
666-
django::db::models::expressions::RawSql::instance(sql) in [
677+
this = DjangoImpl::DB::Models::querySetReturningMethod("annotate").getACall() and
678+
DjangoImpl::DB::Models::Expressions::RawSql::instance(sql) in [
667679
this.getArg(_), this.getArgByName(_)
668680
]
669681
}
@@ -680,8 +692,8 @@ module PrivateDjango {
680692
DataFlow::Node sql;
681693

682694
ObjectsAlias() {
683-
this = django::db::models::querySetReturningMethod("alias").getACall() and
684-
django::db::models::expressions::RawSql::instance(sql) in [
695+
this = DjangoImpl::DB::Models::querySetReturningMethod("alias").getACall() and
696+
DjangoImpl::DB::Models::Expressions::RawSql::instance(sql) in [
685697
this.getArg(_), this.getArgByName(_)
686698
]
687699
}
@@ -697,7 +709,7 @@ module PrivateDjango {
697709
* - https://docs.djangoproject.com/en/3.1/ref/models/querysets/#raw
698710
*/
699711
private class ObjectsRaw extends SqlExecution::Range, DataFlow::CallCfgNode {
700-
ObjectsRaw() { this = django::db::models::querySetReturningMethod("raw").getACall() }
712+
ObjectsRaw() { this = DjangoImpl::DB::Models::querySetReturningMethod("raw").getACall() }
701713

702714
override DataFlow::Node getSql() { result = this.getArg(0) }
703715
}
@@ -708,7 +720,7 @@ module PrivateDjango {
708720
* See https://docs.djangoproject.com/en/3.1/ref/models/querysets/#extra
709721
*/
710722
private class ObjectsExtra extends SqlExecution::Range, DataFlow::CallCfgNode {
711-
ObjectsExtra() { this = django::db::models::querySetReturningMethod("extra").getACall() }
723+
ObjectsExtra() { this = DjangoImpl::DB::Models::querySetReturningMethod("extra").getACall() }
712724

713725
override DataFlow::Node getSql() {
714726
result in [
@@ -723,8 +735,11 @@ module PrivateDjango {
723735
/** Gets a reference to the `django.urls` module. */
724736
API::Node urls() { result = django().getMember("urls") }
725737

738+
/** DEPRECATED: Alias for `Urls` */
739+
deprecated module urls = Urls;
740+
726741
/** Provides models for the `django.urls` module */
727-
module urls {
742+
module Urls {
728743
/**
729744
* Gets a reference to the `django.urls.path` function.
730745
* See https://docs.djangoproject.com/en/3.0/ref/urls/#path
@@ -744,10 +759,16 @@ module PrivateDjango {
744759
/** Gets a reference to the `django.conf` module. */
745760
API::Node conf() { result = django().getMember("conf") }
746761

762+
/** DEPRECATED: Alias for `Conf` */
763+
deprecated module conf = Conf;
764+
747765
/** Provides models for the `django.conf` module */
748-
module conf {
766+
module Conf {
767+
/** DEPRECATED: Alias for `ConfUrls` */
768+
deprecated module conf_urls = ConfUrls;
769+
749770
/** Provides models for the `django.conf.urls` module */
750-
module conf_urls {
771+
module ConfUrls {
751772
// -------------------------------------------------------------------------
752773
// django.conf.urls
753774
// -------------------------------------------------------------------------
@@ -770,16 +791,22 @@ module PrivateDjango {
770791
/** Gets a reference to the `django.http` module. */
771792
API::Node http() { result = django().getMember("http") }
772793

794+
/** DEPRECATED: Alias for `Http` */
795+
deprecated module http = Http;
796+
773797
/** Provides models for the `django.http` module */
774-
module http {
798+
module Http {
775799
// ---------------------------------------------------------------------------
776800
// django.http.request
777801
// ---------------------------------------------------------------------------
778802
/** Gets a reference to the `django.http.request` module. */
779803
API::Node request() { result = http().getMember("request") }
780804

805+
/** DEPRECATED: Alias for `Request` */
806+
deprecated module request = Request;
807+
781808
/** Provides models for the `django.http.request` module. */
782-
module request {
809+
module Request {
783810
/**
784811
* Provides models for the `django.http.request.HttpRequest` class
785812
*
@@ -860,7 +887,7 @@ module PrivateDjango {
860887
// special handling of the `build_absolute_uri` method, see
861888
// https://docs.djangoproject.com/en/3.0/ref/request-response/#django.http.HttpRequest.build_absolute_uri
862889
exists(DataFlow::AttrRead attr, DataFlow::CallCfgNode call, DataFlow::Node instance |
863-
instance = django::http::request::HttpRequest::instance() and
890+
instance = DjangoImpl::Http::Request::HttpRequest::instance() and
864891
attr.getObject() = instance
865892
|
866893
attr.getAttributeName() = "build_absolute_uri" and
@@ -937,8 +964,11 @@ module PrivateDjango {
937964
/** Gets a reference to the `django.http.response` module. */
938965
API::Node response() { result = http().getMember("response") }
939966

967+
/** DEPRECATED: Alias for `Response` */
968+
deprecated module response = Response;
969+
940970
/** Provides models for the `django.http.response` module */
941-
module response {
971+
module Response {
942972
/**
943973
* Provides models for the `django.http.response.HttpResponse` class
944974
*
@@ -1672,17 +1702,17 @@ module PrivateDjango {
16721702

16731703
/** Gets a reference to the `django.http.response.HttpResponse.write` function. */
16741704
private DataFlow::TypeTrackingNode write(
1675-
django::http::response::HttpResponse::InstanceSource instance, DataFlow::TypeTracker t
1705+
DjangoImpl::Http::Response::HttpResponse::InstanceSource instance, DataFlow::TypeTracker t
16761706
) {
16771707
t.startInAttr("write") and
1678-
instance = django::http::response::HttpResponse::instance() and
1708+
instance = DjangoImpl::Http::Response::HttpResponse::instance() and
16791709
result = instance
16801710
or
16811711
exists(DataFlow::TypeTracker t2 | result = write(instance, t2).track(t2, t))
16821712
}
16831713

16841714
/** Gets a reference to the `django.http.response.HttpResponse.write` function. */
1685-
DataFlow::Node write(django::http::response::HttpResponse::InstanceSource instance) {
1715+
DataFlow::Node write(DjangoImpl::Http::Response::HttpResponse::InstanceSource instance) {
16861716
write(instance, DataFlow::TypeTracker::end()).flowsTo(result)
16871717
}
16881718

@@ -1692,7 +1722,7 @@ module PrivateDjango {
16921722
* See https://docs.djangoproject.com/en/3.1/ref/request-response/#django.http.HttpResponse.write
16931723
*/
16941724
class HttpResponseWriteCall extends HTTP::Server::HttpResponse::Range, DataFlow::CallCfgNode {
1695-
django::http::response::HttpResponse::InstanceSource instance;
1725+
DjangoImpl::Http::Response::HttpResponse::InstanceSource instance;
16961726

16971727
HttpResponseWriteCall() { this.getFunction() = write(instance) }
16981728

@@ -1713,7 +1743,7 @@ module PrivateDjango {
17131743
class DjangoResponseSetCookieCall extends HTTP::Server::CookieWrite::Range,
17141744
DataFlow::MethodCallNode {
17151745
DjangoResponseSetCookieCall() {
1716-
this.calls(django::http::response::HttpResponse::instance(), "set_cookie")
1746+
this.calls(DjangoImpl::Http::Response::HttpResponse::instance(), "set_cookie")
17171747
}
17181748

17191749
override DataFlow::Node getHeaderArg() { none() }
@@ -1733,7 +1763,7 @@ module PrivateDjango {
17331763
class DjangoResponseDeleteCookieCall extends HTTP::Server::CookieWrite::Range,
17341764
DataFlow::MethodCallNode {
17351765
DjangoResponseDeleteCookieCall() {
1736-
this.calls(django::http::response::HttpResponse::instance(), "delete_cookie")
1766+
this.calls(DjangoImpl::Http::Response::HttpResponse::instance(), "delete_cookie")
17371767
}
17381768

17391769
override DataFlow::Node getHeaderArg() { none() }
@@ -1760,7 +1790,7 @@ module PrivateDjango {
17601790
this.asCfgNode() = subscript
17611791
|
17621792
cookieLookup.getAttributeName() = "cookies" and
1763-
cookieLookup.getObject() = django::http::response::HttpResponse::instance() and
1793+
cookieLookup.getObject() = DjangoImpl::Http::Response::HttpResponse::instance() and
17641794
exists(DataFlow::Node subscriptObj |
17651795
subscriptObj.asCfgNode() = subscript.getObject()
17661796
|
@@ -1786,8 +1816,11 @@ module PrivateDjango {
17861816
/** Gets a reference to the `django.shortcuts` module. */
17871817
API::Node shortcuts() { result = django().getMember("shortcuts") }
17881818

1819+
/** DEPRECATED: Alias for `Shortcuts` */
1820+
deprecated module shortcuts = Shortcuts;
1821+
17891822
/** Provides models for the `django.shortcuts` module */
1790-
module shortcuts {
1823+
module Shortcuts {
17911824
/**
17921825
* Gets a reference to the `django.shortcuts.redirect` function
17931826
*
@@ -2063,7 +2096,7 @@ module PrivateDjango {
20632096
* See https://docs.djangoproject.com/en/3.0/ref/urls/#path
20642097
*/
20652098
private class DjangoUrlsPathCall extends DjangoRouteSetup, DataFlow::CallCfgNode {
2066-
DjangoUrlsPathCall() { this = django::urls::path().getACall() }
2099+
DjangoUrlsPathCall() { this = DjangoImpl::Urls::path().getACall() }
20672100

20682101
override DataFlow::Node getUrlPatternArg() {
20692102
result in [this.getArg(0), this.getArgByName("route")]
@@ -2146,7 +2179,7 @@ module PrivateDjango {
21462179
*/
21472180
private class DjangoUrlsRePathCall extends DjangoRegexRouteSetup, DataFlow::CallCfgNode {
21482181
DjangoUrlsRePathCall() {
2149-
this = django::urls::re_path().getACall() and
2182+
this = DjangoImpl::Urls::re_path().getACall() and
21502183
// `django.conf.urls.url` (which we support directly with
21512184
// `DjangoConfUrlsUrlCall`), is implemented in Django 2+ as backward compatibility
21522185
// using `django.urls.re_path`. See
@@ -2176,7 +2209,7 @@ module PrivateDjango {
21762209
* See https://docs.djangoproject.com/en/1.11/ref/urls/#django.conf.urls.url
21772210
*/
21782211
private class DjangoConfUrlsUrlCall extends DjangoRegexRouteSetup, DataFlow::CallCfgNode {
2179-
DjangoConfUrlsUrlCall() { this = django::conf::conf_urls::url().getACall() }
2212+
DjangoConfUrlsUrlCall() { this = DjangoImpl::Conf::ConfUrls::url().getACall() }
21802213

21812214
override DataFlow::Node getUrlPatternArg() {
21822215
result in [this.getArg(0), this.getArgByName("regex")]
@@ -2189,7 +2222,7 @@ module PrivateDjango {
21892222
// HttpRequest taint modeling
21902223
// ---------------------------------------------------------------------------
21912224
/** A parameter that will receive the django `HttpRequest` instance when a request handler is invoked. */
2192-
private class DjangoRequestHandlerRequestParam extends django::http::request::HttpRequest::InstanceSource,
2225+
private class DjangoRequestHandlerRequestParam extends DjangoImpl::Http::Request::HttpRequest::InstanceSource,
21932226
RemoteFlowSource::Range, DataFlow::ParameterNode {
21942227
DjangoRequestHandlerRequestParam() {
21952228
this.getParameter() = any(DjangoRouteSetup setup).getARequestHandler().getRequestParam()
@@ -2206,7 +2239,7 @@ module PrivateDjango {
22062239
*
22072240
* See https://docs.djangoproject.com/en/3.1/topics/class-based-views/generic-display/#dynamic-filtering
22082241
*/
2209-
private class DjangoViewClassRequestAttributeRead extends django::http::request::HttpRequest::InstanceSource,
2242+
private class DjangoViewClassRequestAttributeRead extends DjangoImpl::Http::Request::HttpRequest::InstanceSource,
22102243
RemoteFlowSource::Range, DataFlow::Node {
22112244
DjangoViewClassRequestAttributeRead() {
22122245
exists(DataFlow::AttrRead read | this = read |
@@ -2253,7 +2286,7 @@ module PrivateDjango {
22532286
*/
22542287
private class DjangoShortcutsRedirectCall extends HTTP::Server::HttpRedirectResponse::Range,
22552288
DataFlow::CallCfgNode {
2256-
DjangoShortcutsRedirectCall() { this = django::shortcuts::redirect().getACall() }
2289+
DjangoShortcutsRedirectCall() { this = DjangoImpl::Shortcuts::redirect().getACall() }
22572290

22582291
/**
22592292
* Gets the data-flow node that specifies the location of this HTTP redirect response.

0 commit comments

Comments
 (0)