forked from konveyor/analyzer-lsp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrule-example.yaml
More file actions
210 lines (209 loc) · 5.49 KB
/
rule-example.yaml
File metadata and controls
210 lines (209 loc) · 5.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
- message: all go files
ruleID: file-001
description: "Testing that we can get all the go files in the project"
links:
- title: "Golang"
url: "https://go.dev"
labels:
- "testing"
- "test"
category: potential
effort: 3
when:
builtin.file:
pattern: "*.go"
- message: not any go files
ruleID: file-002
effort: 1
when:
builtin.file:
pattern: "*.go"
not: true
- message: POM XML dependencies - '{{{matchingXML}}}'
ruleID: xml-pom-001
effort: 1
when:
builtin.xml:
xpath: "//dependencies/dependency"
- message: '{{{matchingXML}}}'
ruleID: chain-pom-001
effort: 1
when:
or:
- builtin.xml:
xpath: "//dependencies/dependency"
filepaths: "{{poms.filepaths}}"
from: poms
- builtin.file:
pattern: pom.xml
as: poms
ignore: true
- message: apiextensions/v1beta1/customresourcedefinitions is deprecated, apiextensions/v1/customresourcedefinitions should be used instead
ruleID: lang-ref-001
effort: 1
when:
or:
- java.referenced:
pattern: "*apiextensions.v1beta1.CustomResourceDefinition*"
location: TYPE
- go.referenced:
pattern: "v1beta1.CustomResourceDefinition"
- message: testing nested conditions
ruleID: lang-ref-002
effort: 1
when:
# This is purposfully failing, the golang reference will not
# find anything. testing that `and` will work correctly
and:
- go.referenced:
pattern: "*CustomResourceDefinition*"
- java.referenced:
pattern: "*CustomResourceDefinition*"
location: TYPE
- tag:
- License={{matchingText}}
ruleID: tag-license
when:
builtin.filecontent:
pattern: "Apache"
- tag:
- Language=Golang
ruleID: tag-go-000
when:
builtin.file:
pattern: "go.mod"
- tag:
- Infra=Kubernetes
ruleID: tag-k8s-000
when:
builtin.filecontent:
pattern: ".*k8s.io/.*"
filePattern: ".*go.mod"
- tag:
- Java
ruleID: tag-java-000
when:
or:
- builtin.file:
pattern: "pom.xml"
- builtin.file:
pattern: "*.ear"
- builtin.file:
pattern: "*.jar"
- builtin.file:
pattern: "*.war"
- message: "Tags {{tags}} found"
ruleID: tech-tag-001
when:
or:
- builtin.hasTags:
- Golang
- Kubernetes
- builtin.hasTags:
- Java
- message: "error test"
ruleID: error-rule-001
effort: 1
when:
builtin.xml:
xpath:
invalid-query: "test"
- message: "JBoss 5.x EAR descriptor (jboss-app.xml) was found with public-id"
ruleID: jboss-eap5-7-xml-02000
effort: 1
when:
builtin.xmlPublicID:
regex: .*JBoss.+DTD Java EE.+5.*
- message: "Tags {{tags}} found, creating message and new tag both"
ruleID: multiple-actions-001
tag:
- Backend=Golang
when:
builtin.hasTags:
- Golang
- message: "Found usage of openjdk base image"
ruleID: filecontent-codesnip-test
effort: 1
when:
builtin.filecontent:
pattern: "^FROM.*openjdk-11.*"
filePattern: "Dockerfile"
- category: potential
description: "Test code snippets when match is a key of a XML node"
message: "The code snippet should point to <beans> in the beans.xml file"
ruleID: xml-test-key-match
effort: 1
when:
builtin.xml:
filepaths:
- beans.xml
namespaces:
b: http://xmlns.jcp.org/xml/ns/javaee
xpath: /b:beans
- category: optional
description: |
This is same as java-io-file-usage but for the builtin providers. There are multiple instances of the same incidents in different directories.
We are filtering some out using includedPaths setting.
message: Only incidents in dir-0/test.json should be found
ruleID: builtin-inclusion-test-json
effort: 1
when:
and:
- builtin.json:
xpath: //inclusionTestNode
filepaths: "{{incTest.filepaths}}"
from: incTest
- builtin.file:
pattern: inclusion-test.json
as: incTest
ignore: true
- category: optional
description: |
This is same as java-io-file-usage but for the builtin providers. There are multiple instances of the same incidents in different directories.
We are filtering some out using includedPaths setting.
message: Only incidents in dir-0/test.xml should be found
ruleID: builtin-inclusion-test-xml
effort: 1
when:
and:
- builtin.xml:
xpath: //inclusionTestNode
filepaths: "{{incTest.filepaths}}"
from: incTest
- builtin.file:
pattern: inclusion-test.xml
as: incTest
- message: Found React import in .tsx file
ruleID: test-tsx-support-00000
description: Test that .tsx files are scanned (builtin provider)
effort: 1
category: potential
when:
builtin.filecontent:
pattern: "import.*React"
filePattern: "\\.tsx$"
- message: Found React reference using regex pattern
ruleID: test-regex-pattern-00000
description: Test regex pattern for TypeScript/JavaScript files
effort: 1
category: potential
when:
builtin.filecontent:
pattern: "React"
filePattern: "\\.(j|t)sx?$"
- message: Found PatternFly CSS variable using regex pattern
ruleID: test-regex-pattern-00010
description: Test regex pattern for CSS/SCSS files
effort: 1
category: potential
when:
builtin.filecontent:
pattern: "--pf-"
filePattern: "\\.(css|scss)$"
- message: 'System.Net.WebClient found. Consider replacing with System.Net.Http.HttpClient.'
ruleID: dotnet-deprecated-001
effort: 2
when:
c-sharp.referenced:
pattern: "System.Console"
location: CLASS