Skip to content

Commit 1b64835

Browse files
authored
JavaScript workshop: Update highlighting and follow-up links
1 parent 31f1cc6 commit 1b64835

1 file changed

Lines changed: 19 additions & 18 deletions

File tree

javascript.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Each step has a **Solution** that indicates one possible answer. Note that all q
7878
<details>
7979
<summary>Solution</summary>
8080

81-
```
81+
```ql
8282
from CallExpr dollarCall
8383
select dollarCall
8484
```
@@ -96,7 +96,7 @@ Each step has a **Solution** that indicates one possible answer. Note that all q
9696
<details>
9797
<summary>Solution</summary>
9898
99-
```
99+
```ql
100100
from CallExpr dollarCall, Expr dollarArg
101101
where dollarArg = dollarCall.getArgument(0)
102102
select dollarArg
@@ -114,7 +114,7 @@ Each step has a **Solution** that indicates one possible answer. Note that all q
114114
</details><details>
115115
<summary>Solution</summary>
116116
117-
```
117+
```ql
118118
from CallExpr dollarCall, Expr dollarArg
119119
where
120120
dollarArg = dollarCall.getArgument(0) and
@@ -132,11 +132,11 @@ Each step has a **Solution** that indicates one possible answer. Note that all q
132132
- Calling the predicate `jquery()` returns all values that refer to the `$` function.
133133
- To find all calls to this function, use the predicate `getACall()`.
134134
- 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()`.
136136
</details><details>
137137
<summary>Solution</summary>
138138
139-
```
139+
```ql
140140
from Expr dollarArg
141141
where
142142
dollarArg = jquery().getACall().getArgument(0).asExpr()
@@ -145,7 +145,7 @@ Each step has a **Solution** that indicates one possible answer. Note that all q
145145
146146
OR
147147
148-
```
148+
```ql
149149
from DataFlow::Node dollarArg
150150
where
151151
dollarArg = jquery().getACall().getArgument(0)
@@ -168,14 +168,14 @@ Consider creating a new query for these next few steps, or commenting out your e
168168
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`.
169169
<details>
170170
<summary>Hint</summary>
171-
171+
- Declare a new variable of type `DataFlow::Node` to hold the results.
172172
- 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.
173173
- `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.
174174
</details>
175175
<details>
176176
<summary>Solution</summary>
177177

178-
```
178+
```ql
179179
from DataFlow::Node n
180180
where n = jquery().getAPropertyRead("fn")
181181
select n
@@ -224,8 +224,8 @@ Consider creating a new query for these next few steps, or commenting out your e
224224
<details>
225225
<summary>Solution</summary>
226226
227-
```
228-
from DataFlow::FunctionNode plugin
227+
```ql
228+
from DataFlow::Node plugin
229229
where plugin = jquery().getAPropertyRead("fn").getAPropertySource()
230230
select plugin
231231
```
@@ -244,7 +244,7 @@ Consider creating a new query for these next few steps, or commenting out your e
244244
<details>
245245
<summary>Solution</summary>
246246
247-
```
247+
```ql
248248
from DataFlow::FunctionNode plugin, DataFlow::ParameterNode optionsParam
249249
where
250250
plugin = jquery().getAPropertyRead("fn").getAPropertySource() and
@@ -278,9 +278,7 @@ class Config extends TaintTracking::Configuration {
278278
)
279279
}
280280
override predicate isSink(DataFlow::Node sink) {
281-
exists(/** TODO fill me in **/ |
282-
sink = /** TODO fill me in from Section 1 **/
283-
)
281+
sink = /** TODO fill me in from Section 1 **/
284282
}
285283
}
286284
@@ -319,7 +317,8 @@ select sink, source, sink, "Potential XSS vulnerability in plugin."
319317
<summary>Hint</summary>
320318
321319
- Complete the same process as above.
322-
- Remember that the argument of a call to `$` is a sink for XSS vulnerabilities.
320+
- We already found a `DataFlow::Node` in Section 1 as the result of calling `jquery()` and predicates on it.
321+
- Remember that the first argument of a call to `$` is a sink for XSS vulnerabilities.
323322
324323
</details>
325324
<details>
@@ -368,9 +367,11 @@ select sink, source, sink, "Potential XSS vulnerability in plugin."
368367
```
369368
</details>
370369
371-
## Follow-up material
372-
- [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++)).
373374
374375
## Acknowledgements
375376
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

Comments
 (0)