Skip to content

Commit dc992a2

Browse files
Fix query ids
1 parent 104ceb9 commit dc992a2

File tree

9 files changed

+51
-13
lines changed

9 files changed

+51
-13
lines changed

3/1/instructions.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
You will need to set up CodeQL using one of the methods presented in [challenge 2](https://github.com/GitHubSecurityLab/codeql-zero-to-hero/blob/main/2/challenge-2/instructions.md) from CodeQL zero to hero part 2 to run the queries. Remember also to download and [select a CodeQL database](https://github.com/GitHubSecurityLab/codeql-zero-to-hero/blob/main/2/challenge-2/instructions.md#select-codeql-database) - it can be the GitHubSecurityLab/codeql-zero-to-hero database, but you may also choose another project.
22

33
Run the query in this challenge to find all method calls that are called ‘execute’ and come from the `django.db` library.
4+
5+
If the path is not displaying properly, you may need to change the view to ‘alerts’.
6+
7+
<img src=../../images/alert-view.png>

3/1/query.ql

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* @id codeql-zero-to-hero/3-1
3+
* @severity error
4+
* @kind problem
5+
*/
6+
17
import python
28
import semmle.python.ApiGraphs
39

@@ -6,5 +12,4 @@ where node =
612
API::moduleImport("django").getMember("db").getMember("connection").getMember("cursor").getReturn().getMember("execute").getACall()
713
and
814
node.getLocation().getFile().getRelativePath().regexpMatch("2/challenge-1/.*")
9-
10-
select node
15+
select node, "Call to django.db execute"

3/2/query.ql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
/**
2+
* @id codeql-zero-to-hero/3-2
3+
* @severity error
4+
* @kind problem
5+
*/
6+
17
import python
28
import semmle.python.ApiGraphs
39

410
from API::CallNode node
511
where node = API::moduleImport("os").getMember("system").getACall()
612
and node.getLocation().getFile().getRelativePath().regexpMatch("2/challenge-1/.*")
7-
select node
13+
select node, "Call to os.system"

3/3/query.ql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
/**
2+
* @id codeql-zero-to-hero/3-3
3+
* @severity error
4+
* @kind problem
5+
*/
6+
17
import python
28
import semmle.python.ApiGraphs
39

4-
select API::moduleImport("flask").getMember("request").getMember("args").asSource()
10+
select API::moduleImport("flask").getMember("request").getMember("args").asSource(), "Flask request.args source"
511

612
// Note that you can also use a wildcard to query for any method of the request object, for example:
713

3/4/query.ql

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
/**
2+
* @id codeql-zero-to-hero/3-4
3+
* @severity error
4+
* @kind problem
5+
*/
16
import python
27
import semmle.python.ApiGraphs
38

49
from API::CallNode node
510
where node = API::moduleImport("django").getMember("db").getMember("connection").getMember("cursor").getReturn().getMember("execute").getACall()
6-
select node, node.getAQlClass()
11+
select node, "The node has type " + node.getAQlClass()

3/5/query.ql

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* @id codeql-zero-to-hero/3-5
3+
* @severity error
4+
* @kind problem
5+
*/
16
import python
27
import semmle.python.ApiGraphs
38

@@ -18,4 +23,4 @@ predicate executeNotLiteral(DataFlow::CallCfgNode call) {
1823

1924
from DataFlow::CallCfgNode call
2025
where executeNotLiteral(call)
21-
select call
26+
select call, "Call to django.db execute with an argument that is not a literal"

3/6/query.ql

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
/**
2-
* @name DataFlow configuration
3-
* @description DataFlow TaintTracking configuration
42
* @kind path-problem
5-
* @precision low
63
* @problem.severity error
7-
* @id githubsecuritylab/dataflow-query
8-
* @tags template
4+
* @id githubsecuritylab/3-6
95
*/
106

117
import python

3/8/query.ql

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
/**
2+
* @kind problem
3+
* @problem.severity error
4+
* @id githubsecuritylab/3-8
5+
*/
16
import python
27
import semmle.python.dataflow.new.RemoteFlowSources
38

49

510
from RemoteFlowSource rfs
6-
select rfs
11+
select rfs, "A remote flow source"

3/9/query.ql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
/**
2+
* @kind problem
3+
* @problem.severity error
4+
* @id githubsecuritylab/3-9
5+
*/
6+
17
import python
28
import semmle.python.Concepts
39

410
from SqlExecution sink
5-
select sink
11+
select sink, "Potential SQL injection sink"

0 commit comments

Comments
 (0)