Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
19ea034
Added settings cmdlet
taklei1 May 6, 2020
2bed5f9
Some fixes to tests
taklei1 May 7, 2020
3c525a5
Fixed SetSettings
taklei1 May 8, 2020
30688bf
added sessionRecords
taklei1 May 8, 2020
e38c956
Added session records
taklei1 May 11, 2020
560867d
Re-run jit tests
taklei1 May 14, 2020
5f9d126
enabling piping support in settings cmdlet
taklei1 May 14, 2020
e3f7247
Name fix
taklei1 May 14, 2020
827d7b3
updated help
taklei1 May 14, 2020
df5a0db
update settings help files
taklei1 May 16, 2020
639ad2c
Merge with master
taklei1 May 16, 2020
7180fae
Fix help
taklei1 May 16, 2020
6a6c6e5
deleting a test
taklei1 May 19, 2020
2315efe
fixed merge conflict
taklei1 May 19, 2020
efa43ea
fixing help files
taklei1 May 20, 2020
8d99f30
flattening the set settings
taklei1 May 20, 2020
7ca9c49
added a session record
taklei1 May 20, 2020
33b1fce
regenate help
taklei1 May 20, 2020
37c2da5
Merge branch 'master' of https://github.com/Azure/azure-powershell
taklei1 May 20, 2020
4bcd7fc
added new set parameter
taklei1 May 21, 2020
c806fd6
changed the test name
taklei1 May 21, 2020
4b1380d
regenerated help
taklei1 May 21, 2020
ce48daa
renaming tests
taklei1 May 21, 2020
d944d30
Merge branch 'master' of https://github.com/Azure/azure-powershell
taklei1 May 21, 2020
5d80f39
fixing a type
taklei1 May 21, 2020
060e8fd
re-added a default parameter set
taklei1 May 21, 2020
4806b13
regenerate help
taklei1 May 21, 2020
f863d24
updated the change log
taklei1 May 24, 2020
8c22b64
Update Get-AzSecuritySetting.md
VeryEarly May 25, 2020
b3d99a1
Update ChangeLog.md
VeryEarly May 25, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions src/Security/Security.Test/ScenarioTests/SecuritySettingTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.ScenarioTest;
using Microsoft.Azure.ServiceManagement.Common.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Microsoft.Azure.Commands.Security.Test.ScenarioTests
{
public class SecuritySettingTests
{
private readonly XunitTracingInterceptor _logger;

public SecuritySettingTests(Xunit.Abstractions.ITestOutputHelper output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);
TestExecutionHelpers.SetUpSessionAndProfile();
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void GetSubscriptionScope()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecuritySetting-SubscriptionScope");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void GetSubscriptionLevelResource()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzureRmSecuritySetting-SubscriptionLevelResource");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void SetDataExportSettingsScope()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Set-AzureRmSecuritySetting-DataExportSettingsScope");
}
}
}
85 changes: 85 additions & 0 deletions src/Security/Security.Test/ScenarioTests/SecuritySettingTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

<#
.SYNOPSIS
Get Azure Security Center settings on a subscription and its overrides
#>
function Get-AzureRmSecuritySetting-SubscriptionScope
{
$settings = Get-AzSecuritySetting

Validate-Settings $settings
}

<#
.SYNOPSIS
Get an Azure Security Center setting on a subscription
#>
function Get-AzureRmSecuritySetting-SubscriptionLevelResource
{
$setting = Get-AzSecuritySetting -SettingName "MCAS"

Validate-Setting $setting
}

<#
.SYNOPSIS
Set an Azure Security Center setting
#>
function Set-AzureRmSecuritySetting-DataExportSettingsScope
{
$updatedSetting = Set-AzSecuritySetting -SettingName "MCAS" -SettingKind "DataExportSettings" -Enabled $true

Validate-Setting $updatedSetting
Validate-EnabledProperty $updatedSetting
}

