mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C#: Use {get,has}FullyQualifiedName throughout
This commit is contained in:
@@ -10,5 +10,5 @@
|
||||
import csharp
|
||||
|
||||
from CatchClause catch
|
||||
where catch.getCaughtExceptionType().hasQualifiedName("System.IO", "IOException")
|
||||
where catch.getCaughtExceptionType().hasFullyQualifiedName("System.IO", "IOException")
|
||||
select catch
|
||||
|
||||
@@ -10,5 +10,5 @@
|
||||
import csharp
|
||||
|
||||
from ObjectCreation new
|
||||
where new.getObjectType().hasQualifiedName("System", "Exception")
|
||||
where new.getObjectType().hasFullyQualifiedName("System", "Exception")
|
||||
select new
|
||||
|
||||
@@ -13,5 +13,5 @@
|
||||
import csharp
|
||||
|
||||
from RefType type
|
||||
where type.getABaseType+().hasQualifiedName("System.Collections", "IEnumerator")
|
||||
where type.getABaseType+().hasFullyQualifiedName("System.Collections", "IEnumerator")
|
||||
select type
|
||||
|
||||
@@ -11,6 +11,6 @@ import csharp
|
||||
from Field f, FieldRead read
|
||||
where
|
||||
f.hasName("VirtualAddress") and
|
||||
f.getDeclaringType().hasQualifiedName("Mono.Cecil.PE", "Section") and
|
||||
f.getDeclaringType().hasFullyQualifiedName("Mono.Cecil.PE", "Section") and
|
||||
f = read.getTarget()
|
||||
select read
|
||||
|
||||
@@ -12,5 +12,5 @@ from MethodCall call, Method method
|
||||
where
|
||||
call.getTarget() = method and
|
||||
method.hasName("MethodName") and
|
||||
method.getDeclaringType().hasQualifiedName("Company", "Class")
|
||||
method.getDeclaringType().hasFullyQualifiedName("Company", "Class")
|
||||
select call
|
||||
|
||||
@@ -17,6 +17,6 @@ where
|
||||
add.hasName("Add") and
|
||||
add.getDeclaringType()
|
||||
.getUnboundDeclaration()
|
||||
.hasQualifiedName("System.Collections.Generic", "ICollection<>") and
|
||||
.hasFullyQualifiedName("System.Collections.Generic", "ICollection`1") and
|
||||
call.getAnArgument() instanceof NullLiteral
|
||||
select call
|
||||
|
||||
@@ -11,6 +11,6 @@ import csharp
|
||||
from Method override, Method base
|
||||
where
|
||||
base.hasName("ToString") and
|
||||
base.getDeclaringType().hasQualifiedName("System", "Object") and
|
||||
base.getDeclaringType().hasFullyQualifiedName("System", "Object") and
|
||||
base.getAnOverrider() = override
|
||||
select override
|
||||
|
||||
@@ -9,5 +9,6 @@
|
||||
import csharp
|
||||
|
||||
from ThrowStmt throw
|
||||
where throw.getThrownExceptionType().getBaseClass*().hasQualifiedName("System.IO", "IOException")
|
||||
where
|
||||
throw.getThrownExceptionType().getBaseClass*().hasFullyQualifiedName("System.IO", "IOException")
|
||||
select throw
|
||||
|
||||
@@ -2,4 +2,4 @@ import csharp
|
||||
|
||||
from Class c
|
||||
where c.fromSource()
|
||||
select c, c.getBaseClass().getQualifiedName()
|
||||
select c, c.getBaseClass().getFullyQualifiedName()
|
||||
|
||||
@@ -21,12 +21,14 @@ private int numStmts(ForeachStmt fes) {
|
||||
}
|
||||
|
||||
/** Holds if the type's qualified name is "System.Linq.Enumerable" */
|
||||
predicate isEnumerableType(ValueOrRefType t) { t.hasQualifiedName("System.Linq", "Enumerable") }
|
||||
predicate isEnumerableType(ValueOrRefType t) {
|
||||
t.hasFullyQualifiedName("System.Linq", "Enumerable")
|
||||
}
|
||||
|
||||
/** Holds if the type's qualified name starts with "System.Collections.Generic.IEnumerable" */
|
||||
predicate isIEnumerableType(ValueOrRefType t) {
|
||||
exists(string type |
|
||||
t.hasQualifiedName("System.Collections.Generic", type) and
|
||||
t.hasFullyQualifiedName("System.Collections.Generic", type) and
|
||||
type.matches("IEnumerable%")
|
||||
)
|
||||
}
|
||||
@@ -159,7 +161,7 @@ class AnyCall extends MethodCall {
|
||||
exists(Method m |
|
||||
m = this.getTarget().getUnboundDeclaration() and
|
||||
isEnumerableType(m.getDeclaringType()) and
|
||||
m.hasName("Any<>")
|
||||
m.hasName("Any`1")
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -170,7 +172,7 @@ class CountCall extends MethodCall {
|
||||
exists(Method m |
|
||||
m = this.getTarget().getUnboundDeclaration() and
|
||||
isEnumerableType(m.getDeclaringType()) and
|
||||
m.hasName("Count<>")
|
||||
m.hasName("Count`1")
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -186,7 +188,7 @@ class SelectCall extends ExtensionMethodCall {
|
||||
exists(Method m |
|
||||
m = this.getTarget().getUnboundDeclaration() and
|
||||
isEnumerableType(m.getDeclaringType()) and
|
||||
m.hasName("Select<,>")
|
||||
m.hasName("Select`2")
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ class PageDirective extends AspDirective {
|
||||
*/
|
||||
ValueOrRefType getInheritedType() {
|
||||
exists(string qualifier, string type |
|
||||
result.hasQualifiedName(qualifier, type) and
|
||||
result.hasFullyQualifiedName(qualifier, type) and
|
||||
splitQualifiedName(this.getInheritedTypeQualifiedName(), qualifier, type)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ class InvalidOverride extends MethodViolation {
|
||||
|
||||
override string getMessage() {
|
||||
exists(string qualifier, string type |
|
||||
base.getDeclaringType().hasQualifiedName(qualifier, type)
|
||||
base.getDeclaringType().hasFullyQualifiedName(qualifier, type)
|
||||
|
|
||||
result =
|
||||
"Overridden method from " + getQualifiedName(qualifier, type) + " is not in a base type"
|
||||
|
||||
@@ -147,7 +147,7 @@ class Method extends DotNet::Callable, Element, Member, TypeContainer, DataFlowN
|
||||
|
||||
/** Holds if this method is a destructor/finalizer. */
|
||||
predicate isFinalizer() {
|
||||
this.getOverriddenMethod*().hasQualifiedName("System", "Object", "Finalize")
|
||||
this.getOverriddenMethod*().hasFullyQualifiedName("System", "Object", "Finalize")
|
||||
}
|
||||
|
||||
/** Holds if this method is an operator. */
|
||||
@@ -259,7 +259,7 @@ class Setter extends Accessor {
|
||||
|
||||
/** Holds if this setter is an `init` accessor. */
|
||||
predicate isInitOnly() {
|
||||
exists(Type t | t.hasQualifiedName("System.Runtime.CompilerServices", "IsExternalInit") |
|
||||
exists(Type t | t.hasFullyQualifiedName("System.Runtime.CompilerServices", "IsExternalInit") |
|
||||
this.hasRequiredCustomModifier(t)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ private string getTypeArgumentsNames(ConstructedGeneric cg) {
|
||||
|
||||
/**
|
||||
* An unbound generic type. This is a generic type with type parameters
|
||||
* (for example `List<T>`) or elided type parameters (for example `List<>`).
|
||||
* (for example `List<T>`) or elided type parameters (for example ``List`1``).
|
||||
*
|
||||
* Either an unbound generic `struct` (`UnboundGenericStruct`), an unbound generic `class`
|
||||
* (`UnboundGenericClass`), an unbound generic `interface` (`UnboundGenericInterface`), or
|
||||
|
||||
@@ -107,10 +107,10 @@ private ValueOrRefType getAnInterestingBaseType(ValueOrRefType type) {
|
||||
|
||||
private predicate isInterestingBaseType(ValueOrRefType type, ValueOrRefType base) {
|
||||
not base instanceof ObjectType and
|
||||
not base.hasQualifiedName("System", "ValueType") and
|
||||
not base.hasQualifiedName("System", "Delegate") and
|
||||
not base.hasQualifiedName("System", "MulticastDelegate") and
|
||||
not base.hasQualifiedName("System", "Enum") and
|
||||
not base.hasFullyQualifiedName("System", "ValueType") and
|
||||
not base.hasFullyQualifiedName("System", "Delegate") and
|
||||
not base.hasFullyQualifiedName("System", "MulticastDelegate") and
|
||||
not base.hasFullyQualifiedName("System", "Enum") and
|
||||
exists(TypeMention tm | tm.getTarget() = type and tm.getType() = base)
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class BlockStmt extends Stmt, @block_stmt {
|
||||
|
||||
/** Holds if this block is the container of the global statements. */
|
||||
predicate isGlobalStatementContainer() {
|
||||
this.getEnclosingCallable().hasQualifiedName("Program", "<Main>$")
|
||||
this.getEnclosingCallable().hasFullyQualifiedName("Program", "<Main>$")
|
||||
}
|
||||
|
||||
override Stmt stripSingletonBlocks() {
|
||||
|
||||
@@ -287,7 +287,7 @@ class ValueOrRefType extends DotNet::ValueOrRefType, Type, Attributable, @value_
|
||||
|
||||
/** Gets the length of *some* path to the root of the hierarchy. */
|
||||
int getADepth() {
|
||||
this.hasQualifiedName("System", "Object") and result = 0
|
||||
this.hasFullyQualifiedName("System", "Object") and result = 0
|
||||
or
|
||||
result = this.getABaseType().getADepth() + 1 and
|
||||
//prevent recursion on cyclic inheritance (only for incorrect databases)
|
||||
@@ -809,7 +809,7 @@ class AnonymousClass extends Class {
|
||||
* The `object` type, `System.Object`.
|
||||
*/
|
||||
class ObjectType extends Class {
|
||||
ObjectType() { this.hasQualifiedName("System", "Object") }
|
||||
ObjectType() { this.hasFullyQualifiedName("System", "Object") }
|
||||
|
||||
override string toStringWithTypes() { result = "object" }
|
||||
|
||||
@@ -820,7 +820,7 @@ class ObjectType extends Class {
|
||||
* The `string` type, `System.String`.
|
||||
*/
|
||||
class StringType extends Class {
|
||||
StringType() { this.hasQualifiedName("System", "String") }
|
||||
StringType() { this.hasFullyQualifiedName("System", "String") }
|
||||
|
||||
override string toStringWithTypes() { result = "string" }
|
||||
|
||||
@@ -994,7 +994,7 @@ class NullableType extends ValueType, ConstructedType, @nullable_type {
|
||||
}
|
||||
|
||||
override UnboundGenericStruct getUnboundGeneric() {
|
||||
result.hasQualifiedName("System", "Nullable<>")
|
||||
result.hasFullyQualifiedName("System", "Nullable`1")
|
||||
}
|
||||
|
||||
override string toStringWithTypes() {
|
||||
|
||||
@@ -45,10 +45,10 @@ private string genericCollectionNamespaceName() {
|
||||
private string genericCollectionTypeName() {
|
||||
result =
|
||||
[
|
||||
"Dictionary<,>", "HashSet<>", "ICollection<>", "IDictionary<,>", "IList<>", "ISet<>",
|
||||
"LinkedList<>", "List<>", "Queue<>", "SortedDictionary<,>", "SortedList<,>", "SortedSet<>",
|
||||
"Stack<>", "SynchronizedCollection<>", "SynchronizedKeyedCollection<>",
|
||||
"SynchronizedReadOnlyCollection<>"
|
||||
"Dictionary`2", "HashSet`1", "ICollection`1", "IDictionary`2", "IList`1", "ISet`1",
|
||||
"LinkedList`1", "List`1", "Queue`1", "SortedDictionary`2", "SortedList`2", "SortedSet`1",
|
||||
"Stack`1", "SynchronizedCollection`1", "SynchronizedKeyedCollection`1",
|
||||
"SynchronizedReadOnlyCollection`1"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -56,11 +56,11 @@ private string genericCollectionTypeName() {
|
||||
class CollectionType extends RefType {
|
||||
CollectionType() {
|
||||
exists(RefType base | base = this.getABaseType*() |
|
||||
base.hasQualifiedName(collectionNamespaceName(), collectionTypeName())
|
||||
base.hasFullyQualifiedName(collectionNamespaceName(), collectionTypeName())
|
||||
or
|
||||
base.(ConstructedType)
|
||||
.getUnboundGeneric()
|
||||
.hasQualifiedName(genericCollectionNamespaceName(), genericCollectionTypeName())
|
||||
.hasFullyQualifiedName(genericCollectionNamespaceName(), genericCollectionTypeName())
|
||||
)
|
||||
or
|
||||
this instanceof ArrayType
|
||||
|
||||
@@ -14,7 +14,7 @@ class TargetFrameworkAttribute extends Attribute {
|
||||
Assembly assembly;
|
||||
|
||||
TargetFrameworkAttribute() {
|
||||
this.getType().hasQualifiedName("System.Runtime.Versioning", "TargetFrameworkAttribute") and
|
||||
this.getType().hasFullyQualifiedName("System.Runtime.Versioning", "TargetFrameworkAttribute") and
|
||||
assembly = this.getTarget()
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ class MainMethod extends Method {
|
||||
(
|
||||
this.hasName("Main")
|
||||
or
|
||||
this.hasQualifiedName("Program", "<Main>$")
|
||||
this.hasFullyQualifiedName("Program", "<Main>$")
|
||||
) and
|
||||
this.isStatic() and
|
||||
(this.getReturnType() instanceof VoidType or this.getReturnType() instanceof IntType) and
|
||||
|
||||
@@ -780,7 +780,7 @@ module Expressions {
|
||||
nc.getOuterCompletion()
|
||||
.(ThrowCompletion)
|
||||
.getExceptionClass()
|
||||
.hasQualifiedName("System", "InvalidOperationException")
|
||||
.hasFullyQualifiedName("System", "InvalidOperationException")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -51,7 +51,8 @@ private class ThrowingCall extends NonReturningCall {
|
||||
this =
|
||||
any(MethodCall mc |
|
||||
mc.getTarget()
|
||||
.hasQualifiedName("System.Runtime.ExceptionServices", "ExceptionDispatchInfo", "Throw") and
|
||||
.hasFullyQualifiedName("System.Runtime.ExceptionServices", "ExceptionDispatchInfo",
|
||||
"Throw") and
|
||||
(
|
||||
mc.hasNoArguments() and
|
||||
c.getExceptionClass() instanceof SystemExceptionClass
|
||||
@@ -85,8 +86,8 @@ private class DirectlyExitingCallable extends ExitingCallable {
|
||||
DirectlyExitingCallable() {
|
||||
this =
|
||||
any(Method m |
|
||||
m.hasQualifiedName("System", "Environment", "Exit") or
|
||||
m.hasQualifiedName("System.Windows.Forms", "Application", "Exit")
|
||||
m.hasFullyQualifiedName("System", "Environment", "Exit") or
|
||||
m.hasFullyQualifiedName("System.Windows.Forms", "Application", "Exit")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,19 +174,21 @@ SummaryComponent interpretComponentSpecific(AccessPathToken c) {
|
||||
or
|
||||
c = "WithElement" and result = SummaryComponent::withContent(any(ElementContent ec))
|
||||
or
|
||||
// Qualified names may contain commas,such as in `Tuple<,>`, so get the entire argument list
|
||||
// rather than an individual argument.
|
||||
exists(Field f |
|
||||
c.getAnArgument("Field") = f.getFullyQualifiedName() and
|
||||
c.getName() = "Field" and
|
||||
c.getArgumentList() = f.getFullyQualifiedName() and
|
||||
result = SummaryComponent::content(any(FieldContent fc | fc.getField() = f))
|
||||
)
|
||||
or
|
||||
exists(Property p |
|
||||
|
||||
c.getAnArgument("Property") = p.getFullyQualifiedName() and
|
||||
c.getName() = "Property" and
|
||||
c.getArgumentList() = p.getFullyQualifiedName() and
|
||||
result = SummaryComponent::content(any(PropertyContent pc | pc.getProperty() = p))
|
||||
)
|
||||
or
|
||||
exists(SyntheticField f |
|
||||
|
||||
c.getAnArgument("SyntheticField") = f and
|
||||
result = SummaryComponent::content(any(SyntheticFieldContent sfc | sfc.getField() = f))
|
||||
)
|
||||
@@ -198,7 +200,9 @@ private string getContentSpecific(Content c) {
|
||||
or
|
||||
exists(Field f | c = TFieldContent(f) and result = "Field[" + f.getFullyQualifiedName() + "]")
|
||||
or
|
||||
exists(Property p | c = TPropertyContent(p) and result = "Property[" + p.getFullyQualifiedName() + "]")
|
||||
exists(Property p |
|
||||
c = TPropertyContent(p) and result = "Property[" + p.getFullyQualifiedName() + "]"
|
||||
)
|
||||
or
|
||||
exists(SyntheticField f | c = TSyntheticFieldContent(f) and result = "SyntheticField[" + f + "]")
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ private module Impl {
|
||||
*/
|
||||
predicate propertyOverrides(Property p, string namespace, string baseClass, string property) {
|
||||
exists(Property p2 |
|
||||
p2.getUnboundDeclaration().getDeclaringType().hasQualifiedName(namespace, baseClass) and
|
||||
p2.getUnboundDeclaration().getDeclaringType().hasFullyQualifiedName(namespace, baseClass) and
|
||||
p2.hasName(property)
|
||||
|
|
||||
p.overridesOrImplementsOrEquals(p2)
|
||||
|
||||
@@ -83,7 +83,7 @@ private module Impl {
|
||||
*/
|
||||
predicate containerSizeAccess(ExprNode e) {
|
||||
exists(Property p | p = e.getExpr().(PropertyAccess).getTarget() |
|
||||
propertyOverrides(p, "System.Collections.Generic", "IEnumerable<>", "Count") or
|
||||
propertyOverrides(p, "System.Collections.Generic", "IEnumerable`1", "Count") or
|
||||
propertyOverrides(p, "System.Collections", "ICollection", "Count") or
|
||||
propertyOverrides(p, "System", "String", "Length") or
|
||||
propertyOverrides(p, "System", "Array", "Length")
|
||||
|
||||
@@ -21,7 +21,8 @@ module DataAnnotations {
|
||||
class NotMappedAttribute extends Attribute {
|
||||
NotMappedAttribute() {
|
||||
this.getType()
|
||||
.hasQualifiedName("System.ComponentModel.DataAnnotations.Schema", "NotMappedAttribute")
|
||||
.hasFullyQualifiedName("System.ComponentModel.DataAnnotations.Schema",
|
||||
"NotMappedAttribute")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,9 +68,9 @@ module EntityFramework {
|
||||
Method getAnUpdateMethod() { result = this.getAMethod("Update") }
|
||||
}
|
||||
|
||||
/** The class `Microsoft.EntityFrameworkCore.DbSet<>` or `System.Data.Entity.DbSet<>`. */
|
||||
/** The class ``Microsoft.EntityFrameworkCore.DbSet`1`` or ``System.Data.Entity.DbSet`1``. */
|
||||
class DbSet extends EFClass, UnboundGenericClass {
|
||||
DbSet() { this.getName() = "DbSet<>" }
|
||||
DbSet() { this.getName() = "DbSet`1" }
|
||||
|
||||
/** Gets a method that adds or updates entities in a DB set. */
|
||||
Method getAnAddOrUpdateMethod(boolean range) {
|
||||
@@ -89,9 +90,9 @@ module EntityFramework {
|
||||
EFSummarizedCallable() { any() }
|
||||
}
|
||||
|
||||
/** The class `Microsoft.EntityFrameworkCore.DbQuery<>` or `System.Data.Entity.DbQuery<>`. */
|
||||
/** The class ``Microsoft.EntityFrameworkCore.DbQuery`1`` or ``System.Data.Entity.DbQuery`1``. */
|
||||
class DbQuery extends EFClass, UnboundGenericClass {
|
||||
DbQuery() { this.hasName("DbQuery<>") }
|
||||
DbQuery() { this.hasName("DbQuery`1") }
|
||||
}
|
||||
|
||||
/** A generic type or method that takes a mapped type as its type argument. */
|
||||
@@ -134,7 +135,9 @@ module EntityFramework {
|
||||
|
||||
/** The struct `Microsoft.EntityFrameworkCore.RawSqlString`. */
|
||||
private class RawSqlStringStruct extends Struct {
|
||||
RawSqlStringStruct() { this.hasQualifiedName("Microsoft.EntityFrameworkCore", "RawSqlString") }
|
||||
RawSqlStringStruct() {
|
||||
this.hasFullyQualifiedName("Microsoft.EntityFrameworkCore", "RawSqlString")
|
||||
}
|
||||
|
||||
/** Gets a conversion operator from `string` to `RawSqlString`. */
|
||||
ConversionOperator getAConversionTo() {
|
||||
@@ -424,7 +427,7 @@ module EntityFramework {
|
||||
*/
|
||||
string getFullName() {
|
||||
exists(string qualifier, string type, string name |
|
||||
this.hasQualifiedName(qualifier, type, name)
|
||||
this.hasFullyQualifiedName(qualifier, type, name)
|
||||
|
|
||||
result = getQualifiedName(qualifier, type, name)
|
||||
)
|
||||
|
||||
@@ -27,15 +27,15 @@ class FormatMethod extends Method {
|
||||
or
|
||||
(this.hasName("Write") or this.hasName("WriteLine")) and
|
||||
(
|
||||
declType.hasQualifiedName("System", "Console")
|
||||
declType.hasFullyQualifiedName("System", "Console")
|
||||
or
|
||||
declType.hasQualifiedName("System.IO", "TextWriter")
|
||||
declType.hasFullyQualifiedName("System.IO", "TextWriter")
|
||||
or
|
||||
declType.hasQualifiedName("System.Diagnostics", "Debug") and
|
||||
declType.hasFullyQualifiedName("System.Diagnostics", "Debug") and
|
||||
this.getParameter(1).getType() instanceof ArrayType
|
||||
)
|
||||
or
|
||||
declType.hasQualifiedName("System.Diagnostics", "Trace") and
|
||||
declType.hasFullyQualifiedName("System.Diagnostics", "Trace") and
|
||||
(
|
||||
this.hasName("TraceError") or
|
||||
this.hasName("TraceInformation") or
|
||||
@@ -43,14 +43,14 @@ class FormatMethod extends Method {
|
||||
)
|
||||
or
|
||||
this.hasName("TraceInformation") and
|
||||
declType.hasQualifiedName("System.Diagnostics", "TraceSource")
|
||||
declType.hasFullyQualifiedName("System.Diagnostics", "TraceSource")
|
||||
or
|
||||
this.hasName("Print") and
|
||||
declType.hasQualifiedName("System.Diagnostics", "Debug")
|
||||
declType.hasFullyQualifiedName("System.Diagnostics", "Debug")
|
||||
)
|
||||
or
|
||||
this.hasName("Assert") and
|
||||
declType.hasQualifiedName("System.Diagnostics", "Debug") and
|
||||
declType.hasFullyQualifiedName("System.Diagnostics", "Debug") and
|
||||
this.getNumberOfParameters() = 4
|
||||
)
|
||||
}
|
||||
@@ -65,7 +65,7 @@ class FormatMethod extends Method {
|
||||
else
|
||||
if
|
||||
this.hasName("Assert") and
|
||||
this.getDeclaringType().hasQualifiedName("System.Diagnostics", "Debug")
|
||||
this.getDeclaringType().hasFullyQualifiedName("System.Diagnostics", "Debug")
|
||||
then result = 2
|
||||
else result = 0
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ module NHibernate {
|
||||
|
||||
/** The interface `NHibernamte.ISession`. */
|
||||
class ISessionInterface extends Interface {
|
||||
ISessionInterface() { this.hasQualifiedName("NHibernate", "ISession") }
|
||||
ISessionInterface() { this.hasFullyQualifiedName("NHibernate", "ISession") }
|
||||
|
||||
/** Gets a parameter that uses a mapped object. */
|
||||
Parameter getAMappedObjectParameter() {
|
||||
@@ -28,7 +28,7 @@ module NHibernate {
|
||||
|
||||
/** Gets a type parameter that specifies a mapped class. */
|
||||
TypeParameter getAMappedObjectTp() {
|
||||
exists(string methodName | methodName = ["Load<>", "Merge<>", "Get<>", "Query<>"] |
|
||||
exists(string methodName | methodName = ["Load`1", "Merge`1", "Get`1", "Query`1"] |
|
||||
result = this.getAMethod(methodName).(UnboundGenericMethod).getTypeParameter(0)
|
||||
)
|
||||
}
|
||||
@@ -72,7 +72,7 @@ module NHibernate {
|
||||
.getDeclaringType()
|
||||
.getDeclaringNamespace()
|
||||
.getParentNamespace*()
|
||||
.hasQualifiedName("", "NHibernate")
|
||||
.hasFullyQualifiedName("", "NHibernate")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ import csharp
|
||||
/** A class representing a Service */
|
||||
private class ServiceClass extends Class {
|
||||
ServiceClass() {
|
||||
this.getBaseClass+().hasQualifiedName("ServiceStack", "Service") or
|
||||
this.getABaseType*().getABaseInterface().hasQualifiedName("ServiceStack", "IService")
|
||||
this.getBaseClass+().hasFullyQualifiedName("ServiceStack", "Service") or
|
||||
this.getABaseType*().getABaseInterface().hasFullyQualifiedName("ServiceStack", "IService")
|
||||
}
|
||||
|
||||
/** Get a method that handles incoming requests */
|
||||
@@ -54,7 +54,7 @@ module XSS {
|
||||
m.canReturn(e) and
|
||||
(
|
||||
e.getType() instanceof StringType or
|
||||
e.getType().hasQualifiedName("ServiceStack", "HttpResult")
|
||||
e.getType().hasFullyQualifiedName("ServiceStack", "HttpResult")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ class IDbCommandConstructionSqlExpr extends SqlExpr, ObjectCreation {
|
||||
ic.getParameter(0).getType() instanceof StringType and
|
||||
not exists(Type t | t = ic.getDeclaringType() |
|
||||
// Known sealed classes:
|
||||
t.hasQualifiedName("System.Data.SqlClient", "SqlCommand") or
|
||||
t.hasQualifiedName("System.Data.Odbc", "OdbcCommand") or
|
||||
t.hasQualifiedName("System.Data.OleDb", "OleDbCommand") or
|
||||
t.hasQualifiedName("System.Data.EntityClient", "EntityCommand") or
|
||||
t.hasQualifiedName("System.Data.SQLite", "SQLiteCommand")
|
||||
t.hasFullyQualifiedName("System.Data.SqlClient", "SqlCommand") or
|
||||
t.hasFullyQualifiedName("System.Data.Odbc", "OdbcCommand") or
|
||||
t.hasFullyQualifiedName("System.Data.OleDb", "OleDbCommand") or
|
||||
t.hasFullyQualifiedName("System.Data.EntityClient", "EntityCommand") or
|
||||
t.hasFullyQualifiedName("System.Data.SQLite", "SQLiteCommand")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ class SystemIComparableInterface extends SystemInterface {
|
||||
|
||||
/** The `System.IComparable<T>` interface. */
|
||||
class SystemIComparableTInterface extends SystemUnboundGenericInterface {
|
||||
SystemIComparableTInterface() { this.hasName("IComparable<>") }
|
||||
SystemIComparableTInterface() { this.hasName("IComparable`1") }
|
||||
|
||||
/** Gets the `CompareTo(T)` method. */
|
||||
Method getCompareToMethod() {
|
||||
@@ -165,7 +165,7 @@ class SystemIComparableTInterface extends SystemUnboundGenericInterface {
|
||||
|
||||
/** The `System.IEquatable<T>` interface. */
|
||||
class SystemIEquatableTInterface extends SystemUnboundGenericInterface {
|
||||
SystemIEquatableTInterface() { this.hasName("IEquatable<>") }
|
||||
SystemIEquatableTInterface() { this.hasName("IEquatable`1") }
|
||||
|
||||
/** Gets the `Equals(T)` method. */
|
||||
Method getEqualsMethod() {
|
||||
@@ -210,7 +210,7 @@ class SystemInvalidCastExceptionClass extends SystemClass {
|
||||
/** The `System.Lazy<T>` class. */
|
||||
class SystemLazyClass extends SystemUnboundGenericClass {
|
||||
SystemLazyClass() {
|
||||
this.hasName("Lazy<>") and
|
||||
this.hasName("Lazy`1") and
|
||||
this.getNumberOfTypeParameters() = 1
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ class SystemLazyClass extends SystemUnboundGenericClass {
|
||||
/** The `System.Nullable<T>` struct. */
|
||||
class SystemNullableStruct extends SystemUnboundGenericStruct {
|
||||
SystemNullableStruct() {
|
||||
this.hasName("Nullable<>") and
|
||||
this.hasName("Nullable`1") and
|
||||
this.getNumberOfTypeParameters() = 1
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ class SystemOverflowExceptionClass extends SystemClass {
|
||||
/** The `System.Predicate<T>` delegate type. */
|
||||
class SystemPredicateDelegateType extends SystemUnboundGenericDelegateType {
|
||||
SystemPredicateDelegateType() {
|
||||
this.hasName("Predicate<>") and
|
||||
this.hasName("Predicate`1") and
|
||||
this.getNumberOfTypeParameters() = 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,28 +5,28 @@ import csharp
|
||||
/** A `ServiceContract` attribute. */
|
||||
class ServiceContractAttribute extends Attribute {
|
||||
ServiceContractAttribute() {
|
||||
this.getType().hasQualifiedName("System.ServiceModel", "ServiceContractAttribute")
|
||||
this.getType().hasFullyQualifiedName("System.ServiceModel", "ServiceContractAttribute")
|
||||
}
|
||||
}
|
||||
|
||||
/** An `OperationContract` attribute. */
|
||||
class OperationContractAttribute extends Attribute {
|
||||
OperationContractAttribute() {
|
||||
this.getType().hasQualifiedName("System.ServiceModel", "OperationContractAttribute")
|
||||
this.getType().hasFullyQualifiedName("System.ServiceModel", "OperationContractAttribute")
|
||||
}
|
||||
}
|
||||
|
||||
/** A `DataContract` attribute. */
|
||||
class DataContractAttribute extends Attribute {
|
||||
DataContractAttribute() {
|
||||
this.getType().hasQualifiedName("System.Runtime.Serialization", "DataContractAttribute")
|
||||
this.getType().hasFullyQualifiedName("System.Runtime.Serialization", "DataContractAttribute")
|
||||
}
|
||||
}
|
||||
|
||||
/** A `DataMember` attribute. */
|
||||
class DataMemberAttribute extends Attribute {
|
||||
DataMemberAttribute() {
|
||||
this.getType().hasQualifiedName("System.Runtime.Serialization", "DataMemberAttribute")
|
||||
this.getType().hasFullyQualifiedName("System.Runtime.Serialization", "DataMemberAttribute")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ class MicrosoftAspNetCoreMvcController extends Class {
|
||||
.getType()
|
||||
.getABaseType*()
|
||||
// ApiControllerAttribute is derived from ControllerAttribute
|
||||
.hasQualifiedName("Microsoft.AspNetCore.Mvc", "ControllerAttribute")
|
||||
.hasFullyQualifiedName("Microsoft.AspNetCore.Mvc", "ControllerAttribute")
|
||||
) and
|
||||
not this.getABaseType*().getAnAttribute() instanceof
|
||||
MicrosoftAspNetCoreMvcNonControllerAttribute
|
||||
@@ -258,7 +258,7 @@ class MicrosoftAspNetCoreMvcRenderingIHtmlHelperInterface extends Interface {
|
||||
/** A class deriving from `Microsoft.AspNetCore.Mvc.Razor.RazorPageBase`, implements Razor page in ASPNET Core. */
|
||||
class MicrosoftAspNetCoreMvcRazorPageBase extends Class {
|
||||
MicrosoftAspNetCoreMvcRazorPageBase() {
|
||||
this.getABaseType*().hasQualifiedName("Microsoft.AspNetCore.Mvc.Razor", "RazorPageBase")
|
||||
this.getABaseType*().hasFullyQualifiedName("Microsoft.AspNetCore.Mvc.Razor", "RazorPageBase")
|
||||
}
|
||||
|
||||
/** Gets the `WriteLiteral` method. */
|
||||
@@ -268,14 +268,14 @@ class MicrosoftAspNetCoreMvcRazorPageBase extends Class {
|
||||
/** A class deriving from `Microsoft.AspNetCore.Http.HttpRequest`, implements `HttpRequest` in ASP.NET Core. */
|
||||
class MicrosoftAspNetCoreHttpHttpRequest extends Class {
|
||||
MicrosoftAspNetCoreHttpHttpRequest() {
|
||||
this.getABaseType*().hasQualifiedName("Microsoft.AspNetCore.Http", "HttpRequest")
|
||||
this.getABaseType*().hasFullyQualifiedName("Microsoft.AspNetCore.Http", "HttpRequest")
|
||||
}
|
||||
}
|
||||
|
||||
/** A class deriving from `Microsoft.AspNetCore.Http.HttpResponse`, implements `HttpResponse` in ASP.NET Core. */
|
||||
class MicrosoftAspNetCoreHttpHttpResponse extends Class {
|
||||
MicrosoftAspNetCoreHttpHttpResponse() {
|
||||
this.getABaseType*().hasQualifiedName("Microsoft.AspNetCore.Http", "HttpResponse")
|
||||
this.getABaseType*().hasFullyQualifiedName("Microsoft.AspNetCore.Http", "HttpResponse")
|
||||
}
|
||||
|
||||
/** Gets the `Redirect` method. */
|
||||
@@ -288,7 +288,7 @@ class MicrosoftAspNetCoreHttpHttpResponse extends Class {
|
||||
/** An interface that is a wrapper around the collection of cookies in the response. */
|
||||
class MicrosoftAspNetCoreHttpResponseCookies extends Interface {
|
||||
MicrosoftAspNetCoreHttpResponseCookies() {
|
||||
this.hasQualifiedName("Microsoft.AspNetCore.Http", "IResponseCookies")
|
||||
this.hasFullyQualifiedName("Microsoft.AspNetCore.Http", "IResponseCookies")
|
||||
}
|
||||
|
||||
/** Gets the `Append` method. */
|
||||
@@ -298,21 +298,21 @@ class MicrosoftAspNetCoreHttpResponseCookies extends Interface {
|
||||
/** The class `Microsoft.AspNetCore.Http.QueryString`, holds query string in ASP.NET Core. */
|
||||
class MicrosoftAspNetCoreHttpQueryString extends Struct {
|
||||
MicrosoftAspNetCoreHttpQueryString() {
|
||||
this.hasQualifiedName("Microsoft.AspNetCore.Http", "QueryString")
|
||||
this.hasFullyQualifiedName("Microsoft.AspNetCore.Http", "QueryString")
|
||||
}
|
||||
}
|
||||
|
||||
/** A class or interface implementing `IQueryCollection`, holds parsed query string in ASP.NET Core. */
|
||||
class MicrosoftAspNetCoreHttpQueryCollection extends RefType {
|
||||
MicrosoftAspNetCoreHttpQueryCollection() {
|
||||
this.getABaseInterface().hasQualifiedName("Microsoft.AspNetCore.Http", "IQueryCollection")
|
||||
this.getABaseInterface().hasFullyQualifiedName("Microsoft.AspNetCore.Http", "IQueryCollection")
|
||||
}
|
||||
}
|
||||
|
||||
/** The helper class `ResponseHeaders` for setting headers. */
|
||||
class MicrosoftAspNetCoreHttpResponseHeaders extends RefType {
|
||||
MicrosoftAspNetCoreHttpResponseHeaders() {
|
||||
this.hasQualifiedName("Microsoft.AspNetCore.Http.Headers", "ResponseHeaders")
|
||||
this.hasFullyQualifiedName("Microsoft.AspNetCore.Http.Headers", "ResponseHeaders")
|
||||
}
|
||||
|
||||
/** Gets the `Location` property. */
|
||||
@@ -322,7 +322,7 @@ class MicrosoftAspNetCoreHttpResponseHeaders extends RefType {
|
||||
/** The `Microsoft.AspNetCore.Http.HeaderDictionaryExtensions` class. */
|
||||
class MicrosoftAspNetCoreHttpHeaderDictionaryExtensions extends RefType {
|
||||
MicrosoftAspNetCoreHttpHeaderDictionaryExtensions() {
|
||||
this.hasQualifiedName("Microsoft.AspNetCore.Http", "HeaderDictionaryExtensions")
|
||||
this.hasFullyQualifiedName("Microsoft.AspNetCore.Http", "HeaderDictionaryExtensions")
|
||||
}
|
||||
|
||||
/** Gets the `Append` extension method. */
|
||||
@@ -340,35 +340,35 @@ class MicrosoftAspNetCoreHttpHeaderDictionaryExtensions extends RefType {
|
||||
/** The `Microsoft.AspNetCore.Http.CookieOptions` class. */
|
||||
class MicrosoftAspNetCoreHttpCookieOptions extends RefType {
|
||||
MicrosoftAspNetCoreHttpCookieOptions() {
|
||||
this.hasQualifiedName("Microsoft.AspNetCore.Http", "CookieOptions")
|
||||
this.hasFullyQualifiedName("Microsoft.AspNetCore.Http", "CookieOptions")
|
||||
}
|
||||
}
|
||||
|
||||
/** The `Microsoft.AspNetCore.Http.CookieBuilder` class. */
|
||||
class MicrosoftAspNetCoreHttpCookieBuilder extends RefType {
|
||||
MicrosoftAspNetCoreHttpCookieBuilder() {
|
||||
this.hasQualifiedName("Microsoft.AspNetCore.Http", "CookieBuilder")
|
||||
this.hasFullyQualifiedName("Microsoft.AspNetCore.Http", "CookieBuilder")
|
||||
}
|
||||
}
|
||||
|
||||
/** The `Microsoft.AspNetCore.Builder.CookiePolicyOptions` class. */
|
||||
class MicrosoftAspNetCoreBuilderCookiePolicyOptions extends RefType {
|
||||
MicrosoftAspNetCoreBuilderCookiePolicyOptions() {
|
||||
this.hasQualifiedName("Microsoft.AspNetCore.Builder", "CookiePolicyOptions")
|
||||
this.hasFullyQualifiedName("Microsoft.AspNetCore.Builder", "CookiePolicyOptions")
|
||||
}
|
||||
}
|
||||
|
||||
/** The `Microsoft.AspNetCore.CookiePolicy.AppendCookieContext` class. */
|
||||
class MicrosoftAspNetCoreCookiePolicyAppendCookieContext extends RefType {
|
||||
MicrosoftAspNetCoreCookiePolicyAppendCookieContext() {
|
||||
this.hasQualifiedName("Microsoft.AspNetCore.CookiePolicy", "AppendCookieContext")
|
||||
this.hasFullyQualifiedName("Microsoft.AspNetCore.CookiePolicy", "AppendCookieContext")
|
||||
}
|
||||
}
|
||||
|
||||
/** The `Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions` class. */
|
||||
class MicrosoftAspNetCoreAuthenticationCookiesCookieAuthenticationOptions extends RefType {
|
||||
MicrosoftAspNetCoreAuthenticationCookiesCookieAuthenticationOptions() {
|
||||
this.hasQualifiedName("Microsoft.AspNetCore.Authentication.Cookies",
|
||||
this.hasFullyQualifiedName("Microsoft.AspNetCore.Authentication.Cookies",
|
||||
"CookieAuthenticationOptions")
|
||||
}
|
||||
}
|
||||
@@ -376,7 +376,7 @@ class MicrosoftAspNetCoreAuthenticationCookiesCookieAuthenticationOptions extend
|
||||
/** The `Microsoft.AspNetCore.Builder.CookiePolicyAppBuilderExtensions` class. */
|
||||
class MicrosoftAspNetCoreBuilderCookiePolicyAppBuilderExtensions extends RefType {
|
||||
MicrosoftAspNetCoreBuilderCookiePolicyAppBuilderExtensions() {
|
||||
this.hasQualifiedName("Microsoft.AspNetCore.Builder", "CookiePolicyAppBuilderExtensions")
|
||||
this.hasFullyQualifiedName("Microsoft.AspNetCore.Builder", "CookiePolicyAppBuilderExtensions")
|
||||
}
|
||||
|
||||
/** Gets the `UseCookiePolicy` extension method. */
|
||||
@@ -389,7 +389,7 @@ class MicrosoftAspNetCoreBuilderCookiePolicyAppBuilderExtensions extends RefType
|
||||
*/
|
||||
class MicrosoftAspNetCoreHttpHtmlString extends Class {
|
||||
MicrosoftAspNetCoreHttpHtmlString() {
|
||||
this.hasQualifiedName("Microsoft.AspNetCore.Html", "HtmlString")
|
||||
this.hasFullyQualifiedName("Microsoft.AspNetCore.Html", "HtmlString")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ class MicrosoftAspNetCoreHttpHtmlString extends Class {
|
||||
*/
|
||||
class MicrosoftAspNetCoreBuilderEndpointRouteBuilderExtensions extends Class {
|
||||
MicrosoftAspNetCoreBuilderEndpointRouteBuilderExtensions() {
|
||||
this.hasQualifiedName("Microsoft.AspNetCore.Builder", "EndpointRouteBuilderExtensions")
|
||||
this.hasFullyQualifiedName("Microsoft.AspNetCore.Builder", "EndpointRouteBuilderExtensions")
|
||||
}
|
||||
|
||||
/** Gets the `Map` extension method. */
|
||||
|
||||
@@ -25,9 +25,9 @@ module SystemLinq {
|
||||
SystemLinqEnumerableClass() { this.hasName("Enumerable") }
|
||||
|
||||
/** Gets a `Count()` method. */
|
||||
CSharp::ExtensionMethod getACountMethod() { result = this.getAMethod("Count<>") }
|
||||
CSharp::ExtensionMethod getACountMethod() { result = this.getAMethod("Count`1") }
|
||||
|
||||
/** Gets an `Any()` method. */
|
||||
CSharp::ExtensionMethod getAnAnyMethod() { result = this.getAMethod("Any<>") }
|
||||
CSharp::ExtensionMethod getAnAnyMethod() { result = this.getAMethod("Any`1") }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@ class SystemCollectionsGenericUnboundGenericStruct extends UnboundGenericStruct
|
||||
}
|
||||
}
|
||||
|
||||
/** The `System.Collections.Generic.IComparer<>` interface. */
|
||||
/** The ``System.Collections.Generic.IComparer`1`` interface. */
|
||||
class SystemCollectionsGenericIComparerTInterface extends SystemCollectionsGenericUnboundGenericInterface
|
||||
{
|
||||
SystemCollectionsGenericIComparerTInterface() { this.hasName("IComparer<>") }
|
||||
SystemCollectionsGenericIComparerTInterface() { this.hasName("IComparer`1") }
|
||||
|
||||
/** Gets the `int Compare(T, T)` method. */
|
||||
Method getCompareMethod() {
|
||||
@@ -48,10 +48,10 @@ class SystemCollectionsGenericIComparerTInterface extends SystemCollectionsGener
|
||||
}
|
||||
}
|
||||
|
||||
/** The `System.Collections.Generic.IEqualityComparer<>` interface. */
|
||||
/** The ``System.Collections.Generic.IEqualityComparer`1`` interface. */
|
||||
class SystemCollectionsGenericIEqualityComparerTInterface extends SystemCollectionsGenericUnboundGenericInterface
|
||||
{
|
||||
SystemCollectionsGenericIEqualityComparerTInterface() { this.hasName("IEqualityComparer<>") }
|
||||
SystemCollectionsGenericIEqualityComparerTInterface() { this.hasName("IEqualityComparer`1") }
|
||||
|
||||
/** Gets the `bool Equals(T, T)` method. */
|
||||
Method getEqualsMethod() {
|
||||
@@ -64,20 +64,20 @@ class SystemCollectionsGenericIEqualityComparerTInterface extends SystemCollecti
|
||||
}
|
||||
}
|
||||
|
||||
/** The `System.Collections.Generic.IEnumerable<>` interface. */
|
||||
/** The ``System.Collections.Generic.IEnumerable`1`` interface. */
|
||||
class SystemCollectionsGenericIEnumerableTInterface extends SystemCollectionsGenericUnboundGenericInterface
|
||||
{
|
||||
SystemCollectionsGenericIEnumerableTInterface() {
|
||||
this.hasName("IEnumerable<>") and
|
||||
this.hasName("IEnumerable`1") and
|
||||
this.getNumberOfTypeParameters() = 1
|
||||
}
|
||||
}
|
||||
|
||||
/** The `System.Collections.Generic.IEnumerator<>` interface. */
|
||||
/** The ``System.Collections.Generic.IEnumerator`1`` interface. */
|
||||
class SystemCollectionsGenericIEnumeratorInterface extends SystemCollectionsGenericUnboundGenericInterface
|
||||
{
|
||||
SystemCollectionsGenericIEnumeratorInterface() {
|
||||
this.hasName("IEnumerator<>") and
|
||||
this.hasName("IEnumerator`1") and
|
||||
this.getNumberOfTypeParameters() = 1
|
||||
}
|
||||
|
||||
@@ -89,28 +89,28 @@ class SystemCollectionsGenericIEnumeratorInterface extends SystemCollectionsGene
|
||||
}
|
||||
}
|
||||
|
||||
/** The `System.Collections.Generic.IList<>` interface. */
|
||||
/** The ``System.Collections.Generic.IList`1`` interface. */
|
||||
class SystemCollectionsGenericIListTInterface extends SystemCollectionsGenericUnboundGenericInterface
|
||||
{
|
||||
SystemCollectionsGenericIListTInterface() {
|
||||
this.hasName("IList<>") and
|
||||
this.hasName("IList`1") and
|
||||
this.getNumberOfTypeParameters() = 1
|
||||
}
|
||||
}
|
||||
|
||||
/** The `System.Collections.Generic.List<>` class. */
|
||||
/** The ``System.Collections.Generic.List`1`` class. */
|
||||
class SystemCollectionsGenericListClass extends SystemCollectionsGenericUnboundGenericClass {
|
||||
SystemCollectionsGenericListClass() {
|
||||
this.hasName("List<>") and
|
||||
this.hasName("List`1") and
|
||||
this.getNumberOfTypeParameters() = 1
|
||||
}
|
||||
}
|
||||
|
||||
/** The `System.Collections.Generic.KeyValuePair<,>` structure. */
|
||||
/** The ``System.Collections.Generic.KeyValuePair`2`` structure. */
|
||||
class SystemCollectionsGenericKeyValuePairStruct extends SystemCollectionsGenericUnboundGenericStruct
|
||||
{
|
||||
SystemCollectionsGenericKeyValuePairStruct() {
|
||||
this.hasName("KeyValuePair<,>") and
|
||||
this.hasName("KeyValuePair`2") and
|
||||
this.getNumberOfTypeParameters() = 2
|
||||
}
|
||||
|
||||
@@ -129,10 +129,10 @@ class SystemCollectionsGenericKeyValuePairStruct extends SystemCollectionsGeneri
|
||||
}
|
||||
}
|
||||
|
||||
/** The `System.Collections.Generic.ICollection<>` interface. */
|
||||
/** The ``System.Collections.Generic.ICollection`1`` interface. */
|
||||
class SystemCollectionsGenericICollectionInterface extends SystemCollectionsGenericUnboundGenericInterface
|
||||
{
|
||||
SystemCollectionsGenericICollectionInterface() { this.hasName("ICollection<>") }
|
||||
SystemCollectionsGenericICollectionInterface() { this.hasName("ICollection`1") }
|
||||
|
||||
/** Gets the `Count` property. */
|
||||
Property getCountProperty() { result = this.getProperty("Count") }
|
||||
@@ -144,17 +144,17 @@ class SystemCollectionsGenericICollectionInterface extends SystemCollectionsGene
|
||||
Method getAddMethod() { result = this.getAMethod("Add") }
|
||||
}
|
||||
|
||||
/** The `System.Collections.Generic.IList<>` interface. */
|
||||
/** The ``System.Collections.Generic.IList`1`` interface. */
|
||||
class SystemCollectionsGenericIListInterface extends SystemCollectionsGenericUnboundGenericInterface
|
||||
{
|
||||
SystemCollectionsGenericIListInterface() { this.hasName("IList<>") }
|
||||
SystemCollectionsGenericIListInterface() { this.hasName("IList`1") }
|
||||
}
|
||||
|
||||
/** The `System.Collections.Generic.IDictionary<>` interface. */
|
||||
/** The ``System.Collections.Generic.IDictionary`2`` interface. */
|
||||
class SystemCollectionsGenericIDictionaryInterface extends SystemCollectionsGenericUnboundGenericInterface
|
||||
{
|
||||
SystemCollectionsGenericIDictionaryInterface() {
|
||||
this.hasName("IDictionary<,>") and
|
||||
this.hasName("IDictionary`2") and
|
||||
this.getNumberOfTypeParameters() = 2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class SystemDataSqlClientClass extends Class {
|
||||
/** The `System.Data.SqlClient.SqlDataAdapter` class. */
|
||||
class SystemDataSqlClientSqlDataAdapterClass extends SystemDataSqlClientClass {
|
||||
SystemDataSqlClientSqlDataAdapterClass() {
|
||||
this.hasQualifiedName("System.Data.SqlClient", "SqlDataAdapter")
|
||||
this.hasFullyQualifiedName("System.Data.SqlClient", "SqlDataAdapter")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ module SystemLinqExpressions {
|
||||
|
||||
/** The `Expression<TDelegate>` class. */
|
||||
class ExpressionDelegate extends Class, CSharp::UnboundGenericClass {
|
||||
ExpressionDelegate() { this.hasName("Expression<>") }
|
||||
ExpressionDelegate() { this.hasName("Expression`1") }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,10 +19,10 @@ class SystemRuntimeCompilerServicesNamespaceUnboundGenericStruct extends Unbound
|
||||
}
|
||||
}
|
||||
|
||||
/** The `System.Runtime.CompilerServices.TaskAwaiter<>` struct. */
|
||||
/** The ``System.Runtime.CompilerServices.TaskAwaiter`1`` struct. */
|
||||
class SystemRuntimeCompilerServicesTaskAwaiterStruct extends SystemRuntimeCompilerServicesNamespaceUnboundGenericStruct
|
||||
{
|
||||
SystemRuntimeCompilerServicesTaskAwaiterStruct() { this.hasName("TaskAwaiter<>") }
|
||||
SystemRuntimeCompilerServicesTaskAwaiterStruct() { this.hasName("TaskAwaiter`1") }
|
||||
|
||||
/** Gets the `GetResult` method. */
|
||||
Method getGetResultMethod() { result = this.getAMethod("GetResult") }
|
||||
@@ -31,11 +31,11 @@ class SystemRuntimeCompilerServicesTaskAwaiterStruct extends SystemRuntimeCompil
|
||||
Field getUnderlyingTaskField() { result = this.getAField() and result.hasName("m_task") }
|
||||
}
|
||||
|
||||
/** The `System.Runtime.CompilerServices.ConfiguredTaskAwaitable<>` struct. */
|
||||
/** The ``System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1`` struct. */
|
||||
class SystemRuntimeCompilerServicesConfiguredTaskAwaitableTStruct extends SystemRuntimeCompilerServicesNamespaceUnboundGenericStruct
|
||||
{
|
||||
SystemRuntimeCompilerServicesConfiguredTaskAwaitableTStruct() {
|
||||
this.hasName("ConfiguredTaskAwaitable<>")
|
||||
this.hasName("ConfiguredTaskAwaitable`1")
|
||||
}
|
||||
|
||||
/** Gets the `GetAwaiter` method. */
|
||||
@@ -56,7 +56,7 @@ private class SyntheticConfiguredTaskAwaiterField extends SyntheticField {
|
||||
}
|
||||
}
|
||||
|
||||
/** The `System.Runtime.CompilerServices.ConfiguredTaskAwaitable<>.ConfiguredTaskAwaiter` struct. */
|
||||
/** The ``System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter`` struct. */
|
||||
class SystemRuntimeCompilerServicesConfiguredTaskAwaitableTConfiguredTaskAwaiterStruct extends Struct
|
||||
{
|
||||
SystemRuntimeCompilerServicesConfiguredTaskAwaitableTConfiguredTaskAwaiterStruct() {
|
||||
|
||||
@@ -9,7 +9,7 @@ import csharp
|
||||
* the class with the specified `qualifier` and `type`.
|
||||
*/
|
||||
private predicate isCreatingObject(ObjectCreation oc, string qualifier, string type) {
|
||||
exists(RefType t | t = oc.getType() | t.getBaseClass*().hasQualifiedName(qualifier, type))
|
||||
exists(RefType t | t = oc.getType() | t.getBaseClass*().hasFullyQualifiedName(qualifier, type))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -18,7 +18,7 @@ private predicate isCreatingObject(ObjectCreation oc, string qualifier, string t
|
||||
*/
|
||||
private predicate isReturningObject(MethodCall mc, string qualifier, string type) {
|
||||
mc.getTarget().fromLibrary() and
|
||||
exists(RefType t | t = mc.getType() | t.hasQualifiedName(qualifier, type))
|
||||
exists(RefType t | t = mc.getType() | t.hasFullyQualifiedName(qualifier, type))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,7 +31,7 @@ private predicate isMethodCalledWithArg(
|
||||
string argumentValue
|
||||
) {
|
||||
mc.getTarget().fromLibrary() and
|
||||
mc.getTarget().hasQualifiedName(namespace, type, methodName) and
|
||||
mc.getTarget().hasFullyQualifiedName(namespace, type, methodName) and
|
||||
mc.getArgument(argumentIndex).getValue().toUpperCase() = argumentValue.toUpperCase()
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ private predicate isMethodCalledWithArg(
|
||||
*/
|
||||
class SymmetricAlgorithm extends Class {
|
||||
SymmetricAlgorithm() {
|
||||
this.getABaseType*().hasQualifiedName("System.Security.Cryptography", "SymmetricAlgorithm")
|
||||
this.getABaseType*().hasFullyQualifiedName("System.Security.Cryptography", "SymmetricAlgorithm")
|
||||
}
|
||||
|
||||
/** Gets the `IV` property. */
|
||||
|
||||
@@ -36,7 +36,7 @@ class SystemTextRegularExpressionsRegexClass extends SystemTextRegularExpression
|
||||
*/
|
||||
class RegexGlobalTimeout extends MethodCall {
|
||||
RegexGlobalTimeout() {
|
||||
this.getTarget().hasQualifiedName("System.AppDomain", "SetData") and
|
||||
this.getTarget().hasFullyQualifiedName("System.AppDomain", "SetData") and
|
||||
this.getArgumentForName("name").getValue() = "REGEX_DEFAULT_MATCH_TIMEOUT"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@ class SystemThreadingTasksTaskClass extends SystemThreadingTasksClass {
|
||||
SystemThreadingTasksTaskClass() { this.hasName("Task") }
|
||||
}
|
||||
|
||||
/** The `System.Threading.Tasks.Task<T>` class. */
|
||||
/** The ``System.Threading.Tasks.Task`1`` class. */
|
||||
class SystemThreadingTasksTaskTClass extends SystemThreadingTasksUnboundGenericClass {
|
||||
SystemThreadingTasksTaskTClass() { this.hasName("Task<>") }
|
||||
SystemThreadingTasksTaskTClass() { this.hasName("Task`1") }
|
||||
|
||||
/** Gets the `Result` property. */
|
||||
Property getResultProperty() {
|
||||
|
||||
@@ -41,7 +41,7 @@ class NUnitTestMethod extends TestMethod {
|
||||
if expected.getArgument(0).getType() instanceof StringType
|
||||
then
|
||||
exists(string qualifier, string type |
|
||||
result.hasQualifiedName(qualifier, type) and
|
||||
result.hasFullyQualifiedName(qualifier, type) and
|
||||
splitQualifiedName(expected.getArgument(0).getValue(), qualifier, type)
|
||||
)
|
||||
else result = expected.getArgument(0).(TypeofExpr).getTypeAccess().getTarget()
|
||||
@@ -62,12 +62,12 @@ class NUnitFile extends TestFile {
|
||||
/** An attribute of type `NUnit.Framework.ValueSourceAttribute`. */
|
||||
class ValueSourceAttribute extends Attribute {
|
||||
ValueSourceAttribute() {
|
||||
this.getType().hasQualifiedName("NUnit.Framework", "ValueSourceAttribute")
|
||||
this.getType().hasFullyQualifiedName("NUnit.Framework", "ValueSourceAttribute")
|
||||
}
|
||||
|
||||
/** Holds if the first argument is the target type. */
|
||||
private predicate typeSpecified() {
|
||||
this.getArgument(0).getType().(Class).hasQualifiedName("System", "Type") and
|
||||
this.getArgument(0).getType().(Class).hasFullyQualifiedName("System", "Type") and
|
||||
this.getArgument(1).getType() instanceof StringType
|
||||
}
|
||||
|
||||
@@ -95,12 +95,12 @@ class ValueSourceAttribute extends Attribute {
|
||||
/** An attribute of type `NUnit.Framework.TestCaseSourceAttribute`. */
|
||||
class TestCaseSourceAttribute extends Attribute {
|
||||
TestCaseSourceAttribute() {
|
||||
this.getType().hasQualifiedName("NUnit.Framework", "TestCaseSourceAttribute")
|
||||
this.getType().hasFullyQualifiedName("NUnit.Framework", "TestCaseSourceAttribute")
|
||||
}
|
||||
|
||||
/** Holds if the first argument is the target type. */
|
||||
private predicate typeSpecified() {
|
||||
this.getArgument(0).getType().(Class).hasQualifiedName("System", "Type") and
|
||||
this.getArgument(0).getType().(Class).hasFullyQualifiedName("System", "Type") and
|
||||
this.getArgument(1).getType() instanceof StringType
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ class TestCaseSourceAttribute extends Attribute {
|
||||
|
||||
/** The `NUnit.Framework.Assert` class. */
|
||||
class NUnitAssertClass extends Class {
|
||||
NUnitAssertClass() { this.hasQualifiedName("NUnit.Framework", "Assert") }
|
||||
NUnitAssertClass() { this.hasFullyQualifiedName("NUnit.Framework", "Assert") }
|
||||
|
||||
/** Gets a `Null(object, ...)` method. */
|
||||
Method getANullMethod() {
|
||||
@@ -186,5 +186,5 @@ class NUnitAssertClass extends Class {
|
||||
|
||||
/** The `NUnit.Framework.AssertionException` class. */
|
||||
class AssertionExceptionClass extends Class {
|
||||
AssertionExceptionClass() { this.hasQualifiedName("NUnit.Framework", "AssertionException") }
|
||||
AssertionExceptionClass() { this.hasFullyQualifiedName("NUnit.Framework", "AssertionException") }
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ class AuthMethod extends SensitiveExecutionMethod {
|
||||
class SendingMethod extends SensitiveExecutionMethod {
|
||||
SendingMethod() {
|
||||
exists(string s | s.matches("%Socket") |
|
||||
this.getDeclaringType().hasQualifiedName("System.Net.Sockets", s) and
|
||||
this.getDeclaringType().hasFullyQualifiedName("System.Net.Sockets", s) and
|
||||
this.hasName("Send")
|
||||
)
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ private predicate virtualRouteMapping(string virtualRoute, string physicalRoute)
|
||||
exists(MethodCall mapPageRouteCall, StringLiteral virtualLit, StringLiteral physicalLit |
|
||||
mapPageRouteCall
|
||||
.getTarget()
|
||||
.hasQualifiedName("System.Web.Routing", "RouteCollection", "MapPageRoute") and
|
||||
.hasFullyQualifiedName("System.Web.Routing", "RouteCollection", "MapPageRoute") and
|
||||
virtualLit = mapPageRouteCall.getArgument(1) and
|
||||
physicalLit = mapPageRouteCall.getArgument(2) and
|
||||
virtualLit.getValue() = virtualRoute and
|
||||
|
||||
@@ -52,7 +52,7 @@ private predicate callsPlus(Callable c1, Callable c2) = fastTC(calls/2)(c1, c2)
|
||||
private predicate hasAuthorizeAttribute(ActionMethod m) {
|
||||
exists(Attribute attr |
|
||||
getAnUnboundBaseType*(attr.getType())
|
||||
.hasQualifiedName([
|
||||
.hasFullyQualifiedName([
|
||||
"Microsoft.AspNetCore.Authorization", "System.Web.Mvc", "System.Web.Http"
|
||||
], "AuthorizeAttribute")
|
||||
|
|
||||
@@ -65,7 +65,7 @@ private predicate hasAuthorizeAttribute(ActionMethod m) {
|
||||
private predicate hasAllowAnonymousAttribute(ActionMethod m) {
|
||||
exists(Attribute attr |
|
||||
getAnUnboundBaseType*(attr.getType())
|
||||
.hasQualifiedName([
|
||||
.hasFullyQualifiedName([
|
||||
"Microsoft.AspNetCore.Authorization", "System.Web.Mvc", "System.Web.Http"
|
||||
], "AllowAnonymousAttribute")
|
||||
|
|
||||
|
||||
@@ -14,11 +14,11 @@ class AuthExpr extends Expr {
|
||||
AuthExpr() {
|
||||
this.(MethodCall)
|
||||
.getTarget()
|
||||
.hasQualifiedName("System.Security.Principal", "IPrincipal", "IsInRole")
|
||||
.hasFullyQualifiedName("System.Security.Principal", "IPrincipal", "IsInRole")
|
||||
or
|
||||
this.(PropertyAccess)
|
||||
.getTarget()
|
||||
.hasQualifiedName("System.Security.Principal", "IIdentity", ["IsAuthenticated", "Name"])
|
||||
.hasFullyQualifiedName("System.Security.Principal", "IIdentity", ["IsAuthenticated", "Name"])
|
||||
or
|
||||
this.(MethodCall).getTarget().getName().toLowerCase().matches("%auth%")
|
||||
or
|
||||
|
||||
@@ -57,7 +57,7 @@ module HardcodedSymmetricEncryptionKey {
|
||||
|
||||
private class CryptographicBuffer extends Class {
|
||||
CryptographicBuffer() {
|
||||
this.hasQualifiedName("Windows.Security.Cryptography", "CryptographicBuffer")
|
||||
this.hasFullyQualifiedName("Windows.Security.Cryptography", "CryptographicBuffer")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,9 @@ class CompileAssemblyFromSourceSink extends Sink {
|
||||
*/
|
||||
class RoslynCSharpScriptSink extends Sink {
|
||||
RoslynCSharpScriptSink() {
|
||||
exists(Class c | c.hasQualifiedName("Microsoft.CodeAnalysis.CSharp.Scripting", "CSharpScript") |
|
||||
exists(Class c |
|
||||
c.hasFullyQualifiedName("Microsoft.CodeAnalysis.CSharp.Scripting", "CSharpScript")
|
||||
|
|
||||
this.getExpr() = c.getAMethod().getACall().getArgumentForName("code")
|
||||
)
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ class ExternalApiDataNode extends DataFlow::Node {
|
||||
|
||||
/** Holds if the callable being use has name `name` and has qualifier `qualifier`. */
|
||||
predicate hasQualifiedName(string qualifier, string name) {
|
||||
this.getCallable().hasQualifiedName(qualifier, name)
|
||||
this.getCallable().hasFullyQualifiedName(qualifier, name)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -282,7 +282,7 @@ deprecated class TaintToObjectTypeTrackingConfig extends TaintTracking2::Configu
|
||||
override predicate isAdditionalTaintStep(DataFlow::Node n1, DataFlow::Node n2) {
|
||||
exists(MethodCall mc, Method m |
|
||||
m = mc.getTarget() and
|
||||
m.getDeclaringType().hasQualifiedName("System", "Type") and
|
||||
m.getDeclaringType().hasFullyQualifiedName("System", "Type") and
|
||||
m.hasName("GetType") and
|
||||
m.isStatic() and
|
||||
n1.asExpr() = mc.getArgument(0) and
|
||||
@@ -313,7 +313,7 @@ private module TaintToObjectTypeTrackingConfig implements DataFlow::ConfigSig {
|
||||
predicate isAdditionalFlowStep(DataFlow::Node n1, DataFlow::Node n2) {
|
||||
exists(MethodCall mc, Method m |
|
||||
m = mc.getTarget() and
|
||||
m.getDeclaringType().hasQualifiedName("System", "Type") and
|
||||
m.getDeclaringType().hasFullyQualifiedName("System", "Type") and
|
||||
m.hasName("GetType") and
|
||||
m.isStatic() and
|
||||
n1.asExpr() = mc.getArgument(0) and
|
||||
|
||||
@@ -55,7 +55,9 @@ module ZipSlip = TaintTracking::Global<ZipSlipConfig>;
|
||||
class ArchiveFullNameSource extends Source {
|
||||
ArchiveFullNameSource() {
|
||||
exists(PropertyAccess pa | this.asExpr() = pa |
|
||||
pa.getTarget().getDeclaringType().hasQualifiedName("System.IO.Compression", "ZipArchiveEntry") and
|
||||
pa.getTarget()
|
||||
.getDeclaringType()
|
||||
.hasFullyQualifiedName("System.IO.Compression", "ZipArchiveEntry") and
|
||||
pa.getTarget().getName() = "FullName"
|
||||
)
|
||||
}
|
||||
@@ -65,7 +67,8 @@ class ArchiveFullNameSource extends Source {
|
||||
class ExtractToFileArgSink extends Sink {
|
||||
ExtractToFileArgSink() {
|
||||
exists(MethodCall mc |
|
||||
mc.getTarget().hasQualifiedName("System.IO.Compression", "ZipFileExtensions", "ExtractToFile") and
|
||||
mc.getTarget()
|
||||
.hasFullyQualifiedName("System.IO.Compression", "ZipFileExtensions", "ExtractToFile") and
|
||||
this.asExpr() = mc.getArgumentForName("destinationFileName")
|
||||
)
|
||||
}
|
||||
@@ -75,9 +78,9 @@ class ExtractToFileArgSink extends Sink {
|
||||
class FileOpenArgSink extends Sink {
|
||||
FileOpenArgSink() {
|
||||
exists(MethodCall mc |
|
||||
mc.getTarget().hasQualifiedName("System.IO", "File", "Open") or
|
||||
mc.getTarget().hasQualifiedName("System.IO", "File", "OpenWrite") or
|
||||
mc.getTarget().hasQualifiedName("System.IO", "File", "Create")
|
||||
mc.getTarget().hasFullyQualifiedName("System.IO", "File", "Open") or
|
||||
mc.getTarget().hasFullyQualifiedName("System.IO", "File", "OpenWrite") or
|
||||
mc.getTarget().hasFullyQualifiedName("System.IO", "File", "Create")
|
||||
|
|
||||
this.asExpr() = mc.getArgumentForName("path")
|
||||
)
|
||||
@@ -88,7 +91,7 @@ class FileOpenArgSink extends Sink {
|
||||
class FileStreamArgSink extends Sink {
|
||||
FileStreamArgSink() {
|
||||
exists(ObjectCreation oc |
|
||||
oc.getTarget().getDeclaringType().hasQualifiedName("System.IO", "FileStream")
|
||||
oc.getTarget().getDeclaringType().hasFullyQualifiedName("System.IO", "FileStream")
|
||||
|
|
||||
this.asExpr() = oc.getArgumentForName("path")
|
||||
)
|
||||
@@ -103,7 +106,7 @@ class FileStreamArgSink extends Sink {
|
||||
class FileInfoArgSink extends Sink {
|
||||
FileInfoArgSink() {
|
||||
exists(ObjectCreation oc |
|
||||
oc.getTarget().getDeclaringType().hasQualifiedName("System.IO", "FileInfo")
|
||||
oc.getTarget().getDeclaringType().hasFullyQualifiedName("System.IO", "FileInfo")
|
||||
|
|
||||
this.asExpr() = oc.getArgumentForName("fileName")
|
||||
)
|
||||
@@ -117,7 +120,9 @@ class FileInfoArgSink extends Sink {
|
||||
*/
|
||||
class GetFileNameSanitizer extends Sanitizer {
|
||||
GetFileNameSanitizer() {
|
||||
exists(MethodCall mc | mc.getTarget().hasQualifiedName("System.IO", "Path", "GetFileName") |
|
||||
exists(MethodCall mc |
|
||||
mc.getTarget().hasFullyQualifiedName("System.IO", "Path", "GetFileName")
|
||||
|
|
||||
this.asExpr() = mc
|
||||
)
|
||||
}
|
||||
@@ -131,19 +136,19 @@ class GetFileNameSanitizer extends Sanitizer {
|
||||
*/
|
||||
class SubstringSanitizer extends Sanitizer {
|
||||
SubstringSanitizer() {
|
||||
exists(MethodCall mc | mc.getTarget().hasQualifiedName("System", "String", "Substring") |
|
||||
exists(MethodCall mc | mc.getTarget().hasFullyQualifiedName("System", "String", "Substring") |
|
||||
this.asExpr() = mc
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private predicate stringCheckGuard(Guard g, Expr e, AbstractValue v) {
|
||||
g.(MethodCall).getTarget().hasQualifiedName("System", "String", "StartsWith") and
|
||||
g.(MethodCall).getTarget().hasFullyQualifiedName("System", "String", "StartsWith") and
|
||||
g.(MethodCall).getQualifier() = e and
|
||||
// A StartsWith check against Path.Combine is not sufficient, because the ".." elements have
|
||||
// not yet been resolved.
|
||||
not exists(MethodCall combineCall |
|
||||
combineCall.getTarget().hasQualifiedName("System.IO", "Path", "Combine") and
|
||||
combineCall.getTarget().hasFullyQualifiedName("System.IO", "Path", "Combine") and
|
||||
DataFlow::localExprFlow(combineCall, e)
|
||||
) and
|
||||
v.(AbstractValues::BooleanValue).getValue() = true
|
||||
|
||||
@@ -42,8 +42,8 @@ class LogMessageSink extends ExternalLocationSink {
|
||||
class TraceMessageSink extends ExternalLocationSink {
|
||||
TraceMessageSink() {
|
||||
exists(Class trace, string parameterName |
|
||||
trace.hasQualifiedName("System.Diagnostics", "Trace") or
|
||||
trace.hasQualifiedName("System.Diagnostics", "TraceSource")
|
||||
trace.hasFullyQualifiedName("System.Diagnostics", "Trace") or
|
||||
trace.hasFullyQualifiedName("System.Diagnostics", "TraceSource")
|
||||
|
|
||||
this.getExpr() = trace.getAMethod().getACall().getArgumentForName(parameterName) and
|
||||
parameterName = ["format", "args", "message", "category"]
|
||||
@@ -74,16 +74,16 @@ class CookieStorageSink extends ExternalLocationSink, RemoteFlowSink {
|
||||
|
||||
private predicate isFileWriteCall(Expr stream, Expr data) {
|
||||
exists(MethodCall mc, Method m | mc.getTarget() = m.getAnOverrider*() |
|
||||
m.hasQualifiedName("System.IO", "Stream", ["Write", "WriteAsync"]) and
|
||||
m.hasFullyQualifiedName("System.IO", "Stream", ["Write", "WriteAsync"]) and
|
||||
stream = mc.getQualifier() and
|
||||
data = mc.getArgument(0)
|
||||
or
|
||||
m.hasQualifiedName("System.IO", "TextWriter",
|
||||
m.hasFullyQualifiedName("System.IO", "TextWriter",
|
||||
["Write", "WriteAsync", "WriteLine", "WriteLineAsync"]) and
|
||||
stream = mc.getQualifier() and
|
||||
data = mc.getArgument(0)
|
||||
or
|
||||
m.hasQualifiedName("System.Xml.Linq", "XDocument", ["Save", "SaveAsync"]) and
|
||||
m.hasFullyQualifiedName("System.Xml.Linq", "XDocument", ["Save", "SaveAsync"]) and
|
||||
data = mc.getQualifier() and
|
||||
stream = mc.getArgument(0)
|
||||
)
|
||||
@@ -99,7 +99,7 @@ private module LocalFileOutputStreamConfig implements DataFlow::ConfigSig {
|
||||
node.asExpr()
|
||||
.(ObjectCreation)
|
||||
.getObjectType()
|
||||
.hasQualifiedName("System.Security.Cryptography", "CryptoStream")
|
||||
.hasFullyQualifiedName("System.Security.Cryptography", "CryptoStream")
|
||||
}
|
||||
|
||||
predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
|
||||
|
||||
@@ -241,7 +241,7 @@ class AspNetCoreQueryRemoteFlowSource extends AspNetCoreRemoteFlowSource, DataFl
|
||||
exists(Call c |
|
||||
c.getTarget()
|
||||
.getDeclaringType()
|
||||
.hasQualifiedName("Microsoft.AspNetCore.Http", "IQueryCollection") and
|
||||
.hasFullyQualifiedName("Microsoft.AspNetCore.Http", "IQueryCollection") and
|
||||
c.getTarget().getName() = "TryGetValue" and
|
||||
this.asExpr() = c.getArgumentForName("value")
|
||||
)
|
||||
|
||||
@@ -47,7 +47,7 @@ abstract class InsecureXmlProcessing extends Call {
|
||||
*/
|
||||
private predicate isSafeXmlResolver(Expr e) {
|
||||
e instanceof NullLiteral or
|
||||
e.getType().(RefType).hasQualifiedName("System.Xml", "XmlSecureResolver")
|
||||
e.getType().(RefType).hasFullyQualifiedName("System.Xml", "XmlSecureResolver")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +94,7 @@ module XmlSettings {
|
||||
* Holds if the given object creation constructs `XmlReaderSettings` with an insecure resolver.
|
||||
*/
|
||||
predicate insecureResolverSettings(ObjectCreation creation, Expr evidence, string reason) {
|
||||
creation.getObjectType().hasQualifiedName("System.Xml", "XmlReaderSettings") and
|
||||
creation.getObjectType().hasFullyQualifiedName("System.Xml", "XmlReaderSettings") and
|
||||
(
|
||||
// one unsafe assignment to XmlResolver
|
||||
exists(Expr xmlResolverVal | xmlResolverVal = getAValueForProp(creation, "XmlResolver") |
|
||||
@@ -114,7 +114,7 @@ module XmlSettings {
|
||||
* Holds if the given object creation constructs `XmlReaderSettings` with DTD processing enabled.
|
||||
*/
|
||||
predicate dtdEnabledSettings(ObjectCreation creation, Expr evidence, string reason) {
|
||||
creation.getObjectType().hasQualifiedName("System.Xml", "XmlReaderSettings") and
|
||||
creation.getObjectType().hasFullyQualifiedName("System.Xml", "XmlReaderSettings") and
|
||||
(
|
||||
exists(Expr dtdVal | dtdVal = getAValueForProp(creation, "DtdProcessing") |
|
||||
not isSafeDtdSetting(dtdVal) and evidence = dtdVal
|
||||
@@ -146,7 +146,7 @@ module XmlReader {
|
||||
|
||||
private class InsecureXmlReaderCreate extends InsecureXmlProcessing, MethodCall {
|
||||
InsecureXmlReaderCreate() {
|
||||
this.getTarget().hasQualifiedName("System.Xml.XmlReader", "Create")
|
||||
this.getTarget().hasFullyQualifiedName("System.Xml.XmlReader", "Create")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,7 +154,11 @@ module XmlReader {
|
||||
*/
|
||||
Expr getSettings() {
|
||||
result = this.getAnArgument() and
|
||||
result.getType().(RefType).getABaseType*().hasQualifiedName("System.Xml", "XmlReaderSettings")
|
||||
result
|
||||
.getType()
|
||||
.(RefType)
|
||||
.getABaseType*()
|
||||
.hasFullyQualifiedName("System.Xml", "XmlReaderSettings")
|
||||
}
|
||||
|
||||
override predicate isUnsafe(string reason) {
|
||||
@@ -197,7 +201,7 @@ module XmlReader {
|
||||
.getType()
|
||||
.(RefType)
|
||||
.getABaseType*()
|
||||
.hasQualifiedName("System.Xml", "XmlReaderSettings")
|
||||
.hasFullyQualifiedName("System.Xml", "XmlReaderSettings")
|
||||
}
|
||||
|
||||
predicate isSink(DataFlow::Node sink) {
|
||||
@@ -211,7 +215,9 @@ module XmlReader {
|
||||
/** Provides predicates related to `System.Xml.XmlTextReader`. */
|
||||
module XmlTextReader {
|
||||
private class InsecureXmlTextReader extends InsecureXmlProcessing, ObjectCreation {
|
||||
InsecureXmlTextReader() { this.getObjectType().hasQualifiedName("System.Xml", "XmlTextReader") }
|
||||
InsecureXmlTextReader() {
|
||||
this.getObjectType().hasFullyQualifiedName("System.Xml", "XmlTextReader")
|
||||
}
|
||||
|
||||
override predicate isUnsafe(string reason) {
|
||||
not exists(Expr xmlResolverVal |
|
||||
@@ -246,8 +252,8 @@ module XmlDocument {
|
||||
*/
|
||||
class InsecureXmlDocument extends InsecureXmlProcessing, MethodCall {
|
||||
InsecureXmlDocument() {
|
||||
this.getTarget().hasQualifiedName("System.Xml", "XmlDocument", "Load") or
|
||||
this.getTarget().hasQualifiedName("System.Xml", "XmlDocument", "LoadXml")
|
||||
this.getTarget().hasFullyQualifiedName("System.Xml", "XmlDocument", "Load") or
|
||||
this.getTarget().hasFullyQualifiedName("System.Xml", "XmlDocument", "LoadXml")
|
||||
}
|
||||
|
||||
override predicate isUnsafe(string reason) {
|
||||
|
||||
@@ -90,7 +90,7 @@ private class WrapperDeserializer extends UnsafeDeserializer {
|
||||
/** BinaryFormatter */
|
||||
private class BinaryFormatterClass extends Class {
|
||||
BinaryFormatterClass() {
|
||||
this.hasQualifiedName("System.Runtime.Serialization.Formatters.Binary", "BinaryFormatter")
|
||||
this.hasFullyQualifiedName("System.Runtime.Serialization.Formatters.Binary", "BinaryFormatter")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ class BinaryFormatterUnsafeDeserializeMethodResponseMethod extends Method, Unsaf
|
||||
/** SoapFormatter */
|
||||
private class SoapFormatterClass extends Class {
|
||||
SoapFormatterClass() {
|
||||
this.hasQualifiedName("System.Runtime.Serialization.Formatters.Soap", "SoapFormatter")
|
||||
this.hasFullyQualifiedName("System.Runtime.Serialization.Formatters.Soap", "SoapFormatter")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,9 @@ class SoapFormatterDeserializeMethod extends Method, UnsafeDeserializer {
|
||||
|
||||
/** ObjectStateFormatter */
|
||||
private class ObjectStateFormatterClass extends Class {
|
||||
ObjectStateFormatterClass() { this.hasQualifiedName("System.Web.UI", "ObjectStateFormatter") }
|
||||
ObjectStateFormatterClass() {
|
||||
this.hasFullyQualifiedName("System.Web.UI", "ObjectStateFormatter")
|
||||
}
|
||||
}
|
||||
|
||||
/** `System.Web.UI.ObjectStateFormatter.Deserialize` method */
|
||||
@@ -149,7 +151,7 @@ class ObjectStateFormatterDeserializeMethod extends Method, UnsafeDeserializer {
|
||||
/** NetDataContractSerializer */
|
||||
class NetDataContractSerializerClass extends Class {
|
||||
NetDataContractSerializerClass() {
|
||||
this.hasQualifiedName("System.Runtime.Serialization", "NetDataContractSerializer")
|
||||
this.hasFullyQualifiedName("System.Runtime.Serialization", "NetDataContractSerializer")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +174,7 @@ class NetDataContractSerializerReadObjectMethod extends Method, UnsafeDeserializ
|
||||
/** DataContractJsonSerializer */
|
||||
class DataContractJsonSerializerClass extends Class {
|
||||
DataContractJsonSerializerClass() {
|
||||
this.hasQualifiedName("System.Runtime.Serialization.Json", "DataContractJsonSerializer")
|
||||
this.hasFullyQualifiedName("System.Runtime.Serialization.Json", "DataContractJsonSerializer")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +189,7 @@ class DataContractJsonSerializerReadObjectMethod extends Method, UnsafeDeseriali
|
||||
/** JavaScriptSerializer */
|
||||
class JavaScriptSerializerClass extends Class {
|
||||
JavaScriptSerializerClass() {
|
||||
this.hasQualifiedName("System.Web.Script.Serialization", "JavaScriptSerializer")
|
||||
this.hasFullyQualifiedName("System.Web.Script.Serialization", "JavaScriptSerializer")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +212,7 @@ class JavaScriptSerializerClassDeserializeObjectMethod extends Method, UnsafeDes
|
||||
/** XmlObjectSerializer */
|
||||
class XmlObjectSerializerClass extends Class {
|
||||
XmlObjectSerializerClass() {
|
||||
this.hasQualifiedName("System.Runtime.Serialization", "XmlObjectSerializer")
|
||||
this.hasFullyQualifiedName("System.Runtime.Serialization", "XmlObjectSerializer")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,7 +226,7 @@ class XmlObjectSerializerReadObjectMethod extends Method, UnsafeDeserializer {
|
||||
|
||||
/** XmlSerializer */
|
||||
class XmlSerializerClass extends Class {
|
||||
XmlSerializerClass() { this.hasQualifiedName("System.Xml.Serialization", "XmlSerializer") }
|
||||
XmlSerializerClass() { this.hasFullyQualifiedName("System.Xml.Serialization", "XmlSerializer") }
|
||||
}
|
||||
|
||||
/** `System.Xml.Serialization.XmlSerializer.Deserialize` method */
|
||||
@@ -238,7 +240,7 @@ class XmlSerializerDeserializeMethod extends Method, UnsafeDeserializer {
|
||||
/** DataContractSerializer */
|
||||
class DataContractSerializerClass extends Class {
|
||||
DataContractSerializerClass() {
|
||||
this.hasQualifiedName("System.Runtime.Serialization", "DataContractSerializer")
|
||||
this.hasFullyQualifiedName("System.Runtime.Serialization", "DataContractSerializer")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +254,9 @@ class DataContractSerializerReadObjectMethod extends Method, UnsafeDeserializer
|
||||
|
||||
/** XmlMessageFormatter */
|
||||
class XmlMessageFormatterClass extends Class {
|
||||
XmlMessageFormatterClass() { this.hasQualifiedName("System.Messaging", "XmlMessageFormatter") }
|
||||
XmlMessageFormatterClass() {
|
||||
this.hasFullyQualifiedName("System.Messaging", "XmlMessageFormatter")
|
||||
}
|
||||
}
|
||||
|
||||
/** `System.Messaging.XmlMessageFormatter.Read` method */
|
||||
@@ -265,7 +269,7 @@ class XmlMessageFormatterReadMethod extends Method, UnsafeDeserializer {
|
||||
|
||||
/** LosFormatter */
|
||||
private class LosFormatterClass extends Class {
|
||||
LosFormatterClass() { this.hasQualifiedName("System.Web.UI", "LosFormatter") }
|
||||
LosFormatterClass() { this.hasFullyQualifiedName("System.Web.UI", "LosFormatter") }
|
||||
}
|
||||
|
||||
/** `System.Web.UI.LosFormatter.Deserialize` method */
|
||||
@@ -278,7 +282,7 @@ class LosFormatterDeserializeMethod extends Method, UnsafeDeserializer {
|
||||
|
||||
/** fastJSON */
|
||||
private class FastJsonClass extends Class {
|
||||
FastJsonClass() { this.hasQualifiedName("fastJSON", "JSON") }
|
||||
FastJsonClass() { this.hasFullyQualifiedName("fastJSON", "JSON") }
|
||||
}
|
||||
|
||||
/** `fastJSON.JSON.ToObject` method */
|
||||
@@ -292,7 +296,7 @@ class FastJsonClassToObjectMethod extends Method, UnsafeDeserializer {
|
||||
|
||||
/** Activity */
|
||||
private class ActivityClass extends Class {
|
||||
ActivityClass() { this.hasQualifiedName("System.Workflow.ComponentModel", "Activity") }
|
||||
ActivityClass() { this.hasFullyQualifiedName("System.Workflow.ComponentModel", "Activity") }
|
||||
}
|
||||
|
||||
/** `System.Workflow.ComponentModel.Activity.Load` method */
|
||||
@@ -305,7 +309,7 @@ class ActivityLoadMethod extends Method, UnsafeDeserializer {
|
||||
|
||||
/** ResourceReader */
|
||||
private class ResourceReaderClass extends Class {
|
||||
ResourceReaderClass() { this.hasQualifiedName("System.Resources", "ResourceReader") }
|
||||
ResourceReaderClass() { this.hasFullyQualifiedName("System.Resources", "ResourceReader") }
|
||||
}
|
||||
|
||||
/** `System.Resources.ResourceReader` constructor */
|
||||
@@ -319,7 +323,7 @@ class ResourceReaderConstructor extends Constructor, UnsafeDeserializer {
|
||||
/** BinaryMessageFormatter */
|
||||
private class BinaryMessageFormatterClass extends Class {
|
||||
BinaryMessageFormatterClass() {
|
||||
this.hasQualifiedName("System.Messaging", "BinaryMessageFormatter")
|
||||
this.hasFullyQualifiedName("System.Messaging", "BinaryMessageFormatter")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,7 +337,7 @@ class BinaryMessageFormatterReadMethod extends Method, UnsafeDeserializer {
|
||||
|
||||
/** XamlReader */
|
||||
private class XamlReaderClass extends Class {
|
||||
XamlReaderClass() { this.hasQualifiedName("System.Windows.Markup", "XamlReader") }
|
||||
XamlReaderClass() { this.hasFullyQualifiedName("System.Windows.Markup", "XamlReader") }
|
||||
}
|
||||
|
||||
/** `System.Windows.Markup.XamlReader.Parse` method */
|
||||
@@ -364,7 +368,7 @@ class XamlReaderLoadAsyncMethod extends Method, UnsafeDeserializer {
|
||||
|
||||
/** ProxyObject */
|
||||
private class ProxyObjectClass extends Class {
|
||||
ProxyObjectClass() { this.hasQualifiedName("Microsoft.Web.Design.Remote", "ProxyObject") }
|
||||
ProxyObjectClass() { this.hasFullyQualifiedName("Microsoft.Web.Design.Remote", "ProxyObject") }
|
||||
}
|
||||
|
||||
/** `Microsoft.Web.Design.Remote.ProxyObject.DecodeValue` method */
|
||||
@@ -385,7 +389,7 @@ class ProxyObjectDecodeSerializedObjectMethod extends Method, UnsafeDeserializer
|
||||
|
||||
/** SweetJayson */
|
||||
private class JaysonConverterClass extends Class {
|
||||
JaysonConverterClass() { this.hasQualifiedName("Sweet.Jayson", "JaysonConverter") }
|
||||
JaysonConverterClass() { this.hasFullyQualifiedName("Sweet.Jayson", "JaysonConverter") }
|
||||
}
|
||||
|
||||
/** `Sweet.Jayson.JaysonConverter.ToObject` method */
|
||||
@@ -400,7 +404,7 @@ class JaysonConverterToObjectMethod extends Method, UnsafeDeserializer {
|
||||
/** ServiceStack.Text.JsonSerializer */
|
||||
private class ServiceStackTextJsonSerializerClass extends Class {
|
||||
ServiceStackTextJsonSerializerClass() {
|
||||
this.hasQualifiedName("ServiceStack.Text", "JsonSerializer")
|
||||
this.hasFullyQualifiedName("ServiceStack.Text", "JsonSerializer")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,7 +438,7 @@ class ServiceStackTextJsonSerializerDeserializeFromStreamMethod extends Method,
|
||||
/** ServiceStack.Text.TypeSerializer */
|
||||
private class ServiceStackTextTypeSerializerClass extends Class {
|
||||
ServiceStackTextTypeSerializerClass() {
|
||||
this.hasQualifiedName("ServiceStack.Text", "TypeSerializer")
|
||||
this.hasFullyQualifiedName("ServiceStack.Text", "TypeSerializer")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,7 +472,7 @@ class ServiceStackTextTypeSerializerDeserializeFromStreamMethod extends Method,
|
||||
/** ServiceStack.Text.CsvSerializer */
|
||||
private class ServiceStackTextCsvSerializerClass extends Class {
|
||||
ServiceStackTextCsvSerializerClass() {
|
||||
this.hasQualifiedName("ServiceStack.Text", "CsvSerializer")
|
||||
this.hasFullyQualifiedName("ServiceStack.Text", "CsvSerializer")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -502,7 +506,7 @@ class ServiceStackTextCsvSerializerDeserializeFromStreamMethod extends Method, U
|
||||
/** ServiceStack.Text.XmlSerializer */
|
||||
private class ServiceStackTextXmlSerializerClass extends Class {
|
||||
ServiceStackTextXmlSerializerClass() {
|
||||
this.hasQualifiedName("ServiceStack.Text", "XmlSerializer")
|
||||
this.hasFullyQualifiedName("ServiceStack.Text", "XmlSerializer")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -535,7 +539,9 @@ class ServiceStackTextXmlSerializerDeserializeFromStreamMethod extends Method, U
|
||||
|
||||
/** MBrace.FsPickler.FsPicklerSerializer */
|
||||
private class FsPicklerSerializerClass extends Class {
|
||||
FsPicklerSerializerClass() { this.hasQualifiedName("MBrace.FsPickler", "FsPicklerSerializer") }
|
||||
FsPicklerSerializerClass() {
|
||||
this.hasFullyQualifiedName("MBrace.FsPickler", "FsPicklerSerializer")
|
||||
}
|
||||
}
|
||||
|
||||
/** `MBrace.FsPickler.FsPicklerSerializer.Deserialize` method */
|
||||
@@ -604,7 +610,9 @@ class FsPicklerSerializerClassUnPickleUntypedMethod extends Method, UnsafeDeseri
|
||||
|
||||
/** MBrace.CsPickler.CsPicklerSerializer */
|
||||
private class CsPicklerSerializerClass extends Class {
|
||||
CsPicklerSerializerClass() { this.hasQualifiedName("MBrace.CsPickler", "CsPicklerSerializer") }
|
||||
CsPicklerSerializerClass() {
|
||||
this.hasFullyQualifiedName("MBrace.CsPickler", "CsPicklerSerializer")
|
||||
}
|
||||
}
|
||||
|
||||
/** `MBrace.FsPickler.CsPicklerSerializer.Deserialize` method */
|
||||
@@ -626,7 +634,7 @@ class CsPicklerSerializerClassUnPickleMethod extends Method, UnsafeDeserializer
|
||||
/** MBrace.CsPickler.CsPicklerTextSerializer */
|
||||
private class CsPicklerTextSerializerClass extends Class {
|
||||
CsPicklerTextSerializerClass() {
|
||||
this.hasQualifiedName("MBrace.CsPickler", "CsPicklerTextSerializer")
|
||||
this.hasFullyQualifiedName("MBrace.CsPickler", "CsPicklerTextSerializer")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -640,7 +648,7 @@ class CsPicklerSerializerClassUnPickleOfStringMethod extends Method, UnsafeDeser
|
||||
|
||||
/** Polenter.Serialization.SharpSerializer */
|
||||
private class SharpSerializerClass extends Class {
|
||||
SharpSerializerClass() { this.hasQualifiedName("Polenter.Serialization", "SharpSerializer") }
|
||||
SharpSerializerClass() { this.hasFullyQualifiedName("Polenter.Serialization", "SharpSerializer") }
|
||||
}
|
||||
|
||||
/** `Polenter.Serialization.SharpSerializer.Deserialize` method */
|
||||
@@ -654,7 +662,7 @@ class SharpSerializerClassDeserializeMethod extends Method, UnsafeDeserializer {
|
||||
/** YamlDotNet.Serialization.Deserializer */
|
||||
private class YamlDotNetDeserializerClass extends Class {
|
||||
YamlDotNetDeserializerClass() {
|
||||
this.hasQualifiedName("YamlDotNet.Serialization", "Deserializer")
|
||||
this.hasFullyQualifiedName("YamlDotNet.Serialization", "Deserializer")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,12 +36,12 @@ class Declaration extends NamedElement, @dotnet_declaration {
|
||||
*
|
||||
* | Declaration | Unbound declaration |
|
||||
* |-------------------------|---------------------|
|
||||
* | `C<int>` | `C<>` |
|
||||
* | `C<>.Nested` | `C<>.Nested` |
|
||||
* | `C<int>.Nested` | `C<>.Nested` |
|
||||
* | `C<>.Method<>` | `C<>.Method<>` |
|
||||
* | `C<int>.Method<>` | `C<>.Method<>` |
|
||||
* | `C<int>.Method<string>` | `C<>.Method<>` |
|
||||
* | `C<int>` | ``C`1`` |
|
||||
* | ``C`1.Nested`` | ``C`1.Nested`` |
|
||||
* | `C<int>.Nested` | ``C`1.Nested`` |
|
||||
* | ``C`1.Method`1`` | ``C`1.Method`1`` |
|
||||
* | ``C<int>.Method`1`` | ``C`1.Method`1`` |
|
||||
* | `C<int>.Method<string>` | ``C`1.Method`1`` |
|
||||
*/
|
||||
Declaration getUnboundDeclaration() { result = this }
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import Generics
|
||||
* a pointer type (`PointerType`), or an array type (`ArrayType`).
|
||||
*/
|
||||
class Type extends Declaration, @dotnet_type {
|
||||
/** Gets the name of this type without additional syntax such as `[]`, `*`, or `<...>`. */
|
||||
/** Gets the name of this type without additional syntax such as `[]` or `*`. */
|
||||
override string getUndecoratedName() { none() }
|
||||
}
|
||||
|
||||
|
||||
@@ -16,5 +16,5 @@ where
|
||||
c.getTarget() = gcCollect and
|
||||
gcCollect.hasName("Collect") and
|
||||
gcCollect.hasNoParameters() and
|
||||
gcCollect.getDeclaringType().hasQualifiedName("System", "GC")
|
||||
gcCollect.getDeclaringType().hasFullyQualifiedName("System", "GC")
|
||||
select c, "Call to 'GC.Collect()'."
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
import csharp
|
||||
|
||||
class ObsoleteAttribute extends Attribute {
|
||||
ObsoleteAttribute() { this.getType().hasQualifiedName("System", "ObsoleteAttribute") }
|
||||
ObsoleteAttribute() { this.getType().hasFullyQualifiedName("System", "ObsoleteAttribute") }
|
||||
}
|
||||
|
||||
from MethodCall c, Method m
|
||||
|
||||
@@ -15,7 +15,7 @@ import csharp
|
||||
from ValueOrRefType c
|
||||
where
|
||||
c.fromSource() and
|
||||
c.getABaseInterface+().hasQualifiedName("System", "ICloneable") and
|
||||
c.getABaseInterface+().hasFullyQualifiedName("System", "ICloneable") and
|
||||
not c.isSealed() and
|
||||
exists(Method m | m.getDeclaringType() = c and m.hasName("Clone"))
|
||||
select c, "Class '" + c.getName() + "' implements 'ICloneable'."
|
||||
|
||||
@@ -41,6 +41,6 @@ from Method m, Method vm, string namespace, string type, string name
|
||||
where
|
||||
m.fromSource() and
|
||||
nonOverridingMethod(m, vm) and
|
||||
vm.hasQualifiedName(namespace, type, name)
|
||||
vm.hasFullyQualifiedName(namespace, type, name)
|
||||
select m, "Method '" + m.getName() + "' looks like it should override $@ but does not do so.",
|
||||
vm.getUnboundDeclaration(), getQualifiedName(namespace, type, name)
|
||||
|
||||
@@ -13,5 +13,5 @@
|
||||
import csharp
|
||||
|
||||
from SpecificCatchClause scc
|
||||
where scc.getCaughtExceptionType().hasQualifiedName("System", "NullReferenceException")
|
||||
where scc.getCaughtExceptionType().hasFullyQualifiedName("System", "NullReferenceException")
|
||||
select scc, "Poor error handling: try to fix the cause of the 'NullReferenceException'."
|
||||
|
||||
@@ -19,6 +19,6 @@ where
|
||||
m.fromSource() and
|
||||
exists(UsingNamespaceDirective u |
|
||||
u.getFile() = m.getFile() and
|
||||
u.getImportedNamespace().hasQualifiedName("System", "Web")
|
||||
u.getImportedNamespace().hasFullyQualifiedName("System", "Web")
|
||||
)
|
||||
select m, "Remove debug code if your ASP.NET application is in production."
|
||||
|
||||
@@ -99,7 +99,7 @@ from Field f, RefType t, string name, string prefix, string qualifier, string ty
|
||||
where
|
||||
f.getType() = t and
|
||||
f.getName() = name and
|
||||
t.hasQualifiedName(qualifier, type) and
|
||||
t.hasFullyQualifiedName(qualifier, type) and
|
||||
prefix = prefix(qualifier, type) and
|
||||
not name.matches(prefix + "%")
|
||||
select f, "This field should have the prefix '" + prefix + "' to match its types."
|
||||
|
||||
@@ -29,7 +29,7 @@ predicate usedInHumanWrittenCode(Field f) {
|
||||
|
||||
from Field field, ValueOrRefType widget, string prefix
|
||||
where
|
||||
widget.getABaseType*().hasQualifiedName("System.Windows.Forms", "Control") and
|
||||
widget.getABaseType*().hasFullyQualifiedName("System.Windows.Forms", "Control") and
|
||||
field.getType() = widget and
|
||||
field.getName().regexpMatch(prefix + "[0-9]+") and
|
||||
controlName(prefix) and
|
||||
|
||||
@@ -15,5 +15,5 @@
|
||||
import csharp
|
||||
|
||||
from ObjectCreation oc
|
||||
where oc.getType().(Class).hasQualifiedName("System.Web.UI.HtmlControls", "HtmlInputHidden")
|
||||
where oc.getType().(Class).hasFullyQualifiedName("System.Web.UI.HtmlControls", "HtmlInputHidden")
|
||||
select oc, "Avoid using 'HTMLInputHidden' fields."
|
||||
|
||||
@@ -14,30 +14,30 @@ import semmle.code.csharp.commons.Util
|
||||
predicate isConsoleOutRedefinedSomewhere() {
|
||||
exists(MethodCall mc |
|
||||
mc.getTarget().hasName("SetOut") and
|
||||
mc.getTarget().getDeclaringType().hasQualifiedName("System", "Console")
|
||||
mc.getTarget().getDeclaringType().hasFullyQualifiedName("System", "Console")
|
||||
)
|
||||
}
|
||||
|
||||
predicate isConsoleErrorRedefinedSomewhere() {
|
||||
exists(MethodCall mc |
|
||||
mc.getTarget().hasName("SetError") and
|
||||
mc.getTarget().getDeclaringType().hasQualifiedName("System", "Console")
|
||||
mc.getTarget().getDeclaringType().hasFullyQualifiedName("System", "Console")
|
||||
)
|
||||
}
|
||||
|
||||
predicate isCallToConsoleWrite(MethodCall mc) {
|
||||
mc.getTarget().getName().matches("Write%") and
|
||||
mc.getTarget().getDeclaringType().hasQualifiedName("System", "Console")
|
||||
mc.getTarget().getDeclaringType().hasFullyQualifiedName("System", "Console")
|
||||
}
|
||||
|
||||
predicate isAccessToConsoleOut(PropertyAccess pa) {
|
||||
pa.getTarget().hasName("Out") and
|
||||
pa.getTarget().getDeclaringType().hasQualifiedName("System", "Console")
|
||||
pa.getTarget().getDeclaringType().hasFullyQualifiedName("System", "Console")
|
||||
}
|
||||
|
||||
predicate isAccessToConsoleError(PropertyAccess pa) {
|
||||
pa.getTarget().hasName("Error") and
|
||||
pa.getTarget().getDeclaringType().hasQualifiedName("System", "Console")
|
||||
pa.getTarget().getDeclaringType().hasFullyQualifiedName("System", "Console")
|
||||
}
|
||||
|
||||
from Expr e
|
||||
|
||||
@@ -5,7 +5,7 @@ import csharp
|
||||
private class WaitCall extends MethodCall {
|
||||
WaitCall() {
|
||||
this.getTarget().hasName("Wait") and
|
||||
this.getTarget().getDeclaringType().hasQualifiedName("System.Threading", "Monitor")
|
||||
this.getTarget().getDeclaringType().hasFullyQualifiedName("System.Threading", "Monitor")
|
||||
}
|
||||
|
||||
Expr getExpr() { result = this.getArgument(0) }
|
||||
@@ -30,12 +30,13 @@ class WaitStmt extends ExprStmt {
|
||||
|
||||
private class SynchronizedMethodAttribute extends Attribute {
|
||||
SynchronizedMethodAttribute() {
|
||||
this.getType().hasQualifiedName("System.Runtime.CompilerServices", "MethodImplAttribute") and
|
||||
this.getType().hasFullyQualifiedName("System.Runtime.CompilerServices", "MethodImplAttribute") and
|
||||
exists(MemberConstantAccess a, MemberConstant mc |
|
||||
a = this.getArgument(0) and
|
||||
a.getTarget() = mc and
|
||||
mc.hasName("Synchronized") and
|
||||
mc.getDeclaringType().hasQualifiedName("System.Runtime.CompilerServices", "MethodImplOptions")
|
||||
mc.getDeclaringType()
|
||||
.hasFullyQualifiedName("System.Runtime.CompilerServices", "MethodImplOptions")
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -91,7 +92,7 @@ class LockingCall extends MethodCall {
|
||||
LockingCall() {
|
||||
this.getTarget() =
|
||||
any(Method m |
|
||||
m.getDeclaringType().hasQualifiedName("System.Threading", "Monitor") and
|
||||
m.getDeclaringType().hasFullyQualifiedName("System.Threading", "Monitor") and
|
||||
m.getName().matches("%Enter%")
|
||||
) or
|
||||
this.getTarget().hasName("EnterReadLock") or
|
||||
|
||||
@@ -9,16 +9,16 @@ import Concurrency
|
||||
*/
|
||||
class ThreadStartingCallable extends Callable {
|
||||
ThreadStartingCallable() {
|
||||
this.(Constructor).getDeclaringType().hasQualifiedName("System.Threading.Tasks", "Task")
|
||||
this.(Constructor).getDeclaringType().hasFullyQualifiedName("System.Threading.Tasks", "Task")
|
||||
or
|
||||
this.(Method).hasQualifiedName("System.Threading.Tasks", "Task", "Run")
|
||||
this.(Method).hasFullyQualifiedName("System.Threading.Tasks", "Task", "Run")
|
||||
or
|
||||
this.(Constructor).getDeclaringType().hasQualifiedName("System.Threading", "Thread")
|
||||
this.(Constructor).getDeclaringType().hasFullyQualifiedName("System.Threading", "Thread")
|
||||
or
|
||||
this.(Method).hasQualifiedName("System.Threading", "Thread", "Start")
|
||||
this.(Method).hasFullyQualifiedName("System.Threading", "Thread", "Start")
|
||||
or
|
||||
exists(string name |
|
||||
this.(Constructor).getDeclaringType().hasQualifiedName("System.Threading.Tasks", name) and
|
||||
this.(Constructor).getDeclaringType().hasFullyQualifiedName("System.Threading.Tasks", name) and
|
||||
name.matches("Task<%>")
|
||||
)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ Expr getAnAccessByDynamicCall(Method m) {
|
||||
exists(MethodCall mc, Method target |
|
||||
target = mc.getTarget() and
|
||||
target.hasName("InvokeMember") and
|
||||
target.getDeclaringType().hasQualifiedName("System", "Type") and
|
||||
target.getDeclaringType().hasFullyQualifiedName("System", "Type") and
|
||||
mc.getArgument(0).(StringLiteral).getValue() = m.getName() and
|
||||
mc.getArgument(3).getType().(RefType).hasMethod(m) and
|
||||
result = mc
|
||||
@@ -42,7 +42,7 @@ Expr getAMethodAccess(Method m) {
|
||||
|
||||
predicate potentiallyAccessedByForEach(Method m) {
|
||||
m.hasName("GetEnumerator") and
|
||||
m.getDeclaringType().getABaseType+().hasQualifiedName("System.Collections", "IEnumerable")
|
||||
m.getDeclaringType().getABaseType+().hasFullyQualifiedName("System.Collections", "IEnumerable")
|
||||
or
|
||||
foreach_stmt_desugar(_, m, 1)
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@ import semmle.code.csharp.metrics.Coupling
|
||||
|
||||
predicate potentiallyUsedFromXaml(RefType t) {
|
||||
t.getABaseType*()
|
||||
.hasQualifiedName("System.Windows.Data", ["IValueConverter", "IMultiValueConverter"])
|
||||
.hasFullyQualifiedName("System.Windows.Data", ["IValueConverter", "IMultiValueConverter"])
|
||||
}
|
||||
|
||||
class ExportAttribute extends Attribute {
|
||||
ExportAttribute() {
|
||||
this.getType().hasQualifiedName("System.ComponentModel.Composition", "ExportAttribute")
|
||||
this.getType().hasFullyQualifiedName("System.ComponentModel.Composition", "ExportAttribute")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ where
|
||||
or
|
||||
exists(string qualifier, string type |
|
||||
splitQualifiedName(exceptionName, qualifier, type) and
|
||||
throwBaseType.hasQualifiedName(qualifier, type)
|
||||
throwBaseType.hasFullyQualifiedName(qualifier, type)
|
||||
)
|
||||
// and comment.hasBody(offset) // Too slow
|
||||
)
|
||||
|
||||
@@ -17,5 +17,7 @@ import csharp
|
||||
from PropertyAccess pa
|
||||
where
|
||||
pa.getTarget().hasName("PostedFile") and
|
||||
pa.getTarget().getDeclaringType().hasQualifiedName("System.Web.UI.HtmlControls", "HtmlInputFile")
|
||||
pa.getTarget()
|
||||
.getDeclaringType()
|
||||
.hasFullyQualifiedName("System.Web.UI.HtmlControls", "HtmlInputFile")
|
||||
select pa, "Avoid using file upload."
|
||||
|
||||
@@ -15,6 +15,6 @@ import semmle.code.csharp.frameworks.system.web.Http
|
||||
|
||||
from IndexerAccess ia
|
||||
where
|
||||
ia.getTarget().getDeclaringType().hasQualifiedName("System.Web", "HttpRequest") and
|
||||
ia.getTarget().getDeclaringType().hasFullyQualifiedName("System.Web", "HttpRequest") and
|
||||
not isServerVariable(ia.getIndex(0))
|
||||
select ia, "Ambiguous access to variable."
|
||||
|
||||
@@ -15,6 +15,6 @@ import semmle.code.csharp.frameworks.system.web.Http
|
||||
|
||||
from IndexerAccess ia
|
||||
where
|
||||
ia.getTarget().getDeclaringType().hasQualifiedName("System.Web", "HttpRequest") and
|
||||
ia.getTarget().getDeclaringType().hasFullyQualifiedName("System.Web", "HttpRequest") and
|
||||
isServerVariable(ia.getIndex(0))
|
||||
select ia, "Ambiguous access to server variable."
|
||||
|
||||
@@ -15,7 +15,7 @@ import semmle.code.csharp.commons.Assertions
|
||||
|
||||
private predicate propertyOverrides(Property p, string qualifier, string baseClass, string property) {
|
||||
exists(Property p2 |
|
||||
p2.getUnboundDeclaration().getDeclaringType().hasQualifiedName(qualifier, baseClass) and
|
||||
p2.getUnboundDeclaration().getDeclaringType().hasFullyQualifiedName(qualifier, baseClass) and
|
||||
p2.hasName(property)
|
||||
|
|
||||
p.overridesOrImplementsOrEquals(p2)
|
||||
@@ -24,8 +24,8 @@ private predicate propertyOverrides(Property p, string qualifier, string baseCla
|
||||
|
||||
private predicate containerSizeAccess(PropertyAccess pa, string containerKind) {
|
||||
(
|
||||
propertyOverrides(pa.getTarget(), "System.Collections.Generic", "ICollection<>", "Count") or
|
||||
propertyOverrides(pa.getTarget(), "System.Collections.Generic", "IReadOnlyCollection<>", "Count") or
|
||||
propertyOverrides(pa.getTarget(), "System.Collections.Generic", "ICollection`1", "Count") or
|
||||
propertyOverrides(pa.getTarget(), "System.Collections.Generic", "IReadOnlyCollection`1", "Count") or
|
||||
propertyOverrides(pa.getTarget(), "System.Collections", "ICollection", "Count")
|
||||
) and
|
||||
containerKind = "a collection"
|
||||
|
||||
@@ -14,12 +14,12 @@ import semmle.code.csharp.frameworks.System
|
||||
|
||||
predicate dictionary(ConstructedType constructed) {
|
||||
exists(UnboundGenericType dict |
|
||||
dict.hasQualifiedName("System.Collections.Generic", "Dictionary<,>") and
|
||||
dict.hasFullyQualifiedName("System.Collections.Generic", "Dictionary`2") and
|
||||
constructed = dict.getAConstructedGeneric()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hashtable(Class c) { c.hasQualifiedName("System.Collections", "Hashtable") }
|
||||
predicate hashtable(Class c) { c.hasFullyQualifiedName("System.Collections", "Hashtable") }
|
||||
|
||||
predicate hashstructure(Type t) { hashtable(t) or dictionary(t) }
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import csharp
|
||||
|
||||
class ImplementsICryptoTransform extends Class {
|
||||
ImplementsICryptoTransform() {
|
||||
this.getABaseType*().hasQualifiedName("System.Security.Cryptography", "ICryptoTransform")
|
||||
this.getABaseType*().hasFullyQualifiedName("System.Security.Cryptography", "ICryptoTransform")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,14 +16,14 @@ module UnsafeYearCreationFromArithmeticConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node source) {
|
||||
exists(ArithmeticOperation ao, PropertyAccess pa | ao = source.asExpr() |
|
||||
pa = ao.getAChild*() and
|
||||
pa.getProperty().hasQualifiedName("System.DateTime", "Year")
|
||||
pa.getProperty().hasFullyQualifiedName("System.DateTime", "Year")
|
||||
)
|
||||
}
|
||||
|
||||
predicate isSink(DataFlow::Node sink) {
|
||||
exists(ObjectCreation oc |
|
||||
sink.asExpr() = oc.getArgumentForName("year") and
|
||||
oc.getObjectType().getABaseType*().hasQualifiedName("System", "DateTime")
|
||||
oc.getObjectType().getABaseType*().hasFullyQualifiedName("System", "DateTime")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ predicate isEraStart(int year, int month, int day) {
|
||||
|
||||
predicate isExactEraStartDateCreation(ObjectCreation cr) {
|
||||
(
|
||||
cr.getType().hasQualifiedName("System", "DateTime") or
|
||||
cr.getType().hasQualifiedName("System", "DateTimeOffset")
|
||||
cr.getType().hasFullyQualifiedName("System", "DateTime") or
|
||||
cr.getType().hasFullyQualifiedName("System", "DateTimeOffset")
|
||||
) and
|
||||
isEraStart(cr.getArgument(0).getValue().toInt(), cr.getArgument(1).getValue().toInt(),
|
||||
cr.getArgument(2).getValue().toInt())
|
||||
@@ -32,10 +32,10 @@ predicate isExactEraStartDateCreation(ObjectCreation cr) {
|
||||
|
||||
predicate isDateFromJapaneseCalendarToDateTime(MethodCall mc) {
|
||||
(
|
||||
mc.getQualifier().getType().hasQualifiedName("System.Globalization", "JapaneseCalendar") or
|
||||
mc.getQualifier().getType().hasFullyQualifiedName("System.Globalization", "JapaneseCalendar") or
|
||||
mc.getQualifier()
|
||||
.getType()
|
||||
.hasQualifiedName("System.Globalization", "JapaneseLunisolarCalendar")
|
||||
.hasFullyQualifiedName("System.Globalization", "JapaneseLunisolarCalendar")
|
||||
) and
|
||||
mc.getTarget().hasName("ToDateTime") and
|
||||
mc.getArgument(0).hasValue() and
|
||||
@@ -49,16 +49,16 @@ predicate isDateFromJapaneseCalendarToDateTime(MethodCall mc) {
|
||||
|
||||
predicate isDateFromJapaneseCalendarCreation(ObjectCreation cr) {
|
||||
(
|
||||
cr.getType().hasQualifiedName("System", "DateTime") or
|
||||
cr.getType().hasQualifiedName("System", "DateTimeOffset")
|
||||
cr.getType().hasFullyQualifiedName("System", "DateTime") or
|
||||
cr.getType().hasFullyQualifiedName("System", "DateTimeOffset")
|
||||
) and
|
||||
(
|
||||
cr.getArgumentForName("calendar")
|
||||
.getType()
|
||||
.hasQualifiedName("System.Globalization", "JapaneseCalendar") or
|
||||
.hasFullyQualifiedName("System.Globalization", "JapaneseCalendar") or
|
||||
cr.getArgumentForName("calendar")
|
||||
.getType()
|
||||
.hasQualifiedName("System.Globalization", "JapaneseLunisolarCalendar")
|
||||
.hasFullyQualifiedName("System.Globalization", "JapaneseLunisolarCalendar")
|
||||
) and
|
||||
cr.getArgumentForName("year").hasValue()
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ abstract class ParallelSink extends DataFlow::Node { }
|
||||
class LambdaParallelSink extends ParallelSink {
|
||||
LambdaParallelSink() {
|
||||
exists(Class c, Method m, MethodCall mc, Expr e | e = this.asExpr() |
|
||||
c.getABaseType*().hasQualifiedName("System.Threading.Tasks", "Parallel") and
|
||||
c.getABaseType*().hasFullyQualifiedName("System.Threading.Tasks", "Parallel") and
|
||||
c.getAMethod() = m and
|
||||
m.getName() = "Invoke" and
|
||||
m.getACall() = mc and
|
||||
|
||||
@@ -17,7 +17,7 @@ predicate generateRandomNumberMethod(string s) { s = "Next" or s = "NextBytes" o
|
||||
|
||||
from ObjectCreation c, MethodCall m
|
||||
where
|
||||
c.getType().getUnboundDeclaration().(ValueOrRefType).hasQualifiedName("System", "Random") and
|
||||
c.getType().getUnboundDeclaration().(ValueOrRefType).hasFullyQualifiedName("System", "Random") and
|
||||
m.getQualifier() = c and
|
||||
generateRandomNumberMethod(m.getTarget().getName())
|
||||
select m, "Random object created and used only once."
|
||||
|
||||
@@ -19,7 +19,7 @@ import semmle.code.csharp.frameworks.system.collections.Generic
|
||||
class UnsafeField extends Field {
|
||||
UnsafeField() {
|
||||
this.isStatic() and
|
||||
not this.getAnAttribute().getType().hasQualifiedName("System", "ThreadStaticAttribute") and
|
||||
not this.getAnAttribute().getType().hasFullyQualifiedName("System", "ThreadStaticAttribute") and
|
||||
this.getType() instanceof UsesICryptoTransform
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ class UsesICryptoTransform extends ValueOrRefType {
|
||||
|
||||
class ICryptoTransform extends ValueOrRefType {
|
||||
ICryptoTransform() {
|
||||
this.getABaseType*().hasQualifiedName("System.Security.Cryptography", "ICryptoTransform")
|
||||
this.getABaseType*().hasFullyQualifiedName("System.Security.Cryptography", "ICryptoTransform")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,10 @@ module XmlInjectionConfig implements DataFlow::ConfigSig {
|
||||
predicate isSink(DataFlow::Node sink) {
|
||||
exists(MethodCall mc |
|
||||
mc.getTarget().hasName("WriteRaw") and
|
||||
mc.getTarget().getDeclaringType().getABaseType*().hasQualifiedName("System.Xml", "XmlWriter")
|
||||
mc.getTarget()
|
||||
.getDeclaringType()
|
||||
.getABaseType*()
|
||||
.hasFullyQualifiedName("System.Xml", "XmlWriter")
|
||||
|
|
||||
mc.getArgument(0) = sink.asExpr()
|
||||
)
|
||||
@@ -37,7 +40,7 @@ module XmlInjectionConfig implements DataFlow::ConfigSig {
|
||||
mc.getTarget()
|
||||
.getDeclaringType()
|
||||
.getABaseType*()
|
||||
.hasQualifiedName("System.Security", "SecurityElement")
|
||||
.hasFullyQualifiedName("System.Security", "SecurityElement")
|
||||
|
|
||||
mc = node.asExpr()
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ module AssemblyPathInjectionConfig implements DataFlow::ConfigSig {
|
||||
mc.getTarget()
|
||||
.getDeclaringType()
|
||||
.getABaseType*()
|
||||
.hasQualifiedName("System.Reflection", "Assembly") and
|
||||
.hasFullyQualifiedName("System.Reflection", "Assembly") and
|
||||
mc.getArgument(arg) = sink.asExpr()
|
||||
|
|
||||
name = "LoadFrom" and arg = 0 and mc.getNumberOfArguments() = [1 .. 2]
|
||||
|
||||
@@ -19,7 +19,7 @@ module AddCertToRootStoreConfig implements DataFlow::ConfigSig {
|
||||
exists(ObjectCreation oc | oc = source.asExpr() |
|
||||
oc.getType()
|
||||
.(RefType)
|
||||
.hasQualifiedName("System.Security.Cryptography.X509Certificates", "X509Store") and
|
||||
.hasFullyQualifiedName("System.Security.Cryptography.X509Certificates", "X509Store") and
|
||||
oc.getArgument(0).(Access).getTarget().hasName("Root")
|
||||
)
|
||||
}
|
||||
@@ -28,9 +28,10 @@ module AddCertToRootStoreConfig implements DataFlow::ConfigSig {
|
||||
exists(MethodCall mc |
|
||||
(
|
||||
mc.getTarget()
|
||||
.hasQualifiedName("System.Security.Cryptography.X509Certificates", "X509Store", "Add") or
|
||||
.hasFullyQualifiedName("System.Security.Cryptography.X509Certificates", "X509Store",
|
||||
"Add") or
|
||||
mc.getTarget()
|
||||
.hasQualifiedName("System.Security.Cryptography.X509Certificates", "X509Store",
|
||||
.hasFullyQualifiedName("System.Security.Cryptography.X509Certificates", "X509Store",
|
||||
"AddRange")
|
||||
) and
|
||||
sink.asExpr() = mc.getQualifier()
|
||||
|
||||
@@ -30,7 +30,7 @@ predicate loginMethod(Method m, ControlFlow::SuccessorType flowFrom) {
|
||||
/** The `System.Web.SessionState.HttpSessionState` class. */
|
||||
class SystemWebSessionStateHttpSessionStateClass extends Class {
|
||||
SystemWebSessionStateHttpSessionStateClass() {
|
||||
this.hasQualifiedName("System.Web.SessionState", "HttpSessionState")
|
||||
this.hasFullyQualifiedName("System.Web.SessionState", "HttpSessionState")
|
||||
}
|
||||
|
||||
/** Gets the `Abandon` method. */
|
||||
|
||||
@@ -16,7 +16,7 @@ from Assignment a, PropertyAccess pa
|
||||
where
|
||||
a.getLValue() = pa and
|
||||
pa.getTarget().hasName("Domain") and
|
||||
pa.getTarget().getDeclaringType().hasQualifiedName("System.Web", "HttpCookie") and
|
||||
pa.getTarget().getDeclaringType().hasFullyQualifiedName("System.Web", "HttpCookie") and
|
||||
(
|
||||
a.getRValue().getValue().regexpReplaceAll("[^.]", "").length() < 2 or
|
||||
a.getRValue().getValue().matches(".%")
|
||||
|
||||
@@ -16,6 +16,6 @@ from Assignment a, PropertyAccess pa
|
||||
where
|
||||
a.getLValue() = pa and
|
||||
pa.getTarget().hasName("Path") and
|
||||
pa.getTarget().getDeclaringType().hasQualifiedName("System.Web", "HttpCookie") and
|
||||
pa.getTarget().getDeclaringType().hasFullyQualifiedName("System.Web", "HttpCookie") and
|
||||
a.getRValue().getValue() = "/"
|
||||
select a, "Overly broad path for cookie."
|
||||
|
||||
@@ -17,5 +17,5 @@ where
|
||||
a.getTarget() = ecb and
|
||||
ecb.hasName("ECB") and
|
||||
ecb.getDeclaringType() = e and
|
||||
e.hasQualifiedName("System.Security.Cryptography", "CipherMode")
|
||||
e.hasFullyQualifiedName("System.Security.Cryptography", "CipherMode")
|
||||
select a, "The ECB (Electronic Code Book) encryption mode is vulnerable to replay attacks."
|
||||
|
||||
@@ -21,7 +21,7 @@ where
|
||||
pa.getTarget().hasName("EnableHeaderChecking") and
|
||||
pa.getTarget()
|
||||
.getDeclaringType()
|
||||
.hasQualifiedName("System.Web.Configuration", "HttpRuntimeSection") and
|
||||
.hasFullyQualifiedName("System.Web.Configuration", "HttpRuntimeSection") and
|
||||
a.getRValue().getValue() = "false" and
|
||||
a = l
|
||||
)
|
||||
|
||||
@@ -18,7 +18,7 @@ where
|
||||
mc.getTarget().hasName("Encrypt") and
|
||||
mc.getTarget()
|
||||
.getDeclaringType()
|
||||
.hasQualifiedName("System.Security.Cryptography", "RSACryptoServiceProvider") and
|
||||
.hasFullyQualifiedName("System.Security.Cryptography", "RSACryptoServiceProvider") and
|
||||
mc.getArgument(1) = b and
|
||||
b.getValue() = "false"
|
||||
select b, "Enable RSA padding."
|
||||
|
||||
@@ -61,13 +61,13 @@ module Random {
|
||||
RandomSource() {
|
||||
this.getExpr() =
|
||||
any(MethodCall mc |
|
||||
mc.getQualifier().getType().(RefType).hasQualifiedName("System", "Random")
|
||||
mc.getQualifier().getType().(RefType).hasFullyQualifiedName("System", "Random")
|
||||
or
|
||||
// by using `% 87` on a `byte`, `System.Web.Security.Membership.GeneratePassword` has a bias
|
||||
mc.getQualifier()
|
||||
.getType()
|
||||
.(RefType)
|
||||
.hasQualifiedName("System.Web.Security", "Membership") and
|
||||
.hasFullyQualifiedName("System.Web.Security", "Membership") and
|
||||
mc.getTarget().hasName("GeneratePassword")
|
||||
)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ predicate incorrectUseOfRC2(Assignment e, string msg) {
|
||||
pa.getTarget().hasName("EffectiveKeySize") and
|
||||
pa.getTarget()
|
||||
.getDeclaringType()
|
||||
.hasQualifiedName("System.Security.Cryptography", "RC2CryptoServiceProvider")
|
||||
.hasFullyQualifiedName("System.Security.Cryptography", "RC2CryptoServiceProvider")
|
||||
) and
|
||||
e.getRValue().getValue().toInt() < 128 and
|
||||
msg = "Key size should be at least 128 bits for RC2 encryption."
|
||||
@@ -27,7 +27,7 @@ predicate incorrectUseOfRC2(Assignment e, string msg) {
|
||||
predicate incorrectUseOfDsa(ObjectCreation e, string msg) {
|
||||
e.getTarget()
|
||||
.getDeclaringType()
|
||||
.hasQualifiedName("System.Security.Cryptography", "DSACryptoServiceProvider") and
|
||||
.hasFullyQualifiedName("System.Security.Cryptography", "DSACryptoServiceProvider") and
|
||||
exists(Expr i | e.getArgument(0) = i and i.getValue().toInt() < 2048) and
|
||||
msg = "Key size should be at least 2048 bits for DSA encryption."
|
||||
}
|
||||
@@ -35,7 +35,7 @@ predicate incorrectUseOfDsa(ObjectCreation e, string msg) {
|
||||
predicate incorrectUseOfRsa(ObjectCreation e, string msg) {
|
||||
e.getTarget()
|
||||
.getDeclaringType()
|
||||
.hasQualifiedName("System.Security.Cryptography", "RSACryptoServiceProvider") and
|
||||
.hasFullyQualifiedName("System.Security.Cryptography", "RSACryptoServiceProvider") and
|
||||
exists(Expr i | e.getArgument(0) = i and i.getValue().toInt() < 2048) and
|
||||
msg = "Key size should be at least 2048 bits for RSA encryption."
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class FutureDateExpr extends MethodCall {
|
||||
exists(PropertyAccess pa |
|
||||
pa = this.getQualifier() and
|
||||
pa.getTarget().hasName("Now") and
|
||||
pa.getTarget().getDeclaringType().hasQualifiedName("System", "DateTime")
|
||||
pa.getTarget().getDeclaringType().hasFullyQualifiedName("System", "DateTime")
|
||||
) and
|
||||
this.getTarget().getName().matches("Add%")
|
||||
}
|
||||
@@ -55,6 +55,6 @@ where
|
||||
a.getLValue() = pa and
|
||||
a.getRValue() = fde and
|
||||
pa.getTarget().hasName("Expires") and
|
||||
pa.getTarget().getDeclaringType().hasQualifiedName("System.Web", "HttpCookie") and
|
||||
pa.getTarget().getDeclaringType().hasFullyQualifiedName("System.Web", "HttpCookie") and
|
||||
(fde.timeIsNotClear() or fde.getTimeInSecond() > 300) // 5 minutes max
|
||||
select a, "Avoid persistent cookies."
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
import csharp
|
||||
|
||||
predicate incorrectUseOfDES(ObjectCreation e, string msg) {
|
||||
e.getType().(Class).hasQualifiedName("System.Security.Cryptography", "DESCryptoServiceProvider") and
|
||||
e.getType()
|
||||
.(Class)
|
||||
.hasFullyQualifiedName("System.Security.Cryptography", "DESCryptoServiceProvider") and
|
||||
msg =
|
||||
"DES encryption uses keys of 56 bits only. Switch to AesCryptoServiceProvider or RijndaelManaged instead."
|
||||
}
|
||||
@@ -21,7 +23,7 @@ predicate incorrectUseOfDES(ObjectCreation e, string msg) {
|
||||
predicate incorrectUseOfTripleDES(ObjectCreation e, string msg) {
|
||||
e.getType()
|
||||
.(Class)
|
||||
.hasQualifiedName("System.Security.Cryptography", "TripleDESCryptoServiceProvider") and
|
||||
.hasFullyQualifiedName("System.Security.Cryptography", "TripleDESCryptoServiceProvider") and
|
||||
msg =
|
||||
"TripleDES encryption provides at most 112 bits of security. Switch to AesCryptoServiceProvider or RijndaelManaged instead."
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ class ExternalApi extends Callable {
|
||||
* Gets the namespace of this API.
|
||||
*/
|
||||
bindingset[this]
|
||||
string getNamespace() { this.getDeclaringType().hasQualifiedName(result, _) }
|
||||
string getNamespace() { this.getDeclaringType().hasFullyQualifiedName(result, _) }
|
||||
|
||||
/**
|
||||
* Gets the namespace and signature of this API.
|
||||
|
||||
@@ -102,7 +102,7 @@ module RequestForgery {
|
||||
*/
|
||||
private class SystemWebHttpRequestMessageSink extends Sink {
|
||||
SystemWebHttpRequestMessageSink() {
|
||||
exists(Class c | c.hasQualifiedName("System.Net.Http", "HttpRequestMessage") |
|
||||
exists(Class c | c.hasFullyQualifiedName("System.Net.Http", "HttpRequestMessage") |
|
||||
c.getAConstructor().getACall().getArgument(1) = this.asExpr()
|
||||
)
|
||||
}
|
||||
@@ -115,7 +115,8 @@ module RequestForgery {
|
||||
private class SystemNetWebRequestCreateSink extends Sink {
|
||||
SystemNetWebRequestCreateSink() {
|
||||
exists(Method m |
|
||||
m.getDeclaringType().hasQualifiedName("System.Net", "WebRequest") and m.hasName("Create")
|
||||
m.getDeclaringType().hasFullyQualifiedName("System.Net", "WebRequest") and
|
||||
m.hasName("Create")
|
||||
|
|
||||
m.getACall().getArgument(0) = this.asExpr()
|
||||
)
|
||||
@@ -129,7 +130,7 @@ module RequestForgery {
|
||||
private class SystemNetHttpClientSink extends Sink {
|
||||
SystemNetHttpClientSink() {
|
||||
exists(Method m |
|
||||
m.getDeclaringType().hasQualifiedName("System.Net.Http", "HttpClient") and
|
||||
m.getDeclaringType().hasFullyQualifiedName("System.Net.Http", "HttpClient") and
|
||||
m.hasName([
|
||||
"DeleteAsync", "GetAsync", "GetByteArrayAsync", "GetStreamAsync", "GetStringAsync",
|
||||
"PatchAsync", "PostAsync", "PutAsync"
|
||||
@@ -150,8 +151,8 @@ module RequestForgery {
|
||||
p.hasName("BaseAddress") and
|
||||
t = p.getDeclaringType() and
|
||||
(
|
||||
t.hasQualifiedName("System.Net", "WebClient") or
|
||||
t.hasQualifiedName("System.Net.Http", "HttpClient")
|
||||
t.hasFullyQualifiedName("System.Net", "WebClient") or
|
||||
t.hasFullyQualifiedName("System.Net.Http", "HttpClient")
|
||||
)
|
||||
|
|
||||
p.getAnAssignedValue() = this.asExpr()
|
||||
@@ -165,7 +166,7 @@ module RequestForgery {
|
||||
* This guard considers all checks as valid.
|
||||
*/
|
||||
private predicate baseUriGuard(Guard g, Expr e, AbstractValue v) {
|
||||
g.(MethodCall).getTarget().hasQualifiedName("System", "Uri", "IsBaseOf") and
|
||||
g.(MethodCall).getTarget().hasFullyQualifiedName("System", "Uri", "IsBaseOf") and
|
||||
// we consider any checks against the tainted value to sainitize the taint.
|
||||
// This implies any check such as shown below block the taint flow.
|
||||
// Uri url = new Uri("whitelist.com")
|
||||
@@ -184,7 +185,7 @@ module RequestForgery {
|
||||
* This guard considers all checks as valid.
|
||||
*/
|
||||
private predicate stringStartsWithGuard(Guard g, Expr e, AbstractValue v) {
|
||||
g.(MethodCall).getTarget().hasQualifiedName("System", "String", "StartsWith") and
|
||||
g.(MethodCall).getTarget().hasFullyQualifiedName("System", "String", "StartsWith") and
|
||||
// Any check such as the ones shown below
|
||||
// "https://myurl.com/".startsWith(`taint`)
|
||||
// `taint`.startsWith("https://myurl.com/")
|
||||
@@ -205,7 +206,7 @@ module RequestForgery {
|
||||
|
||||
private predicate pathCombineStep(DataFlow::Node prev, DataFlow::Node succ) {
|
||||
exists(MethodCall combineCall |
|
||||
combineCall.getTarget().hasQualifiedName("System.IO", "Path", "Combine") and
|
||||
combineCall.getTarget().hasFullyQualifiedName("System.IO", "Path", "Combine") and
|
||||
combineCall.getArgument(0) = prev.asExpr() and
|
||||
combineCall = succ.asExpr()
|
||||
)
|
||||
@@ -213,7 +214,7 @@ module RequestForgery {
|
||||
|
||||
private predicate uriCreationStep(DataFlow::Node prev, DataFlow::Node succ) {
|
||||
exists(ObjectCreation oc |
|
||||
oc.getTarget().getDeclaringType().hasQualifiedName("System", "Uri") and
|
||||
oc.getTarget().getDeclaringType().hasFullyQualifiedName("System", "Uri") and
|
||||
oc.getArgument(0) = prev.asExpr() and
|
||||
oc = succ.asExpr()
|
||||
)
|
||||
@@ -254,7 +255,7 @@ module RequestForgery {
|
||||
|
||||
private predicate formatConvertStep(DataFlow::Node prev, DataFlow::Node succ) {
|
||||
exists(Method m |
|
||||
m.hasQualifiedName("System", "Convert",
|
||||
m.hasFullyQualifiedName("System", "Convert",
|
||||
["FromBase64String", "FromHexString", "FromBase64CharArray"]) and
|
||||
m.getParameter(0) = prev.asParameter() and
|
||||
succ.asExpr() = m.getACall()
|
||||
|
||||
@@ -19,7 +19,7 @@ import csharp
|
||||
*/
|
||||
predicate isCreatingAzureClientSideEncryptionObject(ObjectCreation oc, Class c, Expr e) {
|
||||
exists(Parameter p | p.hasName("version") |
|
||||
c.hasQualifiedName("Azure.Storage", "ClientSideEncryptionOptions") and
|
||||
c.hasFullyQualifiedName("Azure.Storage", "ClientSideEncryptionOptions") and
|
||||
oc.getTarget() = c.getAConstructor() and
|
||||
e = oc.getArgumentForParameter(p)
|
||||
)
|
||||
@@ -29,7 +29,7 @@ predicate isCreatingAzureClientSideEncryptionObject(ObjectCreation oc, Class c,
|
||||
* Holds if `oc` is an object creation of the outdated type `c` = `Microsoft.Azure.Storage.Blob.BlobEncryptionPolicy`
|
||||
*/
|
||||
predicate isCreatingOutdatedAzureClientSideEncryptionObject(ObjectCreation oc, Class c) {
|
||||
c.hasQualifiedName("Microsoft.Azure.Storage.Blob", "BlobEncryptionPolicy") and
|
||||
c.hasFullyQualifiedName("Microsoft.Azure.Storage.Blob", "BlobEncryptionPolicy") and
|
||||
oc.getTarget() = c.getAConstructor()
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ predicate isObjectCreationArgumentSafeAndUsingSafeVersionOfAssembly(Expr version
|
||||
*/
|
||||
predicate isExprAnAccessToSafeClientSideEncryptionVersionValue(Expr e) {
|
||||
exists(EnumConstant ec |
|
||||
ec.hasQualifiedName("Azure.Storage.ClientSideEncryptionVersion", "V2_0") and
|
||||
ec.hasFullyQualifiedName("Azure.Storage.ClientSideEncryptionVersion", "V2_0") and
|
||||
ec.getAnAccess() = e
|
||||
)
|
||||
}
|
||||
|
||||
@@ -15,19 +15,19 @@ import HashWithoutSalt::PathGraph
|
||||
/** The C# class `Windows.Security.Cryptography.Core.HashAlgorithmProvider`. */
|
||||
class HashAlgorithmProvider extends RefType {
|
||||
HashAlgorithmProvider() {
|
||||
this.hasQualifiedName("Windows.Security.Cryptography.Core", "HashAlgorithmProvider")
|
||||
this.hasFullyQualifiedName("Windows.Security.Cryptography.Core", "HashAlgorithmProvider")
|
||||
}
|
||||
}
|
||||
|
||||
/** The C# class `System.Security.Cryptography.HashAlgorithm`. */
|
||||
class HashAlgorithm extends RefType {
|
||||
HashAlgorithm() { this.hasQualifiedName("System.Security.Cryptography", "HashAlgorithm") }
|
||||
HashAlgorithm() { this.hasFullyQualifiedName("System.Security.Cryptography", "HashAlgorithm") }
|
||||
}
|
||||
|
||||
/** The C# class `System.Security.Cryptography.KeyedHashAlgorithm`. */
|
||||
class KeyedHashAlgorithm extends RefType {
|
||||
KeyedHashAlgorithm() {
|
||||
this.hasQualifiedName("System.Security.Cryptography", "KeyedHashAlgorithm")
|
||||
this.hasFullyQualifiedName("System.Security.Cryptography", "KeyedHashAlgorithm")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,10 +95,10 @@ predicate hasAnotherHashCall(MethodCall mc) {
|
||||
predicate hasFurtherProcessing(MethodCall mc) {
|
||||
mc.getTarget().fromLibrary() and
|
||||
(
|
||||
mc.getTarget().hasQualifiedName("System", "Array", "Copy") or // Array.Copy(passwordHash, 0, password.Length), 0, key, 0, keyLen);
|
||||
mc.getTarget().hasQualifiedName("System", "String", "Concat") or // string.Concat(passwordHash, saltkey)
|
||||
mc.getTarget().hasQualifiedName("System", "Buffer", "BlockCopy") or // Buffer.BlockCopy(passwordHash, 0, allBytes, 0, 20)
|
||||
mc.getTarget().hasQualifiedName("System", "String", "Format") // String.Format("{0}:{1}:{2}", username, salt, password)
|
||||
mc.getTarget().hasFullyQualifiedName("System", "Array", "Copy") or // Array.Copy(passwordHash, 0, password.Length), 0, key, 0, keyLen);
|
||||
mc.getTarget().hasFullyQualifiedName("System", "String", "Concat") or // string.Concat(passwordHash, saltkey)
|
||||
mc.getTarget().hasFullyQualifiedName("System", "Buffer", "BlockCopy") or // Buffer.BlockCopy(passwordHash, 0, allBytes, 0, 20)
|
||||
mc.getTarget().hasFullyQualifiedName("System", "String", "Format") // String.Format("{0}:{1}:{2}", username, salt, password)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ module HashWithoutSaltConfig implements DataFlow::ConfigSig {
|
||||
c.getTarget()
|
||||
.getDeclaringType()
|
||||
.getABaseType*()
|
||||
.hasQualifiedName("System.Security.Cryptography", "DeriveBytes")
|
||||
.hasFullyQualifiedName("System.Security.Cryptography", "DeriveBytes")
|
||||
) and
|
||||
DataFlow::localExprFlow(mc, c.getAnArgument())
|
||||
)
|
||||
@@ -147,7 +147,7 @@ module HashWithoutSaltConfig implements DataFlow::ConfigSig {
|
||||
predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
|
||||
exists(MethodCall mc |
|
||||
mc.getTarget()
|
||||
.hasQualifiedName("Windows.Security.Cryptography", "CryptographicBuffer",
|
||||
.hasFullyQualifiedName("Windows.Security.Cryptography", "CryptographicBuffer",
|
||||
"ConvertStringToBinary") and
|
||||
mc.getArgument(0) = node1.asExpr() and
|
||||
mc = node2.asExpr()
|
||||
@@ -176,7 +176,7 @@ module HashWithoutSaltConfig implements DataFlow::ConfigSig {
|
||||
c.getTarget()
|
||||
.getDeclaringType()
|
||||
.getABaseType*()
|
||||
.hasQualifiedName("System.Security.Cryptography", "DeriveBytes")
|
||||
.hasFullyQualifiedName("System.Security.Cryptography", "DeriveBytes")
|
||||
)
|
||||
or
|
||||
// a salt or key is included in subclasses of `KeyedHashAlgorithm`
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user