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

adds new job #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
10 changes: 7 additions & 3 deletions src/commands/scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ parameters:
default: https://api.probely.com

steps:
- run: mkdir -p workspace
- run:
name: Probely - Starting Security Scan
command: |
Expand All @@ -32,7 +33,10 @@ steps:
echo "Please set the target id as a parameter for this orb."
exit 1
fi
curl -X POST \
-H "Authorization: JWT ${<< parameters.api_key >>}" \
<< parameters.api_url >>/targets/<< parameters.target_id >>/scan_now/
# Save the id to use in Vulnerabilities job
myid=$(curl << parameters.api_url >>/targets/<< parameters.target_id >>/scan_now/ \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: JWT ${<< parameters.api_key >>}"| jq '.id' | tr -d '"')
echo $myid > workspace/echo-output
exit $?
63 changes: 63 additions & 0 deletions src/commands/vulnerabilities.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
description: |
Get scan vulnerabilities.

parameters:
api_key:
default: PROBELY_API_KEY
description: |
The Probely API key to use, defined in the PROBELY_API_KEY environment variable.
type: env_var_name
api_url:
default: https://api.probely.com
description: The URL of Probely's API
type: string
target_id:
description: The id of the target (website) to scan.
type: string

steps:
- attach_workspace:
at: /tmp/workspace
- run:
name: Probely - Getting Security Scan Vulnerabilities
command: |
# Check if API key is set
if [ -z "${<< parameters.api_key >>}" ]; then
echo "NO PROBELY API KEY SET"
echo "Please set your API key in the << parameters.api_key >> variable"
exit 1
fi
# Check if target id is set
if [ -z "<< parameters.target_id >>" ]; then
echo "NO PROBELY TARGET ID SET"
echo "Please set the target id as a parameter for this orb."
exit 1
fi
# Load the id that we saved before
myid=$(cat /tmp/workspace/echo-output)
mystatus="started"
# For every minute verify if the scan is over
while [ "$mystatus" != completed ]
do
sleep 60s
mystatus=$(curl << parameters.api_url >>/targets/<< parameters.target_id >>/scans/$myid/ \
-X GET \
-H "Content-Type: application/json" \
-H "Authorization: JWT ${<< parameters.api_key >>}"| jq '.status' | tr -d '"')
echo status: $mystatus
done
# Get all vulnerabilities
myvulnerabilities=$(curl << parameters.api_url >>/targets/<< parameters.target_id >>/scans/$myid/ \
-X GET \
-H "Content-Type: application/json" \
-H "Authorization: JWT ${<< parameters.api_key >>}"| jq ' . | {lows:.lows,mediums:.mediums,highs:.highs}')
echo Vulnerabilities of your scan = $myvulnerabilities
# We want high vulnerabilities
myhighs=`echo $myvulnerabilities | jq '.highs'`
if [[ $myhighs -eq 0 ]]; then
echo "Everything is fine!";
exit $?
else
echo "We find high vulnerabilities in your scan!";
exit 1
fi
8 changes: 7 additions & 1 deletion src/examples/scan.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
description: Start the scan on a target (website) using Probely.
description: Start the scan on a target (website) using Probely and then get scan vulnerabilities.
usage:
orbs:
probely: probely/[email protected]
Expand All @@ -9,3 +9,9 @@ usage:
- probely/scan:
# Remember to set the PROBELY_API_KEY environment variable!
target_id: probely_target_id # Target id of the website to scan
- probely/vulnerabilities:
requires:
- probely/scan
# Remember to set the PROBELY_API_KEY environment variable!
target_id: probely_target_id # Target id of the website to scan

1 change: 1 addition & 0 deletions src/executors/alpine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ docker:
- image: cibuilds/base:latest
environment:
TERM: dumb
working_directory: /tmp
14 changes: 14 additions & 0 deletions src/jobs/vulnerabilities.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
description: Get scan vulnerabilities.
executor: alpine
parameters:
api_key:
default: PROBELY_API_KEY
description: |
The Probely API key to use, defined in the PROBELY_API_KEY environment variable.
type: env_var_name
target_id:
description: The id of the target (website) to scan.
type: string
steps:
- vulnerabilities:
target_id: << parameters.target_id >>