<#
.SYNOPSIS
Validates a list of security pricings
#>
function Validate-Settings
{
param($settings)

Assert-True { $settings.Count -gt 0 }

Foreach($setting in $settings)
{
Validate-Setting $setting
}
}

<#
.SYNOPSIS
Validates a single setting
#>
function Validate-Setting
{
param($setting)

Assert-NotNull $setting
}

<#
.SYNOPSIS
Validates the enabled property in a setting
#>
function Validate-EnabledProperty
{
param($setting)

Assert-True { $setting.Enabled -eq $true }
}
2 changes: 1 addition & 1 deletion src/Security/Security.Test/Security.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.SecurityCenter" Version="1.1.3" />
<PackageReference Include="Microsoft.Azure.Management.SecurityCenter" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
"RequestBody": "{\r\n \"properties\": {\r\n \"pricingTier\": \"Standard\"\r\n }\r\n}",
"RequestHeaders": {
"x-ms-client-request-id": [
"b7109be3-4bc5-489a-ab83-09869fa140ce"
"07ce869b-870a-4d24-8f60-e91896bcf6fe"
],
"Accept-Language": [
"en-US"
],
"User-Agent": [
"FxVersion/4.6.27414.06",
"FxVersion/4.6.28207.03",
"OSName/Windows",
"OSVersion/Microsoft.Windows.10.0.17763.",
"Microsoft.Azure.Management.Security.SecurityCenterClient/1.0.0.0"
"OSVersion/Microsoft.Windows.10.0.18363.",
"Microsoft.Azure.Management.Security.SecurityCenterClient/2.0.0.0"
],
"Content-Type": [
"application/json; charset=utf-8"
Expand All @@ -33,7 +33,7 @@
"no-cache"
],
"x-ms-request-id": [
"fbe902e7-1799-469e-a16f-8a6f531f50f7"
"e5f7b441-5097-4d3e-8eb6-c63c0fc932f2"
],
"Server": [
"Microsoft-HTTPAPI/2.0"
Expand All @@ -42,10 +42,10 @@
"249"
],
"x-ms-correlation-request-id": [
"8d533159-e0a3-4c2a-9f33-bb07c1aaf305"
"f19f85c2-86c2-4f6b-9fbd-30f33fca6b20"
],
"x-ms-routing-request-id": [
"UKSOUTH2:20190313T201235Z:8d533159-e0a3-4c2a-9f33-bb07c1aaf305"
"GERMANYWESTCENTRAL:20200513T114216Z:f19f85c2-86c2-4f6b-9fbd-30f33fca6b20"
],
"Strict-Transport-Security": [
"max-age=31536000; includeSubDomains"
Expand All @@ -54,7 +54,7 @@
"nosniff"
],
"Date": [
"Wed, 13 Mar 2019 20:12:35 GMT"
"Wed, 13 May 2020 11:42:16 GMT"
],
"Content-Length": [
"248"
Expand All @@ -70,22 +70,22 @@
"StatusCode": 200
},
{
"RequestUri": "/subscriptions/487bb485-b5b0-471e-9c0d-10717612f869/resourceGroups/myService1/providers/Microsoft.Security/locations/centralus/jitNetworkAccessPolicies/default?api-version=2015-06-01-preview",
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvNDg3YmI0ODUtYjViMC00NzFlLTljMGQtMTA3MTc2MTJmODY5L3Jlc291cmNlR3JvdXBzL215U2VydmljZTEvcHJvdmlkZXJzL01pY3Jvc29mdC5TZWN1cml0eS9sb2NhdGlvbnMvY2VudHJhbHVzL2ppdE5ldHdvcmtBY2Nlc3NQb2xpY2llcy9kZWZhdWx0P2FwaS12ZXJzaW9uPTIwMTUtMDYtMDEtcHJldmlldw==",
"RequestUri": "/subscriptions/487bb485-b5b0-471e-9c0d-10717612f869/resourceGroups/myService1/providers/Microsoft.Security/locations/centralus/jitNetworkAccessPolicies/default?api-version=2020-01-01",
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvNDg3YmI0ODUtYjViMC00NzFlLTljMGQtMTA3MTc2MTJmODY5L3Jlc291cmNlR3JvdXBzL215U2VydmljZTEvcHJvdmlkZXJzL01pY3Jvc29mdC5TZWN1cml0eS9sb2NhdGlvbnMvY2VudHJhbHVzL2ppdE5ldHdvcmtBY2Nlc3NQb2xpY2llcy9kZWZhdWx0P2FwaS12ZXJzaW9uPTIwMjAtMDEtMDE=",
"RequestMethod": "PUT",
"RequestBody": "{\r\n \"kind\": \"Basic\",\r\n \"properties\": {\r\n \"virtualMachines\": [\r\n {\r\n \"id\": \"/subscriptions/487bb485-b5b0-471e-9c0d-10717612f869/resourceGroups/myService1/providers/Microsoft.Compute/virtualMachines/testService\",\r\n \"ports\": [\r\n {\r\n \"number\": 22,\r\n \"protocol\": \"TCP\",\r\n \"allowedSourceAddressPrefix\": \"127.0.0.1\",\r\n \"maxRequestAccessDuration\": \"PT3H\"\r\n }\r\n ]\r\n }\r\n ]\r\n }\r\n}",
"RequestHeaders": {
"x-ms-client-request-id": [
"01b7a73d-d3ef-4ea9-a290-29552c39a7d9"
"843f8f3a-5acc-45b4-b7bf-ab14b76616b7"
],
"Accept-Language": [
"en-US"
],
"User-Agent": [
"FxVersion/4.6.27414.06",
"FxVersion/4.6.28207.03",
"OSName/Windows",
"OSVersion/Microsoft.Windows.10.0.17763.",
"Microsoft.Azure.Management.Security.SecurityCenterClient/1.0.0.0"
"OSVersion/Microsoft.Windows.10.0.18363.",
"Microsoft.Azure.Management.Security.SecurityCenterClient/2.0.0.0"
],
"Content-Type": [
"application/json; charset=utf-8"
Expand All @@ -102,7 +102,7 @@
"no-cache"
],
"x-ms-request-id": [
"deb17aef-54ac-467f-a0fd-6a1f3581c59a"
"b2b0940f-35e9-4c45-b827-98f28c95572d"
],
"Server": [
"Microsoft-HTTPAPI/2.0"
Expand All @@ -111,10 +111,10 @@
"1199"
],
"x-ms-correlation-request-id": [
"6df1acc4-dcc0-497f-b4eb-20245f75cc95"
"a7889bb0-81ca-4370-98c3-a803326b4344"
],
"x-ms-routing-request-id": [
"UKSOUTH2:20190313T201237Z:6df1acc4-dcc0-497f-b4eb-20245f75cc95"
"GERMANYWESTCENTRAL:20200513T114217Z:a7889bb0-81ca-4370-98c3-a803326b4344"
],
"Strict-Transport-Security": [
"max-age=31536000; includeSubDomains"
Expand All @@ -123,10 +123,10 @@
"nosniff"
],
"Date": [
"Wed, 13 Mar 2019 20:12:36 GMT"
"Wed, 13 May 2020 11:42:17 GMT"
],
"Content-Length": [
"626"
"644"
],
"Content-Type": [
"application/json; charset=utf-8"
Expand All @@ -135,26 +135,26 @@
"-1"
]
},
"ResponseBody": "{\r\n \"kind\": \"Basic\",\r\n \"properties\": {\r\n \"virtualMachines\": [\r\n {\r\n \"id\": \"/subscriptions/487bb485-b5b0-471e-9c0d-10717612f869/resourceGroups/myService1/providers/Microsoft.Compute/virtualMachines/testService\",\r\n \"ports\": [\r\n {\r\n \"number\": 22,\r\n \"protocol\": \"TCP\",\r\n \"allowedSourceAddressPrefix\": \"127.0.0.1\",\r\n \"maxRequestAccessDuration\": \"PT3H\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"requests\": [],\r\n \"provisioningState\": \"Succeeded\"\r\n },\r\n \"id\": \"/subscriptions/487bb485-b5b0-471e-9c0d-10717612f869/resourceGroups/myService1/providers/Microsoft.Security/locations/centralus/jitNetworkAccessPolicies/default\",\r\n \"name\": \"default\",\r\n \"type\": \"Microsoft.Security/locations/jitNetworkAccessPolicies\",\r\n \"location\": \"centralus\"\r\n}",
"ResponseBody": "{\r\n \"kind\": \"Basic\",\r\n \"properties\": {\r\n \"virtualMachines\": [\r\n {\r\n \"id\": \"/subscriptions/487bb485-b5b0-471e-9c0d-10717612f869/resourceGroups/myService1/providers/Microsoft.Compute/virtualMachines/testService\",\r\n \"ports\": [\r\n {\r\n \"number\": 22,\r\n \"protocol\": \"TCP\",\r\n \"allowedSourceAddressPrefix\": \"127.0.0.1\",\r\n \"maxRequestAccessDuration\": \"PT3H\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"requests\": [],\r\n \"provisioningState\": \"Updating\",\r\n \"appendMode\": false\r\n },\r\n \"id\": \"/subscriptions/487bb485-b5b0-471e-9c0d-10717612f869/resourceGroups/myService1/providers/Microsoft.Security/locations/centralus/jitNetworkAccessPolicies/default\",\r\n \"name\": \"default\",\r\n \"type\": \"Microsoft.Security/locations/jitNetworkAccessPolicies\",\r\n \"location\": \"centralus\"\r\n}",
"StatusCode": 200
},
{
"RequestUri": "/subscriptions/487bb485-b5b0-471e-9c0d-10717612f869/resourceGroups/myService1/providers/Microsoft.Security/locations/centralus/jitNetworkAccessPolicies/default?api-version=2015-06-01-preview",
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvNDg3YmI0ODUtYjViMC00NzFlLTljMGQtMTA3MTc2MTJmODY5L3Jlc291cmNlR3JvdXBzL215U2VydmljZTEvcHJvdmlkZXJzL01pY3Jvc29mdC5TZWN1cml0eS9sb2NhdGlvbnMvY2VudHJhbHVzL2ppdE5ldHdvcmtBY2Nlc3NQb2xpY2llcy9kZWZhdWx0P2FwaS12ZXJzaW9uPTIwMTUtMDYtMDEtcHJldmlldw==",
"RequestUri": "/subscriptions/487bb485-b5b0-471e-9c0d-10717612f869/resourceGroups/myService1/providers/Microsoft.Security/locations/centralus/jitNetworkAccessPolicies/default?api-version=2020-01-01",
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvNDg3YmI0ODUtYjViMC00NzFlLTljMGQtMTA3MTc2MTJmODY5L3Jlc291cmNlR3JvdXBzL215U2VydmljZTEvcHJvdmlkZXJzL01pY3Jvc29mdC5TZWN1cml0eS9sb2NhdGlvbnMvY2VudHJhbHVzL2ppdE5ldHdvcmtBY2Nlc3NQb2xpY2llcy9kZWZhdWx0P2FwaS12ZXJzaW9uPTIwMjAtMDEtMDE=",
"RequestMethod": "GET",
"RequestBody": "",
"RequestHeaders": {
"x-ms-client-request-id": [
"6ce2c63b-887e-47a4-a9f1-7d94270178ca"
"6eb3500e-616d-4645-b212-5ea869178b59"
],
"Accept-Language": [
"en-US"
],
"User-Agent": [
"FxVersion/4.6.27414.06",
"FxVersion/4.6.28207.03",
"OSName/Windows",
"OSVersion/Microsoft.Windows.10.0.17763.",
"Microsoft.Azure.Management.Security.SecurityCenterClient/1.0.0.0"
"OSVersion/Microsoft.Windows.10.0.18363.",
"Microsoft.Azure.Management.Security.SecurityCenterClient/2.0.0.0"
]
},
"ResponseHeaders": {
Expand All @@ -165,7 +165,7 @@
"no-cache"
],
"x-ms-request-id": [
"23a8fa5f-46d9-404e-abff-6a707657bf7a"
"4a9a99b1-0979-4755-9359-a6164c1c62f5"
],
"Server": [
"Microsoft-HTTPAPI/2.0"
Expand All @@ -174,10 +174,10 @@
"749"
],
"x-ms-correlation-request-id": [
"d7958fde-d2a2-479d-9f04-520c03bb48e5"
"024b2900-dbfa-480f-a9cd-e50a72b9ef84"
],
"x-ms-routing-request-id": [
"UKSOUTH2:20190313T201237Z:d7958fde-d2a2-479d-9f04-520c03bb48e5"
"GERMANYWESTCENTRAL:20200513T114217Z:024b2900-dbfa-480f-a9cd-e50a72b9ef84"
],
"Strict-Transport-Security": [
"max-age=31536000; includeSubDomains"
Expand All @@ -186,10 +186,10 @@
"nosniff"
],
"Date": [
"Wed, 13 Mar 2019 20:12:36 GMT"
"Wed, 13 May 2020 11:42:17 GMT"
],
"Content-Length": [
"626"
"644"
],
"Content-Type": [
"application/json; charset=utf-8"
Expand All @@ -198,7 +198,7 @@
"-1"
]
},
"ResponseBody": "{\r\n \"kind\": \"Basic\",\r\n \"properties\": {\r\n \"virtualMachines\": [\r\n {\r\n \"id\": \"/subscriptions/487bb485-b5b0-471e-9c0d-10717612f869/resourceGroups/myService1/providers/Microsoft.Compute/virtualMachines/testService\",\r\n \"ports\": [\r\n {\r\n \"number\": 22,\r\n \"protocol\": \"TCP\",\r\n \"allowedSourceAddressPrefix\": \"127.0.0.1\",\r\n \"maxRequestAccessDuration\": \"PT3H\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"requests\": [],\r\n \"provisioningState\": \"Succeeded\"\r\n },\r\n \"id\": \"/subscriptions/487bb485-b5b0-471e-9c0d-10717612f869/resourceGroups/myService1/providers/Microsoft.Security/locations/centralus/jitNetworkAccessPolicies/default\",\r\n \"name\": \"default\",\r\n \"type\": \"Microsoft.Security/locations/jitNetworkAccessPolicies\",\r\n \"location\": \"centralus\"\r\n}",
"ResponseBody": "{\r\n \"kind\": \"Basic\",\r\n \"properties\": {\r\n \"virtualMachines\": [\r\n {\r\n \"id\": \"/subscriptions/487bb485-b5b0-471e-9c0d-10717612f869/resourceGroups/myService1/providers/Microsoft.Compute/virtualMachines/testService\",\r\n \"ports\": [\r\n {\r\n \"number\": 22,\r\n \"protocol\": \"TCP\",\r\n \"allowedSourceAddressPrefix\": \"127.0.0.1\",\r\n \"maxRequestAccessDuration\": \"PT3H\"\r\n }\r\n ]\r\n }\r\n ],\r\n \"requests\": [],\r\n \"provisioningState\": \"Updating\",\r\n \"appendMode\": false\r\n },\r\n \"id\": \"/subscriptions/487bb485-b5b0-471e-9c0d-10717612f869/resourceGroups/myService1/providers/Microsoft.Security/locations/centralus/jitNetworkAccessPolicies/default\",\r\n \"name\": \"default\",\r\n \"type\": \"Microsoft.Security/locations/jitNetworkAccessPolicies\",\r\n \"location\": \"centralus\"\r\n}",
"StatusCode": 200
}
],
Expand Down
Loading