Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bugs and updated steps file #75

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions playbooks/besman-counterfit-0.0.1-playbook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,29 @@ function __besman_execute() {
if [ xx"$userinput" == xx"y" ];then
break;
else
echo "Steps playbook need to be completed before proceed."
__besman_echo_red "Steps playbook need to be completed before proceed."
fi
done

[[ -z $COUNTERFIT_ATTACKID ]] && __besman_echo_red "Attack Id is not set. Required. Please set it and try again." && return 1
[[ ! -f $BESMAN_DIR/tmp/attack_id ]] && __besman_echo_red "Could not find attack_id, please complete the assessment steps of counterfit" && return 1

[[ ! -f $BESMAN_COUNTERFIT_LOCAL_PATH/targets/results/${COUNTERFIT_ATTACKID}/run_summary.json ]] && __besman_echo_red "Counterfit result file not found. Execute the playbook to generate the results first." && flag="true"
local attack_id=$(cat $BESMAN_DIR/tmp/attack_id)

[[ -z $attack_id ]] && __besman_echo_red "Could not find attack_id, please complete the assessment steps of counterfit" && return 1

export COUNTERFIT_ATTACKID=$attack_id

# echo "attack id = $COUNTERFIT_ATTACKID"
# source ~/.bashrc

# [[ -z $COUNTERFIT_ATTACKID ]] && __besman_echo_red "Attack Id is not set. Required. Please set it and try again." && return 1

[[ ! -f $BESMAN_COUNTERFIT_LOCAL_PATH/counterfit/targets/results/${COUNTERFIT_ATTACKID}/run_summary.json ]] && __besman_echo_red "Counterfit result file not found. Execute the playbook to generate the results first." && flag="true"

duration=$SECONDS

export EXECUTION_DURATION=$duration
if [[ ! -f $BESMAN_COUNTERFIT_LOCAL_PATH/targets/results/${COUNTERFIT_ATTACKID}/run_summary.json ]]; then
if [[ ! -f $BESMAN_COUNTERFIT_LOCAL_PATH/counterfit/targets/results/${COUNTERFIT_ATTACKID}/run_summary.json ]]; then
export PLAYBOOK_EXECUTION_STATUS=failure
return 1
else
Expand All @@ -96,12 +107,12 @@ function __besman_execute() {
}

function __besman_prepare() {
echo "preparing data"
__besman_echo_yellow "preparing data"
EXECUTION_TIMESTAMP=$(date)
export EXECUTION_TIMESTAMP

source ~/.bashrc
cp -f $BESMAN_COUNTERFIT_LOCAL_PATH/targets/results/${COUNTERFIT_ATTACKID}/run_summary.json $DETAILED_REPORT_PATH
mkdir -p "$BESMAN_ASSESSMENT_DATASTORE_DIR/models/$BESMAN_ARTIFACT_NAME/dast"
cp -f $BESMAN_COUNTERFIT_LOCAL_PATH/counterfit/targets/results/${COUNTERFIT_ATTACKID}/run_summary.json $DETAILED_REPORT_PATH



Expand All @@ -128,8 +139,8 @@ function __besman_cleanup() {
unset "$var"
fi
done
[[ -f $BESMAN_DIR/tmp/attack_id ]] && rm "$BESMAN_DIR/tmp/attack_id"
sed -i "/export COUNTERFIT_ATTACKID=/d" ~/.bashrc
deactivate
}

function __besman_launch() {
Expand Down
11 changes: 8 additions & 3 deletions playbooks/besman-counterfit-0.0.1-steps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"\n",
"\n",
"### Steps\n",
"\n",
"Open a new terminal in your machine and run the below steps\n",
"\n",
"#### 1. Change directory to counterfit\n",
"`cd counterfit`\n",
"\n",
Expand Down Expand Up @@ -75,9 +78,11 @@
"#### 14. Deactivate Conda \n",
"`conda deactivate`\n",
"\n",
"#### 15. Export the attack id captured above\n",
"`echo \"export COUNTERFIT_ATTACKID=<ID captured above>\" >> ~/.bashrc`\n",
"`source ~/.bashrc`\n"
"#### 15. Saving the attack id captured above\n",
"\n",
"Run the below command in the terminal to save the attack id.\n",
"\n",
"`echo \"<attack id>\" >> $BESMAN_DIR/tmp/attack_id`\n"
]
}
],
Expand Down