Exemplo n.º 1
0
    def DescribeExplicit(self, args):
        """Describe settings of organization."""

        path = GenerateParent(args) + 'securityCenterSettings'

        try:
            request_message = self.message_module.SecuritycenterOrganizationsGetSecurityCenterSettingsRequest(
                name=path)
            return self.service_client.organizations.GetSecurityCenterSettings(
                request_message)
        except exceptions.HttpNotFoundError:
            raise scc_exceptions.SecurityCenterSettingsException(
                'Invalid argument {}'.format(path))
 def UpdateModuleConfig(self, args):
     """Update a config within a module."""
     if args.clear_config or args.config is None:
         config = None
     else:
         try:
             config = encoding.JsonToMessage(
                 self.message_module.Config.ValueValue, args.config)
         except Exception:
             raise scc_exceptions.SecurityCenterSettingsException(
                 'Invalid argument {}. Check help text for an example json.'
                 .format(args.config))
     enabled = args.enablement_state == 'enabled'
     return self._UpdateModules(args, enabled, args.clear_config, config)
Exemplo n.º 3
0
    def DescribeService(self, args):
        """Describe service settings of organization/folder/project."""

        FallBackFlags(args)
        path = GenerateParent(args) + SERVICES_ENDPOINTS[args.service]

        try:
            if args.organization:
                if args.service == 'web-security-scanner':
                    request_message = self.message_module.SecuritycenterOrganizationsWebSecurityScannerSettingsCalculateRequest(
                        name=path)
                    return self.service_client.organizations_webSecurityScannerSettings.Calculate(
                        request_message)
                elif args.service == 'security-health-analytics':
                    request_message = self.message_module.SecuritycenterOrganizationsSecurityHealthAnalyticsSettingsCalculateRequest(
                        name=path)
                    return self.service_client.organizations_securityHealthAnalyticsSettings.Calculate(
                        request_message)
                elif args.service == 'container-threat-detection':
                    request_message = self.message_module.SecuritycenterOrganizationsContainerThreatDetectionSettingsCalculateRequest(
                        name=path)
                    return self.service_client.organizations_containerThreatDetectionSettings.Calculate(
                        request_message)
                elif args.service == 'event-threat-detection':
                    request_message = self.message_module.SecuritycenterOrganizationsEventThreatDetectionSettingsCalculateRequest(
                        name=path)
                    return self.service_client.organizations_eventThreatDetectionSettings.Calculate(
                        request_message)
            elif args.project:
                if args.service == 'web-security-scanner':
                    request_message = self.message_module.SecuritycenterProjectsWebSecurityScannerSettingsCalculateRequest(
                        name=path)
                    return self.service_client.projects_webSecurityScannerSettings.Calculate(
                        request_message)
                elif args.service == 'security-health-analytics':
                    request_message = self.message_module.SecuritycenterProjectsSecurityHealthAnalyticsSettingsCalculateRequest(
                        name=path)
                    return self.service_client.projects_securityHealthAnalyticsSettings.Calculate(
                        request_message)
                elif args.service == 'container-threat-detection':
                    request_message = self.message_module.SecuritycenterProjectsContainerThreatDetectionSettingsCalculateRequest(
                        name=path)
                    return self.service_client.projects_containerThreatDetectionSettings.Calculate(
                        request_message)
                elif args.service == 'event-threat-detection':
                    request_message = self.message_module.SecuritycenterProjectsEventThreatDetectionSettingsCalculateRequest(
                        name=path)
                    return self.service_client.projects_eventThreatDetectionSettings.Calculate(
                        request_message)
            elif args.folder:
                if args.service == 'web-security-scanner':
                    request_message = self.message_module.SecuritycenterFoldersWebSecurityScannerSettingsCalculateRequest(
                        name=path)
                    return self.service_client.folders_webSecurityScannerSettings.Calculate(
                        request_message)
                elif args.service == 'security-health-analytics':
                    request_message = self.message_module.SecuritycenterFoldersSecurityHealthAnalyticsSettingsCalculateRequest(
                        name=path)
                    return self.service_client.folders_securityHealthAnalyticsSettings.Calculate(
                        request_message)
                elif args.service == 'container-threat-detection':
                    request_message = self.message_module.SecuritycenterFoldersContainerThreatDetectionSettingsCalculateRequest(
                        name=path)
                    return self.service_client.folders_containerThreatDetectionSettings.Calculate(
                        request_message)
                elif args.service == 'event-threat-detection':
                    request_message = self.message_module.SecuritycenterFoldersEventThreatDetectionSettingsCalculateRequest(
                        name=path)
                    return self.service_client.folders_eventThreatDetectionSettings.Calculate(
                        request_message)
        except exceptions.HttpNotFoundError:
            raise scc_exceptions.SecurityCenterSettingsException(
                'Invalid argument {}'.format(path))
