Skip to content

Profile value failure should throw a terminating error #358

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

Closed
juneb opened this issue Nov 12, 2015 · 4 comments
Closed

Profile value failure should throw a terminating error #358

juneb opened this issue Nov 12, 2015 · 4 comments
Assignees

Comments

@juneb
Copy link
Contributor

juneb commented Nov 12, 2015

When you use the Profile parameter, but the value is invalid (hash table, variable containing a hash table, incorrect key name), PSScriptAnalyzer generates a warning, but continues to run the test.

Because the profile is the user's instruction for running the test, when Invoke-ScriptAnalyzer cannot follow that instruction for any reason, the test should immediately fail with a terminating error.

Otherwise, you waste the user's time running the wrong test and, more importantly, if the user has logged output and not examined the warning/error stream, the user might not know that the test they ran was not the test they designed.

Be sure that the error message helps the user to solve the problem. For example, list the valid keys in a profile hash table, rather than just telling the user that the key is invalid.

@raghushantha
Copy link
Member

June. Here is the PR for the issue:
#392

Summary of changes - Let us know if have any input
For an invalid profile - emit non-terminating errors for each issue in Profile and stop the Engine execution - This will prevent any rules from running

For a profile containing combination of valid and invalid keys, emit Warnings for invalid keys, but continue the execution. The Warnings will contain additional info about the Keys supported

@juneb
Copy link
Contributor Author

juneb commented Dec 2, 2015

Why use a warning for an invalid key? The user intended to do something and it failed, so the output is not what they wanted. I think generating output in this situation is confusing. Also, warnings are not widely used in PowerShell. If we don't generate a terminating error, we should generate a non-terminating error.

@raghushantha
Copy link
Member

We want the Engine to be flexible and continue execution as long as it received the correct set of keys. For non-existent/invalid keys, our thinking was to inform the user as a warning since it is simply an anomaly in the input.

I do agree that we have to be consistent in handling all invalid user input across ScriptAnalyzer (ScriptPaths, CustomRulePaths, Profiles, Rule filters etc)

So in this case, we can do #1
(emit non-terminating errors for each issue in Profile and stop the Engine execution - This will prevent any rules from running)

@raghushantha
Copy link
Member

Fixed:
#392

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants