forked from microsoft/PSRule
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for overriding rule severity level microsoft#1180
- Loading branch information
1 parent
11852a9
commit 46086cf
Showing
59 changed files
with
1,320 additions
and
108 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
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,26 @@ | ||
# Options | ||
|
||
Options are used to customize how rules are evaluated and the resulting output. | ||
You can set options in multiple ways, including: | ||
|
||
- Parameters | ||
- Environment variables | ||
- Configuration files | ||
|
||
Rules or modules could also have a defaults configured by the rule or module author. | ||
|
||
## Option precedence | ||
|
||
When setting options, you may have a situation where an option is set to different values. | ||
For example, you may set an option in a configuration file and also set the same option as a parameter. | ||
|
||
When this happens, PSRule will use the option with the highest precedence. | ||
|
||
Option precedence is as follows: | ||
|
||
1. Parameters | ||
2. Explicit baselines | ||
3. Environment variables | ||
4. Configuration files | ||
5. Default baseline | ||
6. Module defaults |
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,19 @@ | ||
# SARIF Output | ||
|
||
PSRule uses a JSON structured output format called the | ||
|
||
SARIF format to report results. | ||
The SARIF format is a standard format for the output of static analysis tools. | ||
The format is designed to be easily consumed by other tools and services. | ||
|
||
## Runs | ||
|
||
When running PSRule executed a run will be generated in `runs` containing details about PSRule and configuration details. | ||
|
||
## Invocation | ||
|
||
The `invocation` property reports runtime information about how the run started. | ||
|
||
### RuleConfigurationOverrides | ||
|
||
When a rule has been overridden in configuration this invocation property will contain any level overrides. |
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
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,72 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections; | ||
using PSRule.Converters; | ||
|
||
namespace PSRule.Data; | ||
|
||
/// <summary> | ||
/// A mapping of string to string arrays. | ||
/// </summary> | ||
public sealed class EnumMap<T> : KeyMap<T> where T : struct, Enum | ||
{ | ||
/// <summary> | ||
/// Create an empty <see cref="EnumMap{T}"/> instance. | ||
/// </summary> | ||
public EnumMap() | ||
: base() { } | ||
|
||
/// <summary> | ||
/// Create an instance by copying an existing <see cref="EnumMap{T}"/>. | ||
/// </summary> | ||
internal EnumMap(EnumMap<T> map) | ||
: base(map) { } | ||
|
||
/// <summary> | ||
/// Create an instance by copying mapped keys from a string dictionary. | ||
/// </summary> | ||
internal EnumMap(IDictionary<string, T> map) | ||
: base(map) { } | ||
|
||
/// <summary> | ||
/// Create an instance by copying mapped keys from a <seealso cref="Hashtable"/>. | ||
/// </summary> | ||
/// <param name="map"></param> | ||
internal EnumMap(Hashtable map) | ||
: base(map) { } | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="hashtable"></param> | ||
public static implicit operator EnumMap<T>(Hashtable hashtable) | ||
{ | ||
return new EnumMap<T>(hashtable); | ||
} | ||
|
||
/// <summary> | ||
/// Convert a hashtable into a <see cref="EnumMap{T}"/> instance. | ||
/// </summary> | ||
public static EnumMap<T> FromHashtable(Hashtable hashtable) | ||
{ | ||
return new EnumMap<T>(hashtable); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="o"></param> | ||
/// <param name="value"></param> | ||
/// <returns></returns> | ||
protected override bool TryConvertValue(object o, out T value) | ||
{ | ||
value = default; | ||
if (TypeConverter.TryEnum<T>(o, convert: true, out var result) && result != null) | ||
{ | ||
value = result.Value; | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
Oops, something went wrong.