This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -7,7 +7,29 @@ Customizing library models for GitHub Actions
GitHub Actions analysis can be customized by adding library models in data extension files.
A data extension for GitHub Actions is a YAML file of the form:
A data extension for GitHub Actions can be written using either JSON or YAML. The JSON format takes the following form:
.. code-block:: json
{
"extensions": [
{
"addsTo": {
"pack": "codeql/actions-all",
"extensible": "<name of extensible predicate>"
},
"data": [
["tuple", 1],
["tuple", 2]
// ...
]
}
]
}
Files in the JSON format must use the ``.json`` file extension. Single-line (``//``) and multi-line (``/* ... */``) comments are supported as a non-standard JSON extension.
A YAML file has the following form:
.. code-block:: yaml
Expand All
@@ -16,8 +38,8 @@ A data extension for GitHub Actions is a YAML file of the form:
pack: codeql/actions-all
extensible: <name of extensible predicate>
data:
- <tuple1>
- <tuple2>
- ["tuple", 1]
- ["tuple", 2]
- ...
The CodeQL library for GitHub Actions exposes the following extensible predicates:
Expand Down
Expand Up
@@ -57,16 +79,23 @@ If there is an Action publisher that you trust, you can include the owner name/o
To allow any Action from the publisher ``octodemo``, such as ``octodemo/3rd-party-action``, follow these steps:
1. Create a data extension file ``/models/trusted-owner.model.yml`` with the following content:
1. Create a data extension file ``/models/trusted-owner.model.json`` with the following content:
.. code-block:: yaml
.. code-block:: json
extensions:
- addsTo:
pack: codeql/actions-all
extensible: trustedActionsOwnerDataModel
data:
- ["octodemo"]
{
"extensions": [
{
"addsTo": {
"pack": "codeql/actions-all",
"extensible": "trustedActionsOwnerDataModel"
},
"data": [
["octodemo"]
]
}
]
}
2. Create a model pack file ``/codeql-pack.yml`` with the following content:
Expand All
@@ -78,7 +107,7 @@ To allow any Action from the publisher ``octodemo``, such as ``octodemo/3rd-part
extensionTargets:
codeql/actions-all: '*'
dataExtensions:
- models/**/*.yml
- models/**/*.json
3. Ensure that the model pack is included in your CodeQL analysis.
Expand All
@@ -91,14 +120,21 @@ GitHub's own organizations (``actions``, ``github`` and ``advanced-security``) a
To distrust the first-party ``github`` owner, add a data extension file with the following content:
.. code-block:: yaml
extensions:
- addsTo:
pack: codeql/actions-all
extensible: trustedActionsOwnerDataModel
data:
- ["!github"]
.. code-block:: json
{
"extensions": [
{
"addsTo": {
"pack": "codeql/actions-all",
"extensible": "trustedActionsOwnerDataModel"
},
"data": [
["!github"]
]
}
]
}
With this in place, the query will once again report unpinned tags for Actions published by ``github``.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Each model of an element is defined using a data extension where each tuple constitutes a model.
A data extension file to extend the standard CPP queries included with CodeQL is a YAML file with the form:
A data extension file to extend the standard CPP queries included with CodeQL can be written using either JSON or YAML. The JSON format takes the following form:
.. code-block:: json
{
"extensions": [
{
"addsTo": {
"pack": "codeql/cpp-all",
"extensible": "<name of extensible predicate>"
},
"data": [
["tuple", 1],
["tuple", 2]
// ...
]
}
]
}
Files in the JSON format must use the ``.json`` file extension. Single-line (``//``) and multi-line (``/* ... */``) comments are supported as a non-standard JSON extension.
A YAML file has the following form:
.. code-block:: yaml
Expand All
@@ -34,11 +56,11 @@ A data extension file to extend the standard CPP queries included with CodeQL is
pack: codeql/cpp-all
extensible: <name of extensible predicate>
data:
- <tuple1>
- <tuple2>
- ["tuple", 1]
- ["tuple", 2]
- ...
Each YAML file may contain one or more top-level extensions.
Each data extension file may contain one or more top-level extensions.
- ``addsTo`` defines the CodeQL pack name and extensible predicate that the extension is injected into.
- ``data`` defines one or more rows of tuples that are injected as values into the extensible predicate. The number of columns and their types must match the definition of the extensible predicate.
Expand Down
Expand Up
@@ -79,20 +101,27 @@ This example shows how the CPP query pack models the return value from the ``rea
We need to add a tuple to the ``sourceModel(namespace, type, subtypes, name, signature, ext, output, kind, provenance)`` extensible predicate by updating a data extension file.
The first five values identify the callable (in this case a free function) to be modeled as a source.
- The first value ``"boost::asio"`` is the namespace name.
- The second value ``""`` is the name of the type (class) that contains the method. Because we're modeling a free function, the type is left blank.
- The third value ``False`` is a flag that indicates whether or not the model also applies to all overrides of the method. For a free function, this should be ``False``.
- The third value ``false`` is a flag that indicates whether or not the model also applies to all overrides of the method. For a free function, this should be ``false``.
- The fourth value ``"read_until"`` is the function name.
- The fifth value is the function input type signature, which can be used to narrow down between functions that have the same name. In this case, we want the model to include all functions in ``boost::asio`` called ``read_until``.
Expand All
@@ -114,20 +143,27 @@ This example shows how the CPP query pack models the second argument of the ``bo
We need to add a tuple to the ``sinkModel(namespace, type, subtypes, name, signature, ext, input, kind, provenance)`` extensible predicate by updating a data extension file.
The first five values identify the callable (in this case a free function) to be modeled as a sink.
- The first value ``"boost::asio"`` is the namespace name.
- The second value ``""`` is the name of the type (class) that contains the method. Because we're modeling a free function, the type is left blank.
- The third value ``False`` is a flag that indicates whether or not the model also applies to all overrides of the method. For a free function, this should be ``False``.
- The third value ``false`` is a flag that indicates whether or not the model also applies to all overrides of the method. For a free function, this should be ``false``.
- The fourth value ``"write"`` is the function name.
- The fifth value is the function input type signature, which can be used to narrow down between functions that have the same name. In this case, we want the model to include all functions in ``boost::asio`` called ``write``.
Expand All
@@ -149,20 +185,27 @@ This example shows how the CPP query pack models flow through a function for a s
We need to add tuples to the ``summaryModel(namespace, type, subtypes, name, signature, ext, input, output, kind, provenance)`` extensible predicate by updating a data extension file:
The first five values identify the callable (in this case free function) to be modeled as a summary.
- The first value ``"boost::asio"`` is the namespace name.
- The second value ``""`` is the name of the type (class) that contains the method. Because we're modeling a free function, the type is left blank.
- The third value ``False`` is a flag that indicates whether or not the model also applies to all overrides of the method. For a free function, this should be ``False``.
- The third value ``false`` is a flag that indicates whether or not the model also applies to all overrides of the method. For a free function, this should be ``false``.
- The fourth value ``"buffer"`` is the function name.
- The fifth value is the function input type signature, which can be used to narrow down between functions that have the same name. In this case, we want the model to include all functions in ``boost::asio`` called ``buffer``.
Expand Down
Expand Up
@@ -190,20 +233,27 @@ This function escapes special characters in a string for use in an SQL statement
We need to add a tuple to the ``barrierModel(namespace, type, subtypes, name, signature, ext, output, kind, provenance)`` extensible predicate by updating a data extension file.
The first five values identify the callable (in this case a free function) to be modeled as a barrier.
- The first value ``""`` is the namespace name.
- The second value ``""`` is the name of the type (class) that contains the method. Because we're modeling a free function, the type is left blank.
- The third value ``False`` is a flag that indicates whether or not the model also applies to all overrides of the method. For a free function, this should be ``False``.
- The third value ``false`` is a flag that indicates whether or not the model also applies to all overrides of the method. For a free function, this should be ``false``.
- The fourth value ``"mysql_real_escape_string"`` is the function name.
- The fifth value is the function input type signature, which can be used to narrow down between functions that have the same name.
Expand All
@@ -229,20 +279,27 @@ Consider a function called ``is_safe`` which returns ``true`` when the data is c
We need to add a tuple to the ``barrierGuardModel(namespace, type, subtypes, name, signature, ext, input, acceptingValue, kind, provenance)`` extensible predicate by updating a data extension file.
The first five values identify the callable (in this case a free function) to be modeled as a barrier guard.
- The first value ``""`` is the namespace name.
- The second value ``""`` is the name of the type (class) that contains the method. Because we're modeling a free function, the type is left blank.
- The third value ``False`` is a flag that indicates whether or not the model guard also applies to all overrides of the method. For a free function, this should be ``False``.
- The third value ``false`` is a flag that indicates whether or not the model guard also applies to all overrides of the method. For a free function, this should be ``false``.
- The fourth value ``"is_safe"`` is the function name.
- The fifth value is the function input type signature, which can be used to narrow down between functions that have the same name.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Docs: update "Customizing library models for <lang>" to cover JSON data extensions #22753
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Are you sure you want to change the base?
Docs: update "Customizing library models for <lang>" to cover JSON data extensions #22753
Filter by extension
Viewed files
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.