|
| 1 | +@{ |
| 2 | + # ========================================================================= |
| 3 | + # Global behavior |
| 4 | + # ========================================================================= |
| 5 | + EnableExit = $true # makes Invoke-ScriptAnalyzer exit non-zero when it finds Error severity findings |
| 6 | + |
| 7 | + # ========================================================================= |
| 8 | + # Baseline rule set (applies repo-wide) |
| 9 | + # ========================================================================= |
| 10 | + IncludeRules = @( |
| 11 | + # Formatting |
| 12 | + 'PSUseConsistentIndentation' |
| 13 | + 'PSUseConsistentWhitespace' |
| 14 | + |
| 15 | + # Style / maintainability |
| 16 | + 'PSAvoidUsingCmdletAliases' |
| 17 | + 'PSUseDeclaredVarsMoreThanAssignments' |
| 18 | + 'PSAvoidGlobalVars' |
| 19 | + |
| 20 | + # Security / safety |
| 21 | + 'PSAvoidUsingWriteHost' |
| 22 | + 'PSAvoidUsingInvokeExpression' |
| 23 | + 'PSAvoidUsingEmptyCatchBlock' |
| 24 | + |
| 25 | + # Correctness for state-changing commands |
| 26 | + 'PSUseShouldProcessForStateChangingFunctions' |
| 27 | + ) |
| 28 | + |
| 29 | + Rules = @{ |
| 30 | + # ------------------------- |
| 31 | + # Formatting config |
| 32 | + # ------------------------- |
| 33 | + PSUseConsistentIndentation = @{ |
| 34 | + Enable = $true |
| 35 | + Kind = 'space' |
| 36 | + IndentationSize = 4 |
| 37 | + PipelineIndentation = 'IncreaseIndentationForFirstPipeline' |
| 38 | + } |
| 39 | + |
| 40 | + PSUseConsistentWhitespace = @{ |
| 41 | + Enable = $true |
| 42 | + CheckInnerBrace = $true |
| 43 | + CheckOpenBrace = $true |
| 44 | + CheckOpenParen = $true |
| 45 | + CheckOperator = $true |
| 46 | + CheckSeparator = $true |
| 47 | + } |
| 48 | + |
| 49 | + # ------------------------- |
| 50 | + # Hygiene / maintainability |
| 51 | + # ------------------------- |
| 52 | + PSAvoidUsingCmdletAliases = @{ Enable = $true } |
| 53 | + PSUseDeclaredVarsMoreThanAssignments = @{ Enable = $true } |
| 54 | + PSAvoidGlobalVars = @{ Enable = $true } |
| 55 | + |
| 56 | + # ------------------------- |
| 57 | + # Security / safety |
| 58 | + # ------------------------- |
| 59 | + PSAvoidUsingWriteHost = @{ Enable = $true } |
| 60 | + PSAvoidUsingInvokeExpression = @{ Enable = $true } |
| 61 | + PSAvoidUsingEmptyCatchBlock = @{ Enable = $true } |
| 62 | + |
| 63 | + # ------------------------- |
| 64 | + # Correctness |
| 65 | + # ------------------------- |
| 66 | + PSUseShouldProcessForStateChangingFunctions = @{ Enable = $true } |
| 67 | + } |
| 68 | + |
| 69 | + # ========================================================================= |
| 70 | + # Severity control (Error vs Warning) |
| 71 | + # ========================================================================= |
| 72 | + RuleSeverity = @{ |
| 73 | + # Formatting: warnings |
| 74 | + PSUseConsistentIndentation = 'Warning' |
| 75 | + PSUseConsistentWhitespace = 'Warning' |
| 76 | + |
| 77 | + # Hygiene: warnings |
| 78 | + PSAvoidUsingCmdletAliases = 'Warning' |
| 79 | + PSUseDeclaredVarsMoreThanAssignments = 'Warning' |
| 80 | + PSAvoidGlobalVars = 'Warning' |
| 81 | + PSAvoidUsingEmptyCatchBlock = 'Warning' |
| 82 | + |
| 83 | + # Security: make IEX an Error |
| 84 | + PSAvoidUsingInvokeExpression = 'Error' |
| 85 | + |
| 86 | + # Behavior: choose Warning (you can flip to Error later if you want) |
| 87 | + PSAvoidUsingWriteHost = 'Warning' |
| 88 | + |
| 89 | + # Best practice gate: Error |
| 90 | + PSUseShouldProcessForStateChangingFunctions = 'Error' |
| 91 | + } |
| 92 | + |
| 93 | + # ========================================================================= |
| 94 | + # Path scoping (GUI-only suppressions, repo-wide scanning otherwise) |
| 95 | + # ========================================================================= |
| 96 | + # |
| 97 | + # PSA still scans everything; these blocks only adjust rules for matching files. |
| 98 | + # |
| 99 | + # IMPORTANT: These regex paths assume Linux-style forward slashes (GitHub ubuntu runner). |
| 100 | + # |
| 101 | + Settings = @( |
| 102 | + # --------------------------------------------------------------------- |
| 103 | + # GUI scripts: suppress console-focused or noisy rules |
| 104 | + # --------------------------------------------------------------------- |
| 105 | + @{ |
| 106 | + Include = @( |
| 107 | + # SysAdmin tools with GUI / WinForms naming |
| 108 | + '^SysAdmin-Tools/.+/(.+GUI.+|.+WinForms.+|.+Form.+)\.ps1$', |
| 109 | + '^SysAdmin-Tools/.+/(.+GUI.+|.+WinForms.+|.+Form.+)\.psm1$', |
| 110 | + |
| 111 | + # Core library GUI helpers / launchers (adjust if needed) |
| 112 | + '^Core-ScriptLibrary/.+/(.+GUI.+|.+WinForms.+|.+Form.+)\.ps1$', |
| 113 | + '^Core-ScriptLibrary/.+/(.+GUI.+|.+WinForms.+|.+Form.+)\.psm1$', |
| 114 | + |
| 115 | + # ITSM GUI scripts |
| 116 | + '^ITSM-Templates-(WKS|SVR)/.+/(.+GUI.+|.+WinForms.+|.+Form.+)\.ps1$', |
| 117 | + '^ITSM-Templates-(WKS|SVR)/.+/(.+GUI.+|.+WinForms.+|.+Form.+)\.psm1$', |
| 118 | + |
| 119 | + # ProSuite Hub launchers often are UI-ish |
| 120 | + '^ProSuite-Hub/.+/(.+GUI.+|.+WinForms.+|.+Form.+|.+Launcher.+)\.ps1$', |
| 121 | + '^ProSuite-Hub/.+/(.+GUI.+|.+WinForms.+|.+Form.+|.+Launcher.+)\.psm1$' |
| 122 | + ) |
| 123 | + |
| 124 | + # In GUI tools, console output rules can be counterproductive. |
| 125 | + ExcludeRules = @( |
| 126 | + 'PSAvoidUsingWriteHost' |
| 127 | + ) |
| 128 | + |
| 129 | + # Optionally relax ShouldProcess for GUI-only wrappers (uncomment if needed) |
| 130 | + # ExcludeRules = @('PSAvoidUsingWriteHost','PSUseShouldProcessForStateChangingFunctions') |
| 131 | + } |
| 132 | + |
| 133 | + # --------------------------------------------------------------------- |
| 134 | + # ProSuite-Hub: often orchestration; keep strict but practical |
| 135 | + # --------------------------------------------------------------------- |
| 136 | + @{ |
| 137 | + Include = @('^ProSuite-Hub/') |
| 138 | + |
| 139 | + # Keep full baseline rules; just adjust severity if desired |
| 140 | + RuleSeverity = @{ |
| 141 | + PSAvoidUsingWriteHost = 'Warning' |
| 142 | + } |
| 143 | + } |
| 144 | + ) |
| 145 | +} |
0 commit comments