Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
54 lines (48 loc) · 1.85 KB

File metadata and controls

54 lines (48 loc) · 1.85 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import json
import os
import logging
from socketdev import socketdev
logging.basicConfig(level=logging.INFO)
sdk = socketdev(token=os.getenv("SOCKET_SECURITY_API_KEY"))
orgs = sdk.org.get()
if len(orgs) > 0:
org_id = None
org_slug = None
for org_key in orgs['organizations']:
org = orgs['organizations'][org_key]
org_id = org_key
org_slug = org['slug']
else:
print("Something went wrong with getting org info")
exit(1)
per_page = 100
response = sdk.repos.get(org_slug, per_page=per_page)
next_page = response.get("nextPage")
repos = response.get("results")
while next_page is not None and next_page != 0:
response = sdk.repos.get(org_slug, per_page=per_page, page=next_page)
next_page = response.get("nextPage")
repos.extend(response.get("results"))
if len(response.get("results", [])) == 0:
break
# repos = repos[:20]
head_full_scans_ids = []
for repo in repos:
head_full_scans_id = repo.get("head_full_scan_id")
if head_full_scans_id:
head_full_scans_ids.append(head_full_scans_id)
socket_results = {}
for head_full_scan_id in head_full_scans_ids:
full_scan_metadata = sdk.fullscans.metadata(org_slug=org_slug, full_scan_id=head_full_scan_id)
full_scan_result = {
"repo": full_scan_metadata.get("repo"),
"branch": full_scan_metadata.get("branch"),
"commit_hash": full_scan_metadata.get("commit_hash"),
"commit_message": full_scan_metadata.get("commit_message"),
"pull_request_url": full_scan_metadata.get("pull_request_url"),
"committers": full_scan_metadata.get("committers"),
"created_at": full_scan_metadata.get("created_at"),
"results": sdk.fullscans.stream(org_slug=org_slug, full_scan_id=head_full_scan_id) or None
}
socket_results[head_full_scan_id] = full_scan_result
print(json.dumps(socket_results, indent=4))
Morty Proxy This is a proxified and sanitized view of the page, visit original site.