From 0eaa4ff3d0dd36cd1d200662e5fc9803cc2fd7be Mon Sep 17 00:00:00 2001 From: naveen <172697+naveensrinivasan@users.noreply.github.com> Date: Thu, 11 Mar 2021 21:27:55 +0000 Subject: [PATCH] Fix - Made the results.json wellformed from cron Fixed the results.json to be wellformed from the cron job. Changed the docker image from gsutil to cloudsdk:slim to `sed` binary which is being used with the cron.sh --- Dockerfile.gsutil | 2 +- cron/cron.sh | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile.gsutil b/Dockerfile.gsutil index 8040bb54..46b1f13a 100644 --- a/Dockerfile.gsutil +++ b/Dockerfile.gsutil @@ -26,7 +26,7 @@ ARG TARGETOS ARG TARGETARCH RUN CGO_ENABLED=0 go build -a -tags netgo -ldflags '-w -extldflags "-static"' -o /out/scorecard . -FROM gcr.io/cloud-builders/gsutil +FROM gcr.io/google.com/cloudsdktool/cloud-sdk:slim COPY --from=build /out/scorecard / COPY ./cron/ /cron/ ENTRYPOINT [ "/scorecard" ] diff --git a/cron/cron.sh b/cron/cron.sh index e04b4613..bd058b7a 100755 --- a/cron/cron.sh +++ b/cron/cron.sh @@ -17,7 +17,7 @@ SOURCE="${BASH_SOURCE[0]}" input=$(dirname "$SOURCE")/projects.txt output=$(date +"%m-%d-%Y").json touch "$output" -curl https://raw.githubusercontent.com/ossf/scorecard/main/cron/projects.txt >projects.txt +echo "{ \"results\": [" >> "$output" # sort and uniqify these, in case there are duplicates # shellcheck disable=SC2002 @@ -28,7 +28,10 @@ while read -r proj; do fi echo "$proj" ../scorecard --repo="$proj" --show-details --format=json >> "$output" + echo "," >> "$output" done <<< "$projects" +sed -i '$d' "$output" # removing the trailing comma which will be last line. +echo "]}" >> "$output" gsutil cp "$output" gs://"$GCS_BUCKET" # Also copy the most recent run into a "latest.json" file