@@ -74,6 +74,16 @@ class OpenSourceVulnerabilitiesChecker extends AbstractChecker
7474 */
7575 protected const ARG_ABANDONED_IGNORE = '--abandoned=ignore ' ;
7676
77+ /**
78+ * @var int
79+ */
80+ protected const RETRY_ATTEMPTS = 7 ;
81+
82+ /**
83+ * @var int
84+ */
85+ protected const RETRY_SLEEP_SECONDS = 3 ;
86+
7787 /**
7888 * @var \Symfony\Component\Console\Application
7989 */
@@ -123,7 +133,7 @@ public function check(CheckerInputDataDto $inputData): CheckerResponseDto
123133 return $ versionViolation ;
124134 }
125135
126- $ rawViolations = $ this ->runAudit ($ projectDir );
136+ $ rawViolations = $ this ->runAuditWithRetries ($ projectDir );
127137
128138 return $ this ->buildResponseFromRaw ($ rawViolations );
129139 }
@@ -182,7 +192,7 @@ protected function ensureMinimumComposer(string $projectDir): ?CheckerResponseDt
182192 *
183193 * @return string
184194 */
185- protected function runAudit (string $ projectDir ): string
195+ protected function runAuditWithRetries (string $ projectDir ): string
186196 {
187197 $ args = [
188198 static ::SUBCMD_AUDIT ,
@@ -191,9 +201,23 @@ protected function runAudit(string $projectDir): string
191201 static ::ARG_NO_INTERACTION ,
192202 static ::ARG_NO_ANSI ,
193203 ];
194- [$ stdout , $ stderr ] = $ this ->runComposerCommand ($ args , $ projectDir );
204+ for ($ i = 1 ; $ i <= static ::RETRY_ATTEMPTS ; $ i ++) {
205+ [$ stdout , $ stderr ] = $ this ->runComposerCommand ($ args , $ projectDir );
206+
207+ if ($ stdout !== '' ) {
208+ return $ stdout ;
209+ }
210+
211+ if ($ i < static ::RETRY_ATTEMPTS ) {
212+ sleep (static ::RETRY_SLEEP_SECONDS );
213+
214+ continue ;
215+ }
216+
217+ return $ stderr ;
218+ }
195219
196- return $ stdout !== '' ? $ stdout : $ stderr ;
220+ return '' ;
197221 }
198222
199223 /**
0 commit comments