@@ -1411,12 +1411,15 @@ private function processInstanceRisks(
1411
1411
);
1412
1412
1413
1413
if ((int )$ instanceRiskData ['specific ' ] === InstanceRisk::TYPE_SPECIFIC ) {
1414
- $ threat = $ this ->threatTable ->findByAnrAndUuid ($ anr , $ threatData ['uuid ' ]);
1414
+ $ threat = $ this ->importCacheHelper ->getItemFromArrayCache ('threats ' , $ threatData ['uuid ' ])
1415
+ ?: $ this ->threatTable ->findByAnrAndUuid ($ anr , $ threatData ['uuid ' ]);
1415
1416
if ($ threat === null ) {
1416
1417
/* The code should be unique. */
1417
- $ threatData ['code ' ] = $ this ->threatTable ->existsWithAnrAndCode ($ anr , $ threatData ['code ' ])
1418
- ? $ threatData ['code ' ] . '- ' . time ()
1419
- : $ threatData ['code ' ];
1418
+ $ threatData ['code ' ] =
1419
+ $ this ->importCacheHelper ->getItemFromArrayCache ('threats_codes ' , $ threatData ['code ' ]) !== null
1420
+ || $ this ->threatTable ->existsWithAnrAndCode ($ anr , $ threatData ['code ' ])
1421
+ ? $ threatData ['code ' ] . '- ' . time ()
1422
+ : $ threatData ['code ' ];
1420
1423
1421
1424
$ threat = (new Threat ())
1422
1425
->setUuid ($ threatData ['uuid ' ])
@@ -1448,15 +1451,23 @@ private function processInstanceRisks(
1448
1451
*/
1449
1452
1450
1453
$ this ->threatTable ->saveEntity ($ threat , false );
1454
+
1455
+ $ this ->importCacheHelper ->addItemToArrayCache ('threats ' , $ threat , $ threat ->getUuid ());
1456
+ $ this ->importCacheHelper
1457
+ ->addItemToArrayCache ('threats_codes ' , $ threat ->getCode (), $ threat ->getCode ());
1451
1458
}
1452
1459
1453
- $ vulnerability = $ this ->vulnerabilityTable ->findByAnrAndUuid ($ anr , $ vulnerabilityData ['uuid ' ], false );
1460
+ $ vulnerability = $ this ->importCacheHelper
1461
+ ->getItemFromArrayCache ('vulnerabilities ' , $ vulnerabilityData ['uuid ' ])
1462
+ ?: $ this ->vulnerabilityTable ->findByAnrAndUuid ($ anr , $ vulnerabilityData ['uuid ' ], false );
1454
1463
if ($ vulnerability === null ) {
1455
1464
/* The code should be unique. */
1456
- $ vulnerabilityData ['code ' ] = $ this ->vulnerabilityTable ->existsWithAnrAndCode (
1457
- $ anr ,
1458
- $ vulnerabilityData ['code ' ]
1459
- ) ? $ vulnerabilityData ['code ' ] . '- ' . time () : $ vulnerabilityData ['code ' ];
1465
+ $ vulnerabilityData ['code ' ] =
1466
+ $ this ->importCacheHelper
1467
+ ->getItemFromArrayCache ('vulnerabilities_codes ' , $ vulnerabilityData ['code ' ]) !== null
1468
+ || $ this ->vulnerabilityTable ->existsWithAnrAndCode ($ anr , $ vulnerabilityData ['code ' ])
1469
+ ? $ vulnerabilityData ['code ' ] . '- ' . time ()
1470
+ : $ vulnerabilityData ['code ' ];
1460
1471
1461
1472
$ vulnerability = (new Vulnerability ())
1462
1473
->setUuid ($ vulnerabilityData ['uuid ' ])
@@ -1469,6 +1480,14 @@ private function processInstanceRisks(
1469
1480
->setCreator ($ this ->connectedUser ->getEmail ());
1470
1481
1471
1482
$ this ->vulnerabilityTable ->saveEntity ($ vulnerability , false );
1483
+
1484
+ $ this ->importCacheHelper
1485
+ ->addItemToArrayCache ('vulnerabilities ' , $ vulnerability , $ vulnerability ->getUuid ());
1486
+ $ this ->importCacheHelper ->addItemToArrayCache (
1487
+ 'vulnerabilities_codes ' ,
1488
+ $ vulnerability ->getCode (),
1489
+ $ vulnerability ->getCode ()
1490
+ );
1472
1491
}
1473
1492
1474
1493
$ instanceRisk = $ this ->createInstanceRiskFromData (
0 commit comments