diff --git a/src/com/sap/piper/WhitesourceConfigurationHelper.groovy b/src/com/sap/piper/WhitesourceConfigurationHelper.groovy index 8bd9876a5..7e94c0f52 100644 --- a/src/com/sap/piper/WhitesourceConfigurationHelper.groovy +++ b/src/com/sap/piper/WhitesourceConfigurationHelper.groovy @@ -38,6 +38,8 @@ class WhitesourceConfigurationHelper implements Serializable { [name: 'ignoreSourceFiles', value: true, force: true], [name: 'resolveAllDependencies', value: false, force: true] ] + if(!['pip', 'golang'].contains(config.scanType)) + script.echo "[Whitesource] Configuration for scanType: '${config.scanType}' is not yet hardened, please do a quality assessment of your scan results." switch (config.scanType) { case 'npm': mapping += [ diff --git a/test/groovy/com/sap/piper/WhiteSourceConfigurationHelperTest.groovy b/test/groovy/com/sap/piper/WhiteSourceConfigurationHelperTest.groovy index d01fe6efd..2ebd5e630 100644 --- a/test/groovy/com/sap/piper/WhiteSourceConfigurationHelperTest.groovy +++ b/test/groovy/com/sap/piper/WhiteSourceConfigurationHelperTest.groovy @@ -5,23 +5,27 @@ import org.junit.Rule import org.junit.Test import org.junit.rules.RuleChain import util.BasePiperTest +import util.JenkinsLoggingRule import util.JenkinsReadFileRule import util.JenkinsWriteFileRule import util.Rules import static org.hamcrest.Matchers.containsString import static org.hamcrest.Matchers.hasItem +import static org.hamcrest.Matchers.not import static org.junit.Assert.assertThat class WhiteSourceConfigurationHelperTest extends BasePiperTest { JenkinsReadFileRule jrfr = new JenkinsReadFileRule(this, 'test/resources/utilsTest/') JenkinsWriteFileRule jwfr = new JenkinsWriteFileRule(this) + JenkinsLoggingRule jlr = new JenkinsLoggingRule(this) @Rule public RuleChain ruleChain = Rules .getCommonRules(this) .around(jrfr) .around(jwfr) + .around(jlr) @Before void init() { @@ -35,6 +39,8 @@ class WhiteSourceConfigurationHelperTest extends BasePiperTest { assertThat(jwfr.files['./config.847f9aec2f93de9000d5fa4e6eaace2283ae6377'], containsString("productName=DIST - name1")) assertThat(jwfr.files['./config.847f9aec2f93de9000d5fa4e6eaace2283ae6377'], containsString("productToken=1234")) assertThat(jwfr.files['./config.847f9aec2f93de9000d5fa4e6eaace2283ae6377'], containsString("userKey=0000")) + + assertThat(jlr.log, containsString("[Whitesource] Configuration for scanType: 'none' is not yet hardened, please do a quality assessment of your scan results.")) } @Test @@ -44,6 +50,8 @@ class WhiteSourceConfigurationHelperTest extends BasePiperTest { assertThat(jwfr.files['./config.847f9aec2f93de9000d5fa4e6eaace2283ae6377'], containsString("productName=DIST - name1")) assertThat(jwfr.files['./config.847f9aec2f93de9000d5fa4e6eaace2283ae6377'], containsString("productToken=1234")) assertThat(jwfr.files['./config.847f9aec2f93de9000d5fa4e6eaace2283ae6377'], containsString("userKey=0000")) + + assertThat(jlr.log, containsString("[Whitesource] Configuration for scanType: 'npm' is not yet hardened, please do a quality assessment of your scan results.")) } @Test @@ -53,6 +61,9 @@ class WhiteSourceConfigurationHelperTest extends BasePiperTest { assertThat(jwfr.files['./config.847f9aec2f93de9000d5fa4e6eaace2283ae6377'], containsString("productName=DIST - name1")) assertThat(jwfr.files['./config.847f9aec2f93de9000d5fa4e6eaace2283ae6377'], containsString("productToken=1234")) assertThat(jwfr.files['./config.847f9aec2f93de9000d5fa4e6eaace2283ae6377'], containsString("userKey=0000")) + + assertThat(jlr.log, containsString("[Whitesource] Configuration for scanType: 'sbt' is not yet hardened, please do a quality assessment of your scan results.")) + } @Test @@ -62,6 +73,8 @@ class WhiteSourceConfigurationHelperTest extends BasePiperTest { assertThat(jwfr.files['./config.847f9aec2f93de9000d5fa4e6eaace2283ae6377'], containsString("productName=DIST - name1")) assertThat(jwfr.files['./config.847f9aec2f93de9000d5fa4e6eaace2283ae6377'], containsString("productToken=1234")) assertThat(jwfr.files['./config.847f9aec2f93de9000d5fa4e6eaace2283ae6377'], containsString("userKey=0000")) + + assertThat(jlr.log, containsString("[Whitesource] Configuration for scanType: 'dlang' is not yet hardened, please do a quality assessment of your scan results.")) } @Test @@ -72,6 +85,8 @@ class WhiteSourceConfigurationHelperTest extends BasePiperTest { assertThat(jwfr.files['./config.847f9aec2f93de9000d5fa4e6eaace2283ae6377'], containsString("productToken=1234")) assertThat(jwfr.files['./config.847f9aec2f93de9000d5fa4e6eaace2283ae6377'], containsString("userKey=0000")) assertThat(jwfr.files['./config.847f9aec2f93de9000d5fa4e6eaace2283ae6377'], containsString("python.resolveDependencies=true")) + + assertThat(jlr.log, not(containsString("[Whitesource] Configuration for scanType: 'pip' is not yet hardened, please do a quality assessment of your scan results."))) } @Test @@ -86,6 +101,7 @@ class WhiteSourceConfigurationHelperTest extends BasePiperTest { assertThat(jwfr.files['./config.847f9aec2f93de9000d5fa4e6eaace2283ae6377'], containsString("log.level=debug")) assertThat(config.stashContent, hasItem(containsString('modified whitesource config '))) + assertThat(jlr.log, not(containsString("[Warning][Whitesource] Configuration for scanType: 'golang' is not yet hardened, please do a quality assessment of your scan results."))) } @Test