How to use the urlscan.komand_urlscan.actions.get_scan_results.schema.Input.SCAN_ID function in urlscan

To help you get started, we’ve selected a few urlscan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rapid7 / insightconnect-plugins / urlscan / komand_urlscan / actions / get_scan_results / action.py View on Github external
def run(self, params={}):
        response = requests.get(f"{self.connection.server}/result/{params[Input.SCAN_ID]}",
                                headers=self.connection.headers)

        try:
            js = response.json()
        except json.JSONDecodeError as e:
            raise PluginException(cause="Received an unexpected response from the Urlscan API. ",
                                  assistance=f"(non-JSON or no response was received). Response was: {response.text}",
                                  data=e)

        # Non-200 status code responses should have a JSON payload containing message, description, and status code
        # Display those values to the user for assistance purposes.
        # See: https://urlscan.io/about-api/#errors
        if response.status_code != 200:
            if response.status_code == 404:
                raise PluginException(cause="The requested scan results were not found. ",
                                      assistance="If you are running this action directly after a new scan, "