Skip to content
This repository was archived by the owner on Sep 1, 2022. It is now read-only.

Commit 015ba3d

Browse files
authored
Merge pull request #39 from github/ll2
Ll2
2 parents 36cac31 + ffa83a5 commit 015ba3d

27 files changed

+2648
-25
lines changed

codeql-learninglab-check/package/src/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,9 @@ function isConfig(config: any): config is Config {
308308
// Upgrade the database if neccesary
309309
const databasePath = path.join(CONFIG_PATH, config.databasePath);
310310
console.log('Upgrading CodeQL Database');
311-
await execFile('codeql', ['database', 'upgrade', databasePath]);
311+
const updateResult = await execFile('codeql', ['database', 'upgrade', '-v', databasePath]);
312+
console.log(updateResult.stderr);
313+
console.log(updateResult.stdout);
312314

313315
const csvPath = (queryPath: string) => path.join(OUTPUT_PATH, queryPath + '.csv');
314316

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# CodeQL LearningLab Course Action Template
2+
3+
Copy this entire directory,
4+
and replace the following:
5+
6+
* Replace `<owner>`, `<repo>` and `<pkg>` in the `image` property in
7+
[`action.yml`](action.yml) to reference the correct repository
8+
where the docker image will be published,
9+
and with a package name of your choice.
10+
(For courses in this repository,
11+
we use the convention of taking the course path,
12+
and replacing slashes with dashes,
13+
e.g. `courses/cpp/ctf-segv` becomes `courses-cpp-ctf-segv`)
14+
* Replace the zip file URL in [`image/Dockerfile`](image/Dockerfile)
15+
to point to the CodeQL database that will be used in your course.
16+
17+
After this,
18+
update [`answers/`](answers) and [`image/config/`](image/config)
19+
to add your model answers and expected query results as appropriate.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: 'Check queries'
2+
description: 'Check that the queries that have been pushed produce the correct results'
3+
author: 'GitHub <[email protected]>'
4+
runs:
5+
using: 'docker'
6+
image: 'docker://docker.pkg.github.com/github/codeql-learninglab-actions/courses-javascript-unsafe-jquery'
7+
branding:
8+
icon: 'check-circle'
9+
color: 'purple'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import javascript
2+
3+
from CallExpr dollarCall, Expr dollarArg
4+
where
5+
dollarArg = dollarCall.getArgument(0) and
6+
dollarCall.getCalleeName() = "$"
7+
select dollarArg
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import javascript
2+
3+
from CallExpr dollarCall
4+
where dollarCall.getCalleeName() = "$"
5+
select dollarCall
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import javascript
2+
3+
from DataFlow::Node dollarArg
4+
where
5+
dollarArg = jquery().getACall().getArgument(0)
6+
select dollarArg
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* @name Cross-site scripting vulnerable plugin
3+
* @kind path-problem
4+
* @id js/xss-unsafe-plugin
5+
*/
6+
7+
import javascript
8+
import DataFlow::PathGraph
9+
10+
class Configuration extends TaintTracking::Configuration {
11+
Configuration() { this = "XssUnsafeJQueryPlugin" }
12+
13+
override predicate isSource(DataFlow::Node source) {
14+
exists(DataFlow::FunctionNode plugin |
15+
plugin = jquery().getAPropertyRead("fn").getAPropertySource() and
16+
source = plugin.getLastParameter()
17+
)
18+
}
19+
20+
override predicate isSink(DataFlow::Node sink) {
21+
sink = jquery().getACall().getArgument(0)
22+
}
23+
}
24+
25+
from Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink
26+
where cfg.hasFlowPath(source, sink)
27+
select sink, source, sink, "Potential XSS vulnerability in plugin."
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import javascript
2+
3+
from DataFlow::Node plugin
4+
where plugin = jquery().getAPropertyRead("fn").getAPropertySource()
5+
select plugin
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import javascript
2+
3+
from DataFlow::FunctionNode plugin, DataFlow::ParameterNode optionsParam
4+
where
5+
plugin = jquery().getAPropertyRead("fn").getAPropertySource() and
6+
optionsParam = plugin.getLastParameter()
7+
select plugin, optionsParam
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import javascript
2+
3+
from DataFlow::Node n
4+
where n = jquery().getAPropertyRead("fn")
5+
select n
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: course-template
2+
version: 0.0.0
3+
libraryPathDependencies: codeql-javascript # Update this with appropriate language
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import javascript
2+
3+
predicate isSource(DataFlow::Node source) {
4+
exists(DataFlow::FunctionNode plugin |
5+
plugin = jquery().getAPropertyRead("fn").getAPropertySource() and
6+
source = plugin.getLastParameter()
7+
)
8+
}
9+
10+
from DataFlow::Node node
11+
where isSource(node)
12+
select node
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM docker.pkg.github.com/github/codeql-learninglab-actions/codeql-learninglab-check:v2.0.0
2+
3+
## Add course config
4+
COPY --chown=codeql:codeql config /home/codeql/config
5+
WORKDIR /home/codeql/config
6+
# Download, unzip and then delete the zip file in one step to reduce image size
7+
RUN wget --quiet https://github.com/githubsatelliteworkshops/codeql/releases/download/v1.0/esbena_bootstrap-pre-27047_javascript.zip -O database.zip && unzip -qq database.zip && rm -rf database.zip

0 commit comments

Comments
 (0)