Skip to content
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

Output of results to include object path #1092

Closed
BernieWhite opened this issue May 20, 2022 · 2 comments · Fixed by #1126
Closed

Output of results to include object path #1092

BernieWhite opened this issue May 20, 2022 · 2 comments · Fixed by #1126
Assignees
Labels
enhancement New feature or request integration: template-analyzer New feature or request for ARM Template Best Practice Analyzer
Milestone

Comments

@BernieWhite
Copy link
Member

Currently when rules report a failure (i.e. the object property is not in the desired state), the failure is reported as:

  • Outcome = Fail
  • One or more reasons, which are a localized message. Both custom and standard reasons are available.
  • Optional, fields or data can be returned.
  • The name of the rule and rule metadata.
  • The source object.
  • The source file and line are reported as determines by PSRule if the objects originate from a file or define a source using the _PSRule property.

The experience and accuracy of source file and line can vary. The current approach will return the line of the object started which could be split across multiple line, not the property that failed the test.

It would be helpful for several integration scenarios to be able to report the object path through the object to the failing property.

@BernieWhite
Copy link
Member Author

BernieWhite commented May 20, 2022

@JohnathonMohr If a rule fails due to the property not existing in these cases what are your thoughts?

  • location in the root of the object does not exist. Report location which is has no line or report the root object path?
  • properties.config2 does not exist. Report properties which was the last path element that was found or properties.config2?
{
  "name": "test1",
  "properties": {
    "config1": "value1"
  }
}

@JohnathonMohr
Copy link

@BernieWhite I think it would be valuable to report the entire path, even if the final property (or properties) don't exist. It could be helpful in some scenarios for the user to see exactly where a rule is making assertions, in case the property needs to be added, so it's easy to see where to add it.

@BernieWhite BernieWhite added the integration: template-analyzer New feature or request for ARM Template Best Practice Analyzer label Jun 7, 2022
@BernieWhite BernieWhite self-assigned this Jun 8, 2022
BernieWhite added a commit to BernieWhite/PSRule that referenced this issue Jun 20, 2022
BernieWhite added a commit to BernieWhite/PSRule that referenced this issue Jun 20, 2022
@BernieWhite BernieWhite added this to the v2.2.0 milestone Jun 20, 2022
@BernieWhite BernieWhite mentioned this issue Jun 30, 2022
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request integration: template-analyzer New feature or request for ARM Template Best Practice Analyzer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants