Skip to content

Commit 4a83a1a

Browse files
committed
Add start scan example with reduced scope
1 parent baf817c commit 4a83a1a

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env python
2+
"""
3+
Start a scan using the API including reduced scope
4+
5+
To create an API token please go to the target settings in the user interface
6+
and under "Integrations" create one.
7+
8+
Alternatively to perform actions as a regular user check the login workflow in
9+
the create_target script.
10+
"""
11+
import requests
12+
from urllib.parse import urljoin
13+
14+
token = input("API Token:")
15+
headers = {"Authorization": "JWT {}".format(token)}
16+
17+
target_id = input("Target ID:")
18+
19+
api_base_url = "https://api.probely.com"
20+
scan_now_endpoint = urljoin(api_base_url, "targets/{target_id}/scan_now/")
21+
22+
reduced_scopes = []
23+
i = 1
24+
while reduced_scope := input("Reduced scope #{} (leave empty to stop):".format(i)):
25+
reduced_scopes.append(reduced_scope)
26+
i += 1
27+
28+
response = requests.post(
29+
scan_now_endpoint.format(target_id=target_id),
30+
headers=headers,
31+
json={
32+
"reduced_scopes": [{"url": reduced_scope} for reduced_scope in reduced_scopes]
33+
},
34+
)
35+

0 commit comments

Comments
 (0)