Skip to content

Commit 9b43b49

Browse files
egregius313owen-mc
andauthored
fixed-version: example
Co-authored-by: Owen Mansel-Chan <[email protected]>
1 parent 7e98d02 commit 9b43b49

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/codeql/codeql-language-guides/customizing-library-models-for-go.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,24 @@ The remaining values are used to define the ``access path``, the ``kind``, and t
288288
- The eighth value ``remote`` is the source kind. This indicates that the source is a remote source of untrusted data.
289289
- The ninth value ``manual`` is the provenance of the source, which is used to identify the origin of the source.
290290

291+
Package versions
292+
~~~~~~~~~~~~~~~~
293+
294+
When the major version number is greater than 1 it is included in the package import path. It usually looks like ``/v2`` after the module import path. This is called the major version suffix. We normally want our models to apply to all versions of a package. Rather than having to repeat models with the package column changed to include all available versions, we can just use the package name without the major version suffix and this will be matched to any version. So models with ``github.com/couchbase/gocb`` in the package column will match packages imported from ``github.com/couchbase/gocb`` and ``github.com/couchbase/gocb/v2`` (or any other version).
295+
296+
Note that packages hosted at ``gopkg.in`` use a slightly different syntax: the major version suffix looks like ``.v2``, and it is present even for version 1. This is also supported. So models with ``gopkg.in/yaml`` in the package column will match packages imported from ``gopkg.in/yaml.v1``, ``gopkg.in/yaml.v2`` and ``gopkg.in/yaml.v3``.
297+
298+
To write models that only apply to ``github.com/couchbase/gocb/v2``, it is sufficient to include the major version suffix (``/v2``) in the package column. To write models that only apply to ``github.com/couchbase/gocb``, you may prefix the package column with ``fixed-version:``. For example, here are two models for a method that has changed name from v1 to v2.
299+
300+
.. code-block:: yaml
301+
extensions:
302+
- addsTo:
303+
pack: codeql/go-all
304+
extensible: sinkModel
305+
data:
306+
- ["fixed-version:github.com/couchbase/gocb", "Cluster", True, "ExecuteAnalyticsQuery", "", "", "Argument[0]", "nosql-injection", "manual"]
307+
- ["github.com/couchbase/gocb/v2", "Cluster", True, "AnalyticsQuery", "", "", "Argument[0]", "nosql-injection", "manual"]
308+
291309
Package grouping
292310
~~~~~~~~~~~~~~~~
293311

0 commit comments

Comments
 (0)