Skip to content

Commit

Permalink
Fix typos in comments and add explanations about usage of tee
Browse files Browse the repository at this point in the history
Co-authored-by: Pushkar Joglekar <[email protected]>
  • Loading branch information
mtardy and PushkarJ committed Jan 22, 2023
1 parent e61ffa9 commit ef13af4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions sig-security-tooling/cve-feed/hack/fetch-cve-feed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@ set -o nounset
set -o errexit
set -o pipefail

#install python-pip3
# install python-pip3
apt-get update
apt-get install -y python3-pip

#install requests module
# install requests module
pip3 install requests

#python script to generate official-cve-feed.json
# python script to generate official-cve-feed.json
# tee duplicates the output from the script to stdout for logs and the JSON file
python3 fetch-official-cve-feed.py | tee official_cve_feed.json

#function to calculate the hash value of official-cve-feed.json
# function to calculate the hash value of official-cve-feed.json
calculate_hash(){
if command -v shasum >/dev/null 2>&1; then
cat "$@" | shasum -a 256 | cut -d' ' -f1
Expand All @@ -39,12 +40,13 @@ calculate_hash(){
fi
}

#check if official-cve-feed.json blob exists in the bucket
# check if official-cve-feed.json blob exists in the bucket
set -e
EXIT_CODE=0
gsutil ls gs://k8s-cve-feed/official-cve-feed.json >/dev/null 2>&1 || EXIT_CODE=$?

#fetch the hash value of existing official-cve-feed.json json, if differs then upload the new cve feed data to the existing blob.
# fetch the hash value of existing official-cve-feed.json json, if differs then
# upload the new cve feed data to the existing blob.
if [[ $EXIT_CODE -eq 1 ]]; then
gsutil cp official-cve-feed.json gs://k8s-cve-feed
calculate_hash official-cve-feed.json > cve-feed-hash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
cve['_kubernetes_io']['issue_number'] = item['number']
cve['content_text'] = item['body']
cve['date_published'] = item['created_at']
# This because some CVEs were titled "CVE-XXXX-XXXX - Something" instead of
# This is because some CVEs were titled "CVE-XXXX-XXXX - Something" instead of
# "CVE-XXXX-XXXX: Something" on GitHub (see https://github.com/kubernetes/kubernetes/issues/60813).
title = item['title'].replace(' -', ':')
# This splits the CVE into its ID and the description/name, however some are in the following forms:
Expand Down

0 comments on commit ef13af4

Please sign in to comment.