22
22
import com .synopsys .integration .blackduck .api .generated .component .DeveloperScansScanItemsTransitiveUpgradeGuidanceLongTermUpgradeGuidanceView ;
23
23
import com .synopsys .integration .blackduck .api .generated .component .DeveloperScansScanItemsTransitiveUpgradeGuidanceShortTermUpgradeGuidanceView ;
24
24
import com .synopsys .integration .blackduck .api .generated .component .DeveloperScansScanItemsTransitiveUpgradeGuidanceView ;
25
- import com .synopsys .integration .blackduck .api .generated .component .DeveloperScansScanItemsView ;
26
- import com .synopsys .integration .blackduck .api .generated .view .DeveloperScansScanView ;
25
+ import com .synopsys .integration .blackduck .api .manual .view .DeveloperScansScanView ;
27
26
28
27
public class RapidScanResultAggregator {
29
28
@@ -68,62 +67,49 @@ public RapidScanAggregateResult aggregateData(List<DeveloperScansScanView> resul
68
67
private List <RapidScanComponentDetail > aggregateComponentData (List <DeveloperScansScanView > results ) {
69
68
// the key is the component identifier
70
69
List <RapidScanComponentDetail > componentDetails = new LinkedList <>();
71
-
72
- for (DeveloperScansScanView resultView : results ) {
73
- processViewItems (componentDetails , resultView );
74
- }
75
-
76
- return componentDetails ;
77
- }
78
70
79
- /**
80
- * @param componentDetails
81
- * @param resultView
82
- */
83
- private void processViewItems (List <RapidScanComponentDetail > componentDetails , DeveloperScansScanView highLevelView ) {
84
-
85
- for (DeveloperScansScanItemsView resultItem : highLevelView .getItems ()) {
86
-
87
- compileTransitiveGuidance (resultItem );
88
-
89
- RapidScanComponentDetail componentDetail = createDetail (resultItem );
90
- componentDetails .add (componentDetail );
91
- RapidScanComponentGroupDetail componentGroupDetail = componentDetail .getComponentDetails ();
92
- RapidScanComponentGroupDetail securityGroupDetail = componentDetail .getSecurityDetails ();
93
- RapidScanComponentGroupDetail licenseGroupDetail = componentDetail .getLicenseDetails ();
94
-
95
- List <DeveloperScansScanItemsComponentViolatingPoliciesView > componentViolations =
96
- resultItem .getComponentViolatingPolicies ();
97
- List <DeveloperScansScanItemsPolicyViolationVulnerabilitiesView > vulnerabilityViolations = resultItem
98
- .getPolicyViolationVulnerabilities ();
99
- List <DeveloperScansScanItemsPolicyViolationLicensesView > licenseViolations = resultItem
100
- .getPolicyViolationLicenses ();
101
-
102
- Set <String > vulnerabilityPolicyNames = vulnerabilityViolations .stream ()
103
- .map (DeveloperScansScanItemsPolicyViolationVulnerabilitiesView ::getViolatingPolicies )
104
- .flatMap (Collection ::stream )
105
- .map (DeveloperScansScanItemsPolicyViolationVulnerabilitiesViolatingPoliciesView ::getPolicyName )
106
- .collect (Collectors .toSet ());
107
-
108
- Set <String > licensePolicyNames = licenseViolations .stream ()
109
- .map (DeveloperScansScanItemsPolicyViolationLicensesView ::getViolatingPolicies )
110
- .flatMap (Collection ::stream )
111
- .map (DeveloperScansScanItemsPolicyViolationLicensesViolatingPoliciesView ::getPolicyName )
112
- .collect (Collectors .toSet ());
113
-
114
- Set <String > componentPolicyNames = componentViolations .stream ()
115
- .map (DeveloperScansScanItemsComponentViolatingPoliciesView ::getPolicyName )
116
- .collect (Collectors .toSet ());
71
+ for (DeveloperScansScanView resultView : results ) {
72
+ this .compileTransitiveGuidance (resultView );
73
+
74
+ RapidScanComponentDetail componentDetail = createDetail (resultView );
75
+ componentDetails .add (componentDetail );
76
+ RapidScanComponentGroupDetail componentGroupDetail = componentDetail .getComponentDetails ();
77
+ RapidScanComponentGroupDetail securityGroupDetail = componentDetail .getSecurityDetails ();
78
+ RapidScanComponentGroupDetail licenseGroupDetail = componentDetail .getLicenseDetails ();
79
+
80
+ List <DeveloperScansScanItemsComponentViolatingPoliciesView > componentViolations =
81
+ resultView .getComponentViolatingPolicies ();
82
+ List <DeveloperScansScanItemsPolicyViolationVulnerabilitiesView > vulnerabilityViolations = resultView
83
+ .getPolicyViolationVulnerabilities ();
84
+ List <DeveloperScansScanItemsPolicyViolationLicensesView > licenseViolations = resultView
85
+ .getPolicyViolationLicenses ();
86
+
87
+ Set <String > vulnerabilityPolicyNames = vulnerabilityViolations .stream ()
88
+ .map (DeveloperScansScanItemsPolicyViolationVulnerabilitiesView ::getViolatingPolicies )
89
+ .flatMap (Collection ::stream )
90
+ .map (DeveloperScansScanItemsPolicyViolationVulnerabilitiesViolatingPoliciesView ::getPolicyName )
91
+ .collect (Collectors .toSet ());
92
+
93
+ Set <String > licensePolicyNames = licenseViolations .stream ()
94
+ .map (DeveloperScansScanItemsPolicyViolationLicensesView ::getViolatingPolicies )
95
+ .flatMap (Collection ::stream )
96
+ .map (DeveloperScansScanItemsPolicyViolationLicensesViolatingPoliciesView ::getPolicyName )
97
+ .collect (Collectors .toSet ());
98
+
99
+ Set <String > componentPolicyNames = componentViolations .stream ()
100
+ .map (DeveloperScansScanItemsComponentViolatingPoliciesView ::getPolicyName )
101
+ .collect (Collectors .toSet ());
117
102
118
- componentGroupDetail .addPolicies (componentPolicyNames );
119
- securityGroupDetail .addPolicies (vulnerabilityPolicyNames );
120
- licenseGroupDetail .addPolicies (licensePolicyNames );
103
+ componentGroupDetail .addPolicies (componentPolicyNames );
104
+ securityGroupDetail .addPolicies (vulnerabilityPolicyNames );
105
+ licenseGroupDetail .addPolicies (licensePolicyNames );
121
106
122
- addComponentData (resultItem , componentViolations , componentGroupDetail );
123
- addVulnerabilityData (resultItem , vulnerabilityViolations , securityGroupDetail );
124
- addLicenseData (resultItem , licenseViolations , licenseGroupDetail );
125
-
107
+ addComponentData (resultView , componentViolations , componentGroupDetail );
108
+ addVulnerabilityData (resultView , vulnerabilityViolations , securityGroupDetail );
109
+ addLicenseData (resultView , licenseViolations , licenseGroupDetail );
126
110
}
111
+
112
+ return componentDetails ;
127
113
}
128
114
129
115
/**
@@ -134,13 +120,13 @@ private void processViewItems(List<RapidScanComponentDetail> componentDetails, D
134
120
* can get a proper lookup of direct comp. -> child component(s). Once this is completed,
135
121
* we can put together the string messages needed.
136
122
*
137
- * @param resultItem
123
+ * @param resultView
138
124
* @param results
139
125
*/
140
- private void compileTransitiveGuidance (DeveloperScansScanItemsView resultItem ) {
141
- List <DeveloperScansScanItemsTransitiveUpgradeGuidanceView > transitiveGuidance = resultItem .getTransitiveUpgradeGuidance ();
126
+ private void compileTransitiveGuidance (DeveloperScansScanView resultView ) {
127
+ List <DeveloperScansScanItemsTransitiveUpgradeGuidanceView > transitiveGuidance = resultView .getTransitiveUpgradeGuidance ();
142
128
if (transitiveGuidance != null && !transitiveGuidance .isEmpty ()) {
143
- String childExternalId = resultItem .getExternalId ();
129
+ String childExternalId = resultView .getExternalId ();
144
130
for (DeveloperScansScanItemsTransitiveUpgradeGuidanceView guidance : transitiveGuidance ) {
145
131
String parentId = guidance .getExternalId ();
146
132
String [] versions = getversionsFromUpgradeGuidance (guidance );
@@ -177,15 +163,15 @@ and suggest that in the guidance (as if stg.version = ltg.version) */
177
163
return new String [] { shortTermVersion , longTermVersion };
178
164
}
179
165
180
- private RapidScanComponentDetail createDetail (DeveloperScansScanItemsView resultItem ) {
181
- String componentName = resultItem .getComponentName ();
182
- String componentVersion = resultItem .getVersionName ();
166
+ private RapidScanComponentDetail createDetail (DeveloperScansScanView resultView ) {
167
+ String componentName = resultView .getComponentName ();
168
+ String componentVersion = resultView .getVersionName ();
183
169
String componentIdentifier = "" ;
184
170
185
- if (StringUtils .isNotBlank (resultItem .getComponentIdentifier ())) {
186
- componentIdentifier = resultItem .getComponentIdentifier ();
187
- } else if (StringUtils .isNotBlank (resultItem .getExternalId ())) {
188
- componentIdentifier = resultItem .getExternalId ();
171
+ if (StringUtils .isNotBlank (resultView .getComponentIdentifier ())) {
172
+ componentIdentifier = resultView .getComponentIdentifier ();
173
+ } else if (StringUtils .isNotBlank (resultView .getExternalId ())) {
174
+ componentIdentifier = resultView .getExternalId ();
189
175
}
190
176
191
177
RapidScanComponentGroupDetail componentGroupDetail = new RapidScanComponentGroupDetail (RapidScanDetailGroup .POLICY );
@@ -196,21 +182,21 @@ private RapidScanComponentDetail createDetail(DeveloperScansScanItemsView result
196
182
securityGroupDetail , licenseGroupDetail );
197
183
}
198
184
199
- private void addVulnerabilityData (DeveloperScansScanItemsView resultItem , List <DeveloperScansScanItemsPolicyViolationVulnerabilitiesView > vulnerabilities , RapidScanComponentGroupDetail securityDetail ) {
185
+ private void addVulnerabilityData (DeveloperScansScanView resultView , List <DeveloperScansScanItemsPolicyViolationVulnerabilitiesView > vulnerabilities , RapidScanComponentGroupDetail securityDetail ) {
200
186
for (DeveloperScansScanItemsPolicyViolationVulnerabilitiesView vulnerabilityPolicyViolation : vulnerabilities ) {
201
- securityDetail .addVulnerabilityMessages (resultItem , vulnerabilityPolicyViolation );
187
+ securityDetail .addVulnerabilityMessages (resultView , vulnerabilityPolicyViolation );
202
188
}
203
189
}
204
190
205
- private void addLicenseData (DeveloperScansScanItemsView resultItem , List <DeveloperScansScanItemsPolicyViolationLicensesView > licenseViolations , RapidScanComponentGroupDetail licenseDetail ) {
191
+ private void addLicenseData (DeveloperScansScanView resultView , List <DeveloperScansScanItemsPolicyViolationLicensesView > licenseViolations , RapidScanComponentGroupDetail licenseDetail ) {
206
192
for (DeveloperScansScanItemsPolicyViolationLicensesView licensePolicyViolation : licenseViolations ) {
207
- licenseDetail .addLicenseMessages (resultItem , licensePolicyViolation );
193
+ licenseDetail .addLicenseMessages (resultView , licensePolicyViolation );
208
194
}
209
195
}
210
196
211
- private void addComponentData (DeveloperScansScanItemsView resultItem , List <DeveloperScansScanItemsComponentViolatingPoliciesView > componentViolations , RapidScanComponentGroupDetail componentGroupDetail ) {
197
+ private void addComponentData (DeveloperScansScanView resultView , List <DeveloperScansScanItemsComponentViolatingPoliciesView > componentViolations , RapidScanComponentGroupDetail componentGroupDetail ) {
212
198
for (DeveloperScansScanItemsComponentViolatingPoliciesView componentPolicyViolation : componentViolations ) {
213
- componentGroupDetail .addComponentMessages (resultItem , componentPolicyViolation );
199
+ componentGroupDetail .addComponentMessages (resultView , componentPolicyViolation );
214
200
}
215
201
}
216
202
0 commit comments