Skip to content

deprecating direct access, bug fix at DDM rules #515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
336 changes: 0 additions & 336 deletions setup/azurecmdfiles.wxi

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,10 @@
<data name="DeprecatedEventTypeUsed" xml:space="preserve">
<value>The use of any of these event types is deprecated: DataAccess, SchemaChanges, DataChanges, SecurityExceptions, RevokePermissions</value>
</data>
<data name="DeprecatedCmdletUsageWarning" xml:space="preserve">
<value>The {0} cmdlet is deprecated and will be removed in a future release.</value>
</data>
<data name="NewDataMaskingRuleIdIsNotValid" xml:space="preserve">
<value>Rule Id cannot contain '&lt;,&gt;,+,=,#,*,%,&amp;,\,/,?' and cannot end with a '.'</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,12 @@ public abstract class BuildAzureSqlDatabaseDataMaskingRule : SqlDatabaseDataMask
/// <summary>
/// Gets or sets the table name
/// </summary>
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The table name.")]
[ValidateNotNullOrEmpty]
public string TableName { get; set; }
public virtual string TableName { get; set; }

/// <summary>
/// Gets or sets the column name
/// </summary>
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The column name.")]
[ValidateNotNullOrEmpty]
public string ColumnName { get; set; }
public virtual string ColumnName { get; set; }

/// <summary>
/// Gets or sets the masking function - the definition of this property as a cmdlet parameter is done in the subclasses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System.Globalization;
using System.Linq;
using System.Management.Automation;
using System.Text.RegularExpressions;

namespace Microsoft.Azure.Commands.Sql.Security.Cmdlet.DataMasking
{
Expand All @@ -28,6 +29,20 @@ namespace Microsoft.Azure.Commands.Sql.Security.Cmdlet.DataMasking
[Cmdlet(VerbsCommon.New, "AzureSqlDatabaseDataMaskingRule")]
public class NewAzureSqlDatabaseDataMaskingRule : BuildAzureSqlDatabaseDataMaskingRule
{
/// <summary>
/// Gets or sets the column name
/// </summary>
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The column name.")]
[ValidateNotNullOrEmpty]
public override string ColumnName { get; set; }

/// <summary>
/// Gets or sets the table name
/// </summary>
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The table name.")]
[ValidateNotNullOrEmpty]
public override string TableName { get; set; }

/// <summary>
/// Gets or sets the masking function
/// </summary>
Expand All @@ -52,6 +67,12 @@ protected override IEnumerable<DatabaseDataMaskingRuleModel> GetEntity()
/// <returns>An error message or null if all is fine</returns>
protected override string ValidateOperation(IEnumerable<DatabaseDataMaskingRuleModel> rules)
{
var ruleIdRegex = new Regex("^[^/\\\\#+=<>*%&:?]*[^/\\\\#+=<>*%&:?.]$");

if (!ruleIdRegex.IsMatch(RuleId)) // an invalid rule name
{
return string.Format(CultureInfo.InvariantCulture, Resources.NewDataMaskingRuleIdIsNotValid, RuleId);
}
if(rules.Any(r=> r.RuleId == RuleId))
{
return string.Format(CultureInfo.InvariantCulture, Resources.NewDataMaskingRuleIdAlreadyExistError, RuleId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ namespace Microsoft.Azure.Commands.Sql.Security.Cmdlet.DataMasking
[Cmdlet(VerbsCommon.Set, "AzureSqlDatabaseDataMaskingRule")]
public class SetAzureSqlDatabaseDataMaskingRule : BuildAzureSqlDatabaseDataMaskingRule
{

/// <summary>
/// Gets or sets the column name
/// </summary>
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The column name.")]
public override string ColumnName { get; set; }

/// <summary>
/// Gets or sets the table name
/// </summary>
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The table name.")]
public override string TableName { get; set; }


/// <summary>
/// Gets or sets the masking function
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Sql.Properties;
using Microsoft.Azure.Commands.Sql.Security.Model;
using System.Management.Automation;

Expand Down Expand Up @@ -41,6 +42,8 @@ public class DisableAzureSqlDatabaseDirectAccess : SqlDatabaseSecureConnectionCm
/// <param name="model">A model object</param>
protected override DatabaseSecureConnectionPolicyModel ApplyUserInputToModel(DatabaseSecureConnectionPolicyModel model)
{

WriteWarning(string.Format(Resources.DeprecatedCmdletUsageWarning, "Disable-AzureSqlDatabaseDirectAccess"));
model.SecureConnectionState = SecureConnectionStateType.Required;
return model;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Sql.Properties;
using Microsoft.Azure.Commands.Sql.Security.Model;
using System.Management.Automation;

Expand Down Expand Up @@ -41,6 +42,7 @@ public class EnableAzureSqlDatabaseDirectAccess : SqlDatabaseSecureConnectionCmd
/// <param name="model">A model object</param>
protected override DatabaseSecureConnectionPolicyModel ApplyUserInputToModel(DatabaseSecureConnectionPolicyModel model)
{
WriteWarning(string.Format(Resources.DeprecatedCmdletUsageWarning, "Enable-AzureSqlDatabaseDirectAccess"));
model.SecureConnectionState = SecureConnectionStateType.Optional;
return model;
}
Expand Down