Skip to content

Instantly share code, notes, and snippets.

@judavi
Last active August 22, 2019 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save judavi/e9fdff2b9d57048e5162e2872c88089c to your computer and use it in GitHub Desktop.
Save judavi/e9fdff2b9d57048e5162e2872c88089c to your computer and use it in GitHub Desktop.
Download CVE notes from Grafeas API in Google Container registry

This is an script to download CVE notes from Grafeas. Could be really handy if you need to populate your Grafeas instance with some initial information

#This will insert all the CVE.json files in your grafeas instance
for entry in *.json
do
echo "$entry"
name="${entry/.json/}"
echo $name
URL="https://grafeas.url/v1beta1/projects/goog-vulnz/notes?note_id=$name"
echo $URL
curl -X POST $URL -H "accept: application/json" -H "Content-Type: application/json" -d @$entry
done
cve=(
'CVE-2015-2730'
'CVE-2016-6153'
)
#
# Count the number of possible testers.
# (Loop until we find an empty string.)
#
total=${#cve[*]}
for f in "${cve[@]}"
do
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $(gcloud auth print-access-token)" "https://containeranalysis.googleapis.com/v1beta1/projects/goog-vulnz/notes/$f" >> $f.json
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment