-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support list unroll to hash function
- Added an initial implementation of the unroll(hash,'key','value') function for JMESPath. Still not sure what it should be called, but the logic should word. Closes #5. - Add an online appinspect checking script.
- Loading branch information
Showing
3 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ venv | |
.latest_release | ||
build | ||
dist | ||
app_inspect*.json | ||
|
||
# Just stuff to avoid | ||
*.zip | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/bin/bash | ||
# Really?!?! Why did I have to write this myself? c'mon Splunk!! | ||
USERNAME=${USERNAME-lalleman} | ||
|
||
# jp - jmsepath CLI tool. | ||
|
||
if [[ ! -x $(command -v jp) ]] | ||
then | ||
echo "Install the 'jp' command line too. https://github.com/jmespath/jp" | ||
exit 1 | ||
fi | ||
|
||
set -e | ||
|
||
t=$(mktemp) | ||
|
||
if [[ -z $token ]] | ||
then | ||
echo "No token found. Logging in." | ||
curl -s -X GET \ | ||
-u "$USERNAME" \ | ||
--url "https://api.splunk.com/2.0/rest/login/splunk" -o "$t" | ||
cat "$t" | ||
echo | ||
token=$(jp -f "$t" -u data.token) | ||
echo "To reuse the token later, run this in your shell:" | ||
echo "export token=$token" | ||
fi | ||
|
||
echo "Uploading $(<.latest_release) to AppInspect via APIs" | ||
curl -s -X POST \ | ||
-H "Authorization: bearer $token" \ | ||
-H "Cache-Control: no-cache" \ | ||
-F "app_package=@\"$(<.latest_release)\"" \ | ||
--url "https://appinspect.splunk.com/v1/app/validate" -o "$t" | ||
cat "$t" | ||
echo | ||
request_id=$(jp -f "$t" -u request_id) | ||
echo "Request id: $request_id" | ||
|
||
while true | ||
do | ||
curl -s -X GET \ | ||
-H "Authorization: bearer $token" \ | ||
-H "Cache-Control: no-cache" \ | ||
--url "https://appinspect.splunk.com/v1/app/validate/status/${request_id}" -o "$t" | ||
|
||
status=$(jp -f "$t" -u status) | ||
|
||
echo "STATUS: $status" | ||
#cat "$t" | ||
|
||
if [[ $status = "SUCCESS" ]]; then break; fi | ||
|
||
sleep 10 | ||
|
||
done | ||
|
||
RPT="app_inspect.report-${request_id}.json" | ||
echo "Downloading report." | ||
curl -s -X GET -H "Authorization: bearer $token" \ | ||
-H "Cache-Control: no-cache" \ | ||
--url "https://appinspect.splunk.com/v1/app/report/${request_id}" \ | ||
-o "${RPT}" | ||
|
||
echo "Summary" | ||
jp -f "$RPT" 'reports[0].{name:app_name,description:app_description,author:app_author,version:app_version,hash:app_hash,appinspect_ver:run_parameters.appinspect_version}' | ||
|
||
jp -f "$RPT" 'reports[0].summary' | ||
|
||
jp -f "$RPT" "reports[0].groups[].checks[].{name:name,description:description,result:result} | [?result!='success' && result!='not_applicable'] | [][name, description, result]" | ||
|
||
echo "See $RPT" |
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