@@ -103,7 +103,7 @@ test("Should create subsequent scans for open HTTPS ports (NMAP findings)", () =
103103 ],
104104 },
105105 "spec": Object {
106- "affinity": Object {} ,
106+ "affinity": undefined ,
107107 "cascades": Object {},
108108 "env": Array [],
109109 "hookSelector": Object {},
@@ -113,7 +113,7 @@ test("Should create subsequent scans for open HTTPS ports (NMAP findings)", () =
113113 "foobar.com:443",
114114 ],
115115 "scanType": "sslyze",
116- "tolerations": Array [] ,
116+ "tolerations": undefined ,
117117 "volumeMounts": Array [],
118118 "volumes": Array [],
119119 },
@@ -243,7 +243,7 @@ test("Should not crash when the annotations are not set", () => {
243243 ],
244244 },
245245 "spec": Object {
246- "affinity": Object {} ,
246+ "affinity": undefined ,
247247 "cascades": Object {},
248248 "env": Array [],
249249 "hookSelector": Object {},
@@ -253,7 +253,7 @@ test("Should not crash when the annotations are not set", () => {
253253 "foobar.com:443",
254254 ],
255255 "scanType": "sslyze",
256- "tolerations": Array [] ,
256+ "tolerations": undefined ,
257257 "volumeMounts": Array [],
258258 "volumes": Array [],
259259 },
@@ -377,7 +377,7 @@ test("Should allow wildcards in cascadingRules", () => {
377377 ],
378378 },
379379 "spec": Object {
380- "affinity": Object {} ,
380+ "affinity": undefined ,
381381 "cascades": Object {},
382382 "env": Array [],
383383 "hookSelector": Object {},
@@ -387,7 +387,7 @@ test("Should allow wildcards in cascadingRules", () => {
387387 "foobar.com:8443",
388388 ],
389389 "scanType": "sslyze",
390- "tolerations": Array [] ,
390+ "tolerations": undefined ,
391391 "volumeMounts": Array [],
392392 "volumes": Array [],
393393 },
@@ -1129,7 +1129,7 @@ test("Templating should apply to environment variables", () => {
11291129 ],
11301130 },
11311131 "spec": Object {
1132- "affinity": Object {} ,
1132+ "affinity": undefined ,
11331133 "cascades": Object {},
11341134 "env": Array [
11351135 Object {
@@ -1144,7 +1144,7 @@ test("Templating should apply to environment variables", () => {
11441144 "foobar.com:443",
11451145 ],
11461146 "scanType": "sslyze",
1147- "tolerations": Array [] ,
1147+ "tolerations": undefined ,
11481148 "volumeMounts": Array [
11491149 Object {
11501150 "mountPath": "/test",
@@ -1252,7 +1252,7 @@ test("Templating should apply to initContainer commands", () => {
12521252 ],
12531253 },
12541254 "spec": Object {
1255- "affinity": Object {} ,
1255+ "affinity": undefined ,
12561256 "cascades": Object {},
12571257 "env": Array [],
12581258 "hookSelector": Object {},
@@ -1279,7 +1279,7 @@ test("Templating should apply to initContainer commands", () => {
12791279 "foobar.com:443",
12801280 ],
12811281 "scanType": "sslyze",
1282- "tolerations": Array [] ,
1282+ "tolerations": undefined ,
12831283 "volumeMounts": Array [
12841284 Object {
12851285 "mountPath": "/test",
@@ -1388,7 +1388,7 @@ test("Templating should apply to initContainer environment variables", () => {
13881388 ],
13891389 },
13901390 "spec": Object {
1391- "affinity": Object {} ,
1391+ "affinity": undefined ,
13921392 "cascades": Object {},
13931393 "env": Array [],
13941394 "hookSelector": Object {},
@@ -1418,7 +1418,7 @@ test("Templating should apply to initContainer environment variables", () => {
14181418 "foobar.com:443",
14191419 ],
14201420 "scanType": "sslyze",
1421- "tolerations": Array [] ,
1421+ "tolerations": undefined ,
14221422 "volumeMounts": Array [
14231423 Object {
14241424 "mountPath": "/test",
@@ -1526,7 +1526,7 @@ test("Templating should not break special encoding (http://...) when using tripl
15261526 ],
15271527 },
15281528 "spec": Object {
1529- "affinity": Object {} ,
1529+ "affinity": undefined ,
15301530 "cascades": Object {},
15311531 "env": Array [],
15321532 "hookSelector": Object {},
@@ -1553,7 +1553,7 @@ test("Templating should not break special encoding (http://...) when using tripl
15531553 "https://github.com/secureCodeBox/secureCodeBox",
15541554 ],
15551555 "scanType": "sslyze",
1556- "tolerations": Array [] ,
1556+ "tolerations": undefined ,
15571557 "volumeMounts": Array [
15581558 Object {
15591559 "mountPath": "/test",
@@ -1850,9 +1850,9 @@ test("should not copy tolerations and affinity into cascaded scan if label disab
18501850
18511851 const cascadedScan = cascadedScans [ 0 ] ;
18521852
1853- expect ( cascadedScan . spec . affinity ) . toMatchInlineSnapshot ( `Object {} ` ) ;
1853+ expect ( cascadedScan . spec . affinity ) . toMatchInlineSnapshot ( `undefined ` ) ;
18541854
1855- expect ( cascadedScan . spec . tolerations ) . toMatchInlineSnapshot ( `Array [] ` ) ;
1855+ expect ( cascadedScan . spec . tolerations ) . toMatchInlineSnapshot ( `undefined ` ) ;
18561856} ) ;
18571857
18581858test ( "should merge tolerations and replace affinity in cascaded scan if cascading spec sets new ones" , ( ) => {
@@ -1976,6 +1976,70 @@ test("should merge tolerations and replace affinity in cascaded scan if cascadin
19761976 ` ) ;
19771977} ) ;
19781978
1979+ test ( "should not set affinity or tolerations to undefined if they are defined to be an empty map / list in upstream scan" , ( ) => {
1980+ const findings = [
1981+ {
1982+ name : "Port 443 is open" ,
1983+ category : "Open Port" ,
1984+ attributes : {
1985+ state : "open" ,
1986+ hostname : "foobar.com" ,
1987+ port : 443 ,
1988+ service : "https"
1989+ }
1990+ }
1991+ ] ;
1992+
1993+ parentScan . spec . affinity = { }
1994+
1995+ parentScan . spec . tolerations = [ ]
1996+
1997+ const cascadedScans = getCascadingScans (
1998+ parentScan ,
1999+ findings ,
2000+ sslyzeCascadingRules
2001+ ) ;
2002+
2003+ const cascadedScan = cascadedScans [ 0 ] ;
2004+
2005+ // New values will completely replace the old values, not be merged
2006+ expect ( cascadedScan . spec . affinity ) . toMatchInlineSnapshot ( `Object {}` ) ;
2007+
2008+ expect ( cascadedScan . spec . tolerations ) . toMatchInlineSnapshot ( `Array []` ) ;
2009+ } ) ;
2010+
2011+ test ( "Should not set affinity or tolerations to undefined if they are defined to be an empty map / list in cascading ScanSpec" , ( ) => {
2012+ const findings = [
2013+ {
2014+ name : "Port 443 is open" ,
2015+ category : "Open Port" ,
2016+ attributes : {
2017+ state : "open" ,
2018+ hostname : "foobar.com" ,
2019+ port : 443 ,
2020+ service : "https"
2021+ }
2022+ }
2023+ ] ;
2024+
2025+ sslyzeCascadingRules [ 0 ] . spec . scanSpec . tolerations = [ ] ;
2026+
2027+ sslyzeCascadingRules [ 0 ] . spec . scanSpec . affinity = { } ;
2028+
2029+ const cascadedScans = getCascadingScans (
2030+ parentScan ,
2031+ findings ,
2032+ sslyzeCascadingRules
2033+ ) ;
2034+
2035+ const cascadedScan = cascadedScans [ 0 ] ;
2036+
2037+ // New values will completely replace the old values, not be merged
2038+ expect ( cascadedScan . spec . affinity ) . toMatchInlineSnapshot ( `Object {}` ) ;
2039+
2040+ expect ( cascadedScan . spec . tolerations ) . toMatchInlineSnapshot ( `Array []` ) ;
2041+ } ) ;
2042+
19792043test ( "should only use tolerations and affinity of cascaded scan if inheritance is disabled" , ( ) => {
19802044 parentScan . spec . cascades . inheritAffinity = false ;
19812045 parentScan . spec . cascades . inheritTolerations = false ;
0 commit comments