Skip to content

Commit

Permalink
feat: retry nvd cache on failure (#264)
Browse files Browse the repository at this point in the history
* feat: retry nvd cache on failure

* fix: updated per peer review
  • Loading branch information
jeremylong authored Feb 16, 2025
1 parent e99ccdd commit 6dffb79
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion vulnz/src/docker/scripts/mirror.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ function remove_lockfile() {
}
trap remove_lockfile SIGHUP SIGINT SIGQUIT SIGABRT SIGALRM SIGTERM SIGTSTP

java $JAVA_OPT -jar /usr/local/bin/vulnz cve $DELAY_ARG $DEBUG_ARG $MAX_RETRY_ARG $MAX_RECORDS_PER_PAGE_ARG $CONTINUE_ARG --cache --directory /usr/local/apache2/htdocs
attempt=1
max_attempts=5

set +e
while [ $attempt -le $max_attempts ]; do
java $JAVA_OPT -jar /usr/local/bin/vulnz cve $DELAY_ARG $DEBUG_ARG $MAX_RETRY_ARG $MAX_RECORDS_PER_PAGE_ARG $CONTINUE_ARG --cache --directory /usr/local/apache2/htdocs
exit_code=$?
# 100: one or more years of data failed to update; 101 there was an error updating the modified CVE list
# if either of these codes are returned, we will retry the update immediately
if [ $exit_code -ne 100 ] && [ $exit_code -ne 101 ]; then
break
fi
echo "Got exit code $exit_code, attempt $attempt of $max_attempts"
attempt=$((attempt + 1))
done
set -e

rm -f $LOCKFILE

0 comments on commit 6dffb79

Please sign in to comment.