Skip to content

Commit 29ccac8

Browse files
committed
C#: Address review comments.
1 parent 6b35098 commit 29ccac8

File tree

27 files changed

+50
-51
lines changed

27 files changed

+50
-51
lines changed

csharp/ql/lib/semmle/code/cil/ConsistencyChecks.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ class InvalidOverride extends MethodViolation {
489489
base.getDeclaringType().hasQualifiedName(namespace, type)
490490
|
491491
result =
492-
"Overridden method from " + printQualifiedName(namespace, type) + " is not in a base type"
492+
"Overridden method from " + getQualifiedName(namespace, type) + " is not in a base type"
493493
)
494494
}
495495
}

csharp/ql/lib/semmle/code/cil/Type.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Type extends DotNet::Type, Declaration, TypeContainer, @cil_type {
5454
override predicate hasQualifiedName(string namespace, string name) {
5555
name = this.getName() and
5656
exists(string pnamespace, string pname | this.getParent().hasQualifiedName(pnamespace, pname) |
57-
namespace = printQualifiedName(pnamespace, pname)
57+
namespace = getQualifiedName(pnamespace, pname)
5858
)
5959
}
6060

csharp/ql/lib/semmle/code/csharp/Callable.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ class LocalFunction extends Callable, Modifiable, Attributable, @local_function
10041004
override predicate hasQualifiedName(string namespace, string name) {
10051005
exists(string cnamespace, string type |
10061006
this.getEnclosingCallable().hasQualifiedName(cnamespace, type) and
1007-
namespace = printQualifiedName(cnamespace, type)
1007+
namespace = getQualifiedName(cnamespace, type)
10081008
) and
10091009
name = this.getName()
10101010
}

csharp/ql/lib/semmle/code/csharp/Generics.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ bindingset[t]
102102
private string getFullName(Type t) {
103103
exists(string namespace, string name |
104104
t.hasQualifiedName(namespace, name) and
105-
result = printQualifiedName(namespace, name)
105+
result = getQualifiedName(namespace, name)
106106
)
107107
}
108108

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
/**
2-
* Provides predicates related to C# qualified name.
2+
* Provides predicates related to C# qualified names.
33
*/
44

55
/**
6-
* Returns the concatenation of `qualifier` and `name`, separated by a dot.
6+
* Returns the concatenation of `namespace` and `name`, separated by a dot.
77
*/
88
bindingset[namespace, name]
9-
string printQualifiedName(string namespace, string name) {
9+
string getQualifiedName(string namespace, string name) {
1010
if namespace = "" then result = name else result = namespace + "." + name
1111
}
1212

1313
/**
14-
* Returns the concatenation of `qualifier`, `type` and `name`, separated by a dot.
14+
* Returns the concatenation of `namespace`, `type` and `name`, separated by a dot.
1515
*/
1616
bindingset[namespace, type, name]
17-
string printQualifiedName(string namespace, string type, string name) {
18-
result = printQualifiedName(namespace, type) + "." + name
17+
string getQualifiedName(string namespace, string type, string name) {
18+
result = getQualifiedName(namespace, type) + "." + name
1919
}
2020

21-
private string getNameSplitter() { result = "(.*)\\.([^\\.]+)$" }
22-
2321
/**
22+
* Holds if `qualifiedName` is the concatenation of `qualifier` and `name`, separated by a dot.
2423
*/
2524
bindingset[qualifiedName]
2625
predicate splitQualifiedName(string qualifiedName, string qualifier, string name) {
27-
if qualifiedName.regexpMatch(getNameSplitter())
28-
then
29-
qualifier = qualifiedName.regexpCapture(getNameSplitter(), 1) and
30-
name = qualifiedName.regexpCapture(getNameSplitter(), 2)
31-
else (
32-
qualifier = "" and name = qualifiedName
26+
exists(string nameSplitter | nameSplitter = "(.*)\\.([^\\.]+)$" |
27+
qualifier = qualifiedName.regexpCapture(nameSplitter, 1) and
28+
name = qualifiedName.regexpCapture(nameSplitter, 2)
29+
or
30+
not qualifiedName.regexpMatch(nameSplitter) and
31+
qualifier = "" and
32+
name = qualifiedName
3333
)
3434
}

csharp/ql/lib/semmle/code/csharp/security/dataflow/ExternalAPIsQuery.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class ExternalApiDataNode extends DataFlow::Node {
8383
*/
8484
deprecated string getCallableDescription() {
8585
exists(string namespace, string name |
86-
this.hasQualifiedName(namespace, name) and result = printQualifiedName(namespace, name)
86+
this.hasQualifiedName(namespace, name) and result = getQualifiedName(namespace, name)
8787
)
8888
}
8989
}

csharp/ql/lib/semmle/code/dotnet/Declaration.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Declaration extends NamedElement, @dotnet_declaration {
1111
override predicate hasQualifiedName(string namespace, string name) {
1212
exists(string dnamespace, string dname |
1313
this.getDeclaringType().hasQualifiedName(dnamespace, dname) and
14-
namespace = printQualifiedName(dnamespace, dname)
14+
namespace = getQualifiedName(dnamespace, dname)
1515
) and
1616
name = this.getName()
1717
}

csharp/ql/lib/semmle/code/dotnet/Namespace.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Namespace extends Declaration, @namespace {
2828
override predicate hasQualifiedName(string namespace, string name) {
2929
exists(string pnamespace, string pname |
3030
this.getParentNamespace().hasQualifiedName(pnamespace, pname) and
31-
namespace = printQualifiedName(pnamespace, pname)
31+
namespace = getQualifiedName(pnamespace, pname)
3232
) and
3333
name = this.getName()
3434
}
@@ -52,7 +52,7 @@ class Namespace extends Declaration, @namespace {
5252
string getFullName() {
5353
exists(string namespace, string name |
5454
this.hasQualifiedName(namespace, name) and
55-
result = printQualifiedName(namespace, name)
55+
result = getQualifiedName(namespace, name)
5656
)
5757
}
5858
}

csharp/ql/src/API Abuse/NonOverridingMethod.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ where
4343
nonOverridingMethod(m, vm) and
4444
vm.hasQualifiedName(namespace, type, name)
4545
select m, "Method '" + m.getName() + "' looks like it should override $@ but does not do so.",
46-
vm.getUnboundDeclaration(), printQualifiedName(namespace, type, name)
46+
vm.getUnboundDeclaration(), getQualifiedName(namespace, type, name)

csharp/ql/src/Security Features/CWE-020/UntrustedDataToExternalAPI.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ where
2121
config.hasFlowPath(source, sink) and
2222
sink.getNode().(ExternalApiDataNode).hasQualifiedName(namespace, name)
2323
select sink, source, sink,
24-
"Call to " + printQualifiedName(namespace, name) + " with untrusted data from $@.", source,
24+
"Call to " + getQualifiedName(namespace, name) + " with untrusted data from $@.", source,
2525
source.toString()

0 commit comments

Comments
 (0)