Here are the examples of the python api lib.sqlalchemy.check_network_service_scanning_status taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
0
View Complete Implementation : base.py
Copyright GNU General Public License v3.0
Author : lavalamp-
Copyright GNU General Public License v3.0
Author : lavalamp-
@websight_app.task(bind=True, base=NetworkServiceTask)
def scan_network_service(
self,
org_uuid=None,
network_service_uuid=None,
check_liveness=True,
liveness_cause=None,
order_uuid=None,
):
"""
Scan the given network service for all network service relevant data supported by Web Sight.
:param org_uuid: The UUID of the organization that owns the network service.
:param network_service_uuid: The UUID of the network service to scan.
:param check_liveness: Whether or not to check if the network service is alive.
:param liveness_cause: The reason that this network service task was configured to not check
for liveness.
network service fingerprinting.
:return: None
"""
logger.info(
"Now scanning network service %s for organization %s."
% (network_service_uuid, org_uuid)
)
should_scan = check_network_service_scanning_status(
db_session=self.db_session,
service_uuid=network_service_uuid,
update_status=True,
)
if not should_scan:
logger.info(
"Should not scan network service %s. Exiting."
% (network_service_uuid,)
)
network_service_scan = create_new_network_service_scan(
network_service_uuid=network_service_uuid,
db_session=self.db_session,
)
self.db_session.add(network_service_scan)
self.db_session.commit()
scan_config = self.scan_config
if check_liveness and scan_config.network_service_inspect_liveness:
is_alive = self.inspector.check_if_open()
if not is_alive:
logger.info(
"Network service at %s is not alive."
% (network_service_uuid,)
)
return
else:
liveness_model = NetworkServiceLivenessModel.from_database_model(
network_service_scan,
is_alive=True,
liveness_cause="network service scan liveness check"
)
liveness_model.save(org_uuid)
else:
liveness_model = NetworkServiceLivenessModel.from_database_model(
network_service_scan,
is_alive=True,
liveness_cause=liveness_cause,
)
liveness_model.save(org_uuid)
task_sigs = []
task_kwargs = {
"org_uuid": org_uuid,
"network_service_uuid": network_service_uuid,
"network_service_scan_uuid": network_service_scan.uuid,
"order_uuid": order_uuid,
}
if scan_config.scan_ssl_support:
supports_ssl = self.inspector.check_ssl_support()
if supports_ssl:
task_sigs.append(inspect_tcp_service_for_ssl_support.si(**task_kwargs))
if scan_config.network_service_fingerprint:
task_sigs.append(fingerprint_network_service.si(**task_kwargs))
task_sigs.append(create_report_for_network_service_scan.si(**task_kwargs))
task_sigs.append(update_network_service_scan_elasticsearch.si(**task_kwargs))
task_sigs.append(update_network_service_scan_completed.si(**task_kwargs))
scanning_status_sig = update_network_service_scanning_status.si(
network_service_uuid=network_service_uuid,
scanning_status=False,
order_uuid=order_uuid,
)
task_sigs.append(scanning_status_sig)
if scan_config.network_service_inspect_app:
task_sigs.append(inspect_service_application.si(**task_kwargs))
logger.info(
"Now kicking off all necessary tasks to scan network service %s."
% (network_service_uuid,)
)
canvas_sig = chain(task_sigs, link_error=scanning_status_sig)
self.finish_after(signature=canvas_sig)