From 9abfaeec583753642ab28523fd09ad739404444c Mon Sep 17 00:00:00 2001 From: stas Date: Mon, 25 Oct 2021 12:36:53 -0700 Subject: [PATCH] . --- src/api-service/__app__/instance_config/__init__.py | 10 +++++++--- src/api-service/__app__/onefuzzlib/azure/nsg.py | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/api-service/__app__/instance_config/__init__.py b/src/api-service/__app__/instance_config/__init__.py index 1aaf653f3c7..43da667d879 100644 --- a/src/api-service/__app__/instance_config/__init__.py +++ b/src/api-service/__app__/instance_config/__init__.py @@ -13,7 +13,6 @@ from ..onefuzzlib.config import InstanceConfig from ..onefuzzlib.endpoint_authorization import call_if_user, can_modify_config from ..onefuzzlib.request import not_ok, ok, parse_request -from ..onefuzzlib.workers.scalesets import Scaleset def get(req: func.HttpRequest) -> func.HttpResponse: @@ -49,14 +48,19 @@ def post(req: func.HttpRequest) -> func.HttpResponse: if update_nsg: nsgs = list_nsgs() for nsg in nsgs: - logging.info("Checking if nsg: %s (%s) owned by OneFuzz" % (nsg.location, nsg.name)) + logging.info( + "Checking if nsg: %s (%s) owned by OneFuzz" % (nsg.location, nsg.name) + ) if is_one_fuzz_nsg(nsg.location, nsg.name): result = set_allowed(nsg.location, request.config.proxy_nsg_config) if isinstance(result, Error): return not_ok( Error( code=ErrorCode.UNABLE_TO_CREATE, - errors=["Unable to update nsg %s due to %s" % (nsg.location, result)], + errors=[ + "Unable to update nsg %s due to %s" + % (nsg.location, result) + ], ), context="instance_config_update", ) diff --git a/src/api-service/__app__/onefuzzlib/azure/nsg.py b/src/api-service/__app__/onefuzzlib/azure/nsg.py index 4d828936167..4098ad94860 100644 --- a/src/api-service/__app__/onefuzzlib/azure/nsg.py +++ b/src/api-service/__app__/onefuzzlib/azure/nsg.py @@ -105,9 +105,11 @@ def update_nsg(nsg: NetworkSecurityGroup) -> Union[None, Error]: def ok_to_delete(active_regions: Set[Region], nsg_region: str, nsg_name: str) -> bool: return nsg_region not in active_regions and nsg_region == nsg_name + def is_one_fuzz_nsg(nsg_region: str, nsg_name: str) -> bool: return nsg_region == nsg_name + def delete_nsg(name: str) -> bool: # NSG can be only deleted if no other resource is associated with it resource_group = get_base_resource_group()