Skip to content

Commit 7a6a715

Browse files
authored
Merge pull request #88 from GitHubSecurityLab/java/removequerysuitedependecy
Java: Remove dependency to the CodeQL java query pack.
2 parents 853765d + 09a70a7 commit 7a6a715

File tree

7 files changed

+125
-10
lines changed

7 files changed

+125
-10
lines changed
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/**
2+
* Provides classes for working with MyBatis mapper xml files and their content.
3+
*/
4+
5+
import java
6+
7+
/**
8+
* MyBatis Mapper XML file.
9+
*/
10+
class MyBatisMapperXmlFile extends XmlFile {
11+
MyBatisMapperXmlFile() {
12+
count(XmlElement e | e = this.getAChild()) = 1 and
13+
this.getAChild().getName() = "mapper"
14+
}
15+
}
16+
17+
/**
18+
* An XML element in a `MyBatisMapperXMLFile`.
19+
*/
20+
class MyBatisMapperXmlElement extends XmlElement {
21+
MyBatisMapperXmlElement() { this.getFile() instanceof MyBatisMapperXmlFile }
22+
23+
/**
24+
* Gets the value for this element, with leading and trailing whitespace trimmed.
25+
*/
26+
string getValue() { result = this.allCharactersString().trim() }
27+
28+
/**
29+
* Gets the reference type bound to MyBatis Mapper XML File.
30+
*/
31+
RefType getNamespaceRefType() {
32+
result.getQualifiedName() = this.getAttribute("namespace").getValue()
33+
}
34+
}
35+
36+
/**
37+
* An MyBatis Mapper sql operation element.
38+
*/
39+
abstract class MyBatisMapperSqlOperation extends MyBatisMapperXmlElement {
40+
/**
41+
* Gets the value of the `id` attribute of MyBatis Mapper sql operation element.
42+
*/
43+
string getId() { result = this.getAttribute("id").getValue() }
44+
45+
/**
46+
* Gets the `<include>` element in a `MyBatisMapperSqlOperation`.
47+
*/
48+
MyBatisMapperInclude getInclude() { result = this.getAChild*() }
49+
50+
/**
51+
* Gets the method bound to MyBatis Mapper XML File.
52+
*/
53+
Method getMapperMethod() {
54+
result.getName() = this.getId() and
55+
result.getDeclaringType() = this.getParent().(MyBatisMapperXmlElement).getNamespaceRefType()
56+
}
57+
}
58+
59+
/**
60+
* A `<insert>` element in a `MyBatisMapperSqlOperation`.
61+
*/
62+
class MyBatisMapperInsert extends MyBatisMapperSqlOperation {
63+
MyBatisMapperInsert() { this.getName() = "insert" }
64+
}
65+
66+
/**
67+
* A `<update>` element in a `MyBatisMapperSqlOperation`.
68+
*/
69+
class MyBatisMapperUpdate extends MyBatisMapperSqlOperation {
70+
MyBatisMapperUpdate() { this.getName() = "update" }
71+
}
72+
73+
/**
74+
* A `<delete>` element in a `MyBatisMapperSqlOperation`.
75+
*/
76+
class MyBatisMapperDelete extends MyBatisMapperSqlOperation {
77+
MyBatisMapperDelete() { this.getName() = "delete" }
78+
}
79+
80+
/**
81+
* A `<select>` element in a `MyBatisMapperSqlOperation`.
82+
*/
83+
class MyBatisMapperSelect extends MyBatisMapperSqlOperation {
84+
MyBatisMapperSelect() { this.getName() = "select" }
85+
}
86+
87+
/**
88+
* A `<sql>` element in a `MyBatisMapperXMLElement`.
89+
*/
90+
class MyBatisMapperSql extends MyBatisMapperXmlElement {
91+
MyBatisMapperSql() { this.getName() = "sql" }
92+
93+
/**
94+
* Gets the value of the `id` attribute of this `<sql>`.
95+
*/
96+
string getId() { result = this.getAttribute("id").getValue() }
97+
}
98+
99+
/**
100+
* A `<include>` element in a `MyBatisMapperXMLElement`.
101+
*/
102+
class MyBatisMapperInclude extends MyBatisMapperXmlElement {
103+
MyBatisMapperInclude() { this.getName() = "include" }
104+
105+
/**
106+
* Gets the value of the `refid` attribute of this `<include>`.
107+
*/
108+
string getRefid() { result = this.getAttribute("refid").getValue() }
109+
}
110+
111+
/**
112+
* A `<foreach>` element in a `MyBatisMapperXMLElement`.
113+
*/
114+
class MyBatisMapperForeach extends MyBatisMapperXmlElement {
115+
MyBatisMapperForeach() { this.getName() = "foreach" }
116+
}

java/src/codeql-pack.lock.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ dependencies:
55
version: 1.1.5
66
codeql/java-all:
77
version: 4.2.0
8-
codeql/java-queries:
9-
version: 1.1.8
108
codeql/mad:
119
version: 1.0.11
1210
codeql/rangeanalysis:
@@ -15,8 +13,6 @@ dependencies:
1513
version: 1.0.11
1614
codeql/ssa:
1715
version: 1.0.11
18-
codeql/suite-helpers:
19-
version: 1.0.11
2016
codeql/threat-models:
2117
version: 1.0.11
2218
codeql/tutorial:

java/src/qlpack.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ suites: suites
55
defaultSuiteFile: suites/java.qls
66
dependencies:
77
codeql/java-all: '*'
8-
codeql/java-queries: '*'
98
githubsecuritylab/codeql-java-libs: '*'

java/test/codeql-pack.lock.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ dependencies:
55
version: 1.1.5
66
codeql/java-all:
77
version: 4.2.0
8-
codeql/java-queries:
9-
version: 1.1.8
108
codeql/mad:
119
version: 1.0.11
1210
codeql/rangeanalysis:
@@ -15,8 +13,6 @@ dependencies:
1513
version: 1.0.11
1614
codeql/ssa:
1715
version: 1.0.11
18-
codeql/suite-helpers:
19-
version: 1.0.11
2016
codeql/threat-models:
2117
version: 1.0.11
2218
codeql/tutorial:

java/test/qlpack.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: githubsecurtylab/codeql-java-tests
22
groups: [java, test]
33
dependencies:
44
codeql/java-all: '*'
5-
codeql/java-queries: '*'
65
githubsecuritylab/codeql-java-queries: '*'
76
githubsecuritylab/codeql-java-libs: '*'
87
githubsecuritylab/codeql-java-library-sources: '*'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import java
2+
import semmle.code.java.security.DecompressionBombQuery
3+
import TestUtilities.InlineFlowTest
4+
import TaintFlowTestArgString<DecompressionBombsConfig, getArgString/2>
5+
6+
string getArgString(DataFlow::Node src, DataFlow::Node sink) {
7+
exists(src) and
8+
result = "\"" + sink.toString() + "\""
9+
}

0 commit comments

Comments
 (0)