Skip to content

Commit

Permalink
{dev} Added script to get vulns
Browse files Browse the repository at this point in the history
  • Loading branch information
adiffpirate committed Oct 5, 2023
1 parent d6d9001 commit cfaa29c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions dev/_utils/get_vulns.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

usage="$(basename "$0") [-h|a|d]
Get vulns from DGraph.
flags:
-h show this help text
-p get vulns from the past '-p' time (e.g. '1 hour')
"

# Defaults
args=""

while getopts ":h?a:p:" opt; do
case "$opt" in
h) echo "$usage" && exit 0 ;;
a) args=$OPTARG ;;
p) past_time=$OPTARG ;;
esac
done
# If an argument was passed but it was not the -p flag
if [ -n "$1" ] && [ -z "$past_time" ]; then
echo "$usage"
exit 1
fi

script_path=$(dirname "$0")

$script_path/query_dgraph.sh -t dql -q "{
results(func: gt(Vuln.updatedOn, \"$(date -Iseconds -d "-$past_time")\")) {
Vuln.name,
Vuln.evidence { Evidence.target }
}
}" | jq -r '.data.results | .[]'

0 comments on commit cfaa29c

Please sign in to comment.