Skip to content

Commit da523d1

Browse files
4383anatolystansler
authored andcommitted
feat: using braces to delimiting variable names (#292)
Enforce variable security by using braces on all variables of the do.sh script.
1 parent 4eba22d commit da523d1

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

do.sh

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,61 +28,61 @@ GRADLE_VERSION=4.2.0
2828

2929
# run only inside build container
3030
build_jar_inside() {
31-
if [ "$NAMESPACE" == "sandbox" ]; then
31+
if [ "${NAMESPACE}" == "sandbox" ]; then
3232
API="https://sandbox.sourcerer/api/commit"
3333
LOG="debug"
34-
elif [ "$NAMESPACE" == "staging" ]; then
34+
elif [ "${NAMESPACE}" == "staging" ]; then
3535
API="https://staging.sourcerer/api/commit"
3636
LOG="info"
37-
elif [ "$NAMESPACE" == "local" ]; then
37+
elif [ "${NAMESPACE}" == "local" ]; then
3838
API="http://localhost:3181"
3939
LOG="debug"
4040
else
4141
API="https://sourcerer.io/api/commit"
4242
LOG="info"
4343
fi
44-
gradle -Penv=$NAMESPACE -Plog=$LOG -Papi=$API build
44+
gradle -Penv=${NAMESPACE} -Plog=${LOG} -Papi=${API} build
4545
}
4646

4747
build_jar() {
48-
docker run -i -v $VOLUME:/home/gradle/app --workdir=/home/gradle/app \
49-
-e LOG=$LOG -e NAMESPACE=$NAMESPACE \
50-
gradle:$GRADLE_VERSION \
48+
docker run -i -v ${VOLUME}:/home/gradle/app --workdir=/home/gradle/app \
49+
-e LOG=${LOG} -e NAMESPACE=${NAMESPACE} \
50+
gradle:${GRADLE_VERSION} \
5151
./do.sh build_jar_inside
5252
}
5353

5454
build_prod_inside() {
55-
docker build -t $REPO_NAME .
55+
docker build -t ${REPO_NAME} .
5656
}
5757

5858
deploy() {
5959
source ./deploy/${NAMESPACE}_env.sh
6060
envsubst < ./deploy/sourcerer-app.yaml > /tmp/deploy.yaml
61-
kubectl --namespace=$NAMESPACE apply -f /tmp/deploy.yaml
61+
kubectl --namespace=${NAMESPACE} apply -f /tmp/deploy.yaml
6262
}
6363

6464
######################
6565

6666
run_jar() {
67-
docker run -i -v $VOLUME:/app --workdir=/app gradle:$GRADLE_VERSION \
67+
docker run -i -v ${VOLUME}:/app --workdir=/app gradle:${GRADLE_VERSION} \
6868
java -jar build/libs/app.jar
6969
}
7070

7171
run_prod() {
72-
docker run -i -p $PORT:80 $REPO_NAME
72+
docker run -i -p ${PORT}:80 ${REPO_NAME}
7373
}
7474

7575
push() {
76-
gcloud docker -- push $REPO_NAME
76+
gcloud docker -- push ${REPO_NAME}
7777
}
7878

7979
#---------------------#
8080
#----- Execution -----#
8181
#---------------------#
8282

83-
fn_exists $COMMAND
83+
fn_exists ${COMMAND}
8484
if [ $? -eq 0 ]; then
85-
$COMMAND $ARGUMENTS
85+
${COMMAND} ${ARGUMENTS}
8686
else
8787
echo "Command not found"
8888
fi

0 commit comments

Comments
 (0)