File tree Expand file tree Collapse file tree 2 files changed +34
-6
lines changed Expand file tree Collapse file tree 2 files changed +34
-6
lines changed Original file line number Diff line number Diff line change @@ -270,10 +270,35 @@ export default class RulesProvider implements Engine {
270
270
}
271
271
272
272
prepareMutations = ( findings : RuleFinding [ ] = [ ] ) : Entity [ ] => {
273
- const processedFindings = findings . filter (
274
- ( { typename } ) => typename !== 'manual'
275
- )
276
- const unprocessedFindings = findings
273
+ const processedFindings = findings
274
+ . filter ( ( { typename } ) => typename !== 'manual' )
275
+ . map ( finding => {
276
+ if ( finding . typename !== 'composite' ) {
277
+ const parentRule = findings . find (
278
+ f =>
279
+ f . rule ?. relatedRules ?. includes ( finding . rule ?. id ) &&
280
+ f . typename === 'composite'
281
+ )
282
+
283
+ if ( parentRule ?. rule ) {
284
+ const {
285
+ id,
286
+ rule : { relatedRules, ...ruleMetadata } ,
287
+ } = parentRule
288
+ return {
289
+ ...finding ,
290
+ id : `${ id } /${ finding . id } ` ,
291
+ rule : ruleMetadata ,
292
+ }
293
+ }
294
+
295
+ return finding
296
+ }
297
+ return undefined
298
+ } )
299
+ . filter ( Boolean )
300
+
301
+ const manualFindings = findings
277
302
. filter ( ( { typename } ) => typename === 'manual' )
278
303
. map ( ( { typename, ...filteredFinding } ) => ( { ...filteredFinding } ) )
279
304
@@ -295,7 +320,7 @@ export default class RulesProvider implements Engine {
295
320
}
296
321
}
297
322
` ,
298
- data : unprocessedFindings ,
323
+ data : manualFindings ,
299
324
} ,
300
325
]
301
326
}
Original file line number Diff line number Diff line change @@ -52,13 +52,16 @@ export interface Rule {
52
52
resource : string
53
53
relatedRules ?: string [ ]
54
54
}
55
- export interface RuleFinding {
55
+ export interface Finding {
56
56
id : string
57
57
resourceId ?: string
58
58
result : Result
59
59
typename : string
60
60
}
61
61
62
+ export interface RuleFinding extends Finding {
63
+ rule ?: Rule
64
+ }
62
65
export interface JsonRule extends Rule {
63
66
conditions : Condition
64
67
}
You can’t perform that action at this time.
0 commit comments