mirror of
https://github.com/github/codeql.git
synced 2026-04-26 09:15:12 +02:00
Merge branch 'rc/1.22' into 1.22-mergeback-master
Conflicts resolved in favour of master: docs/language/learn-ql/cpp/conversions-classes.rst docs/language/learn-ql/cpp/function-classes.rst docs/language/learn-ql/cpp/introduce-libraries-cpp.rst docs/language/learn-ql/csharp/ql-for-csharp.rst docs/language/learn-ql/javascript/introduce-libraries-ts.rst docs/language/learn-ql/python/introduce-libraries-python.rst docs/language/ql-training/cpp/bad-overflow-guard.rst docs/language/ql-training/cpp/control-flow-cpp.rst docs/language/ql-training/cpp/global-data-flow-cpp.rst docs/language/ql-training/cpp/intro-ql-cpp.rst docs/language/ql-training/cpp/program-representation-cpp.rst docs/language/ql-training/cpp/snprintf.rst docs/language/ql-training/index.rst docs/language/ql-training/java/global-data-flow-java.rst docs/language/ql-training/java/intro-ql-java.rst docs/language/ql-training/java/program-representation-java.rst docs/language/ql-training/java/query-injection-java.rst
This commit is contained in:
@@ -87,6 +87,10 @@ Now we can write a query using these classes:
|
||||
|
||||
Note that there is no need to check whether anything is added to the ``strlen`` expression, as it would be in the corrected C code ``malloc(strlen(string) + 1)``. This is because the corrected code would in fact be an ``AddExpr`` containing a ``StrlenCall``, not an instance of ``StrlenCall`` itself. A side-effect of this approach is that we omit certain unlikely patterns such as ``malloc(strlen(string) + 0``). In practice we can always come back and extend our query to cover this pattern if it is a concern.
|
||||
|
||||
.. pull-quote::
|
||||
|
||||
Tip
|
||||
|
||||
For some projects, this query may not return any results. Possibly the project you are querying does not have any problems of this kind, but it is also important to make sure the query itself is working properly. One solution is to set up a test project with examples of correct and incorrect code to run the query against (the C code at the very top of this page makes a good starting point). Another approach is to test each part of the query individually to make sure everything is working.
|
||||
|
||||
When you have defined the basic query then you can refine the query to include further coding patterns or to exclude false positives:
|
||||
|
||||
Reference in New Issue
Block a user