Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Step 5 - Using the jquery predicate #7

Closed
github-learning-lab bot opened this issue Jul 24, 2021 · 2 comments
Closed

Step 5 - Using the jquery predicate #7

github-learning-lab bot opened this issue Jul 24, 2021 · 2 comments
Assignees

Comments

@github-learning-lab
Copy link

Step 5: Using the jQuery library

So far we have looked for the function name $. Are there other ways of calling the jQuery $ function? Perhaps the CodeQL library can handle these for us?

The CodeQL standard library for JavaScript has a built-in predicate jquery() to describe references to $.
Calling the predicate jquery() returns all values that refer to the $ function, and chaining this call with getACall(), will give you all calls to this function.

@github-learning-lab
Copy link
Author

⌨️ Rewrite your query

Use this library to rewrite your previous query, that gets you all the first argument to a call to $. Use a new file dollar-arg-node.ql.

Notice that when you call jquery(), getACall(), and getArgument() in succession, you get return values of type DataFlow::Node, and not Expr as in your previous query, so you have to change your return variable to have this type.

📖 The DataFlow::Node type

These data flow nodes 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.

You new query should give you the same results as the previous one. Submit your solution in the new file dollar-arg-node.ql when you're happy with it.

@github-learning-lab
Copy link
Author

Congratulations, looks like the query you introduced in 9e63f48 finds the correct results!

Take a look at the instructions for the next step to continue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant