Skip to content

Commit 4233363

Browse files
authored
Merge pull request github#13480 from github/jhelie/clean-up-mad-kinds-use
Java: clean up mad kinds use
2 parents c626890 + baf6b74 commit 4233363

File tree

5 files changed

+22
-32
lines changed

5 files changed

+22
-32
lines changed

java/ql/src/Telemetry/AutomodelApplicationModeCharacteristics.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ module ApplicationCandidatesImpl implements SharedCharacteristics::CandidateSig
5959
e.getType() instanceof NumberType
6060
)
6161
or
62-
t instanceof AutomodelEndpointTypes::TaintedPathSinkType and
62+
t instanceof AutomodelEndpointTypes::PathInjectionSinkType and
6363
e instanceof PathSanitizer::PathInjectionSanitizer
6464
}
6565

6666
RelatedLocation asLocation(Endpoint e) { result = e.asExpr() }
6767

68-
predicate isKnownKind = AutomodelJavaUtil::isKnownKind/3;
68+
predicate isKnownKind = AutomodelJavaUtil::isKnownKind/2;
6969

7070
predicate isSink(Endpoint e, string kind) {
7171
exists(string package, string type, string name, string signature, string ext, string input |
@@ -79,7 +79,7 @@ module ApplicationCandidatesImpl implements SharedCharacteristics::CandidateSig
7979
predicate isNeutral(Endpoint e) {
8080
exists(string package, string type, string name, string signature |
8181
sinkSpec(e, package, type, name, signature, _, _) and
82-
ExternalFlow::neutralModel(package, type, name, [signature, ""], _, _)
82+
ExternalFlow::neutralModel(package, type, name, [signature, ""], "sink", _)
8383
)
8484
}
8585

java/ql/src/Telemetry/AutomodelEndpointTypes.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@ class NegativeSinkType extends SinkType {
4040
}
4141

4242
/** A sink relevant to the SQL injection query */
43-
class SqlSinkType extends SinkType {
44-
SqlSinkType() { this = "sql" }
43+
class SqlInjectionSinkType extends SinkType {
44+
SqlInjectionSinkType() { this = "sql-injection" }
4545
}
4646

4747
/** A sink relevant to the tainted path injection query. */
48-
class TaintedPathSinkType extends SinkType {
49-
TaintedPathSinkType() { this = "tainted-path" }
48+
class PathInjectionSinkType extends SinkType {
49+
PathInjectionSinkType() { this = "path-injection" }
5050
}
5151

5252
/** A sink relevant to the SSRF query. */
5353
class RequestForgerySinkType extends SinkType {
54-
RequestForgerySinkType() { this = "ssrf" }
54+
RequestForgerySinkType() { this = "request-forgery" }
5555
}
5656

5757
/** A sink relevant to the command injection query. */

java/ql/src/Telemetry/AutomodelFrameworkModeCharacteristics.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module FrameworkCandidatesImpl implements SharedCharacteristics::CandidateSig {
4848

4949
RelatedLocation asLocation(Endpoint e) { result = e.asParameter() }
5050

51-
predicate isKnownKind = AutomodelJavaUtil::isKnownKind/3;
51+
predicate isKnownKind = AutomodelJavaUtil::isKnownKind/2;
5252

5353
predicate isSink(Endpoint e, string kind) {
5454
exists(string package, string type, string name, string signature, string ext, string input |
@@ -60,7 +60,7 @@ module FrameworkCandidatesImpl implements SharedCharacteristics::CandidateSig {
6060
predicate isNeutral(Endpoint e) {
6161
exists(string package, string type, string name, string signature |
6262
sinkSpec(e, package, type, name, signature, _, _) and
63-
ExternalFlow::neutralModel(package, type, name, [signature, ""], _, _)
63+
ExternalFlow::neutralModel(package, type, name, [signature, ""], "sink", _)
6464
)
6565
}
6666

java/ql/src/Telemetry/AutomodelJavaUtil.qll

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,17 @@ class DollarAtString extends string {
2727
* Holds for all combinations of MaD kinds (`kind`) and their human readable
2828
* descriptions.
2929
*/
30-
predicate isKnownKind(
31-
string kind, string humanReadableKind, AutomodelEndpointTypes::EndpointType type
32-
) {
33-
kind = "read-file" and
34-
humanReadableKind = "read file" and
35-
type instanceof AutomodelEndpointTypes::TaintedPathSinkType
30+
predicate isKnownKind(string kind, AutomodelEndpointTypes::EndpointType type) {
31+
kind = "path-injection" and
32+
type instanceof AutomodelEndpointTypes::PathInjectionSinkType
3633
or
37-
kind = "create-file" and
38-
humanReadableKind = "create file" and
39-
type instanceof AutomodelEndpointTypes::TaintedPathSinkType
34+
kind = "sql-injection" and
35+
type instanceof AutomodelEndpointTypes::SqlInjectionSinkType
4036
or
41-
kind = "sql" and
42-
humanReadableKind = "mad modeled sql" and
43-
type instanceof AutomodelEndpointTypes::SqlSinkType
44-
or
45-
kind = "open-url" and
46-
humanReadableKind = "open url" and
47-
type instanceof AutomodelEndpointTypes::RequestForgerySinkType
48-
or
49-
kind = "jdbc-url" and
50-
humanReadableKind = "jdbc url" and
37+
kind = "request-forgery" and
5138
type instanceof AutomodelEndpointTypes::RequestForgerySinkType
5239
or
5340
kind = "command-injection" and
54-
humanReadableKind = "command injection" and
5541
type instanceof AutomodelEndpointTypes::CommandInjectionSinkType
5642
}
5743

java/ql/src/Telemetry/AutomodelSharedCharacteristics.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ signature module CandidateSig {
5050
/**
5151
* Defines what MaD kinds are known, and what endpoint type they correspond to.
5252
*/
53-
predicate isKnownKind(string kind, string humanReadableLabel, EndpointType type);
53+
predicate isKnownKind(string kind, EndpointType type);
5454

5555
/**
5656
* Holds if `e` is a flow sanitizer, and has type `t`.
@@ -276,7 +276,11 @@ module SharedCharacteristics<CandidateSig Candidate> {
276276
string madKind;
277277
Candidate::EndpointType endpointType;
278278

279-
KnownSinkCharacteristic() { Candidate::isKnownKind(madKind, this, endpointType) }
279+
KnownSinkCharacteristic() {
280+
Candidate::isKnownKind(madKind, endpointType) and
281+
// bind "this" to a unique string differing from that of the SinkType classes
282+
this = madKind + "-characteristic"
283+
}
280284

281285
override predicate appliesToEndpoint(Candidate::Endpoint e) { Candidate::isSink(e, madKind) }
282286

0 commit comments

Comments
 (0)