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 syntax based on shellcheck (#27) #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
62 changes: 31 additions & 31 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/sh
#!/bin/bash
Copy link
Contributor

@konstruktoid konstruktoid Mar 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this will break unless bash is added to the image.

$ git diff run.sh 
diff --git a/run.sh b/run.sh
index dcbcdf2..a8833ca 100755
--- a/run.sh
+++ b/run.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 current_time=$(date "+%Y.%m.%d-%H.%M")
 if [[ -z $upload ]]
$ docker run -ti --entrypoint=/bin/sh flan_scan
/ # ls -l /bin/bash
ls: /bin/bash: No such file or directory
/ # exit
$ make html
docker run --name flan_1585682201 -v "xxx/Github/flan/shared:/shared:Z" -e format=html flan_scan
standard_init_linux.go:211: exec user process caused "no such file or directory"
make: *** [html] Error 1


current_time=$(date "+%Y.%m.%d-%H.%M")
if [[ -z $upload ]]
upload="${upload:-}"
current_time="$(date "+%Y.%m.%d-%H.%M")"
if [ -z "$upload" ]
then
root_dir=/shared/
else
Expand All @@ -10,48 +11,47 @@ else
mkdir /reports
fi

report_extension="tex"
report_extension="${format:-tex}"

if [[ ! -z $format ]]
then
report_extension=$format
fi
xml_dir="xml_files/$current_time"
report_file="reports/report_$current_time.$report_extension"
report_file_path="${root_dir}${report_file}"

xml_dir=xml_files/$current_time
report_file=reports/report_$current_time.$report_extension

function upload {
if [[ -z $upload ]]
upload() {
if [ -z "$upload" ]
then
return
elif [ $upload = "aws" ]
fi
if [ "$upload" = "aws" ]
then
python /aws_push.py $1
elif [ $upload = "gcp" ]
python /aws_push.py "$1"
elif [ "$upload" = "gcp" ]
then
python /gcp_push.py $1
python /gcp_push.py "$1"
fi
}

function get_filename(){
echo $1 | tr / -
get_filename() {
echo "$1" | tr / -
}

mkdir $root_dir$xml_dir
mkdir -p "$root_dir$xml_dir"
while IFS= read -r line
do
current_time=$(date "+%Y.%m.%d-%H.%M.%S")
filename=$(get_filename $line)".xml"
nmap -sV -oX $root_dir$xml_dir/$filename -oN - -v1 $@ --script=vulners/vulners.nse $line
upload $xml_dir/$filename
current_time="$(date "+%Y.%m.%d-%H.%M.%S")"
filename="$(get_filename "$line").xml"
# $@ without quotes required to expand additional options
# shellcheck disable=SC2068
nmap -sV -oX "$root_dir$xml_dir/$filename" -oN - -v1 $@ --script=vulners/vulners.nse "$line"
upload "$xml_dir/$filename"
done < /shared/ips.txt

python /output_report.py $root_dir$xml_dir $root_dir$report_file /shared/ips.txt
if [[ $report_extension = "tex" ]]
python /output_report.py "$root_dir$xml_dir" "$report_file_path" /shared/ips.txt
if [[ "$report_extension" = "tex" ]]
then
sed -i 's/_/\\_/g' $root_dir$report_file
sed -i 's/\$/\\\$/g' $root_dir$report_file
sed -i 's/#/\\#/g' $root_dir$report_file
sed -i 's/%/\\%/g' $root_dir$report_file
sed -i 's/_/\\_/g' "$report_file_path"
sed -i 's/\$/\\\$/g' "$report_file_path"
sed -i 's/#/\\#/g' "$report_file_path"
sed -i 's/%/\\%/g' "$report_file_path"
fi
upload $report_file
upload "$report_file_path"