mirror of
https://github.com/hohn/codeql-lab.git
synced 2025-12-16 09:53:04 +01:00
*** (PARTIAL) Extending Queries with Customizations.qll for C
This commit is contained in:
committed by
=Michael Hohn
parent
9ba32c29cd
commit
aeb7a5d4bd
50
README.org
50
README.org
@@ -235,36 +235,40 @@
|
|||||||
extensions affect propagation logic.
|
extensions affect propagation logic.
|
||||||
|
|
||||||
*** (PARTIAL) Extending Queries with Customizations.qll for C
|
*** (PARTIAL) Extending Queries with Customizations.qll for C
|
||||||
The manual YAML modeling approach described earlier works well for small or
|
The manual YAML modeling approach described earlier works well for isolated or
|
||||||
isolated cases. However, to fully integrate with idiomatic CodeQL
|
prototype cases. However, for idiomatic, large-scale, or reusable CodeQL
|
||||||
queries—especially for large-scale or reusable analysis—you will want to
|
analysis, it is often preferable to define custom dataflow logic directly in
|
||||||
extend the language’s internal dataflow configuration using
|
QL—using =Customizations.qll=.
|
||||||
=Customizations.qll=.
|
|
||||||
|
|
||||||
Most CodeQL-supported languages (e.g., Java, Python) include out-of-the-box
|
Most CodeQL-supported languages (e.g., Java, Python) include built-in support
|
||||||
support for =Customizations.qll=. In these cases, the primary language module
|
for this mechanism. For example, Java’s primary entry point [[./ql/java/ql/lib/java.qll][java.qll]]
|
||||||
(e.g., [[./ql/java/ql/lib/java.qll][java.qll]]) automatically imports [[./ql/java/ql/lib/Customizations.qll][Customizations.qll]], which defines
|
automatically imports [[./ql/java/ql/lib/Customizations.qll][Customizations.qll]], exposing extension points for
|
||||||
extension points for user-defined sources, sinks, and flow steps.
|
user-defined sources, sinks, and flow steps.
|
||||||
|
|
||||||
Unfortunately, C and C++ do not include this mechanism by default. Enabling it
|
In contrast, C and C++ do *not* support this out of the box. To enable it, you
|
||||||
requires modifying the language pack and rebuilding the CodeQL bundle.
|
must manually patch the language pack and (optionally) rebuild the CodeQL
|
||||||
|
bundle.
|
||||||
|
|
||||||
This section is *partially complete*: we illustrate the required QL changes,
|
This section is *partially complete*: we document the required source-level QL
|
||||||
but do *not yet include* the full bundling process.
|
changes, but the bundling process is still pending.
|
||||||
|
|
||||||
To add Customizations support for C/C++, make the following changes:
|
To enable =Customizations.qll= support for C/C++, perform the following:
|
||||||
|
|
||||||
1. Modify =ql/cpp/ql/lib/cpp.qll= to import your =Customizations.qll= module.
|
1. Modify =ql/cpp/ql/lib/cpp.qll= to import your =Customizations.qll= module.
|
||||||
2. Create and populate =ql/cpp/ql/lib/Customizations.qll= with definitions for
|
2. Create and populate =ql/cpp/ql/lib/Customizations.qll= with new
|
||||||
new sources, sinks, or flow steps.
|
source/sink/flow logic.
|
||||||
3. For full deployment: Rebuild the CodeQL bundle to reflect these changes.
|
3. *For full deployment:* Rebuild the CodeQL bundle to include the updated
|
||||||
|
QL files.
|
||||||
|
- This allows portable use in CLI runs and IDE workflows.
|
||||||
|
- Once bundled, C/C++ customization behaves like any other supported
|
||||||
|
language.
|
||||||
|
4. *For workshops and local development:* No bundling is needed.
|
||||||
|
- If you run queries directly from the modified source tree, the changes
|
||||||
|
take effect immediately.
|
||||||
|
|
||||||
The rebuilt bundle can then be used in VS Code or the CLI, enabling you to
|
A working demonstration of this modification (without bundling) is provided
|
||||||
model C/C++ flows in a way that mirrors Java and other languages. Once this
|
in:
|
||||||
bundling step is automated, custom C/C++ modeling will follow the same
|
[[./codeql-dataflow-sql-injection-c/README.org]]
|
||||||
developer workflow as any other language.
|
|
||||||
|
|
||||||
4. For workshops: The modifications have immediate effect
|
|
||||||
|
|
||||||
** TODO CodeQL Bundling
|
** TODO CodeQL Bundling
|
||||||
This section will provide a detailed walkthrough of the CodeQL bundling process
|
This section will provide a detailed walkthrough of the CodeQL bundling process
|
||||||
|
|||||||
Reference in New Issue
Block a user