Skip to content

Commit aeb7a5d

Browse files
committed
*** (PARTIAL) Extending Queries with Customizations.qll for C
1 parent 9ba32c2 commit aeb7a5d

1 file changed

Lines changed: 29 additions & 25 deletions

File tree

README.org

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -235,37 +235,41 @@
235235
extensions affect propagation logic.
236236

237237
*** (PARTIAL) Extending Queries with Customizations.qll for C
238-
The manual YAML modeling approach described earlier works well for small or
239-
isolated cases. However, to fully integrate with idiomatic CodeQL
240-
queries—especially for large-scale or reusable analysis—you will want to
241-
extend the language’s internal dataflow configuration using
242-
=Customizations.qll=.
238+
The manual YAML modeling approach described earlier works well for isolated or
239+
prototype cases. However, for idiomatic, large-scale, or reusable CodeQL
240+
analysis, it is often preferable to define custom dataflow logic directly in
241+
QL—using =Customizations.qll=.
243242

244-
Most CodeQL-supported languages (e.g., Java, Python) include out-of-the-box
245-
support for =Customizations.qll=. In these cases, the primary language module
246-
(e.g., [[./ql/java/ql/lib/java.qll][java.qll]]) automatically imports [[./ql/java/ql/lib/Customizations.qll][Customizations.qll]], which defines
247-
extension points for user-defined sources, sinks, and flow steps.
243+
Most CodeQL-supported languages (e.g., Java, Python) include built-in support
244+
for this mechanism. For example, Java’s primary entry point [[./ql/java/ql/lib/java.qll][java.qll]]
245+
automatically imports [[./ql/java/ql/lib/Customizations.qll][Customizations.qll]], exposing extension points for
246+
user-defined sources, sinks, and flow steps.
248247

249-
Unfortunately, C and C++ do not include this mechanism by default. Enabling it
250-
requires modifying the language pack and rebuilding the CodeQL bundle.
248+
In contrast, C and C++ do *not* support this out of the box. To enable it, you
249+
must manually patch the language pack and (optionally) rebuild the CodeQL
250+
bundle.
251251

252-
This section is *partially complete*: we illustrate the required QL changes,
253-
but do *not yet include* the full bundling process.
252+
This section is *partially complete*: we document the required source-level QL
253+
changes, but the bundling process is still pending.
254254

255-
To add Customizations support for C/C++, make the following changes:
255+
To enable =Customizations.qll= support for C/C++, perform the following:
256256

257257
1. Modify =ql/cpp/ql/lib/cpp.qll= to import your =Customizations.qll= module.
258-
2. Create and populate =ql/cpp/ql/lib/Customizations.qll= with definitions for
259-
new sources, sinks, or flow steps.
260-
3. For full deployment: Rebuild the CodeQL bundle to reflect these changes.
261-
262-
The rebuilt bundle can then be used in VS Code or the CLI, enabling you to
263-
model C/C++ flows in a way that mirrors Java and other languages. Once this
264-
bundling step is automated, custom C/C++ modeling will follow the same
265-
developer workflow as any other language.
266-
267-
4. For workshops: The modifications have immediate effect
268-
258+
2. Create and populate =ql/cpp/ql/lib/Customizations.qll= with new
259+
source/sink/flow logic.
260+
3. *For full deployment:* Rebuild the CodeQL bundle to include the updated
261+
QL files.
262+
- This allows portable use in CLI runs and IDE workflows.
263+
- Once bundled, C/C++ customization behaves like any other supported
264+
language.
265+
4. *For workshops and local development:* No bundling is needed.
266+
- If you run queries directly from the modified source tree, the changes
267+
take effect immediately.
268+
269+
A working demonstration of this modification (without bundling) is provided
270+
in:
271+
[[./codeql-dataflow-sql-injection-c/README.org]]
272+
269273
** TODO CodeQL Bundling
270274
This section will provide a detailed walkthrough of the CodeQL bundling process
271275
using the CLI tool at https://github.com/advanced-security/codeql-bundle. This

0 commit comments

Comments
 (0)