-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Impelement secrets detection for Az modules (#412)
* Impelement secrets detection for Az modules * Move some implementation from common to Az.Accounts and revise/rename ISanitizerSettings interface. * Rename telemetry property name * Make DefaultProviderResolver public due to reference needed in Az.Accounts * Add IgnoredProperties in ISanitizerService to filter out special properties that may cause performance concern like lazy load properties. * Return null for AzurePSSanitizer when AzureSession is not properly initialized * Skip indexed properties in the object traverse * Update sanitizer and move providers out to Az.Accounts
- Loading branch information
1 parent
2cd3afb
commit 0b6cb59
Showing
7 changed files
with
170 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// 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. | ||
// ---------------------------------------------------------------------------------- | ||
|
||
namespace Microsoft.WindowsAzure.Commands.Common.Sanitizer | ||
{ | ||
public interface IOutputSanitizer | ||
{ | ||
bool RequireSecretsDetection { get; } | ||
|
||
void Sanitize(object sanitizingObject, out SanitizerTelemetry telemetryData); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// 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 System; | ||
using System.Collections.Generic; | ||
|
||
namespace Microsoft.WindowsAzure.Commands.Common.Sanitizer | ||
{ | ||
public class SanitizerTelemetry | ||
{ | ||
public bool ShowSecretsWarning { get; set; } = false; | ||
|
||
public HashSet<string> DetectedProperties { get; set; } = new HashSet<string>(); | ||
|
||
public bool HasErrorInDetection { get; set; } = false; | ||
|
||
public Exception DetectionError { get; set; } | ||
|
||
public TimeSpan SanitizeDuration { get; set; } | ||
|
||
public void Combine(SanitizerTelemetry telemetry) | ||
{ | ||
if (telemetry != null) | ||
{ | ||
ShowSecretsWarning = ShowSecretsWarning || telemetry.ShowSecretsWarning; | ||
DetectedProperties.UnionWith(telemetry.DetectedProperties); | ||
HasErrorInDetection = HasErrorInDetection || telemetry.HasErrorInDetection; | ||
DetectionError = DetectionError ?? telemetry.DetectionError; | ||
SanitizeDuration += telemetry.SanitizeDuration; | ||
} | ||
} | ||
} | ||
} |