mirror of
https://github.com/github/codeql.git
synced 2025-12-18 01:33:15 +01:00
C#: Autoformat QLL files
This commit is contained in:
@@ -4,28 +4,18 @@ private import semmle.code.csharp.frameworks.System
|
||||
private import semmle.code.csharp.frameworks.system.web.UI
|
||||
|
||||
class DisposableType extends RefType {
|
||||
DisposableType() {
|
||||
this.getABaseType+() instanceof SystemIDisposableInterface
|
||||
}
|
||||
DisposableType() { this.getABaseType+() instanceof SystemIDisposableInterface }
|
||||
}
|
||||
|
||||
class DisposableField extends Field {
|
||||
DisposableField() {
|
||||
this.getType() instanceof DisposableType
|
||||
}
|
||||
DisposableField() { this.getType() instanceof DisposableType }
|
||||
}
|
||||
|
||||
class WebControl extends RefType {
|
||||
WebControl() {
|
||||
this.getBaseClass*() instanceof SystemWebUIControlClass
|
||||
}
|
||||
WebControl() { this.getBaseClass*() instanceof SystemWebUIControlClass }
|
||||
}
|
||||
|
||||
class WebPage extends RefType {
|
||||
WebPage() {
|
||||
this.getBaseClass*() instanceof SystemWebUIPageClass
|
||||
}
|
||||
}
|
||||
class WebPage extends RefType { WebPage() { this.getBaseClass*() instanceof SystemWebUIPageClass } }
|
||||
|
||||
/**
|
||||
* Holds if `f` is an auto-disposed web control.
|
||||
@@ -37,15 +27,13 @@ class WebPage extends RefType {
|
||||
* `UnloadRecursive()`.
|
||||
*/
|
||||
predicate isAutoDisposedWebControl(Field f) {
|
||||
f.getType() instanceof WebControl
|
||||
and
|
||||
f.getType() instanceof WebControl and
|
||||
f.getDeclaringType() = any(RefType t |
|
||||
t instanceof WebControl or
|
||||
t instanceof WebPage
|
||||
)
|
||||
t instanceof WebControl or
|
||||
t instanceof WebPage
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* An object creation that creates an `IDisposable` instance into the local scope.
|
||||
*/
|
||||
@@ -56,13 +44,13 @@ class LocalScopeDisposableCreation extends Call {
|
||||
// Type extends IDisposable
|
||||
t instanceof DisposableType and
|
||||
// Within function, not field or instance initializer
|
||||
exists(this.getEnclosingCallable()) |
|
||||
exists(this.getEnclosingCallable())
|
||||
|
|
||||
// Either an ordinary object creation
|
||||
this instanceof ObjectCreation
|
||||
or
|
||||
// Or a creation using a factory method
|
||||
exists(Method create |
|
||||
this.getTarget() = create |
|
||||
exists(Method create | this.getTarget() = create |
|
||||
create.hasName("Create") and
|
||||
create.isStatic() and
|
||||
create.getDeclaringType().getSourceDeclaration() = t.getSourceDeclaration()
|
||||
@@ -74,20 +62,17 @@ class LocalScopeDisposableCreation extends Call {
|
||||
* Gets an expression that, if it is disposed of, will imply that the object
|
||||
* created by this creation is disposed of as well.
|
||||
*/
|
||||
Expr getADisposeTarget() {
|
||||
result = getADisposeTarget0().asExpr()
|
||||
}
|
||||
Expr getADisposeTarget() { result = getADisposeTarget0().asExpr() }
|
||||
|
||||
private DataFlow::Node getADisposeTarget0() {
|
||||
result = exprNode(this)
|
||||
or
|
||||
exists(DataFlow::Node mid |
|
||||
mid = this.getADisposeTarget0() |
|
||||
exists(DataFlow::Node mid | mid = this.getADisposeTarget0() |
|
||||
localFlowStep(mid, result)
|
||||
or
|
||||
result.asExpr() = any(LocalScopeDisposableCreation other |
|
||||
other.getAnArgument() = mid.asExpr()
|
||||
)
|
||||
other.getAnArgument() = mid.asExpr()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user