stevespringett / nist-data-mirror

A simple Java command-line utility to mirror the CVE JSON data from NIST.
Apache License 2.0
206 stars 93 forks source link

Return exit code 2 if invoked with wrong arguments #72

Closed phxql closed 3 years ago

phxql commented 3 years ago

Hi,

i added an exit code if the application was invoked with the wrong arguments.

We use your tool to mirror the NIST data in a scheduled job. This job has failed to download the data for 2 weeks, and we didn't noticed that the invocation arguments have changed. With this change we can check for the exit code and fail the build if needed.

Best regards, Moritz

mookkiah commented 3 years ago

Hi Moritz,

Good Thought. I have been in this situation when someone made mistake in configuration, the mirroring did not run for days. But the web server continue to run with old data.

This can be identified when comparing the content from these urls. https://nvd.nist.gov/feeds/json/cve/1.1/nvdcve-1.1-modified.meta https://your-nist-mirror.domain/nvdcve-1.1-modified.meta

But your solution helps to signal. Good Job. Can we think of somehow stop the web server or leave an entry somewhere so that the user can check that the last update was a successful one before using the mirror.

Thanks, Mahendran Mookkiah

mookkiah commented 3 years ago

@phxql Please share your thoughts on how you are planning to use the exit code. Let us see if we can script that too.

https://github.com/stevespringett/nist-data-mirror/blob/f5b2867c3e5568acf9ebf355ec763ed233890c19/src/docker/scripts/mirror.sh#L5

stevespringett commented 3 years ago

Thanks for the PR.

phxql commented 3 years ago

@phxql Please share your thoughts on how you are planning to use the exit code. Let us see if we can script that too.

we run the mirror-tool in a gitlab CI to download the NIST data every night. As somewhere on the update from 1.3.0 to 1.5.0 the arguments of the tool have been changed, our CI ran through (status green), but no new data has been download.

Now the tool returns exit code 2 and our CI would fail in that case.