Skip to content

Python: convert data extensions to JSON - #23076

Open
nickrolfe wants to merge 3 commits into
mainfrom
nickrolfe/json-data-extensions-python
Open

nickrolfe wants to merge 3 commits into
mainfrom
nickrolfe/json-data-extensions-python

Conversation

@nickrolfe

Copy link
Copy Markdown
Contributor

CodeQL CLI 2.27.3 supports JSON data extensions (aka MaD models), and can load them significantly faster than YAML. This PR converts those in Python's library pack (first commit), along with $TEST.ext.yml files (second commit). The conversions were automated by an LLM-generated Python script (which I will add in a separate PR).

Although JSON is preferred going forward, python/ql/lib/qlpack.yml now has patterns that will pick up both .model.yml and .model.json files, so that any YAML files that do get checked in won't get silently dropped.

To verify successful conversion in the first commit, I cherry-picked it onto #23075, which has a temporary test that enumerates all tuples from data extensions. The test still passes after conversion.

For the second commit, I manually inspected the diffs.

@nickrolfe
nickrolfe force-pushed the nickrolfe/json-data-extensions-python branch from 6d8f897 to 497b803 Compare November 10, 2026 13:58
@nickrolfe
nickrolfe marked this pull request as ready for review November 10, 2026 14:37
@nickrolfe
nickrolfe requested review from a team as code owners November 10, 2026 14:38
Copilot AI auto review requested due to automatic review settings November 10, 2026 14:38
@nickrolfe nickrolfe added the no-change-note-required This PR does not need a change note label Nov 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The conversion still has an active generator-output mismatch and lacks DCA validation of downstream alert effects, so correctness and impact remain unresolved.

2 open issues
What changed in this PR

This pull request migrates Python CodeQL library and test data extensions from YAML to JSON, preserving the existing model data while enabling faster loading with CodeQL CLI 2.27.3.

Changes:

  • Converts Python framework, threat-model, and test extensions to JSON.
  • Updates pack discovery patterns to support both JSON and YAML extensions.
  • Updates identical-file metadata for the converted test extensions.
