diff --git a/src/PSRule.Types/Definitions/ResourceHelper.cs b/src/PSRule.Types/Definitions/ResourceHelper.cs index e8d780a697..d56611e438 100644 --- a/src/PSRule.Types/Definitions/ResourceHelper.cs +++ b/src/PSRule.Types/Definitions/ResourceHelper.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +using PSRule.Definitions.Rules; + namespace PSRule.Definitions; internal static class ResourceHelper diff --git a/src/PSRule.Types/Definitions/SeverityLevel.cs b/src/PSRule.Types/Definitions/Rules/SeverityLevel.cs similarity index 93% rename from src/PSRule.Types/Definitions/SeverityLevel.cs rename to src/PSRule.Types/Definitions/Rules/SeverityLevel.cs index a929f8e687..bf55cc6b4f 100644 --- a/src/PSRule.Types/Definitions/SeverityLevel.cs +++ b/src/PSRule.Types/Definitions/Rules/SeverityLevel.cs @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -namespace PSRule.Definitions; +namespace PSRule.Definitions.Rules; /// /// If the rule fails, how serious is the result. diff --git a/src/PSRule/Common/ReasonExtensions.cs b/src/PSRule/Common/ReasonExtensions.cs index 8abcf5772f..4c0f455466 100644 --- a/src/PSRule/Common/ReasonExtensions.cs +++ b/src/PSRule/Common/ReasonExtensions.cs @@ -10,7 +10,7 @@ internal static class ReasonExtensions internal static string[] GetStrings(this IList reason) { if (reason == null || reason.Count == 0) - return Array.Empty(); + return []; var result = new string[reason.Count]; for (var i = 0; i < reason.Count; i++) diff --git a/src/PSRule/Common/SeverityLevelExtensions.cs b/src/PSRule/Common/SeverityLevelExtensions.cs index 6644a8d998..b86cd4be91 100644 --- a/src/PSRule/Common/SeverityLevelExtensions.cs +++ b/src/PSRule/Common/SeverityLevelExtensions.cs @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using PSRule.Definitions; +using PSRule.Definitions.Rules; namespace PSRule; diff --git a/src/PSRule/Data/IInputFileInfoCollection.cs b/src/PSRule/Data/IInputFileInfoCollection.cs new file mode 100644 index 0000000000..79dbc34a15 --- /dev/null +++ b/src/PSRule/Data/IInputFileInfoCollection.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +namespace PSRule.Data; + +/// +/// A collection of . +/// +public interface IInputFileInfoCollection : IEnumerable +{ + /// + /// Filters the collection to only include with a specific file extension. + /// + /// A file extension to filter the collection to. + /// A filtered collection. + IInputFileInfoCollection WithExtension(string extension); +} diff --git a/src/PSRule/Data/ITargetIssueCollection.cs b/src/PSRule/Data/ITargetIssueCollection.cs index 6c928219cf..198d143c68 100644 --- a/src/PSRule/Data/ITargetIssueCollection.cs +++ b/src/PSRule/Data/ITargetIssueCollection.cs @@ -22,48 +22,3 @@ public interface ITargetIssueCollection /// Returns true if any the collection contains any issues matching the specified . bool Any(string type = null); } - -/// -/// A collection of issues reported by a downstream tool. -/// -internal sealed class TargetIssueCollection : ITargetIssueCollection -{ - private List _Items; - - internal TargetIssueCollection() { } - - /// - public bool Any(string type = null) - { - return Get(type).Length > 0; - } - - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0046:Convert to conditional expression", Justification = "Avoid nested conditional expressions that increase complexity.")] - public TargetIssueInfo[] Get(string type = null) - { - if (_Items == null) - return Array.Empty(); - - return type == null ? _Items.ToArray() : _Items.Where(i => StringComparer.OrdinalIgnoreCase.Equals(i.Type, type)).ToArray(); - } - - /// - /// Add one or more issues into the collection. - /// - /// An array of instance to add to the collection. - internal void AddRange(TargetIssueInfo[] issueInfo) - { - for (var i = 0; issueInfo != null && i < issueInfo.Length; i++) - Add(issueInfo[i]); - } - - private void Add(TargetIssueInfo issueInfo) - { - if (issueInfo == null || string.IsNullOrEmpty(issueInfo.Type)) - return; - - _Items ??= new List(); - _Items.Add(issueInfo); - } -} diff --git a/src/PSRule/Data/InputFileInfoCollection.cs b/src/PSRule/Data/InputFileInfoCollection.cs index b5370004ed..b06914ea18 100644 --- a/src/PSRule/Data/InputFileInfoCollection.cs +++ b/src/PSRule/Data/InputFileInfoCollection.cs @@ -5,19 +5,6 @@ namespace PSRule.Data; -/// -/// A collection of . -/// -public interface IInputFileInfoCollection : IEnumerable -{ - /// - /// Filters the collection to only include with a specific file extension. - /// - /// A file extension to filter the collection to. - /// A filtered collection. - IInputFileInfoCollection WithExtension(string extension); -} - /// /// A collection of . /// diff --git a/src/PSRule/Data/TargetIssueCollection.cs b/src/PSRule/Data/TargetIssueCollection.cs new file mode 100644 index 0000000000..d78af94ce6 --- /dev/null +++ b/src/PSRule/Data/TargetIssueCollection.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +namespace PSRule.Data; + +/// +/// A collection of issues reported by a downstream tool. +/// +internal sealed class TargetIssueCollection : ITargetIssueCollection +{ + private List _Items; + + internal TargetIssueCollection() { } + + /// + public bool Any(string type = null) + { + return Get(type).Length > 0; + } + + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0046:Convert to conditional expression", Justification = "Avoid nested conditional expressions that increase complexity.")] + public TargetIssueInfo[] Get(string type = null) + { + if (_Items == null) + return Array.Empty(); + + return type == null ? _Items.ToArray() : _Items.Where(i => StringComparer.OrdinalIgnoreCase.Equals(i.Type, type)).ToArray(); + } + + /// + /// Add one or more issues into the collection. + /// + /// An array of instance to add to the collection. + internal void AddRange(TargetIssueInfo[] issueInfo) + { + for (var i = 0; issueInfo != null && i < issueInfo.Length; i++) + Add(issueInfo[i]); + } + + private void Add(TargetIssueInfo issueInfo) + { + if (issueInfo == null || string.IsNullOrEmpty(issueInfo.Type)) + return; + + _Items ??= new List(); + _Items.Add(issueInfo); + } +} diff --git a/src/PSRule/Definitions/Baselines/Baseline.cs b/src/PSRule/Definitions/Baselines/Baseline.cs index db07b0eb6f..4f5ff0704b 100644 --- a/src/PSRule/Definitions/Baselines/Baseline.cs +++ b/src/PSRule/Definitions/Baselines/Baseline.cs @@ -1,41 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using System.Management.Automation; using Newtonsoft.Json; -using PSRule.Configuration; using PSRule.Pipeline; -using PSRule.Resources; using YamlDotNet.Serialization; namespace PSRule.Definitions.Baselines; -/// -/// A specification for a V1 baseline resource. -/// -internal interface IBaselineV1Spec -{ - /// - /// Options that affect property binding. - /// - BindingOption Binding { get; set; } - - /// - /// Allows configuration key/ values to be specified that can be used within rule definitions. - /// - ConfigurationOption Configuration { get; set; } - - /// - /// Options that configure conventions. - /// - ConventionOption Convention { get; set; } - - /// - /// Options for that affect which rules are executed by including and filtering discovered rules. - /// - RuleOption Rule { get; set; } -} - /// /// A baseline resource V1. /// @@ -61,63 +32,3 @@ public Baseline(string apiVersion, SourceFile source, ResourceMetadata metadata, [YamlIgnore] public string Synopsis => Info.Synopsis.Text; } - -/// -/// A specification for a V1 baseline resource. -/// -public sealed class BaselineSpec : Spec, IBaselineV1Spec -{ - /// - public BindingOption Binding { get; set; } - - /// - public ConfigurationOption Configuration { get; set; } - - /// - public ConventionOption Convention { get; set; } - - /// - public RuleOption Rule { get; set; } -} - -internal sealed class BaselineFilter : IResourceFilter -{ - private readonly HashSet _Include; - private readonly WildcardPattern _WildcardMatch; - - public BaselineFilter(string[] include) - { - _Include = include == null || include.Length == 0 ? null : new HashSet(include, StringComparer.OrdinalIgnoreCase); - _WildcardMatch = null; - if (include != null && include.Length > 0 && WildcardPattern.ContainsWildcardCharacters(include[0])) - { - if (include.Length > 1) - throw new NotSupportedException(PSRuleResources.MatchSingleName); - - _WildcardMatch = new WildcardPattern(include[0]); - } - } - - ResourceKind IResourceFilter.Kind => ResourceKind.Baseline; - - public bool Match(IResource resource) - { - return _Include == null || _Include.Contains(resource.Name) || MatchWildcard(resource.Name); - } - - private bool MatchWildcard(string name) - { - return _WildcardMatch != null && _WildcardMatch.IsMatch(name); - } -} - -internal sealed class BaselineRef : ResourceRef -{ - public readonly ScopeType Type; - - public BaselineRef(string id, ScopeType scopeType) - : base(id, ResourceKind.Baseline) - { - Type = scopeType; - } -} diff --git a/src/PSRule/Definitions/Baselines/BaselineFilter.cs b/src/PSRule/Definitions/Baselines/BaselineFilter.cs new file mode 100644 index 0000000000..4101b0d742 --- /dev/null +++ b/src/PSRule/Definitions/Baselines/BaselineFilter.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using System.Management.Automation; +using PSRule.Resources; + +namespace PSRule.Definitions.Baselines; + +internal sealed class BaselineFilter : IResourceFilter +{ + private readonly HashSet _Include; + private readonly WildcardPattern _WildcardMatch; + + public BaselineFilter(string[] include) + { + _Include = include == null || include.Length == 0 ? null : new HashSet(include, StringComparer.OrdinalIgnoreCase); + _WildcardMatch = null; + if (include != null && include.Length > 0 && WildcardPattern.ContainsWildcardCharacters(include[0])) + { + if (include.Length > 1) + throw new NotSupportedException(PSRuleResources.MatchSingleName); + + _WildcardMatch = new WildcardPattern(include[0]); + } + } + + ResourceKind IResourceFilter.Kind => ResourceKind.Baseline; + + public bool Match(IResource resource) + { + return _Include == null || _Include.Contains(resource.Name) || MatchWildcard(resource.Name); + } + + private bool MatchWildcard(string name) + { + return _WildcardMatch != null && _WildcardMatch.IsMatch(name); + } +} diff --git a/src/PSRule/Definitions/Baselines/BaselineRef.cs b/src/PSRule/Definitions/Baselines/BaselineRef.cs new file mode 100644 index 0000000000..19f909c9e5 --- /dev/null +++ b/src/PSRule/Definitions/Baselines/BaselineRef.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using PSRule.Pipeline; + +namespace PSRule.Definitions.Baselines; + +internal sealed class BaselineRef : ResourceRef +{ + public readonly ScopeType Type; + + public BaselineRef(string id, ScopeType scopeType) + : base(id, ResourceKind.Baseline) + { + Type = scopeType; + } +} diff --git a/src/PSRule/Definitions/Baselines/BaselineSpec.cs b/src/PSRule/Definitions/Baselines/BaselineSpec.cs new file mode 100644 index 0000000000..2550f3549f --- /dev/null +++ b/src/PSRule/Definitions/Baselines/BaselineSpec.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using PSRule.Configuration; + +namespace PSRule.Definitions.Baselines; + +/// +/// A specification for a V1 baseline resource. +/// +public sealed class BaselineSpec : Spec, IBaselineV1Spec +{ + /// + public BindingOption Binding { get; set; } + + /// + public ConfigurationOption Configuration { get; set; } + + /// + public ConventionOption Convention { get; set; } + + /// + public RuleOption Rule { get; set; } +} diff --git a/src/PSRule/Definitions/Baselines/IBaselineV1Spec.cs b/src/PSRule/Definitions/Baselines/IBaselineV1Spec.cs new file mode 100644 index 0000000000..cf23413366 --- /dev/null +++ b/src/PSRule/Definitions/Baselines/IBaselineV1Spec.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using PSRule.Configuration; + +namespace PSRule.Definitions.Baselines; + +/// +/// A specification for a V1 baseline resource. +/// +internal interface IBaselineV1Spec +{ + /// + /// Options that affect property binding. + /// + BindingOption Binding { get; set; } + + /// + /// Allows configuration key/ values to be specified that can be used within rule definitions. + /// + ConfigurationOption Configuration { get; set; } + + /// + /// Options that configure conventions. + /// + ConventionOption Convention { get; set; } + + /// + /// Options for that affect which rules are executed by including and filtering discovered rules. + /// + RuleOption Rule { get; set; } +} diff --git a/src/PSRule/Definitions/Conventions/BaseConvention.cs b/src/PSRule/Definitions/Conventions/BaseConvention.cs index 27ababf42b..da2d54698f 100644 --- a/src/PSRule/Definitions/Conventions/BaseConvention.cs +++ b/src/PSRule/Definitions/Conventions/BaseConvention.cs @@ -3,48 +3,10 @@ using System.Collections; using System.Diagnostics; -using System.Management.Automation; -using PSRule.Pipeline; -using PSRule.Resources; using PSRule.Runtime; namespace PSRule.Definitions.Conventions; -internal sealed class ConventionFilter : IResourceFilter -{ - private readonly HashSet _Include; - private readonly WildcardPattern _WildcardMatch; - - public ConventionFilter(string[] include) - { - _Include = include == null || include.Length == 0 ? null : new HashSet(include, StringComparer.OrdinalIgnoreCase); - _WildcardMatch = null; - if (include != null && include.Length > 0 && WildcardPattern.ContainsWildcardCharacters(include[0])) - { - if (include.Length > 1) - throw new NotSupportedException(PSRuleResources.MatchSingleName); - - _WildcardMatch = new WildcardPattern(include[0]); - } - } - - ResourceKind IResourceFilter.Kind => ResourceKind.Convention; - - public bool Match(IResource resource) - { - return _Include != null && - (_Include.Contains(resource.Name) || - _Include.Contains(resource.Id.Value) || - MatchWildcard(resource.Name) || - MatchWildcard(resource.Id.Value)); - } - - private bool MatchWildcard(string name) - { - return _WildcardMatch != null && _WildcardMatch.IsMatch(name); - } -} - [DebuggerDisplay("{Id}")] internal abstract class BaseConvention : IConvention { diff --git a/src/PSRule/Definitions/Conventions/ConventionFilter.cs b/src/PSRule/Definitions/Conventions/ConventionFilter.cs new file mode 100644 index 0000000000..30c767ee16 --- /dev/null +++ b/src/PSRule/Definitions/Conventions/ConventionFilter.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using System.Management.Automation; +using PSRule.Resources; + +namespace PSRule.Definitions.Conventions; + +internal sealed class ConventionFilter : IResourceFilter +{ + private readonly HashSet _Include; + private readonly WildcardPattern _WildcardMatch; + + public ConventionFilter(string[] include) + { + _Include = include == null || include.Length == 0 ? null : new HashSet(include, StringComparer.OrdinalIgnoreCase); + _WildcardMatch = null; + if (include != null && include.Length > 0 && WildcardPattern.ContainsWildcardCharacters(include[0])) + { + if (include.Length > 1) + throw new NotSupportedException(PSRuleResources.MatchSingleName); + + _WildcardMatch = new WildcardPattern(include[0]); + } + } + + ResourceKind IResourceFilter.Kind => ResourceKind.Convention; + + public bool Match(IResource resource) + { + return _Include != null && + (_Include.Contains(resource.Name) || + _Include.Contains(resource.Id.Value) || + MatchWildcard(resource.Name) || + MatchWildcard(resource.Id.Value)); + } + + private bool MatchWildcard(string name) + { + return _WildcardMatch != null && _WildcardMatch.IsMatch(name); + } +} diff --git a/src/PSRule/Definitions/Conventions/ScriptBlockConvention.cs b/src/PSRule/Definitions/Conventions/ScriptBlockConvention.cs index 379659d127..f69b28ba18 100644 --- a/src/PSRule/Definitions/Conventions/ScriptBlockConvention.cs +++ b/src/PSRule/Definitions/Conventions/ScriptBlockConvention.cs @@ -3,7 +3,6 @@ using System.Collections; using System.Management.Automation; -using PSRule.Pipeline; using PSRule.Runtime; namespace PSRule.Definitions.Conventions; diff --git a/src/PSRule/Definitions/Expressions/ExpressionContext.cs b/src/PSRule/Definitions/Expressions/ExpressionContext.cs index 4587373e8d..cf7e5b0309 100644 --- a/src/PSRule/Definitions/Expressions/ExpressionContext.cs +++ b/src/PSRule/Definitions/Expressions/ExpressionContext.cs @@ -69,7 +69,7 @@ public void Reason(IOperand operand, string text, params object[] args) if (string.IsNullOrEmpty(text) || !RunspaceContext.CurrentThread.IsScope(RunspaceScope.Rule)) return; - _Reason ??= new List(); + _Reason ??= []; _Reason.Add(new ResultReason(Context.TargetObject?.Path, operand, text, args)); } @@ -78,7 +78,7 @@ public void Reason(string text, params object[] args) if (string.IsNullOrEmpty(text) || !RunspaceContext.CurrentThread.IsScope(RunspaceScope.Rule)) return; - _Reason ??= new List(); + _Reason ??= []; _Reason.Add(new ResultReason(Context.TargetObject?.Path, null, text, args)); } diff --git a/src/PSRule/Definitions/ModuleConfigs/ModuleConfig.cs b/src/PSRule/Definitions/ModuleConfigs/ModuleConfig.cs index 77bb33d6de..7308be47fb 100644 --- a/src/PSRule/Definitions/ModuleConfigs/ModuleConfig.cs +++ b/src/PSRule/Definitions/ModuleConfigs/ModuleConfig.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using Newtonsoft.Json; -using PSRule.Configuration; using PSRule.Pipeline; using YamlDotNet.Serialization; @@ -24,19 +23,3 @@ public ModuleConfigV1(string apiVersion, SourceFile source, ResourceMetadata met [YamlIgnore] public string Synopsis => Info.Synopsis.Text; } - -/// -/// A specification for a module configuration. -/// -internal sealed class ModuleConfigV1Spec : Spec -{ - public BindingOption Binding { get; set; } - - public ConfigurationOption Configuration { get; set; } - - public ConventionOption Convention { get; set; } - - public OutputOption Output { get; set; } - - public RuleOption Rule { get; set; } -} diff --git a/src/PSRule/Definitions/ModuleConfigs/ModuleConfigV1Spec.cs b/src/PSRule/Definitions/ModuleConfigs/ModuleConfigV1Spec.cs new file mode 100644 index 0000000000..4103a9a5bd --- /dev/null +++ b/src/PSRule/Definitions/ModuleConfigs/ModuleConfigV1Spec.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using PSRule.Configuration; + +namespace PSRule.Definitions.ModuleConfigs; + +/// +/// A specification for a module configuration. +/// +internal sealed class ModuleConfigV1Spec : Spec +{ + public BindingOption Binding { get; set; } + + public ConfigurationOption Configuration { get; set; } + + public ConventionOption Convention { get; set; } + + public OutputOption Output { get; set; } + + public RuleOption Rule { get; set; } +} diff --git a/src/PSRule/Definitions/Selectors/Selector.cs b/src/PSRule/Definitions/Selectors/SelectorV1.cs similarity index 67% rename from src/PSRule/Definitions/Selectors/Selector.cs rename to src/PSRule/Definitions/Selectors/SelectorV1.cs index e66c8e0aa1..ccbea2f6b5 100644 --- a/src/PSRule/Definitions/Selectors/Selector.cs +++ b/src/PSRule/Definitions/Selectors/SelectorV1.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using PSRule.Definitions.Expressions; using PSRule.Pipeline; namespace PSRule.Definitions.Selectors; @@ -15,11 +14,3 @@ internal sealed class SelectorV1 : InternalResource public SelectorV1(string apiVersion, SourceFile source, ResourceMetadata metadata, IResourceHelpInfo info, ISourceExtent extent, SelectorV1Spec spec) : base(ResourceKind.Selector, apiVersion, source, metadata, info, extent, spec) { } } - -/// -/// A specification for a V1 selector resource. -/// -internal sealed class SelectorV1Spec : Spec -{ - public LanguageIf If { get; set; } -} diff --git a/src/PSRule/Definitions/Selectors/SelectorV1Spec.cs b/src/PSRule/Definitions/Selectors/SelectorV1Spec.cs new file mode 100644 index 0000000000..8a7ba7670b --- /dev/null +++ b/src/PSRule/Definitions/Selectors/SelectorV1Spec.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using PSRule.Definitions.Expressions; + +namespace PSRule.Definitions.Selectors; + +/// +/// A specification for a V1 selector resource. +/// +internal sealed class SelectorV1Spec : Spec +{ + public LanguageIf If { get; set; } +} diff --git a/src/PSRule/Definitions/Selectors/SelectorVisitor.cs b/src/PSRule/Definitions/Selectors/SelectorVisitor.cs index 251acc731e..13b9fde195 100644 --- a/src/PSRule/Definitions/Selectors/SelectorVisitor.cs +++ b/src/PSRule/Definitions/Selectors/SelectorVisitor.cs @@ -3,7 +3,6 @@ using System.Diagnostics; using PSRule.Definitions.Expressions; -using PSRule.Pipeline; using PSRule.Resources; using PSRule.Runtime; diff --git a/src/PSRule/Definitions/SuppressionGroups/SuppressionGroup.cs b/src/PSRule/Definitions/SuppressionGroups/ISuppressionGroupV1Spec.cs similarity index 50% rename from src/PSRule/Definitions/SuppressionGroups/SuppressionGroup.cs rename to src/PSRule/Definitions/SuppressionGroups/ISuppressionGroupV1Spec.cs index 6462f5acb1..1e69df583e 100644 --- a/src/PSRule/Definitions/SuppressionGroups/SuppressionGroup.cs +++ b/src/PSRule/Definitions/SuppressionGroups/ISuppressionGroupV1Spec.cs @@ -1,8 +1,7 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using PSRule.Definitions.Expressions; -using PSRule.Pipeline; namespace PSRule.Definitions.SuppressionGroups; @@ -29,28 +28,3 @@ internal interface ISuppressionGroupV1Spec /// LanguageIf If { get; } } - -/// -/// A suppression group resource V1. -/// -[Spec(Specs.V1, Specs.SuppressionGroup)] -internal sealed class SuppressionGroupV1 : InternalResource -{ - public SuppressionGroupV1(string apiVersion, SourceFile source, ResourceMetadata metadata, IResourceHelpInfo info, ISourceExtent extent, SuppressionGroupV1Spec spec) - : base(ResourceKind.SuppressionGroup, apiVersion, source, metadata, info, extent, spec) { } -} - -/// -/// A specification for a V1 suppression group resource. -/// -internal sealed class SuppressionGroupV1Spec : Spec, ISuppressionGroupV1Spec -{ - /// - public DateTime? ExpiresOn { get; set; } - - /// - public string[] Rule { get; set; } - - /// - public LanguageIf If { get; set; } -} diff --git a/src/PSRule/Definitions/SuppressionGroups/SuppressionGroupV1.cs b/src/PSRule/Definitions/SuppressionGroups/SuppressionGroupV1.cs new file mode 100644 index 0000000000..5f11f024b2 --- /dev/null +++ b/src/PSRule/Definitions/SuppressionGroups/SuppressionGroupV1.cs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using PSRule.Pipeline; + +namespace PSRule.Definitions.SuppressionGroups; + +/// +/// A suppression group resource V1. +/// +[Spec(Specs.V1, Specs.SuppressionGroup)] +internal sealed class SuppressionGroupV1 : InternalResource +{ + public SuppressionGroupV1(string apiVersion, SourceFile source, ResourceMetadata metadata, IResourceHelpInfo info, ISourceExtent extent, SuppressionGroupV1Spec spec) + : base(ResourceKind.SuppressionGroup, apiVersion, source, metadata, info, extent, spec) { } +} diff --git a/src/PSRule/Definitions/SuppressionGroups/SuppressionGroupV1Spec.cs b/src/PSRule/Definitions/SuppressionGroups/SuppressionGroupV1Spec.cs new file mode 100644 index 0000000000..f539806a2d --- /dev/null +++ b/src/PSRule/Definitions/SuppressionGroups/SuppressionGroupV1Spec.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using PSRule.Definitions.Expressions; + +namespace PSRule.Definitions.SuppressionGroups; + +/// +/// A specification for a V1 suppression group resource. +/// +internal sealed class SuppressionGroupV1Spec : Spec, ISuppressionGroupV1Spec +{ + /// + public DateTime? ExpiresOn { get; set; } + + /// + public string[] Rule { get; set; } + + /// + public LanguageIf If { get; set; } +} diff --git a/src/PSRule/Pipeline/AssertPipelineBuilder.cs b/src/PSRule/Pipeline/AssertPipelineBuilder.cs index 9e6a95892b..de0a7999a4 100644 --- a/src/PSRule/Pipeline/AssertPipelineBuilder.cs +++ b/src/PSRule/Pipeline/AssertPipelineBuilder.cs @@ -3,7 +3,7 @@ using System.Management.Automation; using PSRule.Configuration; -using PSRule.Definitions; +using PSRule.Definitions.Rules; using PSRule.Pipeline.Formatters; using PSRule.Pipeline.Output; using PSRule.Resources; diff --git a/src/PSRule/Pipeline/DefaultPipelineResult.cs b/src/PSRule/Pipeline/DefaultPipelineResult.cs index 49491d4f83..c7d1bf64b0 100644 --- a/src/PSRule/Pipeline/DefaultPipelineResult.cs +++ b/src/PSRule/Pipeline/DefaultPipelineResult.cs @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using PSRule.Definitions; +using PSRule.Definitions.Rules; using PSRule.Options; namespace PSRule.Pipeline; diff --git a/src/PSRule/Pipeline/Formatters/AzurePipelinesFormatter.cs b/src/PSRule/Pipeline/Formatters/AzurePipelinesFormatter.cs index 83847d78e2..0a7dc1ee1b 100644 --- a/src/PSRule/Pipeline/Formatters/AzurePipelinesFormatter.cs +++ b/src/PSRule/Pipeline/Formatters/AzurePipelinesFormatter.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License. using PSRule.Configuration; +using PSRule.Definitions.Rules; using PSRule.Rules; namespace PSRule.Pipeline.Formatters; @@ -50,13 +51,13 @@ protected override void FailDetail(RuleRecord record) { base.FailDetail(record); var message = GetFailMessage(record); - if (record.Level == Definitions.SeverityLevel.Error) + if (record.Level == SeverityLevel.Error) Error(message); - if (record.Level == Definitions.SeverityLevel.Warning) + if (record.Level == SeverityLevel.Warning) Warning(message); - if (record.Level != Definitions.SeverityLevel.Information) + if (record.Level != SeverityLevel.Information) LineBreak(); } } diff --git a/src/PSRule/Pipeline/Formatters/GitHubActionsFormatter.cs b/src/PSRule/Pipeline/Formatters/GitHubActionsFormatter.cs index 9a95edcfe2..3c57d3fa7c 100644 --- a/src/PSRule/Pipeline/Formatters/GitHubActionsFormatter.cs +++ b/src/PSRule/Pipeline/Formatters/GitHubActionsFormatter.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License. using PSRule.Configuration; +using PSRule.Definitions.Rules; using PSRule.Rules; namespace PSRule.Pipeline.Formatters; @@ -52,13 +53,13 @@ protected override void FailDetail(RuleRecord record) { base.FailDetail(record); var message = GetFailMessage(record); - if (record.Level == Definitions.SeverityLevel.Error) + if (record.Level == SeverityLevel.Error) Error(message); - if (record.Level == Definitions.SeverityLevel.Warning) + if (record.Level == SeverityLevel.Warning) Warning(message); - if (record.Level == Definitions.SeverityLevel.Information) + if (record.Level == SeverityLevel.Information) Information(message); LineBreak(); diff --git a/src/PSRule/Pipeline/InvokeResult.cs b/src/PSRule/Pipeline/InvokeResult.cs index 1abb4bce83..a95a27b132 100644 --- a/src/PSRule/Pipeline/InvokeResult.cs +++ b/src/PSRule/Pipeline/InvokeResult.cs @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using PSRule.Definitions; +using PSRule.Definitions.Rules; using PSRule.Rules; namespace PSRule.Pipeline;