Skip to content

Commit

Permalink
Merge pull request #25 from GSA-TTS/gap-analysis
Browse files Browse the repository at this point in the history
Simple control-status script
  • Loading branch information
rahearn authored Aug 26, 2024
2 parents efc3b3c + f409f32 commit d84f5ea
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions scripts/control-status
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env bash

usage="
$0: Get rough list of implementation statuses from control markdown files
Usage:
$0 -h
$0 [-s INCLUDE_STATUS_LIST] [-i IGNORED_STATUS_LIST] [-m MARKDOWN_DIR]
Options:
-h: show help and exit
-s: status names to include, given as comma separated list. Defaults to all controls
-i: status names to ignore, given as comma separated list.
-m: Directory containing markdown files. Defaults to 'markdown' value in config, or 'control-statements'
Notes:
* passing '-s' will take precedence over '-i'
"

set -eo pipefail

source /app/bin/functions.sh
markdown=$(yaml_parse_value 'trestle-config.yaml' 'markdown' 'control-statements')
ignored=""
status=""

while getopts "hs:i:m:" opt; do
case "$opt" in
s)
status=`sed s/,/"\\\\\|"/g <<< ${OPTARG}`
;;
i)
ignored=`sed s/,/"\\\\\|"/g <<< ${OPTARG}`
;;
m)
markdown=${OPTARG}
;;
h)
echo "$usage"
exit 0
;;
esac
done

echo "==========================================================================="
echo "Gap report for /app/docs/$markdown"
echo "==========================================================================="

result=`grep -R "Implementation Status:" /app/docs/"$markdown"/* | cut -d':' -f1,3 | cut -d'/' -f5`
if [ "$status" != "" ]; then
result=`grep $status <<< $result`
elif [ "$ignored" != "" ]; then
result=`grep -v $ignored <<< $result`
fi

cat <<< $result
echo "==========================================================================="
echo "$(wc -l <<< $result) controls found"
cut -d':' -f2 <<< $result | sort | uniq -c
echo "==========================================================================="

0 comments on commit d84f5ea

Please sign in to comment.