1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-18 05:18:24 +02:00

Avoid using Iterators to get around NotSerializableException (#1220)

This commit is contained in:
Sven Merk 2020-02-25 12:25:26 +01:00 committed by GitHub
parent d754a669b2
commit 4c97231ff9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 11 deletions

View File

@ -103,11 +103,11 @@ class WhitesourceConfigurationHelper implements Serializable {
if (!moduleSpecificFile)
moduleSpecificFile = [:]
mapping.each {
entry ->
def dependentValue = entry.omitIfPresent ? moduleSpecificFile[entry.omitIfPresent] : null
if ((entry.omitIfPresent && !dependentValue || !entry.omitIfPresent) && (entry.force || moduleSpecificFile[entry.name] == null) && entry.value != 'null')
moduleSpecificFile[entry.name] = entry.value.toString()
for(int i = 0; i < mapping.size(); i++) {
def entry = mapping.get(i)
def dependentValue = entry.omitIfPresent ? moduleSpecificFile[entry.omitIfPresent] : null
if ((entry.omitIfPresent && !dependentValue || !entry.omitIfPresent) && (entry.force || moduleSpecificFile[entry.name] == null) && entry.value != 'null')
moduleSpecificFile[entry.name] = entry.value.toString()
}
def output = serializationClosure(moduleSpecificFile)

View File

@ -53,8 +53,9 @@ class WhitesourceOrgAdminRepository implements Serializable {
def groups = []
def users = []
config.whitesource.emailAddressesOfInitialProductAdmins.each {
email -> users.add(["email": email])
for(int i = 0; i < config.whitesource.emailAddressesOfInitialProductAdmins.size(); i++) {
def email = config.whitesource.emailAddressesOfInitialProductAdmins.get(i)
users.add(["email": email])
}
requestBody = [

View File

@ -521,10 +521,10 @@ int checkSecurityViolations(Map config, WhitesourceRepository repository) {
def projectsMetaInformation = repository.fetchProjectsMetaInfo()
def vulnerabilities = repository.fetchVulnerabilities(projectsMetaInformation)
def severeVulnerabilities = 0
vulnerabilities.each {
item ->
if ((item.vulnerability.score >= config.whitesource.cvssSeverityLimit || item.vulnerability.cvss3_score >= config.whitesource.cvssSeverityLimit) && config.whitesource.cvssSeverityLimit >= 0)
severeVulnerabilities++
for(int i = 0; i < vulnerabilities.size(); i++) {
def item = vulnerabilities.get(i)
if ((item.vulnerability.score >= config.whitesource.cvssSeverityLimit || item.vulnerability.cvss3_score >= config.whitesource.cvssSeverityLimit) && config.whitesource.cvssSeverityLimit >= 0)
severeVulnerabilities++
}
writeFile(file: "${config.vulnerabilityReportFileName}.json", text: new JsonUtils().groovyObjectToPrettyJsonString(vulnerabilities))