Exemplo n.º 4
0
    def DescribeServiceExplicit(self, args):
        """Describe effective service settings of organization/folder/project."""

        FallBackFlags(args)
        path = GenerateParent(args) + SERVICES_ENDPOINTS[args.service]

        try:
            if args.organization:
                if args.service == 'web-security-scanner':
                    request_message = self.message_module.SecuritycenterOrganizationsGetWebSecurityScannerSettingsRequest(
                        name=path)
                    return self.service_client.organizations.GetWebSecurityScannerSettings(
                        request_message)
                elif args.service == 'security-health-analytics':
                    request_message = self.message_module.SecuritycenterOrganizationsGetSecurityHealthAnalyticsSettingsRequest(
                        name=path)
                    return self.service_client.organizations.GetSecurityHealthAnalyticsSettings(
                        request_message)
                elif args.service == 'container-threat-detection':
                    request_message = self.message_module.SecuritycenterOrganizationsGetContainerThreatDetectionSettingsRequest(
                        name=path)
                    return self.service_client.organizations.GetContainerThreatDetectionSettings(
                        request_message)
                elif args.service == 'event-threat-detection':
                    request_message = self.message_module.SecuritycenterOrganizationsGetEventThreatDetectionSettingsRequest(
                        name=path)
                    return self.service_client.organizations.GetEventThreatDetectionSettings(
                        request_message)
            elif args.project:
                if args.service == 'web-security-scanner':
                    request_message = self.message_module.SecuritycenterProjectsGetWebSecurityScannerSettingsRequest(
                        name=path)
                    return self.service_client.projects.GetWebSecurityScannerSettings(
                        request_message)
                elif args.service == 'security-health-analytics':
                    request_message = self.message_module.SecuritycenterProjectsGetSecurityHealthAnalyticsSettingsRequest(
                        name=path)
                    return self.service_client.projects.GetSecurityHealthAnalyticsSettings(
                        request_message)
                elif args.service == 'container-threat-detection':
                    request_message = self.message_module.SecuritycenterProjectsGetContainerThreatDetectionSettingsRequest(
                        name=path)
                    return self.service_client.projects.GetContainerThreatDetectionSettings(
                        request_message)
                elif args.service == 'event-threat-detection':
                    request_message = self.message_module.SecuritycenterProjectsGetEventThreatDetectionSettingsRequest(
                        name=path)
                    return self.service_client.projects.GetEventThreatDetectionSettings(
                        request_message)
            elif args.folder:
                if args.service == 'web-security-scanner':
                    request_message = self.message_module.SecuritycenterFoldersGetWebSecurityScannerSettingsRequest(
                        name=path)
                    return self.service_client.folders.GetWebSecurityScannerSettings(
                        request_message)
                elif args.service == 'security-health-analytics':
                    request_message = self.message_module.SecuritycenterFoldersGetSecurityHealthAnalyticsSettingsRequest(
                        name=path)
                    return self.service_client.folders.GetSecurityHealthAnalyticsSettings(
                        request_message)
                elif args.service == 'container-threat-detection':
                    request_message = self.message_module.SecuritycenterFoldersGetContainerThreatDetectionSettingsRequest(
                        name=path)
                    return self.service_client.folders.GetContainerThreatDetectionSettings(
                        request_message)
                elif args.service == 'event-threat-detection':
                    request_message = self.message_module.SecuritycenterFoldersGetEventThreatDetectionSettingsRequest(
                        name=path)
                    return self.service_client.folders.GetEventThreatDetectionSettings(
                        request_message)
        except exceptions.HttpError:
            # TODO(b/152617502): handle 404 error instead of general HttpError
            raise scc_exceptions.SecurityCenterSettingsException(
                'Invalid argument {}'.format(path))