Skip to content

Commit

Permalink
Allow 'asazure.windows.net' for no-hardcoded-env-urls (#8871)
Browse files Browse the repository at this point in the history
* Allow 'asazure.windows.net' for no-hardcoded-env-urls

* fix tests

Co-authored-by: Stephen Weatherford <Stephen.Weatherford.com>
  • Loading branch information
StephenWeatherford authored Nov 3, 2022
1 parent e43d137 commit 1384ca1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public void GetBuiltInConfiguration_NoParameter_ReturnsBuiltInConfigurationWithA
""level"": ""warning"",
""disallowedhosts"": [
""api.loganalytics.io"",
""asazure.windows.net"",
""azuredatalakeanalytics.net"",
""azuredatalakestore.net"",
""batch.core.windows.net"",
Expand Down Expand Up @@ -211,7 +210,6 @@ public void GetBuiltInConfiguration_DisableAnalyzers_ReturnsBuiltInConfiguration
""level"": ""off"",
""disallowedhosts"": [
""api.loganalytics.io"",
""asazure.windows.net"",
""azuredatalakeanalytics.net"",
""azuredatalakestore.net"",
""batch.core.windows.net"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void InsideExpressions(int diagnosticCount, string text)
}

[DataTestMethod]
// valid matches
// valid matches (i.e., linter rule fails)
[DataRow("aschema.management.azure.com", true)]
[DataRow("azure.aschema.management.azure.com", true)]
[DataRow("management.azure.com", true)]
Expand All @@ -142,7 +142,7 @@ public void InsideExpressions(int diagnosticCount, string text)
[DataRow("subdomain1.management.azure.com", true)]
[DataRow("http://subdomain1.management.azure.com", true)]
[DataRow("https://subdomain1.management.azure.com", true)]
// should not match
// should not match (i.e., linter rule passes)
[DataRow("azure.schema.management.azure.com", false)]
[DataRow("othermanagement.azure.com", false)]
[DataRow("azure.schema.mannnnagement.azure.com", false)]
Expand All @@ -152,6 +152,8 @@ public void InsideExpressions(int diagnosticCount, string text)
[DataRow("subdomain1.management.azzzure.com", false)]
[DataRow("http://subdomain1.manageeeement.azure.com", false)]
[DataRow("https://subdomain1.managemeeeent.azure.com", false)]
[DataRow("asazure.windows.net/servers}", false)]
[DataRow("${'location'}.asazure.windows.net/servers/${'aasServerName'}", false)]
public void DisallowedHostsMatchingTest(string testString, bool isMatch)
{
AssertLinterRuleDiagnostics(NoHardcodedEnvironmentUrlsRule.Code, @$"output str string = '{testString}'", diags =>
Expand All @@ -168,15 +170,17 @@ public void DisallowedHostsMatchingTest(string testString, bool isMatch)
}

[DataTestMethod]
// valid matches
// valid matches (i.e. it will be excluded and there should be no linter failures)
[DataRow("schema.management.azure.com", true)]
[DataRow("http://schema.management.azure.com", true)]
[DataRow("https://schema.management.azure.com", true)]
[DataRow("subany.schema.management.azure.com", true)]
[DataRow("http://subany.schema.management.azure.com", true)]
[DataRow("https://subany.schema.management.azure.com", true)]
[DataRow("https://subany.SCHEMA.MANAGEMENT.Azure.Com", true)]
[DataRow("all the world is a stage, but subdomain1.schema.management.azure.com should not be hardcoded", true)]
// should not match
[DataRow("rasazure.windows.net/servers}", true)]
// should not match (i.e. it will not be excluded and there *should* be linter failures)
[DataRow("aschema.management.azure.com", false)]
[DataRow("azure.aschema.management.azure.com", false)]
[DataRow("management.azure.com", false)]
Expand All @@ -186,7 +190,7 @@ public void DisallowedHostsMatchingTest(string testString, bool isMatch)
[DataRow("http://subdomain1.management.azure.com", false)]
[DataRow("https://subdomain1.management.azure.com", false)]
[DataRow("all the world is a stage, but subdomain1.management.azure.com should not be hardcoded", false)]
[DataRow("all the world is a stage, but subdomain1.schema.management.azure.com should not be hardcoded", true)]
[DataRow("all the world is a stage, but subdomain1.1schema.management.azure.com should not be hardcoded", false)]
public void ExcludedHostsMatchingTest(string testString, bool isMatch)
{
AssertLinterRuleDiagnostics(NoHardcodedEnvironmentUrlsRule.Code, @$"output str string = '{testString}'", diags =>
Expand Down
1 change: 0 additions & 1 deletion src/Bicep.Core/Configuration/bicepconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"level": "warning",
"disallowedhosts": [
"api.loganalytics.io",
"asazure.windows.net",
"azuredatalakeanalytics.net",
"azuredatalakestore.net",
"batch.core.windows.net",
Expand Down
1 change: 0 additions & 1 deletion src/vscode-bicep/schemas/bicepconfig.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@
"type": "array",
"default": [
"api.loganalytics.io",
"asazure.windows.net",
"azuredatalakeanalytics.net",
"azuredatalakestore.net",
"batch.core.windows.net",
Expand Down

0 comments on commit 1384ca1

Please sign in to comment.