GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — socket-sdk-python/example-socket-export.py at main · SocketDev/socket-sdk-python

Expand file tree

/

example-socket-export.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
54 lines (48 loc) · 1.85 KB
/

example-socket-export.py

Copy path

File metadata and controls

54 lines (48 loc) · 1.85 KB
Raw
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))
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.