Comments (2)
⌨️ Activity: Find all ntoh*
macros
- Edit the file
5_macro_definitions.ql
- Write a query that finds the definitions of the macros named
ntohs
,ntohl
orntohll
. Use the auto-completion in the Visual Studio Code extension to guide you:- Wait a moment after typing
from
to get a list of available classes in the CodeQL standard library for C/C++. Which class in this list represents macros? Create a variable with this class as its type. - In the
where
section, type<your_variable_name>
followed by a dot.
, and wait a moment to get the list of predicates available for a value in the variable's type. Hover over each predicate to see the inline documentation. - Which predicate will give us the name of a macro?
- Use the
or
keyword to combine multiple conditions where you want at least one condition to be met. Here we are interested in three possible macro names.
- Wait a moment after typing
- To write a more compact query that searches for all three macros at once, instead of using three cases combined by
or
you have 2 choices:- Use a regular expression. Check out the predicate
string::regexpMatch
in the built-in predicates for string. CodeQL uses thejava.util.Pattern
regexp conventions). - Use a set literal expression to equate
<your_variable_name>
to a lists of choices<your_variable_name> in ['bar', 'baz', 'quux']
- Use a regular expression. Check out the predicate
- Once you're happy with the results, submit your solution.
from codeql-uboot.
Congratulations, looks like the query you introduced in f776ee7 finds the correct results!
If you created a pull request, merge it.
Let's continue to the next step.
from codeql-uboot.
Related Issues (10)
- Step 1 - Welcome to the course! HOT 1
- Step 8 - Changing the selected output HOT 2
- Step 9 - Write your own class HOT 3
- Step 10 - Data flow and taint tracking analysis HOT 2
- Step 2 - Set up your IDE HOT 2
- Step 3 - Your first query HOT 3
- Step 4 - Anatomy of a query HOT 2
- Step 6 - Relating two variables HOT 3
- Step 7 - Relating two variables, continued HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from codeql-uboot.