diff --git a/src/azure-cli/azure/cli/command_modules/security/_client_factory.py b/src/azure-cli/azure/cli/command_modules/security/_client_factory.py index 882d91bcf92..03a9adf6ad9 100644 --- a/src/azure-cli/azure/cli/command_modules/security/_client_factory.py +++ b/src/azure-cli/azure/cli/command_modules/security/_client_factory.py @@ -156,3 +156,7 @@ def cf_security_security_solutions_reference_data(cli_ctx, _): def cf_security_automations(cli_ctx, _): return _cf_security(cli_ctx).automations + + +def cf_security_security_solutions(cli_ctx, _): + return _cf_security(cli_ctx) diff --git a/src/azure-cli/azure/cli/command_modules/security/_help.py b/src/azure-cli/azure/cli/command_modules/security/_help.py index c655b5008a2..b0cd0336563 100644 --- a/src/azure-cli/azure/cli/command_modules/security/_help.py +++ b/src/azure-cli/azure/cli/command_modules/security/_help.py @@ -1225,6 +1225,20 @@ short-summary: Creates security automation event hub action. """ +helps['security security-solutions'] = """ +type: group +short-summary: Display all security solutions at the subscription level. +""" + +helps['security security-solutions list'] = """ +type: command +short-summary: Display all security solutions at the subscription level. +examples: + - name: Display all security solutions. + text: > + az security security-solutions list +""" + helps['security automation-action-event-hub create'] = """ type: command short-summary: Creates security automation event hub action. diff --git a/src/azure-cli/azure/cli/command_modules/security/commands.py b/src/azure-cli/azure/cli/command_modules/security/commands.py index dce88386bcc..4a3c79fee62 100644 --- a/src/azure-cli/azure/cli/command_modules/security/commands.py +++ b/src/azure-cli/azure/cli/command_modules/security/commands.py @@ -37,8 +37,9 @@ cf_security_secure_scores, cf_security_secure_score_controls, cf_security_secure_score_control_definitions, - cf_security_security_solutions_reference_data, - cf_security_automations) + cf_security_automations, + cf_security_security_solutions, + cf_security_security_solutions_reference_data) # pylint: disable=line-too-long @@ -238,6 +239,11 @@ def load_command_table(self, _): operation_group='security_automations' ) + security_solutions_sdk = CliCommandType( + operations_tmpl='azure.mgmt.security.operations#SecuritySolutionsOperations.{}', + client_factory=cf_security_security_solutions + ) + with self.command_group('security secure-scores', security_secure_scores_sdk, client_factory=cf_security_secure_scores) as g: @@ -496,15 +502,22 @@ def load_command_table(self, _): with self.command_group('security automation-action-logic-app', security_automations_sdk, client_factory=cf_security_automations) as g: + g.custom_command('create', 'create_security_automation_action_logic_app') with self.command_group('security automation-action-event-hub', security_automations_sdk, client_factory=cf_security_automations) as g: + g.custom_command('create', 'create_security_automation_action_event_hub') with self.command_group('security automation-action-workspace', security_automations_sdk, client_factory=cf_security_automations) as g: g.custom_command('create', 'create_security_automation_action_workspace') + with self.command_group('security security-solutions', + security_solutions_sdk, + client_factory=cf_security_security_solutions) as g: + g.custom_command('list', 'list_security_security_solutions') + with self.command_group('security'): pass diff --git a/src/azure-cli/azure/cli/command_modules/security/custom.py b/src/azure-cli/azure/cli/command_modules/security/custom.py index c85c3fafe10..7e65469d277 100644 --- a/src/azure-cli/azure/cli/command_modules/security/custom.py +++ b/src/azure-cli/azure/cli/command_modules/security/custom.py @@ -325,6 +325,15 @@ def get_security_discovered_security_solution(client, resource_name, resource_gr return client.discovered_security_solutions.get(resource_group_name, resource_name) +# -------------------------------------------------------------------------------------------- +# Security Solutions +# -------------------------------------------------------------------------------------------- + +def list_security_security_solutions(client): + + return client.security_solutions.list() + + # -------------------------------------------------------------------------------------------- # External Security Solutions # -------------------------------------------------------------------------------------------- diff --git a/src/azure-cli/azure/cli/command_modules/security/tests/latest/recordings/test_security_security_solutions.yaml b/src/azure-cli/azure/cli/command_modules/security/tests/latest/recordings/test_security_security_solutions.yaml new file mode 100644 index 00000000000..5c04b59763c --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/security/tests/latest/recordings/test_security_security_solutions.yaml @@ -0,0 +1,94 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - security security-solutions list + Connection: + - keep-alive + User-Agent: + - AZURECLI/2.38.0 azsdk-python-mgmt-security/2.0.0b1 Python/3.7.8rc1 (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Security/securitySolutions?api-version=2020-01-01 + response: + body: + string: '{"value":[{"properties":{"securityFamily":"Va","integrationLevel":"SemiIntegrated","protectionStatus":"Good","template":"qualys.qualysAgent","protectedResourcesStates":[],"protectedResourcesTypes":[],"managementUrl":"http://www.qualys.com/","creationDate":"2017-10-09T12:37:15.9527562Z","provisioningState":"Succeeded","clusterId":"67931ECFB2B86BFFE512B04C745D307FE7F15FF4","configurations":{"AutoUpdate":false}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/QualysLICTest/providers/Microsoft.Security/locations/centralus/securitySolutions/QualysLICTest","name":"QualysLICTest","type":"Microsoft.Security/locations/securitySolutions","location":"westcentralus"},{"properties":{"securityFamily":"SaasWaf","integrationLevel":"SemiIntegrated","protectionStatus":"Good","template":"Microsoft.ApplicationGateway-ARM","protectedResourcesStates":[],"protectedResourcesTypes":[],"managementUrl":"https://portal.azure.com#resource/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/OfriWafTest/providers/Microsoft.Network/applicationGateways/OfriWafTest/overview","creationDate":"2020-10-05T11:01:57.6339395Z","provisioningState":"Succeeded","clusterId":"9C29D374728B41DC6923D87B1E159EFCB0BF2768"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/OfriWafTest/providers/Microsoft.Security/locations/centralus/securitySolutions/OfriWafTest","name":"OfriWafTest","type":"Microsoft.Security/locations/securitySolutions","location":"eastus"},{"properties":{"securityFamily":"SaasWaf","integrationLevel":"SemiIntegrated","protectionStatus":"UnReported","template":"microsoft.ApplicationGateway-ARM","protectedResourcesStates":[],"protectedResourcesTypes":[],"managementUrl":"https://portal.azure.com#resource/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/waf155/providers/Microsoft.Network/applicationGateways/waf155vm/overview","creationDate":"2020-07-22T11:45:47.9115946Z","provisioningState":"Succeeded","clusterId":"2C8995EFB1500186BC1958C032CC360BAC33C5BC"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/waf155/providers/Microsoft.Security/locations/centralus/securitySolutions/waf155vm","name":"waf155vm","type":"Microsoft.Security/locations/securitySolutions","location":"westcentralus"},{"properties":{"securityFamily":"SaasWaf","integrationLevel":"SemiIntegrated","protectionStatus":"Good","template":"microsoft.ApplicationGateway-ARM","protectedResourcesStates":[],"protectedResourcesTypes":[],"managementUrl":"https://portal.azure.com#resource/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/solutionsProdTest/providers/Microsoft.Network/applicationGateways/msWafProdTest/overview","creationDate":"2020-12-22T12:36:21.3564505Z","provisioningState":"Succeeded","clusterId":"DF6A40AD0A3A9FEDA4635882E1D15AEF63E2CAF9"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/solutionsProdTest/providers/Microsoft.Security/locations/centralus/securitySolutions/msWafProdTest","name":"msWafProdTest","type":"Microsoft.Security/locations/securitySolutions","location":"westus"},{"properties":{"securityFamily":"SaasWaf","integrationLevel":"SemiIntegrated","protectionStatus":"Good","template":"microsoft.ApplicationGateway-ARM","protectedResourcesStates":[],"protectedResourcesTypes":[],"managementUrl":"https://portal.azure.com#resource/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/waf-rg2/providers/Microsoft.Network/applicationGateways/Ofri-WAF/overview","creationDate":"2021-08-16T15:07:07.0095098Z","provisioningState":"Succeeded","clusterId":"8E21D225069917B73D65FB806785076F443F4530"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/waf-rg2/providers/Microsoft.Security/locations/centralus/securitySolutions/Ofri-WAF","name":"Ofri-WAF","type":"Microsoft.Security/locations/securitySolutions","location":"eastus"},{"properties":{"securityFamily":"Va","integrationLevel":"SemiIntegrated","protectionStatus":"UnReported","template":"qualys.qualysAgent","protectedResourcesStates":[],"protectedResourcesTypes":[],"managementUrl":"http://www.qualys.com/","creationDate":"2021-03-09T10:40:18.7014776Z","provisioningState":"Succeeded","clusterId":"FDE9EB85DB07E8354B3AFF34DA84B0929F14F222","configurations":{"AutoUpdate":false}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/tryNomisolutions/providers/Microsoft.Security/locations/centralus/securitySolutions/DedicatedEHTest3","name":"DedicatedEHTest3","type":"Microsoft.Security/locations/securitySolutions","location":"westcentralus"},{"properties":{"securityFamily":"Va","integrationLevel":"SemiIntegrated","protectionStatus":"Good","template":"qualys.qualysAgent","protectedResourcesStates":[],"protectedResourcesTypes":[],"managementUrl":"http://www.qualys.com/","creationDate":"2017-10-01T14:51:37.5457917Z","provisioningState":"Succeeded","clusterId":"3120660E864F689F9166DB122386B71E27C2D565","configurations":{"AutoUpdate":false}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/QualysLinuxTest/providers/Microsoft.Security/locations/centralus/securitySolutions/Qualys1","name":"Qualys1","type":"Microsoft.Security/locations/securitySolutions","location":"westcentralus"},{"properties":{"securityFamily":"Va","integrationLevel":"SemiIntegrated","protectionStatus":"NotReporting","template":"rapid7.insightplatform","protectedResourcesStates":[],"protectedResourcesTypes":[],"managementUrl":"","creationDate":"2018-06-11T13:24:27.1314378Z","provisioningState":"Succeeded","clusterId":"1A54F1A20AB90FDAD835897B4A413B1F40473DD9","configurations":{"AutoUpdate":false}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Rapid7Va/providers/Microsoft.Security/locations/centralus/securitySolutions/Rapid7VaRome3","name":"Rapid7VaRome3","type":"Microsoft.Security/locations/securitySolutions","location":"centralus"},{"properties":{"securityFamily":"SaasWaf","integrationLevel":"SemiIntegrated","protectionStatus":"Good","template":"microsoft.ApplicationGateway-ARM","protectedResourcesStates":[],"protectedResourcesTypes":[],"managementUrl":"https://portal.azure.com#resource/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MatanWafTest/providers/Microsoft.Network/applicationGateways/MatanWAFtEST/overview","creationDate":"2021-08-16T15:06:32.3284944Z","provisioningState":"Succeeded","clusterId":"B95CAE8386CD79955A26A6E2AF0D62B7331D17D5"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MatanWafTest/providers/Microsoft.Security/locations/centralus/securitySolutions/MatanWAFtEST","name":"MatanWAFtEST","type":"Microsoft.Security/locations/securitySolutions","location":"eastus2"}]}' + headers: + cache-control: + - no-cache + content-length: + - '6739' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 26 Jul 2022 17:09:12 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-original-request-ids: + - '' + - '' + - '' + x-ms-ratelimit-remaining-subscription-resource-requests: + - '747' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - security security-solutions list + Connection: + - keep-alive + User-Agent: + - AZURECLI/2.38.0 azsdk-python-mgmt-security/2.0.0b1 Python/3.7.8rc1 (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Security/securitySolutions?api-version=2020-01-01 + response: + body: + string: '{"value":[{"properties":{"securityFamily":"Va","integrationLevel":"SemiIntegrated","protectionStatus":"Good","template":"qualys.qualysAgent","protectedResourcesStates":[],"protectedResourcesTypes":[],"managementUrl":"http://www.qualys.com/","creationDate":"2017-10-09T12:37:15.9527562Z","provisioningState":"Succeeded","clusterId":"67931ECFB2B86BFFE512B04C745D307FE7F15FF4","configurations":{"AutoUpdate":false}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/QualysLICTest/providers/Microsoft.Security/locations/centralus/securitySolutions/QualysLICTest","name":"QualysLICTest","type":"Microsoft.Security/locations/securitySolutions","location":"westcentralus"},{"properties":{"securityFamily":"SaasWaf","integrationLevel":"SemiIntegrated","protectionStatus":"Good","template":"Microsoft.ApplicationGateway-ARM","protectedResourcesStates":[],"protectedResourcesTypes":[],"managementUrl":"https://portal.azure.com#resource/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/OfriWafTest/providers/Microsoft.Network/applicationGateways/OfriWafTest/overview","creationDate":"2020-10-05T11:01:57.6339395Z","provisioningState":"Succeeded","clusterId":"9C29D374728B41DC6923D87B1E159EFCB0BF2768"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/OfriWafTest/providers/Microsoft.Security/locations/centralus/securitySolutions/OfriWafTest","name":"OfriWafTest","type":"Microsoft.Security/locations/securitySolutions","location":"eastus"},{"properties":{"securityFamily":"SaasWaf","integrationLevel":"SemiIntegrated","protectionStatus":"UnReported","template":"microsoft.ApplicationGateway-ARM","protectedResourcesStates":[],"protectedResourcesTypes":[],"managementUrl":"https://portal.azure.com#resource/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/waf155/providers/Microsoft.Network/applicationGateways/waf155vm/overview","creationDate":"2020-07-22T11:45:47.9115946Z","provisioningState":"Succeeded","clusterId":"2C8995EFB1500186BC1958C032CC360BAC33C5BC"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/waf155/providers/Microsoft.Security/locations/centralus/securitySolutions/waf155vm","name":"waf155vm","type":"Microsoft.Security/locations/securitySolutions","location":"westcentralus"},{"properties":{"securityFamily":"SaasWaf","integrationLevel":"SemiIntegrated","protectionStatus":"Good","template":"microsoft.ApplicationGateway-ARM","protectedResourcesStates":[],"protectedResourcesTypes":[],"managementUrl":"https://portal.azure.com#resource/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/solutionsProdTest/providers/Microsoft.Network/applicationGateways/msWafProdTest/overview","creationDate":"2020-12-22T12:36:21.3564505Z","provisioningState":"Succeeded","clusterId":"DF6A40AD0A3A9FEDA4635882E1D15AEF63E2CAF9"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/solutionsProdTest/providers/Microsoft.Security/locations/centralus/securitySolutions/msWafProdTest","name":"msWafProdTest","type":"Microsoft.Security/locations/securitySolutions","location":"westus"},{"properties":{"securityFamily":"SaasWaf","integrationLevel":"SemiIntegrated","protectionStatus":"Good","template":"microsoft.ApplicationGateway-ARM","protectedResourcesStates":[],"protectedResourcesTypes":[],"managementUrl":"https://portal.azure.com#resource/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/waf-rg2/providers/Microsoft.Network/applicationGateways/Ofri-WAF/overview","creationDate":"2021-08-16T15:07:07.0095098Z","provisioningState":"Succeeded","clusterId":"8E21D225069917B73D65FB806785076F443F4530"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/waf-rg2/providers/Microsoft.Security/locations/centralus/securitySolutions/Ofri-WAF","name":"Ofri-WAF","type":"Microsoft.Security/locations/securitySolutions","location":"eastus"},{"properties":{"securityFamily":"Va","integrationLevel":"SemiIntegrated","protectionStatus":"UnReported","template":"qualys.qualysAgent","protectedResourcesStates":[],"protectedResourcesTypes":[],"managementUrl":"http://www.qualys.com/","creationDate":"2021-03-09T10:40:18.7014776Z","provisioningState":"Succeeded","clusterId":"FDE9EB85DB07E8354B3AFF34DA84B0929F14F222","configurations":{"AutoUpdate":false}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/tryNomisolutions/providers/Microsoft.Security/locations/centralus/securitySolutions/DedicatedEHTest3","name":"DedicatedEHTest3","type":"Microsoft.Security/locations/securitySolutions","location":"westcentralus"},{"properties":{"securityFamily":"Va","integrationLevel":"SemiIntegrated","protectionStatus":"Good","template":"qualys.qualysAgent","protectedResourcesStates":[],"protectedResourcesTypes":[],"managementUrl":"http://www.qualys.com/","creationDate":"2017-10-01T14:51:37.5457917Z","provisioningState":"Succeeded","clusterId":"3120660E864F689F9166DB122386B71E27C2D565","configurations":{"AutoUpdate":false}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/QualysLinuxTest/providers/Microsoft.Security/locations/centralus/securitySolutions/Qualys1","name":"Qualys1","type":"Microsoft.Security/locations/securitySolutions","location":"westcentralus"},{"properties":{"securityFamily":"Va","integrationLevel":"SemiIntegrated","protectionStatus":"NotReporting","template":"rapid7.insightplatform","protectedResourcesStates":[],"protectedResourcesTypes":[],"managementUrl":"","creationDate":"2018-06-11T13:24:27.1314378Z","provisioningState":"Succeeded","clusterId":"1A54F1A20AB90FDAD835897B4A413B1F40473DD9","configurations":{"AutoUpdate":false}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Rapid7Va/providers/Microsoft.Security/locations/centralus/securitySolutions/Rapid7VaRome3","name":"Rapid7VaRome3","type":"Microsoft.Security/locations/securitySolutions","location":"centralus"},{"properties":{"securityFamily":"SaasWaf","integrationLevel":"SemiIntegrated","protectionStatus":"Good","template":"microsoft.ApplicationGateway-ARM","protectedResourcesStates":[],"protectedResourcesTypes":[],"managementUrl":"https://portal.azure.com#resource/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MatanWafTest/providers/Microsoft.Network/applicationGateways/MatanWAFtEST/overview","creationDate":"2021-08-16T15:06:32.3284944Z","provisioningState":"Succeeded","clusterId":"B95CAE8386CD79955A26A6E2AF0D62B7331D17D5"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MatanWafTest/providers/Microsoft.Security/locations/centralus/securitySolutions/MatanWAFtEST","name":"MatanWAFtEST","type":"Microsoft.Security/locations/securitySolutions","location":"eastus2"}]}' + headers: + cache-control: + - no-cache + content-length: + - '6739' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 26 Jul 2022 17:09:13 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-original-request-ids: + - '' + - '' + - '' + x-ms-ratelimit-remaining-subscription-resource-requests: + - '746' + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/security/tests/latest/test_security_solutions_scenario.py b/src/azure-cli/azure/cli/command_modules/security/tests/latest/test_security_solutions_scenario.py new file mode 100644 index 00000000000..80f51c2e7ad --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/security/tests/latest/test_security_solutions_scenario.py @@ -0,0 +1,18 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk import ScenarioTest +from azure.cli.testsdk.scenario_tests import AllowLargeResponse + + +class SecuritySoluytionsTests(ScenarioTest): + + def test_security_security_solutions(self): + + security_solutions = self.cmd('az security security-solutions list').get_output_in_json() + + assert len(security_solutions) >= 0 + + self.cmd('az security security-solutions list')