From 6eff549a4cf6eca040f4ed3724ecce1bc578da18 Mon Sep 17 00:00:00 2001 From: Rafal Walczyna Date: Thu, 2 Apr 2020 09:59:47 +0200 Subject: [PATCH] [Tools] Add script for SAM with SVACE 3.0 engine Change-Id: I421dad53fc79ae0ab45d26b4b9c75af0f2a1f725 Signed-off-by: Rafal Walczyna --- tools/sam/README.md | 12 +++++-- tools/sam/run_sam.sh | 2 +- tools/sam/run_sam_svace3.0.sh | 64 +++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 4 deletions(-) create mode 100755 tools/sam/run_sam_svace3.0.sh diff --git a/tools/sam/README.md b/tools/sam/README.md index 079c59db..d220f325 100644 --- a/tools/sam/README.md +++ b/tools/sam/README.md @@ -19,11 +19,11 @@ with gbs profile and one of the parameter below: i.e: - webapi-plugins(SAM)$ tools/sam/run_sam.sh -a 55unified + webapi-plugins(SAM)$ tools/sam/run_sam.sh -a unified Analysis Report will be located in output/html/ directory. -Script assumes that `55unified` profile exists in ~/.gbs.conf file. +Script assumes that `unified` profile exists in ~/.gbs.conf file. # Links @@ -31,4 +31,10 @@ Script assumes that `55unified` profile exists in ~/.gbs.conf file. [Getting Started](https://github.sec.samsung.net/RS7-Architectural-Refactoring/SAM-Tools/wiki/Getting-Started) -[SAM Metric](https://github.sec.samsung.net/RS7-Architectural-Refactoring/SAM-Tools/wiki/Metrics-in-SAM) \ No newline at end of file +[SAM Metric](https://github.sec.samsung.net/RS7-Architectural-Refactoring/SAM-Tools/wiki/Metrics-in-SAM) + +# Troubleshooting + +In case of problems with processing files - too small Lines of Code number - use `tools/sam/run_sam_svace3.0.sh`. + +More details [here](https://github.sec.samsung.net/RS7-Architectural-Refactoring/SAM-Tools/issues/708). \ No newline at end of file diff --git a/tools/sam/run_sam.sh b/tools/sam/run_sam.sh index 01de705b..b43e7d99 100755 --- a/tools/sam/run_sam.sh +++ b/tools/sam/run_sam.sh @@ -3,7 +3,7 @@ export WEBAPI_DIRECTORY="${PWD}" DIR_NAME="${PWD##*/}" -export BUILD_PROFILE="55unified" +export BUILD_PROFILE="unified" PATH_TO_SAM_TOOLS="$WEBAPI_DIRECTORY/../SAM-Tools" diff --git a/tools/sam/run_sam_svace3.0.sh b/tools/sam/run_sam_svace3.0.sh new file mode 100755 index 00000000..e5e0d192 --- /dev/null +++ b/tools/sam/run_sam_svace3.0.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +WEBAPI_DIRECTORY="${PWD}" +DIR_NAME="${PWD##*/}" + +BUILD_PROFILE="unified" + +PATH_TO_SAM_TOOLS="$WEBAPI_DIRECTORY/../SAM-Tools" + +if [ "$PWD" != "$(git rev-parse --show-toplevel)" ] ; then + echo "Script must be executed from root directory of git repository" + exit 0 +fi + +function generate { + if [ -z "$1" ] ; then + echo "No gbs profile provided, using $BUILD_PROFILE" + else + BUILD_PROFILE="$1" + fi + + if [ ! -f "$PATH_TO_SAM_TOOLS/hub/code-analysis-hub/scap/plugins/scra/svace-3.0.0-x64-linux/bin/svace" ] ; then + echo "ERROR: SVACE binary not found in $PATH_TO_SAM_TOOLS/hub/code-analysis-hub/scap/plugins/scra/svace-3.0.0-x64-linux/bin/svace" + exit 0 + fi + "$PATH_TO_SAM_TOOLS/hub/code-analysis-hub/bin/scap" init + "$PATH_TO_SAM_TOOLS/hub/code-analysis-hub/scap/plugins/scra/svace-3.0.0-x64-linux/bin/svace" init + "$PATH_TO_SAM_TOOLS/hub/code-analysis-hub/scap/plugins/scra/svace-3.0.0-x64-linux/bin/svace" scra-params SCRA_RUNLINK_DYNAMIC_LIBS on + "$PATH_TO_SAM_TOOLS/hub/code-analysis-hub/scap/plugins/scra/svace-3.0.0-x64-linux/bin/svace" scra-params SCRA_BUILD_IGNORE_MACRO_METRIC on + + mkdir -p ".scap/workspace/scra/" + "$PATH_TO_SAM_TOOLS/hub/code-analysis-hub/scap/plugins/scra/svace-3.0.0-x64-linux/bin/svace" build gbs build -A armv7l --profile="$BUILD_PROFILE" --include-all + + "$PATH_TO_SAM_TOOLS/hub/code-analysis-hub/scap/plugins/scra/svace-3.0.0-x64-linux/bin/svace" scra-analyze -T -o ".scap/workspace/scra/" + + $WEBAPI_DIRECTORY/tools/sam/run_sam.sh -g "$BUILD_PROFILE" +} + +function usage { +echo "Usage: +$0 GBS_PROFILE + +Be sure that you have SVACE 3.0 engine in your SAM-Tools directory. +1. Download the latest version of SVACE3.0 engine from at http://code.sec.samsung.net/ahub/resources/scra/dev/to-sam/ +2. Extract it to /hub/code-analysis-hub/scap/plugins/scra/ +" +} + +function main { + LOOP=false + while getopts "h" opt; do + LOOP=true + case "$opt" in + "h") + usage + ;; + esac + done + if [ "$LOOP" = false ] ; then + generate $@ + fi +} + +main "$@" -- 2.34.1