Skip to content

Commit 50b53d1

Browse files
authored
fix(python): add timeouts for requests
fixes bandit sast medium findings
1 parent 37f3fac commit 50b53d1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

xingdumper.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@
5454

5555
# retrieve company id from the api
5656
postdata1 = {"operationName":"EntitySubpage","variables":{"id":company,"moduleType":"employees"},"query":"query EntitySubpage($id: SlugOrID!, ) {\n entityPageEX(id: $id) {\n ... on EntityPage {\n slug\n title\n context {\n companyId\n }\n }\n }\n}\n"}
57-
r = requests.post(api, data=json.dumps(postdata1), headers=headers, cookies=cookies_dict)
57+
r = requests.post(api, data=json.dumps(postdata1), headers=headers, cookies=cookies_dict, timeout=10)
5858
response1 = r.json()
5959

6060
companyID = response1["data"]["entityPageEX"]["context"]["companyId"]
6161

6262
# retrieve employee information from the api based on previously obtained company id
6363
postdata2 = {"operationName":"Employees","variables":{"consumer":"","id":companyID,"first":count,"query":{"consumer":"web.entity_pages.employees_subpage","sort":"CONNECTION_DEGREE"}},"query":"query Employees($id: SlugOrID!, $first: Int, $after: String, $query: CompanyEmployeesQueryInput!, $consumer: String! = \"\", $includeTotalQuery: Boolean = false) {\n company(id: $id) {\n id\n totalEmployees: employees(first: 0, query: {consumer: $consumer}) @include(if: $includeTotalQuery) {\n total\n }\n employees(first: $first, after: $after, query: $query) {\n total\n edges {\n node {\n profileDetails {\n id\n firstName\n lastName\n displayName\n gender\n pageName\n location {\n displayLocation\n }\n occupations {\n subline\n }\n }\n }\n }\n }\n }\n}\n"}
64-
r2 = requests.post(api, data=json.dumps(postdata2), headers=headers, cookies=cookies_dict)
64+
r2 = requests.post(api, data=json.dumps(postdata2), headers=headers, cookies=cookies_dict, timeout=10)
6565
response2 = r2.json()
6666

6767
if not args.quiet:
@@ -118,7 +118,7 @@
118118
if args.full:
119119
# dump additional contact details for each employee. Most often is "None", so no default api queries for this data
120120
postdata3 = {"operationName":"getXingId","variables":{"profileId":pagename},"query":"query getXingId($profileId: SlugOrID!, $actionsFilter: [AvailableAction!]) {\n profileModules(id: $profileId) {\n __typename\n xingIdModule(actionsFilter: $actionsFilter) {\n xingId {\n status {\n localizationValue\n __typename\n }\n __typename\n }\n __typename\n ...xingIdContactDetails\n }\n }\n}\n\nfragment xingIdContactDetails on XingIdModule {\n contactDetails {\n business {\n email\n fax {\n phoneNumber\n }\n mobile {\n phoneNumber\n }\n phone {\n phoneNumber\n }\n }\n __typename\n }\n __typename\n}\n"}
121-
r3 = requests.post(api, data=json.dumps(postdata3), headers=headers, cookies=cookies_dict)
121+
r3 = requests.post(api, data=json.dumps(postdata3), headers=headers, cookies=cookies_dict, timeout=10)
122122
response3 = r3.json()
123123
try:
124124
# try to extract contact details

0 commit comments

Comments
 (0)