Code Monkey home page Code Monkey logo

Comments (2)

github-learning-lab avatar github-learning-lab commented on July 16, 2024

⌨️ Activity: Find all the calls to memcpy

  1. Edit the file 6_memcpy_calls.ql
  2. Use the auto-completion feature to find the class that represents function calls, and declare a variable that belongs to this class.
  3. Use auto-completion again on your function call variable to guess the predicate that tells us the target function that is being called.
  4. Combine this with your logic from step 4 to make sure the target function is named memcpy.
  5. Once you're happy with the results, submit your solution.

Tip: You can have a look at the following C++ example. Note that your query will be simpler as you won't need to consider the declaringType.

Finds calls to std::map<...>::find()

import cpp

from FunctionCall call, Function fcn
where
  call.getTarget() = fcn and
  fcn.getDeclaringType().getSimpleName() = "map" and
  fcn.getDeclaringType().getNamespace().getName() = "std" and
  fcn.hasName("find")
select call

Note: Once you have good results, you can try to make your query more compact by omitting the intermediate Function variable. The 2 queries below are equivalent:

from Class1 c1, Class2 c2
where
  c1.getClass2() = c2 and
  c2.getProp() = "something"
select c1
from Class1 c1
where c1.getClass2().getProp() = "something"
select c1

from codeql-uboot.

github-learning-lab avatar github-learning-lab commented on July 16, 2024

Congratulations, looks like the query you introduced in 7c813b1 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.