2020-07-24 10:08:28 +00:00
|
|
|
#!/bin/bash
|
|
|
|
[ -f /.dockerenv ] || { echo "please run in supplied container"; exit 1; }
|
|
|
|
set -e; source environment
|
|
|
|
|
|
|
|
build_dir="${BUILD_DIR?}"
|
|
|
|
audit_dir="${BUILD_DIR?}/audit"
|
|
|
|
buildroot_dir="${build_dir}/buildroot"
|
|
|
|
heads_dir="${build_dir}/heads"
|
|
|
|
|
|
|
|
mkdir -p ${audit_dir}
|
|
|
|
|
2020-07-24 20:18:53 +00:00
|
|
|
printf "Generating OS source tar hashes... "
|
2020-07-24 10:08:28 +00:00
|
|
|
openssl sha256 -r ${buildroot_dir}/dl/*/*.tar.* > ${audit_dir}/os_src_hashes.txt
|
2020-07-24 20:18:53 +00:00
|
|
|
echo "done"
|
|
|
|
|
|
|
|
printf "Generating firmware source tar hashes... "
|
2020-07-24 10:08:28 +00:00
|
|
|
openssl sha256 -r ${heads_dir}/packages/* > ${audit_dir}/fw_src_hashes.txt
|
2020-07-24 20:18:53 +00:00
|
|
|
echo "done"
|
2020-07-24 10:08:28 +00:00
|
|
|
|
2020-07-24 20:18:53 +00:00
|
|
|
printf "Generating combined/uniqued source tar hashes... "
|
2020-07-24 10:08:28 +00:00
|
|
|
cat ${audit_dir}/os_src_hashes.txt \
|
|
|
|
${audit_dir}/fw_src_hashes.txt \
|
|
|
|
| sed 's/ .*\// /g' \
|
|
|
|
| awk '{ t = $1; $1 = $2; $2 = t; print;}' \
|
|
|
|
| sort \
|
|
|
|
| uniq \
|
2020-07-24 20:18:53 +00:00
|
|
|
> ${audit_dir}/all_hashes.txt
|
|
|
|
echo "done"
|
|
|
|
|
|
|
|
printf "Generating buildroot package stats... "
|
|
|
|
( cd ${buildroot_dir} \
|
|
|
|
&& support/scripts/pkg-stats --json ${audit_dir}/pkg-stats.json \
|
|
|
|
> /dev/null 2>&1
|
|
|
|
)
|
|
|
|
echo "done"
|
2020-07-24 10:08:28 +00:00
|
|
|
|
2020-07-24 20:18:53 +00:00
|
|
|
printf "Generating NIST CPE definitions... "
|
|
|
|
( cd ${buildroot_dir} && make cpe-info > /dev/null 2>&1 )
|
2020-07-24 10:08:28 +00:00
|
|
|
cp ${buildroot_dir}/output/cpe-manifest.csv ${audit_dir}/cpe-manifest.csv
|
2020-07-24 20:18:53 +00:00
|
|
|
echo "done"
|
|
|
|
|
|
|
|
printf "Generating license usage reports... "
|
|
|
|
( cd ${buildroot_dir} && make legal-info > /dev/null 2>&1 )
|
2020-07-24 10:08:28 +00:00
|
|
|
cp -R ${buildroot_dir}/output/legal-info ${audit_dir}/legal-info
|
2020-07-24 20:18:53 +00:00
|
|
|
echo "done"
|
|
|
|
|
|
|
|
echo "Wrote: build/audit/os_src_hashes.txt"
|
|
|
|
echo "Wrote: build/audit/fw_src_hashes.txt"
|
|
|
|
echo "Wrote: build/audit/all_hashes.txt"
|
|
|
|
echo "Wrote: build/audit/pkg-stats.json"
|
|
|
|
echo "Wrote: build/audit/cpe-manifest.cve"
|
|
|
|
echo "Wrote: build/audit/legal-info"
|
|
|
|
|
|
|
|
total_cves=$(cat build/audit/pkg-stats.json | jq '.stats["total-cves"]')
|
|
|
|
printf "Total CVEs: ${total_cves}"
|