Skip to content

SuppressMessageAttribute does not suppress rules in DSC configurations #523

@PlagueHO

Description

@PlagueHO

PSSA is being run as part of the DSC resource validation process.

Many of the DSC resources contain samples that violate various rules, the most common being PSAvoidUsingConvertToSecureStringWithPlainText.

We should be able to suppress these errors by adding a function decoration:

[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")]

However, the SuppressMessageAttribute decorations only seem to suppress the rule violation message in a Function, not a DSC Configuration.

E.g. This suppresses correctly:

Function xFileUpload
{  
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")]
param ([string] $decryptedPassword)
$securePassword = ConvertTo-SecureString $decryptedPassword -AsPlainText -Force
}

Rule violation suppression does not work:

Configuration xFileUpload
{   
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")]
param ([string] $decryptedPassword)
$securePassword = ConvertTo-SecureString $decryptedPassword -AsPlainText -Force
}

Many of the current community DSC resources can't be updated (without causing build failures) due to this.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions