Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions build-lab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,58 @@ else
fi


echo -e "${LINE_ASCII_CONSOLE}\n"

# First check for Heimdall Lite repo
if ! ls -A ./dev_repos/heimdall2 &> /dev/null
then
echo -e "${VERB}Pulling down MITRE Heimdall Lite repository into the Environment.${RSET}"
git clone https://github.com/mitre/heimdall2 dev_repos/heimdall2
else
echo -e "${HIGH}MITRE Heimdall Lite repository is already present.${RSET}"
fi


echo -e "${LINE_ASCII_CONSOLE}\n"

# Then check for Node packages
if ! ls -A ./dev_repos/heimdall2/node_modules &> /dev/null
then
echo -e "${VERB}Installing required Node packages for MITRE Heimdall Lite repository.${RSET}"
cd dev_repos/heimdall2
yarn install --frozen-lockfile
cd ../..
else
echo -e "${HIGH}MITRE Heimdall Lite Node packages are already present.${RSET}"
fi


echo -e "${LINE_ASCII_CONSOLE}\n"

# First check for SAF CLI repo
if ! ls -A ./dev_repos/saf &> /dev/null
then
echo -e "${VERB}Pulling down MITRE SAF CLI repository into the Environment.${RSET}"
git clone https://github.com/mitre/saf dev_repos/saf
else
echo -e "${HIGH}MITRE SAF CLI repository is already present.${RSET}"
fi


echo -e "${LINE_ASCII_CONSOLE}\n"

# Then check for Node packages
if ! ls -A ./dev_repos/saf/node_modules &> /dev/null
then
echo -e "${VERB}Installing required Node packages for MITRE SAF CLI repository.${RSET}"
cd dev_repos/saf
npm ci
cd ../..
else
echo -e "${HIGH}MITRE SAF CLI Node packages are already present.${RSET}"
fi


echo -e "${LINE_ASCII_CONSOLE}\n"

echo -e "${VERB}Setting up the required Docker containers.${RSET}"
Expand Down
Empty file added dev_repos/.gitkeep
Empty file.
44 changes: 44 additions & 0 deletions test-lab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ echo -e "${LINE_ASCII_CONSOLE}\n"
echo -e "${VERB}Verify the script returns the following information:
* A \"MITRE SAF\" version number.
* An \"InSpec\" version number.
* The Git integrity of the Heimdall Lite and SAF CLI repositories.
* A Node package installation verification for the the Heimdall Lite and SAF CLI repositories.
* Two running containers:
- nginx
- redhat
Expand All @@ -25,6 +27,14 @@ containersRunning=$(docker ps)
containersMissing=''
verificationSuccessful=true

cd dev_repos/heimdall2 &> /dev/null
gitIntegrityHeimdall=$(git status)
yarnCheckHeimdall=$(yarn check --verify-tree)
cd ../saf &> /dev/null
gitIntegritySaf=$(git status)
yarnCheckSaf=$(yarn check --verify-tree)
cd ../.. &> /dev/null

if [ -z "${versionSaf}" ]
then
verificationSuccessful=false
Expand All @@ -41,6 +51,36 @@ else
statusInspec="${PASS}${versionInspec}${RSET}"
fi

if ! echo "${gitIntegrityHeimdall}" | grep --silent --extended-regexp 'working tree clean'
then
verificationSuccessful=false
statusGitHeimdall="${FAIL}The Heimdall Lite repository has mismatched files.${RSET}"
else
statusGitHeimdall="${PASS}The Heimdall Lite repository is in sync with remote.${RSET}"
fi
if ! echo "${yarnCheckHeimdall}" | grep --silent --extended-regexp 'success Folder in sync'
then
verificationSuccessful=false
statusNodeHeimdall="${FAIL}The Heimdall Lite repository has mismatched Node packages.${RSET}"
else
statusNodeHeimdall="${PASS}The Heimdall Lite repository has correct Node packages.${RSET}"
fi

if ! echo "${gitIntegritySaf}" | grep --silent --extended-regexp 'working tree clean'
then
verificationSuccessful=false
statusGitSaf="${FAIL}The SAF CLI repository has mismatched files.${RSET}"
else
statusGitSaf="${PASS}The SAF CLI repository is in sync with remote.${RSET}"
fi
if ! echo "${yarnCheckSaf}" | grep --silent --extended-regexp 'success Folder in sync'
then
verificationSuccessful=false
statusNodeSaf="${FAIL}The SAF CLI repository has mismatched Node packages.${RSET}"
else
statusNodeSaf="${PASS}The SAF CLI repository has correct Node packages.${RSET}"
fi

if ! echo "${containersRunning}" | grep --silent --extended-regexp 'nginx'
then
verificationSuccessful=false
Expand All @@ -55,6 +95,10 @@ fi
echo -e "${HIGH}* MITRE SAF Version:${RSET} ${statusSaf}"
echo -e "${HIGH}* InSpec Version:${RSET} ${statusInspec}"
echo -e "${HIGH}* Docker is running the following container(s):${RSET}"
echo -e "${HIGH}* Heimdall repository integrity:${RSET} ${statusGitHeimdall}"
echo -e "${HIGH}* Heimdall Node verification:${RSET} ${statusNodeHeimdall}"
echo -e "${HIGH}* SAF CLI repository integrity:${RSET} ${statusGitSaf}"
echo -e "${HIGH}* SAF CLI Node verification:${RSET} ${statusNodeSaf}"
echo "${containersRunning}" | \
GREP_COLORS='mt=0;32' \
grep --color=always --extended-regexp \
Expand Down