You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/codeql/codeql-cli/extractor-options.rst
+26-22Lines changed: 26 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,36 +39,36 @@ Each extractor defines its own set of configuration options. To find out which o
39
39
40
40
The extractor option names and descriptions are listed under ``extractor_options``. Each option may contain the following fields::
41
41
42
-
* ``title`` (required): The title of the option
43
-
* ``description`` (required): The description of the option
44
-
* ``type`` (required): The type of the option, which can be
42
+
* ``title`` (required): The title of the option
43
+
* ``description`` (required): The description of the option
44
+
* ``type`` (required): The type of the option, which can be
45
45
46
-
* ``string``: indicating that the option can have a single string value
47
-
* ``array``: indicating that the option can have a sequence of string values
48
-
* ``object``: indicating that it is not an option itself, but a grouping that may contain other options and option groups
46
+
* ``string``: indicating that the option can have a single string value
47
+
* ``array``: indicating that the option can have a sequence of string values
48
+
* ``object``: indicating that it is not an option itself, but a grouping that may contain other options and option groups
49
49
50
-
* ``pattern`` (optional): The regular expression patterns that all values of the option should match. Note that the extractor may impose additional constraints on option values that are not or cannot be expressed in this regular expression pattern. Such constraints, if they exist, would be explained under the description field.
51
-
* ``properties`` (optional): A map from extractor option names in the option group to the corresponding extractor option descriptions. This field can only be present for option groups. For example, options of ``object`` type.
50
+
* ``pattern`` (optional): The regular expression patterns that all values of the option should match. Note that the extractor may impose additional constraints on option values that are not or cannot be expressed in this regular expression pattern. Such constraints, if they exist, would be explained under the description field.
51
+
* ``properties`` (optional): A map from extractor option names in the option group to the corresponding extractor option descriptions. This field can only be present for option groups. For example, options of ``object`` type.
52
52
53
53
In the example above, the extractor declares two options::
54
54
55
-
* ``option1`` is a ``string`` option with value matching ``[a-z]+``
56
-
* ``group1.option2`` is an ``array`` option with values matching ``[1-9][0-9]*``
55
+
* ``option1`` is a ``string`` option with value matching ``[a-z]+``
56
+
* ``group1.option2`` is an ``array`` option with values matching ``[1-9][0-9]*``
57
57
58
58
Setting extractor options with the CodeQL CLI
59
59
---------------------------------------------
60
60
61
61
The CodeQL CLI supports setting extractor options in subcommands that directly or indirectly invoke extractors. These commands are::
62
62
63
-
* ``codeql database create``
64
-
* ``codeql database start-tracing``
65
-
* ``codeql database trace-command``
66
-
* ``codeql database index-files``
63
+
* ``codeql database create``
64
+
* ``codeql database start-tracing``
65
+
* ``codeql database trace-command``
66
+
* ``codeql database index-files``
67
67
68
68
When running these subcommands, you can set extractor options with the ``--extractor-option`` CLI option. For example::
``--extractor-option`` requires exactly one argument of the form ``extractor_option_name=extractor_option_value``. ``extractor_option_name`` is the name of the extractor (in this example, ``java``) followed by a period and then the name of the extractor option (in this example, either ``option1`` or ``group1.option2``). ``extractor_option_value`` is the value being assigned to the extractor option. The value must match the regular expression pattern of the extractor option (if it exists), and it must not contain newline characters.
74
74
@@ -78,8 +78,8 @@ The CodeQL CLI accepts multiple ``--extractor-option`` options in the same invoc
78
78
79
79
You can also specify extractor option names without the extractor name. For example::
If you do not specify an extractor name, the extractor option settings will apply to all extractors that declare an option with the given name. In the above example, the first command would set the extractor option ``option1`` to ``abc`` for the ``java`` extractor and every extractor that has an option of ``option1``, for example the ``cpp`` extractor, if the ``option1`` extractor option exists for that extractor.
85
85
@@ -88,8 +88,8 @@ Setting extractor options from files
88
88
89
89
You can also set extractor options through a file. The CodeQL CLI subcommands that accept ``--extractor-option`` also accept ``--extractor-options-file``, which has a required argument of the path to a YAML file (with extension ``.yaml`` or ``.yml``) or a JSON file (with extension ``.json``). For example::
Each option file contains a tree structure of nested maps. At the root is an extractor map key, and beneath it are map keys that correspond to extractor names. Starting at the third level, there are extractor options and option groups.
95
95
@@ -116,9 +116,13 @@ In YAML::
116
116
option2: [ 102 ]
117
117
118
118
The value for a ``string`` extractor option must be a string or a number (which will be converted to a string before further processing).
119
+
119
120
The value for an ``array`` extractor option must be an array of strings or numbers.
121
+
120
122
The value for an option group (of type ``object``) must be a map, which may contain nested extractor options and option groups.
123
+
121
124
Each extractor option value must match the regular expression pattern of the extractor option (if it exists), and it must not contain newline characters.
125
+
122
126
Assigning an extractor option that does not exist is an error. You can make the CodeQL CLI ignore unknown extractor options by using a special ``__allow_unknown_properties`` Boolean field. For example, the following option file asks the CodeQL CLI to ignore all unknown extractor options and option groups under ``group1``::
123
127
124
128
extractor:
@@ -130,7 +134,7 @@ Assigning an extractor option that does not exist is an error. You can make the
130
134
131
135
You can specify ``--extractor-options-file`` multiple times. The extractor option assignments are processed in the following order::
132
136
133
-
# All extractor option files specified by ``--extractor-options-file`` are processed in the order they appear on the command line, then
134
-
# All extractor option assignments specified by ``--extractor-option`` are processed in the order they appear on the command line
137
+
# All extractor option files specified by ``--extractor-options-file`` are processed in the order they appear on the command line, then
138
+
# All extractor option assignments specified by ``--extractor-option`` are processed in the order they appear on the command line
135
139
136
140
The same rules govern what happens when the same extractor option is set multiple times, regardless of whether the assignments are done using ``--extractor-option``, using ``--extractor-options-file``, or some combination of the two. If you set a ``string`` extractor option multiple times, the last option value overwrites all previous values. If you set an ``array`` extractor option multiple times, all option values are concatenated in order.
0 commit comments