Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def run(self, params=None):
if params is None:
params = {}
body = {'url': params[Input.URL]}
if params[Input.PUBLIC]:
body['public'] = 'on'
response = requests.post(f'{self.connection.server}/scan', headers=self.connection.headers, data=body)
try:
out = response.json()
except json.decoder.JSONDecodeError:
raise PluginException(cause="Received an unexpected response from the Urlscan API. ",
assistance=f"(non-JSON or no response was received). Response was: {response.text}")
if 'uuid' in out:
return {Output.SCAN_ID: out['uuid']}
if 'status' in out:
if out['status'] == 401:
def run(self, params=None):
if params is None:
params = {}
body = {'url': params[Input.URL]}
if params[Input.PUBLIC]:
body['public'] = 'on'
response = requests.post(f'{self.connection.server}/scan', headers=self.connection.headers, data=body)
try:
out = response.json()
except json.decoder.JSONDecodeError:
raise PluginException(cause="Received an unexpected response from the Urlscan API. ",
assistance=f"(non-JSON or no response was received). Response was: {response.text}")
if 'uuid' in out:
return {Output.SCAN_ID: out['uuid']}
if 'status' in out:
if out['status'] == 401:
# {'message': "No API key supplied. Send the key using the 'API-Key' header", 'status': 401}