-
Notifications
You must be signed in to change notification settings - Fork 472
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
incomprehensible behavior when testing with different versions of goss #845
Comments
Hello, thank you for opening this. Can you give a simple reproducible Goss.yaml example? Also, what's the expectation vs incorrect result? At a quick glance of this issue text it appears both are saying the same thing, but in a different way? Seems v0.3.x, says what it expected and found. While version 0.4.x says what it expected and missing/failed? Also, I assume this is using --format json? |
Upon rereading the message, I realized it's the I'll explain the problem first and perhaps there's a suggestion for a better message. Some tests return an Reader by default. This allows goss to do verification on say a 2GB file without consuming 2GB of memory. This format is efficient. However, because it reads content line by line, it has no storage of "actual." One option would be to not include actual whenever that is the case, rather than showing the confusion {
"Actual": "Not Available - Content loaded line by line"
} I'm leaning towards having the message, seems that would be much clearer to the user. |
Then I don’t understand how to work with the new version of goss. this problem appeared starting from version 0.4.x, before this version there was no Actual field and this problem did not exist. Below is a task that has not changed for a long time.
The output result of this task in different versions:
<=0.3.23
|
Right, the matcher logic changed quite a bit between goss 0.3.x and 0.4.x. If you don't mind, can you expand a bit on how you were using "found" before? For example: yaml: command:
echo "hip":
exit-status: 1
stdout:
- hi
- bye
timeout: 10000 Goss v0.3.xx:
Goss v0.4.xx:
Where the differences start to show more is with goss v0.4.xx the command output can be treated as a string, so for example: command:
echo "hip":
exit-status: 1
stdout: "hi"
timeout: 10000 Goss v0.3.xxx: Error/Not supported Goss v0.4.xxx:
Hopefully, the above helps explain why the API was changed, I'm open for changing it based on feedback. Just trying to better understand how you're using the fields from goss v0.3.xx and the bug that this is introducing. Somewhat related note: The other goss outputs are pretty much derived from |
above is my task
goss -g auditfile.yml --vars varsfile_patch v -f json -o pretty >report.json |
For the above, what would you like to see in report.json? is the preference to have it be null when reading line by line? "matcher-result": {
"Actual": null, |
Tagging @uk-bolly since I noticed you're tagged in a linked issue. Would love to understand this better and collaborate on best path forward. |
As far as I understand, Actual is what is found from the Expected field, and MissingElement is what was not found during the search process. I'm generally confused by the conclusion that the new version offers. In the old version it was simply Expected and Found. And now I can’t figure out how I can parse a new format, for example in Python, and get a beautiful test report - What I wanted to find - What I found - What’s missing - And my result Successfull |
Gotcha, so for clarity. You're right that In goss v0.3.xx, I assume these questions were answered as follows:
In goss v0.4.xx, the data that's presented inversely:
So found is the one that has to be calculated from the other two. I can enrich the matcher-result object to contain both Some boring detailsBefore goss would track "found" and when rendering would subtract expected-found to display messages when running other (non-json) outputs: https://github.com/goss-org/goss/blob/v0.3.23/outputs/outputs.go#L92 strings.Join(subtractSlice(r.Expected, r.Found), ", ") There was nowhere in goss code that was using Path forward / Questions
Thank you for your patience and clarifications on this, feedback is what makes goss better for everyone. Appreciate you taking the time to file this. |
I think that adding the Found-elements attribute will solve the problem in terms of converting json to html report - it will be beautiful! I'll have to rewrite my json parser - but it'll be worth it. Attribute "Actual" - unfortunately, I don’t know what to use it for. |
Sounds good, marked issue as approved. If your html report generator is open source I would love to see it. If not, I understand. |
I'm ready to share - the code is not a trade secret. If you help improve it or rewrite it in GO, I don’t mind... I’ll post it on github and give you a link |
I'll release a new version soon that includes this enhancement. I would love your feedback once it's released. |
Cut a new release just now. |
Glad to hear it! I'll test it soon. |
Works! But it’s not quite as it should be yet. It is necessary to check the tasks and results expected to be obtained. In my opinion, the issue can be closed. |
Before we close our the issue, can you explain the last message. This way I can improve on this in a future release. |
I can not explain. It seems to me that the verification logic needs to be changed. I am attaching json and html results. |
Forgot to close this. Closing, thanks for filing this issue. |
Goss version: TLDR; This issue is already closed, but in my opinion, Like @sysop200, I am confused at the decision to switch the Using your example, imagine I am an incident responder and I run:
for a test:
with result:
Great, I got some information about what was expected and what was missing, but not having the result of the failed operation creates extra investigative efforts for the responder to now have to check:
Only after all these steps will they know what the cause for failure could be. I would like to implement Goss at my company but this is truly a blocking issue. If I am missing something that would make the validation results more actionable, I would love to hear it! |
Hello, thanks for reaching out. If you don't care for the value to be read line by line, you can use the command:
test:
exec: echo "I need to know what this is"
exit-status: 1
stdout:
have-patterns:
- hi
- test default output:
json:
I'll update the docs over the weekend or next week to document that matcher. It's basically the same as the default one, except it doesn't read line-by-line. So if it's a giant input, it'll use more memory. |
This is great @aelsabbahy, thanks for the timely reply! I will have to test to see the difference in performance for matcher vs. default as you mentioned, but looks like it will work at first glance. |
Describe the error
I carry out testing as described in this repository:
https://github.com/ansible-lockdown/RHEL8-CIS-Audit
When using version 0.3.23, the report turns out good:
"expected": [
"/^MaxAuthTries [1-4]/",
"!/^MaxAuthTries [5-9]/"
],
"found": [
"!/^MaxAuthTries [5-9]/"
],
When using version >0.4.0, the field does not contain the correct queries:
"matcher-result": {
### "Actual": "object: *bytes.Reader",
"Expected": [
"/^MaxAuthTries [1-4]/",
"!/^MaxAuthTries [5-9]/"
],
"ExtraElements": null,
"Message": "to have patterns",
"MissingElements": [
"/^MaxAuthTries [1-4]/"
How to play
Download the repository and check your Linux computer with standard settings
The text was updated successfully, but these errors were encountered: