Skip to content

Commit 6e724bd

Browse files
author
Prabha Kylasamiyer Sundara Rajan
committed
Modified builtin xml fields and rulesets
Signed-off-by: Prabha Kylasamiyer Sundara Rajan <[email protected]>
1 parent 861bf3e commit 6e724bd

File tree

3 files changed

+40
-13
lines changed

3 files changed

+40
-13
lines changed

assemblies/rules-development-guide/assembly_rule-rulesets.adoc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ Note that if you want to use the `--target` or `--source` option in the CLI, the
2323

2424
include::topics/rules-development/yaml-rulesets.adoc[leveloffset=+1]
2525

26-
include::topics/rules-development/create-basic-yaml-ruleset-template.adoc[leveloffset=+1]
27-
28-
include::topics/rules-development/running-analysis-using-custom-yaml-rule.adoc[leveloffset=+1]
29-
3026
ifdef::parent-context-of-rule-rulesets[:context: {parent-context-of-rule-rulesets}]
3127
ifndef::parent-context-of-rule-rulesets[:!context:]
3228

docs/topics/rules-development/yaml-provider-conditions.adoc

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The analyzer currently supports the following `provider` conditions:
2929
* `python`
3030
* `dotnet`
3131
32-
:FeatureName:Dotnet provider:
32+
:FeatureName: Dotnet provider
3333
include::developer-preview-admonition.adoc[]
3434

3535

@@ -265,15 +265,44 @@ when:
265265
.3+|xml
266266
|xpath
267267
|Yes
268-
|Xpath query
268+
a|Xpath query
269+
[source, yaml]
270+
----
271+
when:
272+
builtin.xml:
273+
xpath: "//dependencies/dependency"
274+
----
269275

270276
|namespaces
271277
|No
272-
|A map to scope down query to namespaces.
278+
a|A map to scope down query to namespaces.
279+
[source, yaml]
280+
----
281+
when:
282+
builtin.xml:
283+
filepaths:
284+
- beans.xml
285+
namespaces:
286+
b: http://xmlns.jcp.org/xml/ns/javaee
287+
xpath: /b:beans
288+
----
273289

274290
|filepaths
275291
|No
276-
|Optional list of files to scope down search.
292+
a|Optional list of files to scope down search.
293+
[source, yaml]
294+
----
295+
when:
296+
or:
297+
- builtin.xml:
298+
xpath: "//dependencies/dependency"
299+
filepaths: "{{poms.filepaths}}"
300+
from: poms
301+
- builtin.file:
302+
pattern: pom.xml
303+
as: poms
304+
ignore: true
305+
----
277306

278307
.2+|json
279308
|xpath

docs/topics/rules-development/yaml-rulesets.adoc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
:_mod-docs-content-type: REFERENCE
66
[id="yaml-rulesets_{context}"]
7-
= Creating and using a ruleset
7+
= Creating and using a custom ruleset
88

99
[role="_abstract"]
10-
You can create a ruleset by placing one or more YAML rules in a directory and creating a `ruleset.yaml` file at the directory root. When you pass this directory as input to the {ProductShortName} {CLIName} by using the `--rules` option, all rules in this directory are treated as a part of the ruleset defined by the `ruleset.yaml` file.
10+
You can create a ruleset by placing one or more custom rules in a directory and creating a `ruleset.yaml` file at the directory root. When you perform an analysis, you pass this directory as input to the {ProductShortName} {CLIName} by using the `--rules` option. All rules in this directory are treated as a part of the ruleset defined by the `ruleset.yaml` file.
1111

12-
The `ruleset.yaml` file stores the metadata of the ruleset.
12+
The `ruleset.yaml` file stores the metadata of the ruleset. You can group multiple similar custom rules and create a ruleset for them. When you pass this directory as input to the {ProductShortName} {CLIName} using the `--rules` option, {ProductShortName} treats all the files in the directory as belonging to the ruleset defined in the `ruleset.yaml` file.
1313

1414
[source,yaml]
1515
----
@@ -32,6 +32,8 @@ $ mta-cli analyze --input=<application_to_analyze> --output=<output_dir> --rules
3232

3333
* Replace `<application_to_analyze>` with the name of your application.
3434
* Replace `<output_dir>` with the directory of your choice.
35-
* Replace `<custom_rule_dir>` with the custom rulesets file.
35+
* Replace `<custom_rule_dir>` with the custom rule file.
36+
* To use multiple rule files, you need to place them in a directory and to add a `ruleset.yaml` file. Then the directory is treated as a _ruleset_, and you can pass it as input to the `--rules` option.
37+
+
3638

37-
On initiation, the mta-cli tool determines the type of application and the provider needed for analysis. It then starts the provider in a container that has the required dependencies and tools. Finally, the provider uses the analyzer to execute a series of rulesets to analyze the source code.
39+
Note that if you want to use the `--target` or `--source` option in the CLI, the engine will only select rules that match the label for that target. Therefore, make sure that you have added target or source labels on your rules. See xref:reserved-label_rule-yaml-metadata[Reserved labels] for more details.

0 commit comments

Comments
 (0)