File Description
python/​ql/​test/​query-tests/​Security/​CWE-089-SqlInjection-local-threat-model/​SqlInjection.ext.yml Removes the YAML SQL injection threat-model test extension.
python/​ql/​test/​query-tests/​Security/​CWE-089-SqlInjection-local-threat-model/​SqlInjection.ext.json Adds the equivalent JSON SQL injection threat-model test extension.
python/​ql/​test/​modelling/​FrameworkModeEndpoints.ext.yml Removes the YAML framework endpoint modelling extension.
python/​ql/​test/​modelling/​FrameworkModeEndpoints.ext.json Adds the equivalent JSON framework endpoint modelling extension.
python/​ql/​test/​library-tests/​frameworks/​data/​warnings.ext.yml Removes the YAML framework warning-model test extension.
python/​ql/​test/​library-tests/​frameworks/​data/​warnings.ext.json Adds the equivalent JSON framework warning-model test extension.
python/​ql/​test/​library-tests/​frameworks/​data/​test.ext.yml Removes the YAML framework data test extension.
python/​ql/​test/​library-tests/​frameworks/​data/​test.ext.json Adds the equivalent JSON framework data test extension.
python/​ql/​test/​library-tests/​dataflow/​model-summaries/​NormalDataflowTest.ext.yml Removes the YAML normal dataflow model-summary extension.
python/​ql/​test/​library-tests/​dataflow/​model-summaries/​NormalDataflowTest.ext.json Adds the equivalent JSON normal dataflow model-summary extension.
python/​ql/​test/​library-tests/​dataflow/​model-summaries/​InlineTaintTest.ext.yml Removes the YAML inline-taint model-summary extension.
python/​ql/​test/​library-tests/​dataflow/​model-summaries/​InlineTaintTest.ext.json Adds the equivalent JSON inline-taint model-summary extension.
python/​ql/​lib/​semmle/​python/​frameworks/​xml.model.yml Removes the YAML XML framework model.
python/​ql/​lib/​semmle/​python/​frameworks/​xml.model.json Adds the JSON XML framework model.
python/​ql/​lib/​semmle/​python/​frameworks/​Stdlib.model.yml Removes the YAML standard-library models.
python/​ql/​lib/​semmle/​python/​frameworks/​Stdlib.model.json Adds the JSON standard-library models.
python/​ql/​lib/​semmle/​python/​frameworks/​openai.model.yml Removes the YAML OpenAI models.
python/​ql/​lib/​semmle/​python/​frameworks/​openai.model.json Adds the JSON OpenAI models.
python/​ql/​lib/​semmle/​python/​frameworks/​lxml.model.yml Removes the YAML lxml model.
python/​ql/​lib/​semmle/​python/​frameworks/​lxml.model.json Adds the JSON lxml model.
python/​ql/​lib/​semmle/​python/​frameworks/​Gevent.model.yml Removes the YAML Gevent model.
python/​ql/​lib/​semmle/​python/​frameworks/​Gevent.model.json Adds the JSON Gevent model.
python/​ql/​lib/​semmle/​python/​frameworks/​Eventlet.model.yml Removes the YAML Eventlet model.
python/​ql/​lib/​semmle/​python/​frameworks/​Eventlet.model.json Adds the JSON Eventlet model.
python/​ql/​lib/​semmle/​python/​frameworks/​Django.model.yml Removes the YAML Django model.
python/​ql/​lib/​semmle/​python/​frameworks/​Django.model.json Adds the JSON Django model.
python/​ql/​lib/​semmle/​python/​frameworks/​data/​internal/​empty.model.yml Removes the YAML empty internal model definitions.
python/​ql/​lib/​semmle/​python/​frameworks/​data/​internal/​empty.model.json Adds the JSON empty internal model definitions.
python/​ql/​lib/​semmle/​python/​frameworks/​builtins.model.yml Removes the generated YAML built-in exception model.
python/​ql/​lib/​semmle/​python/​frameworks/​builtins.model.json Adds the generated JSON built-in exception model.
python/​ql/​lib/​semmle/​python/​frameworks/​Azure.Storage.model.yml Removes the YAML Azure Storage models.
python/​ql/​lib/​semmle/​python/​frameworks/​Azure.Storage.model.json Adds the JSON Azure Storage models.
python/​ql/​lib/​semmle/​python/​frameworks/​Azure.Keyvault.model.yml Removes the YAML Azure Key Vault models.
python/​ql/​lib/​semmle/​python/​frameworks/​Azure.Keyvault.model.json Adds the JSON Azure Key Vault models.
python/​ql/​lib/​semmle/​python/​frameworks/​Asyncpg.model.yml Removes the YAML Asyncpg models.
python/​ql/​lib/​semmle/​python/​frameworks/​Asyncpg.model.json Adds the JSON Asyncpg models.
python/​ql/​lib/​semmle/​python/​frameworks/​AntiSSRF.model.yml Removes the YAML AntiSSRF model.
python/​ql/​lib/​semmle/​python/​frameworks/​AntiSSRF.model.json Adds the JSON AntiSSRF model.
python/​ql/​lib/​semmle/​python/​frameworks/​anthropic.model.yml Removes the YAML Anthropic models.
python/​ql/​lib/​semmle/​python/​frameworks/​anthropic.model.json Adds the JSON Anthropic models.
python/​ql/​lib/​semmle/​python/​frameworks/​agent.model.yml Removes the YAML agent model.
python/​ql/​lib/​semmle/​python/​frameworks/​agent.model.json Adds the JSON agent model.
python/​ql/​lib/​qlpack.yml Adds JSON data-extension discovery patterns while retaining YAML compatibility.
python/​ql/​lib/​ext/​default-threat-models-fixup.model.yml Removes the YAML default threat-model fixup.
python/​ql/​lib/​ext/​default-threat-models-fixup.model.json Adds the JSON default threat-model fixup.
config/​identical-files.json Updates identical-file metadata to reference the converted JSON test extensions.

Review effort: Lite (auto)

Comment thread python/ql/lib/qlpack.yml
Comment on lines +21 to +22
- semmle/python/frameworks/**/*.model.json
- ext/*.model.json
@@ -0,0 +1,257 @@
// process-builtin-exceptions 0.0.1; Python 3.11.0rc2

@owen-mc owen-mc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot brought up a good point about python/ql/src/meta/ClassHierarchy/process-builtin-exceptions.py (I think).

@nickrolfe

nickrolfe commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

I've pushed a commit to update process-builtin-exceptions.py. I've tested it manually, along with the split-model-files.py and join-model-files.py scripts, and they all seem to be working.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-change-note-required This PR does not need a change note Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants