lib.sqlalchemy.get_or_create_web_service_from_network_service - python examples

Here are the examples of the python api lib.sqlalchemy.get_or_create_web_service_from_network_service taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

0 View Complete Implementation : base.py
Copyright GNU General Public License v3.0
Author : lavalamp-
@websight_app.task(bind=True, base=NetworkServiceTask)
def populate_and_scan_web_services_from_network_service_scan(
        self,
        org_uuid=None,
        network_service_scan_uuid=None,
        network_service_uuid=None,
        use_ssl=None,
        order_uuid=None,
):
    """
    Populate all of the relevant web services as found through the given network service scan
    and kick off scanning for all of the web services.
    :param org_uuid: The UUID of the organization to kick scans off for.
    :param network_service_scan_uuid: The UUID of the network service scan that invoked this task.
    :param network_service_uuid: The UUID of the network service that was scanned.
    :param use_ssl: Whether the web services created from this task should be marked as HTTPS or not.
    :return: None
    """
    logger.info(
        "Now populating and scanning web services for network service scan %s."
        % (network_service_scan_uuid,)
    )
    domain_names = get_all_domains_for_ip_address(
        org_uuid=org_uuid,
        ip_address=self.network_service.ip_address.address,
        filter_by_latest=True,
    )
    task_sigs = []
    for domain_name in domain_names:
        web_service = get_or_create_web_service_from_network_service(
            network_service_uuid=network_service_uuid,
            db_session=self.db_session,
            host_name=domain_name,
            ip_address=self.network_service.ip_address.address,
            port=self.network_service.port,
            use_ssl=use_ssl,
        )
        task_sigs.append(scan_web_service.si(
            org_uuid=org_uuid,
            web_service_uuid=web_service.uuid,
            order_uuid=order_uuid,
        ))
    if len(task_sigs) == 0:
        logger.info(
            "No tasks created for scanning web services for network service scan %s."
            % (network_service_scan_uuid,)
        )
    group(task_sigs).apply_async()

0 View Complete Implementation : base.py
Copyright GNU General Public License v3.0
Author : lavalamp-
@websight_app.task(bind=True, base=NetworkServiceTask)
def inspect_virtual_hosts_for_network_service(
        self,
        org_uuid=None,
        network_service_scan_uuid=None,
        network_service_uuid=None,
        use_ssl=None,
        order_uuid=None,
):
    """
    Perform inspection for all of the virtual hosts astociated with the given network service as discovered
    during the given network service scan.
    :param org_uuid: The UUID of the organization to inspect virtual hosts on behalf of.
    :param network_service_scan_uuid: The UUID of the network service scan that this task is being
    invoked on behalf of.
    :param network_service_uuid: The UUID of the network service where the virtual hosts reside.
    :param use_ssl: Whether or not to interact with the remote service over SSL.
    :return: None
    """
    logger.info(
        "Now beginning inspection of virtual hosts found at network service %s for organization %s."
        % (network_service_uuid, org_uuid)
    )
    ip_address, port, protocol = self.get_endpoint_information()
    virtual_host_domains = get_virtual_hosts_from_network_service_scan(
        scan_uuid=network_service_scan_uuid,
        org_uuid=org_uuid,
    )
    logger.info(
        "A total of %s virtual hosts were found for network service %s."
        % (len(virtual_host_domains), network_service_uuid)
    )
    task_sigs = []
    scan_config = self.scan_config
    #TODO refactor this into invocations of scan_web_service
    for domain in virtual_host_domains:
        web_service = get_or_create_web_service_from_network_service(
            network_service_uuid=network_service_uuid,
            db_session=self.db_session,
            host_name=domain,
            ip_address=ip_address,
            port=port,
            use_ssl=use_ssl,
        )
        web_service_scan = create_new_web_service_scan(
            web_service_uuid=web_service.uuid,
            db_session=self.db_session,
        )
        self.commit_session()
        web_scan_task_sigs = []
        task_kwargs = {
            "org_uuid": org_uuid,
            "web_service_scan_uuid": web_service_scan.uuid,
            "web_service_uuid": web_service.uuid,
            "order_uuid": order_uuid,
        }
        if scan_config.web_app_enum_user_agents:
            web_scan_task_sigs.append(enumerate_user_agent_fingerprints_for_web_service.si(**task_kwargs))
        if scan_config.web_app_do_crawling:
            web_scan_task_sigs.append(crawl_web_service.si(**task_kwargs))
        else:
            web_scan_task_sigs.append(retrieve_landing_resource_for_web_service.si(**task_kwargs))
        if scan_config.web_app_take_screenshot:
            web_scan_task_sigs.append(screenshot_web_service.si(**task_kwargs))
        web_scan_task_sigs.append(create_report_for_web_service_scan.si(**task_kwargs))
        web_scan_task_sigs.append(apply_flags_to_web_service_scan.si(**task_kwargs))
        web_scan_task_sigs.append(update_web_service_scan_elasticsearch.si(**task_kwargs))
        web_scan_task_sigs.append(update_web_service_scan_completed.si(**task_kwargs))
        scanning_status_sig = update_web_service_scanning_status.si(
            web_service_uuid=web_service.uuid,
            scanning_status=False,
            order_uuid=order_uuid,
        )
        web_scan_task_sigs.append(scanning_status_sig)
        task_sigs.append(chain(web_scan_task_sigs))
    logger.info(
        "Now kicking off scans to yyyyze %s virtual hosts astociated with network service %s."
        % (len(task_sigs), network_service_uuid)
    )
    canvas_sig = group(task_sigs)
    canvas_sig.apply_async()