You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: javascript.md
+19-18Lines changed: 19 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,7 +78,7 @@ Each step has a **Solution** that indicates one possible answer. Note that all q
78
78
<details>
79
79
<summary>Solution</summary>
80
80
81
-
```
81
+
```ql
82
82
from CallExpr dollarCall
83
83
select dollarCall
84
84
```
@@ -96,7 +96,7 @@ Each step has a **Solution** that indicates one possible answer. Note that all q
96
96
<details>
97
97
<summary>Solution</summary>
98
98
99
-
```
99
+
```ql
100
100
from CallExpr dollarCall, Expr dollarArg
101
101
where dollarArg = dollarCall.getArgument(0)
102
102
select dollarArg
@@ -114,7 +114,7 @@ Each step has a **Solution** that indicates one possible answer. Note that all q
114
114
</details><details>
115
115
<summary>Solution</summary>
116
116
117
-
```
117
+
```ql
118
118
from CallExpr dollarCall, Expr dollarArg
119
119
where
120
120
dollarArg = dollarCall.getArgument(0) and
@@ -132,11 +132,11 @@ Each step has a **Solution** that indicates one possible answer. Note that all q
132
132
- Calling the predicate `jquery()` returns all values that refer to the `$` function.
133
133
- To find all calls to this function, use the predicate `getACall()`.
134
134
- Notice that when you call `jquery()`, `getACall()`, and `getAnArgument()` in succession, you get return values of type `DataFlow::Node`, not `Expr`. These are **data flow nodes**. They describe a part of the source program that may have a value, and let us do more complex reasoning about this value. We'll learn more about these in the next section.
135
-
- You can convert the data flow node back into an `Expr` using the predicate `asExpr()`.
135
+
- You can change your `dollarArg` variable to have type `DataFlow::Node`, or convert the data flow node back into an `Expr` using the predicate `asExpr()`.
@@ -145,7 +145,7 @@ Each step has a **Solution** that indicates one possible answer. Note that all q
145
145
146
146
OR
147
147
148
-
```
148
+
```ql
149
149
from DataFlow::Node dollarArg
150
150
where
151
151
dollarArg = jquery().getACall().getArgument(0)
@@ -168,14 +168,14 @@ Consider creating a new query for these next few steps, or commenting out your e
168
168
1. You have already seen how to find references to the jQuery `$` function. Now find all places in the code that read the property `$.fn`.
169
169
<details>
170
170
<summary>Hint</summary>
171
-
171
+
- Declare a new variable of type `DataFlow::Node` to hold the results.
172
172
- Notice that `jQuery()` returns a value of type `DataFlow::SourceNode`. Source nodes are places in the program that introduce a new value, from which the flow of data may be tracked.
173
173
-`DataFlow::SourceNode` has a predicate named `getAPropertyRead(string)`, which finds all reads of a particular property on the same object. The string argument is the name of the property.
174
174
</details>
175
175
<details>
176
176
<summary>Solution</summary>
177
177
178
-
```
178
+
```ql
179
179
from DataFlow::Node n
180
180
where n = jquery().getAPropertyRead("fn")
181
181
select n
@@ -224,8 +224,8 @@ Consider creating a new query for these next few steps, or commenting out your e
224
224
<details>
225
225
<summary>Solution</summary>
226
226
227
-
```
228
-
from DataFlow::FunctionNode plugin
227
+
```ql
228
+
from DataFlow::Node plugin
229
229
where plugin = jquery().getAPropertyRead("fn").getAPropertySource()
230
230
select plugin
231
231
```
@@ -244,7 +244,7 @@ Consider creating a new query for these next few steps, or commenting out your e
244
244
<details>
245
245
<summary>Solution</summary>
246
246
247
-
```
247
+
```ql
248
248
from DataFlow::FunctionNode plugin, DataFlow::ParameterNode optionsParam
249
249
where
250
250
plugin = jquery().getAPropertyRead("fn").getAPropertySource() and
@@ -278,9 +278,7 @@ class Config extends TaintTracking::Configuration {
- [Tutorial: Analyzing data flow in JavaScript and TypeScript](https://help.semmle.com/QL/learn-ql/javascript/dataflow.html)
370
+
## What's next?
371
+
- Read the [tutorial on analyzing data flow in JavaScript and TypeScript](https://help.semmle.com/QL/learn-ql/javascript/dataflow.html).
372
+
- Try out the latest CodeQL Capture-the-Flag challenge on the [GitHub Security Lab website](https://securitylab.github.com/ctf) for a chance to win a prize! Or try one of the older Capture-the-Flag challenges to improve your CodeQL skills.
373
+
- Try out a CodeQL course on [GitHub Learning Lab](https://lab.github.com/githubtraining/codeql-u-boot-challenge-(cc++)).
373
374
374
375
## Acknowledgements
375
376
376
-
This is a reduced version of a Capture-the-Flag challenge devised by @esbena, available at https://securitylab.github.com/ctf/jquery. Try out the full version!
377
+
This is a reduced version of a Capture-the-Flag challenge devised by @esbena, available at https://securitylab.github.com/ctf/jquery. Try out the full version! Thanks to our moderators for valuable feedback on the workshop.
0 commit comments