CHEF-3849: InSpec should exit quickly and clearly if waiver file is malformed/corrupt#6644
Merged
clintoncwolfe merged 17 commits intomainfrom Sep 12, 2023
Conversation
✅ Deploy Preview for chef-inspec canceled.
|
a278a24 to
d496b66
Compare
Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
d496b66 to
bf7262e
Compare
Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
…waiver file Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
…lumn without headers in waiver file Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
8acca95 to
6aabedc
Compare
Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
…heck. Co-authored-by: Sathish Babu <80091550+sathish-progress@users.noreply.github.com> Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
c553131 to
80f23cc
Compare
Nik08
reviewed
Sep 6, 2023
Nik08
reviewed
Sep 6, 2023
Nik08
approved these changes
Sep 6, 2023
Contributor
Nik08
left a comment
There was a problem hiding this comment.
Functionally it looks good to me. Just have some small refactoring suggestions. Thanks
…other functionalities like waiver file Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
9aa2f9e to
44bc614
Compare
Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
…l the data fields as it was not called inside the loop where we are iterating over the data and fetching the headers. Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
…ra parameters Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
…required parameters and extra parameters in waivers file in all format i.e (yaml, json and csv). Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
…ages for waiver file validation Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
… and instead of return data in array it will now return the data in hash Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com>
clintoncwolfe
approved these changes
Sep 12, 2023
Nik08
pushed a commit
that referenced
this pull request
Sep 13, 2024
…alformed/corrupt (#6644) * Functional test for malformed waiver file Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Raise error for malformed yaml content and exit Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Updates functional test for malformed yaml waiver file and for empty waiver file Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Raises error in case of missing required parameters in waiver file Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Update functional test for missing parameters, extra parameters or column without headers in waiver file Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Fix linting Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Fix warning and error messages Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Updates nil and false check for yaml data and adds additional empty check. Co-authored-by: Sathish Babu <80091550+sathish-progress@users.noreply.github.com> Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Adds more generic message as this yaml reader is now getting used by other functionalities like waiver file Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Fixed test description to reflect correct use case Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Fix validate headers was not validating the required parametes for all the data fields as it was not called inside the loop where we are iterating over the data and fetching the headers. Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Updates the test files for the use case to missing parameters and extra parameters Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Updates code to better handle errors and warnings related to missing required parameters and extra parameters in waivers file in all format i.e (yaml, json and csv). Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Updated functional test to capture the updated error and warning messages for waiver file validation Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Fix linting Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Deleted fixture file which is not required Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Refactor: Renamed method validate_headers to reflect whats it's doing and instead of return data in array it will now return the data in hash Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> --------- Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> Co-authored-by: Sathish Babu <80091550+sathish-progress@users.noreply.github.com>
Nik08
pushed a commit
that referenced
this pull request
Mar 27, 2025
…alformed/corrupt (#6644) * Functional test for malformed waiver file Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Raise error for malformed yaml content and exit Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Updates functional test for malformed yaml waiver file and for empty waiver file Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Raises error in case of missing required parameters in waiver file Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Update functional test for missing parameters, extra parameters or column without headers in waiver file Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Fix linting Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Fix warning and error messages Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Updates nil and false check for yaml data and adds additional empty check. Co-authored-by: Sathish Babu <80091550+sathish-progress@users.noreply.github.com> Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Adds more generic message as this yaml reader is now getting used by other functionalities like waiver file Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Fixed test description to reflect correct use case Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Fix validate headers was not validating the required parametes for all the data fields as it was not called inside the loop where we are iterating over the data and fetching the headers. Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Updates the test files for the use case to missing parameters and extra parameters Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Updates code to better handle errors and warnings related to missing required parameters and extra parameters in waivers file in all format i.e (yaml, json and csv). Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Updated functional test to capture the updated error and warning messages for waiver file validation Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Fix linting Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Deleted fixture file which is not required Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Refactor: Renamed method validate_headers to reflect whats it's doing and instead of return data in array it will now return the data in hash Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> --------- Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> Co-authored-by: Sathish Babu <80091550+sathish-progress@users.noreply.github.com>
4 tasks
Nik08
pushed a commit
that referenced
this pull request
Apr 9, 2025
…alformed/corrupt (#6644) * Functional test for malformed waiver file Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Raise error for malformed yaml content and exit Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Updates functional test for malformed yaml waiver file and for empty waiver file Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Raises error in case of missing required parameters in waiver file Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Update functional test for missing parameters, extra parameters or column without headers in waiver file Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Fix linting Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Fix warning and error messages Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Updates nil and false check for yaml data and adds additional empty check. Co-authored-by: Sathish Babu <80091550+sathish-progress@users.noreply.github.com> Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Adds more generic message as this yaml reader is now getting used by other functionalities like waiver file Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Fixed test description to reflect correct use case Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Fix validate headers was not validating the required parametes for all the data fields as it was not called inside the loop where we are iterating over the data and fetching the headers. Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Updates the test files for the use case to missing parameters and extra parameters Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Updates code to better handle errors and warnings related to missing required parameters and extra parameters in waivers file in all format i.e (yaml, json and csv). Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Updated functional test to capture the updated error and warning messages for waiver file validation Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Fix linting Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Deleted fixture file which is not required Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> * Refactor: Renamed method validate_headers to reflect whats it's doing and instead of return data in array it will now return the data in hash Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> --------- Signed-off-by: Vasu1105 <vasundhara.jagdale@progress.com> Co-authored-by: Sathish Babu <80091550+sathish-progress@users.noreply.github.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
If you provide a malformed waiver file - one that fails YAML lint, in other words - inspec will continue to run, showing an error as the first control failing with a control source code error.
This buries the error message(Warning) deeply in the InSpec reporting output, which on a large profile may be hundred of kilobytes of text.
It also wastes the user’s time, since on a large profile, we know waiver file is bad immediately, but we doggedly execute the whole profile (which may take hours) before finally returning unusable (incorrect, unwaivered) results.
In case of invalid parameters in the waiver file currently it shows a warning message whereas it should raise the error in case of required parameters are not present in the waiver file.
This fix includes
In case of an empty waiver file, extra parameters, or nil header (in CSV formatted) waiver file it will show a warning message that there will not be any behavioral changes.
Related Issue
Types of changes
Checklist: