Skip to content

Commit 21d5fa8

Browse files
committed
Python: Autoformat
1 parent ef97e53 commit 21d5fa8

File tree

21 files changed

+196
-99
lines changed

21 files changed

+196
-99
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,8 @@ module Http {
10191019
* Extend this class to refine existing API models. If you want to model new APIs,
10201020
* extend `CsrfLocalProtectionSetting::Range` instead.
10211021
*/
1022-
class CsrfLocalProtectionSetting extends DataFlow::Node instanceof CsrfLocalProtectionSetting::Range {
1022+
class CsrfLocalProtectionSetting extends DataFlow::Node instanceof CsrfLocalProtectionSetting::Range
1023+
{
10231024
/**
10241025
* Gets a request handler whose CSRF protection is changed.
10251026
*/

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ class SyntheticPreUpdateNode extends Node, TSyntheticPreUpdateNode {
110110
* func(1, 2, 3)
111111
*/
112112
class SynthStarArgsElementParameterNode extends ParameterNodeImpl,
113-
TSynthStarArgsElementParameterNode {
113+
TSynthStarArgsElementParameterNode
114+
{
114115
DataFlowCallable callable;
115116

116117
SynthStarArgsElementParameterNode() { this = TSynthStarArgsElementParameterNode(callable) }

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ module AiohttpWebModel {
5959
* Extend this class to refine existing API models. If you want to model new APIs,
6060
* extend `AiohttpRouteSetup::Range` instead.
6161
*/
62-
class AiohttpRouteSetup extends Http::Server::RouteSetup::Range instanceof AiohttpRouteSetup::Range {
62+
class AiohttpRouteSetup extends Http::Server::RouteSetup::Range instanceof AiohttpRouteSetup::Range
63+
{
6364
override Parameter getARoutedParameter() { none() }
6465

6566
override string getFramework() { result = "aiohttp.web" }
@@ -252,7 +253,8 @@ module AiohttpWebModel {
252253
}
253254

254255
/** A request handler defined in an `aiohttp.web` view class, that has no known route. */
255-
private class AiohttpViewClassRequestHandlerWithoutKnownRoute extends Http::Server::RequestHandler::Range {
256+
private class AiohttpViewClassRequestHandlerWithoutKnownRoute extends Http::Server::RequestHandler::Range
257+
{
256258
AiohttpViewClassRequestHandlerWithoutKnownRoute() {
257259
exists(AiohttpViewClass vc | vc.getARequestHandler() = this) and
258260
not exists(AiohttpRouteSetup setup | setup.getARequestHandler() = this)
@@ -440,7 +442,8 @@ module AiohttpWebModel {
440442
* handler is invoked.
441443
*/
442444
class AiohttpRequestHandlerRequestParam extends Request::InstanceSource, RemoteFlowSource::Range,
443-
DataFlow::ParameterNode {
445+
DataFlow::ParameterNode
446+
{
444447
AiohttpRequestHandlerRequestParam() {
445448
exists(Function requestHandler |
446449
requestHandler = any(AiohttpCoroutineRouteSetup setup).getARequestHandler() and
@@ -470,7 +473,8 @@ module AiohttpWebModel {
470473
* which is the request being processed currently.
471474
*/
472475
class AiohttpViewClassRequestAttributeRead extends Request::InstanceSource,
473-
RemoteFlowSource::Range, DataFlow::Node {
476+
RemoteFlowSource::Range, DataFlow::Node
477+
{
474478
AiohttpViewClassRequestAttributeRead() {
475479
this.(DataFlow::AttrRead).getObject() = any(AiohttpViewClass vc).getASelfRef() and
476480
this.(DataFlow::AttrRead).getAttributeName() = "request"
@@ -494,7 +498,8 @@ module AiohttpWebModel {
494498
* - https://docs.aiohttp.org/en/stable/web_quickstart.html#aiohttp-web-exceptions
495499
*/
496500
class AiohttpWebResponseInstantiation extends Http::Server::HttpResponse::Range,
497-
Response::InstanceSource, DataFlow::CallCfgNode {
501+
Response::InstanceSource, DataFlow::CallCfgNode
502+
{
498503
API::Node apiNode;
499504

500505
AiohttpWebResponseInstantiation() {
@@ -562,7 +567,8 @@ module AiohttpWebModel {
562567
* See the part about redirects at https://docs.aiohttp.org/en/stable/web_quickstart.html#aiohttp-web-exceptions
563568
*/
564569
class AiohttpRedirectExceptionInstantiation extends AiohttpWebResponseInstantiation,
565-
Http::Server::HttpRedirectResponse::Range {
570+
Http::Server::HttpRedirectResponse::Range
571+
{
566572
AiohttpRedirectExceptionInstantiation() {
567573
exists(string httpRedirectExceptionClassName |
568574
httpRedirectExceptionClassName in [
@@ -585,7 +591,8 @@ module AiohttpWebModel {
585591
/**
586592
* A call to `set_cookie` on a HTTP Response.
587593
*/
588-
class AiohttpResponseSetCookieCall extends Http::Server::CookieWrite::Range, DataFlow::CallCfgNode {
594+
class AiohttpResponseSetCookieCall extends Http::Server::CookieWrite::Range, DataFlow::CallCfgNode
595+
{
589596
AiohttpResponseSetCookieCall() {
590597
this = aiohttpResponseInstance().getMember("set_cookie").getACall()
591598
}
@@ -600,7 +607,8 @@ module AiohttpWebModel {
600607
/**
601608
* A call to `del_cookie` on a HTTP Response.
602609
*/
603-
class AiohttpResponseDelCookieCall extends Http::Server::CookieWrite::Range, DataFlow::CallCfgNode {
610+
class AiohttpResponseDelCookieCall extends Http::Server::CookieWrite::Range, DataFlow::CallCfgNode
611+
{
604612
AiohttpResponseDelCookieCall() {
605613
this = aiohttpResponseInstance().getMember("del_cookie").getACall()
606614
}

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ private module CryptodomeModel {
2323
* See https://pycryptodome.readthedocs.io/en/latest/src/public_key/rsa.html#Crypto.PublicKey.RSA.generate
2424
*/
2525
class CryptodomePublicKeyRsaGenerateCall extends Cryptography::PublicKey::KeyGeneration::RsaRange,
26-
DataFlow::CallCfgNode {
26+
DataFlow::CallCfgNode
27+
{
2728
CryptodomePublicKeyRsaGenerateCall() {
2829
this =
2930
API::moduleImport(["Crypto", "Cryptodome"])
@@ -44,7 +45,8 @@ private module CryptodomeModel {
4445
* See https://pycryptodome.readthedocs.io/en/latest/src/public_key/dsa.html#Crypto.PublicKey.DSA.generate
4546
*/
4647
class CryptodomePublicKeyDsaGenerateCall extends Cryptography::PublicKey::KeyGeneration::DsaRange,
47-
DataFlow::CallCfgNode {
48+
DataFlow::CallCfgNode
49+
{
4850
CryptodomePublicKeyDsaGenerateCall() {
4951
this =
5052
API::moduleImport(["Crypto", "Cryptodome"])
@@ -65,7 +67,8 @@ private module CryptodomeModel {
6567
* See https://pycryptodome.readthedocs.io/en/latest/src/public_key/ecc.html#Crypto.PublicKey.ECC.generate
6668
*/
6769
class CryptodomePublicKeyEccGenerateCall extends Cryptography::PublicKey::KeyGeneration::EccRange,
68-
DataFlow::CallCfgNode {
70+
DataFlow::CallCfgNode
71+
{
6972
CryptodomePublicKeyEccGenerateCall() {
7073
this =
7174
API::moduleImport(["Crypto", "Cryptodome"])
@@ -105,7 +108,8 @@ private module CryptodomeModel {
105108
* A cryptographic operation on an instance from the `Cipher` subpackage of `Cryptodome`/`Crypto`.
106109
*/
107110
class CryptodomeGenericCipherOperation extends Cryptography::CryptographicOperation::Range,
108-
DataFlow::CallCfgNode {
111+
DataFlow::CallCfgNode
112+
{
109113
string methodName;
110114
string cipherName;
111115
API::CallNode newCall;
@@ -175,7 +179,8 @@ private module CryptodomeModel {
175179
* A cryptographic operation on an instance from the `Signature` subpackage of `Cryptodome`/`Crypto`.
176180
*/
177181
class CryptodomeGenericSignatureOperation extends Cryptography::CryptographicOperation::Range,
178-
DataFlow::CallCfgNode {
182+
DataFlow::CallCfgNode
183+
{
179184
string methodName;
180185
string signatureName;
181186

@@ -214,7 +219,8 @@ private module CryptodomeModel {
214219
* A cryptographic operation on an instance from the `Hash` subpackage of `Cryptodome`/`Crypto`.
215220
*/
216221
class CryptodomeGenericHashOperation extends Cryptography::CryptographicOperation::Range,
217-
DataFlow::CallCfgNode {
222+
DataFlow::CallCfgNode
223+
{
218224
string hashName;
219225

220226
CryptodomeGenericHashOperation() {

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ private module CryptographyModel {
8282
* See https://cryptography.io/en/latest/hazmat/primitives/asymmetric/rsa.html#cryptography.hazmat.primitives.asymmetric.rsa.generate_private_key
8383
*/
8484
class CryptographyRsaGeneratePrivateKeyCall extends Cryptography::PublicKey::KeyGeneration::RsaRange,
85-
DataFlow::CallCfgNode {
85+
DataFlow::CallCfgNode
86+
{
8687
CryptographyRsaGeneratePrivateKeyCall() {
8788
this =
8889
API::moduleImport("cryptography")
@@ -105,7 +106,8 @@ private module CryptographyModel {
105106
* See https://cryptography.io/en/latest/hazmat/primitives/asymmetric/dsa.html#cryptography.hazmat.primitives.asymmetric.dsa.generate_private_key
106107
*/
107108
class CryptographyDsaGeneratePrivateKeyCall extends Cryptography::PublicKey::KeyGeneration::DsaRange,
108-
DataFlow::CallCfgNode {
109+
DataFlow::CallCfgNode
110+
{
109111
CryptographyDsaGeneratePrivateKeyCall() {
110112
this =
111113
API::moduleImport("cryptography")
@@ -128,7 +130,8 @@ private module CryptographyModel {
128130
* See https://cryptography.io/en/latest/hazmat/primitives/asymmetric/ec.html#cryptography.hazmat.primitives.asymmetric.ec.generate_private_key
129131
*/
130132
class CryptographyEcGeneratePrivateKeyCall extends Cryptography::PublicKey::KeyGeneration::EccRange,
131-
DataFlow::CallCfgNode {
133+
DataFlow::CallCfgNode
134+
{
132135
CryptographyEcGeneratePrivateKeyCall() {
133136
this =
134137
API::moduleImport("cryptography")
@@ -204,7 +207,8 @@ private module CryptographyModel {
204207
* An encrypt or decrypt operation from `cryptography.hazmat.primitives.ciphers`.
205208
*/
206209
class CryptographyGenericCipherOperation extends Cryptography::CryptographicOperation::Range,
207-
DataFlow::MethodCallNode {
210+
DataFlow::MethodCallNode
211+
{
208212
string algorithmName;
209213
string modeName;
210214

@@ -262,7 +266,8 @@ private module CryptographyModel {
262266
* An hashing operation from `cryptography.hazmat.primitives.hashes`.
263267
*/
264268
class CryptographyGenericHashOperation extends Cryptography::CryptographicOperation::Range,
265-
DataFlow::MethodCallNode {
269+
DataFlow::MethodCallNode
270+
{
266271
string algorithmName;
267272

268273
CryptographyGenericHashOperation() {

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

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,23 +1271,26 @@ module PrivateDjango {
12711271
}
12721272

12731273
/** An attribute read on an django request that is a `MultiValueDict` instance. */
1274-
private class DjangoHttpRequestMultiValueDictInstances extends Django::MultiValueDict::InstanceSource {
1274+
private class DjangoHttpRequestMultiValueDictInstances extends Django::MultiValueDict::InstanceSource
1275+
{
12751276
DjangoHttpRequestMultiValueDictInstances() {
12761277
this.(DataFlow::AttrRead).getObject() = instance() and
12771278
this.(DataFlow::AttrRead).getAttributeName() in ["GET", "POST", "FILES"]
12781279
}
12791280
}
12801281

12811282
/** An attribute read on an django request that is a `ResolverMatch` instance. */
1282-
private class DjangoHttpRequestResolverMatchInstances extends Django::ResolverMatch::InstanceSource {
1283+
private class DjangoHttpRequestResolverMatchInstances extends Django::ResolverMatch::InstanceSource
1284+
{
12831285
DjangoHttpRequestResolverMatchInstances() {
12841286
this.(DataFlow::AttrRead).getObject() = instance() and
12851287
this.(DataFlow::AttrRead).getAttributeName() = "resolver_match"
12861288
}
12871289
}
12881290

12891291
/** An `UploadedFile` instance that originates from a django request. */
1290-
private class DjangoHttpRequestUploadedFileInstances extends Django::UploadedFile::InstanceSource {
1292+
private class DjangoHttpRequestUploadedFileInstances extends Django::UploadedFile::InstanceSource
1293+
{
12911294
DjangoHttpRequestUploadedFileInstances() {
12921295
// TODO: this currently only works in local-scope, since writing type-trackers for
12931296
// this is a little too much effort. Once API-graphs are available for more
@@ -1421,7 +1424,8 @@ module PrivateDjango {
14211424
* Use the predicate `HttpResponseRedirect::instance()` to get references to instances of `django.http.response.HttpResponseRedirect`.
14221425
*/
14231426
abstract class InstanceSource extends HttpResponse::InstanceSource,
1424-
Http::Server::HttpRedirectResponse::Range, DataFlow::Node { }
1427+
Http::Server::HttpRedirectResponse::Range, DataFlow::Node
1428+
{ }
14251429

14261430
/** A direct instantiation of `django.http.response.HttpResponseRedirect`. */
14271431
private class ClassInstantiation extends InstanceSource, DataFlow::CallCfgNode {
@@ -1483,7 +1487,8 @@ module PrivateDjango {
14831487
* Use the predicate `HttpResponsePermanentRedirect::instance()` to get references to instances of `django.http.response.HttpResponsePermanentRedirect`.
14841488
*/
14851489
abstract class InstanceSource extends HttpResponse::InstanceSource,
1486-
Http::Server::HttpRedirectResponse::Range, DataFlow::Node { }
1490+
Http::Server::HttpRedirectResponse::Range, DataFlow::Node
1491+
{ }
14871492

14881493
/** A direct instantiation of `django.http.response.HttpResponsePermanentRedirect`. */
14891494
private class ClassInstantiation extends InstanceSource, DataFlow::CallCfgNode {
@@ -2086,7 +2091,8 @@ module PrivateDjango {
20862091
*
20872092
* See https://docs.djangoproject.com/en/3.1/ref/request-response/#django.http.HttpResponse.write
20882093
*/
2089-
class HttpResponseWriteCall extends Http::Server::HttpResponse::Range, DataFlow::CallCfgNode {
2094+
class HttpResponseWriteCall extends Http::Server::HttpResponse::Range, DataFlow::CallCfgNode
2095+
{
20902096
DjangoImpl::DjangoHttp::Response::HttpResponse::InstanceSource instance;
20912097

20922098
HttpResponseWriteCall() { this.getFunction() = write(instance) }
@@ -2106,7 +2112,8 @@ module PrivateDjango {
21062112
* A call to `set_cookie` on a HTTP Response.
21072113
*/
21082114
class DjangoResponseSetCookieCall extends Http::Server::CookieWrite::Range,
2109-
DataFlow::MethodCallNode {
2115+
DataFlow::MethodCallNode
2116+
{
21102117
DjangoResponseSetCookieCall() {
21112118
this.calls(DjangoImpl::DjangoHttp::Response::HttpResponse::instance(), "set_cookie")
21122119
}
@@ -2126,7 +2133,8 @@ module PrivateDjango {
21262133
* A call to `delete_cookie` on a HTTP Response.
21272134
*/
21282135
class DjangoResponseDeleteCookieCall extends Http::Server::CookieWrite::Range,
2129-
DataFlow::MethodCallNode {
2136+
DataFlow::MethodCallNode
2137+
{
21302138
DjangoResponseDeleteCookieCall() {
21312139
this.calls(DjangoImpl::DjangoHttp::Response::HttpResponse::instance(), "delete_cookie")
21322140
}
@@ -2429,7 +2437,8 @@ module PrivateDjango {
24292437

24302438
/** A request handler defined in a django view class, that has no known route. */
24312439
private class DjangoViewClassHandlerWithoutKnownRoute extends Http::Server::RequestHandler::Range,
2432-
DjangoRouteHandler {
2440+
DjangoRouteHandler
2441+
{
24332442
DjangoViewClassHandlerWithoutKnownRoute() {
24342443
exists(DjangoViewClass vc | vc.getARequestHandler() = this) and
24352444
not exists(DjangoRouteSetup setup | setup.getARequestHandler() = this)
@@ -2587,7 +2596,8 @@ module PrivateDjango {
25872596
// ---------------------------------------------------------------------------
25882597
/** A parameter that will receive the django `HttpRequest` instance when a request handler is invoked. */
25892598
private class DjangoRequestHandlerRequestParam extends DjangoImpl::DjangoHttp::Request::HttpRequest::InstanceSource,
2590-
RemoteFlowSource::Range, DataFlow::ParameterNode {
2599+
RemoteFlowSource::Range, DataFlow::ParameterNode
2600+
{
25912601
DjangoRequestHandlerRequestParam() {
25922602
this.getParameter() = any(DjangoRouteSetup setup).getARequestHandler().getRequestParam()
25932603
or
@@ -2604,7 +2614,8 @@ module PrivateDjango {
26042614
* See https://docs.djangoproject.com/en/3.1/topics/class-based-views/generic-display/#dynamic-filtering
26052615
*/
26062616
private class DjangoViewClassRequestAttributeRead extends DjangoImpl::DjangoHttp::Request::HttpRequest::InstanceSource,
2607-
RemoteFlowSource::Range, DataFlow::Node {
2617+
RemoteFlowSource::Range, DataFlow::Node
2618+
{
26082619
DjangoViewClassRequestAttributeRead() {
26092620
exists(DataFlow::AttrRead read | this = read |
26102621
read.getObject() = any(DjangoViewClass vc).getASelfRef() and
@@ -2624,7 +2635,8 @@ module PrivateDjango {
26242635
* See https://docs.djangoproject.com/en/3.1/topics/class-based-views/generic-display/#dynamic-filtering
26252636
*/
26262637
private class DjangoViewClassRoutedParamsAttributeRead extends RemoteFlowSource::Range,
2627-
DataFlow::Node {
2638+
DataFlow::Node
2639+
{
26282640
DjangoViewClassRoutedParamsAttributeRead() {
26292641
exists(DataFlow::AttrRead read | this = read |
26302642
read.getObject() = any(DjangoViewClass vc).getASelfRef() and
@@ -2652,7 +2664,8 @@ module PrivateDjango {
26522664
* - https://docs.djangoproject.com/en/3.1/topics/http/file-uploads/#handling-uploaded-files-with-a-model
26532665
*/
26542666
private class DjangoFileFieldUploadToFunctionFilenameParam extends RemoteFlowSource::Range,
2655-
DataFlow::ParameterNode {
2667+
DataFlow::ParameterNode
2668+
{
26562669
DjangoFileFieldUploadToFunctionFilenameParam() {
26572670
exists(DataFlow::CallCfgNode call, DataFlow::Node uploadToArg, Function func |
26582671
this.getParameter() = func.getArg(1) and
@@ -2679,7 +2692,8 @@ module PrivateDjango {
26792692
* See https://docs.djangoproject.com/en/3.1/topics/http/shortcuts/#redirect
26802693
*/
26812694
private class DjangoShortcutsRedirectCall extends Http::Server::HttpRedirectResponse::Range,
2682-
DataFlow::CallCfgNode {
2695+
DataFlow::CallCfgNode
2696+
{
26832697
DjangoShortcutsRedirectCall() { this = DjangoImpl::Shortcuts::redirect().getACall() }
26842698

26852699
/**
@@ -2713,7 +2727,8 @@ module PrivateDjango {
27132727
* See https://docs.djangoproject.com/en/3.1/ref/class-based-views/base/#redirectview
27142728
*/
27152729
private class DjangoRedirectViewGetRedirectUrlReturn extends Http::Server::HttpRedirectResponse::Range,
2716-
DataFlow::CfgNode {
2730+
DataFlow::CfgNode
2731+
{
27172732
DjangoRedirectViewGetRedirectUrlReturn() {
27182733
node = any(GetRedirectUrlFunction f).getAReturnValueFlowNode()
27192734
}

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ private module FabricV1 {
4444
* - https://docs.fabfile.org/en/1.14/api/core/operations.html#fabric.operations.sudo
4545
*/
4646
private class FabricApiLocalRunSudoCall extends SystemCommandExecution::Range,
47-
DataFlow::CallCfgNode {
47+
DataFlow::CallCfgNode
48+
{
4849
FabricApiLocalRunSudoCall() { this = api().getMember(["local", "run", "sudo"]).getACall() }
4950

5051
override DataFlow::Node getCommand() {
@@ -153,7 +154,8 @@ private module FabricV2 {
153154
* - https://docs.fabfile.org/en/2.5/api/connection.html#fabric.connection.Connection.local
154155
*/
155156
private class FabricConnectionRunSudoLocalCall extends SystemCommandExecution::Range,
156-
DataFlow::CallCfgNode {
157+
DataFlow::CallCfgNode
158+
{
157159
FabricConnectionRunSudoLocalCall() {
158160
this.getFunction() = Fabric::Connection::ConnectionClass::instanceRunMethods()
159161
}
@@ -176,7 +178,8 @@ private module FabricV2 {
176178
}
177179

178180
class FabricTaskFirstParamConnectionInstance extends Fabric::Connection::ConnectionClass::InstanceSource,
179-
DataFlow::ParameterNode {
181+
DataFlow::ParameterNode
182+
{
180183
FabricTaskFirstParamConnectionInstance() {
181184
exists(Function func |
182185
func.getADecorator() = Fabric::Tasks::task().getAValueReachableFromSource().asExpr() and

0 commit comments

Comments
 (0)