Last active
October 12, 2016 15:32
-
-
Save DinisCruz/9a7d3b0e0b6ccaeee96ff9dab3671c00 to your computer and use it in GitHub Desktop.
Misc veracode code snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function does_application_exist { | |
local app_name=$1 | |
local result=$(veracode_get_app_Id "$app_name") | |
if [[ "$result" != "" ]]; then | |
echo "it exists" | |
else | |
echo "it doesn't exist" | |
fi | |
} | |
function test2 { | |
clear | |
#veracode_create_app "abc" | |
#veracode_get_app_Id "webgoat" | |
#veracode_get_app_Id "abc" | |
does_application_exist "asd" | |
does_application_exist "webgoat" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function does_application_exist { | |
local app_name=$1 | |
local result=$(veracode_get_app_Id "$app_name") | |
if [[ "$result" != "" ]]; then | |
return 0 | |
else | |
return 1 | |
fi | |
} | |
function test2 { | |
clear | |
#veracode_create_app "abc" | |
#veracode_get_app_Id "webgoat" | |
#veracode_get_app_Id "abc" | |
if does_application_exist "asd" ; then echo "it exists" ; else echo "it don't exists" ; fi | |
if does_application_exist "webgoat" ; then echo "it exists" ; else echo "it don't exists" ; fi | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function veracode_get_app_Id { | |
local app_Name=$1 | |
local data="$(veracode_app_list)" # get data using curl | |
local formated_Data=$(echo "$data" | xmllint --format --noent --nonet -) # format it so that grep works | |
get_value_from_string "$formated_Data" "$app_Name" 2 # call get_value_from_string method | |
} | |
function get_value_from_string { | |
local data=$1 # text to search | |
local selector=$2 # value to find | |
local position=$3 # position to return | |
echo $(echo "$data" | \ | |
grep $selector | \ | |
awk -F"\"" "{print \$$position}") # feed value of data | |
# into grep which will pick the lines with $selector | |
# split strings and get value in $ position | |
} | |
function test2 { | |
clear | |
veracode_create_app "abc" | |
veracode_get_app_Id "webgoat" | |
veracode_get_app_Id "abc" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment