Repository navigation
Replies: 4 comments 1 reply
|
This can't be easily done, and you'll need to either have a modified copy of the queries/libraries around, which is be slow because it most likely requires a lot of query recompilation, or create your own bundle. Some inspiration for the latter can be found here: https://github.com/advanced-security/codeql-bundle. You might also want to check whether the customizations discussed there could be of use to you. Note that we don't offer support on any of this. If you need support then you will need to contact our expert services team: https://github.com/services. |
|
Thanks. We do build own custom bundle. I was wondering if we could add something to Customizations.qll to achieve the goal above. We would like to avoid recompiling everything, though. |
|
this technique used here could be applied to other sanitizer types, if those are deemed valuable to do so for |
|
Short answer: QL has no way to override or remove a class from a library you import. Customizations.qll and data extensions are additive only (they add sources, sinks, sanitizers), so they can't subtract an existing sanitizer. What you can do is avoid the problem at the query level, which keeps recompilation small. Option 1: own copy of the query configuration, filtering the barrier Instead of reusing the library's shared configuration as is, define your own configuration module in a query in your own pack. Reuse the library's sources and sinks, and in the barrier predicate keep the library's sanitizers except the ones you want to drop. Roughly: The exact module and class names depend on the language and the query, so check how that query's library defines its configuration. This only works if the sanitizer you want to drop is a named class or can be identified by a predicate. If it is hard-coded inside isBarrier/isSanitizer with no class to exclude, you can't filter it out this way. Option 2: why this keeps recompilation small If only your query file changes and the library code in your bundle stays the same, the library compilation cache can be reused, so only your query is recompiled. Editing the standard library files themselves invalidates much more, which is the slow path you want to avoid. Option 3: if it really has to change in the library Make a small, targeted change to the library (for example, add an extra overridable predicate or guard for that sanitizer), build it into your custom bundle once, and keep the rest of the library untouched. That could also be a good candidate to propose upstream as a customization point. Note that this is generally not an officially supported customization, as mentioned above, so behavior can change between CodeQL versions. It's worth pinning the bundle version and re-checking after upgrades. If you tell us the language and which query/sanitizer you want to drop, we can be more specific. |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
Are there any options to replace/override a class definition within the CodeQL standard library? We would like to change/remove some sanitizer definitions.
Thanks!
All reactions