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

changed authinfo comparison from nil to empty struct #39

Merged

Conversation

lucamrgs
Copy link
Collaborator

@lucamrgs lucamrgs commented Mar 11, 2024

The addAuthTo function in utils/http/http.go performs a check of httpOptions.Auth to be nil, as to check whether it was specified or not, for authentication information is an optional property.

But, an Authentication information should always be passed as property to the capability.Execute() function, hence it is always a struct: either completely empty, or not.

As a consequence, the check in utils/http/http.go addAuthTo is not correct, and the logic further checks for consistency in the field of an empty struct to add authInfo to the headers. This obviously fails, whereas instead it should not be checked, as no auth headers should be added if an empty authInfo struct is passed.

@lucamrgs
Copy link
Collaborator Author

So, many tests in unittest/utils/http/htpp_test.go leave the Auth information non specified, hence the check on empty struct alone will throw an error, because the supposed empty struct is in fact a nil.

In the overall SOARCA execution, it should never happen that authentication information is nil, but it should always be either a completely empty struct, or a non completely empty struct.

So at the moment, I just left both checks, but logically, there should never be a null authenticationInformation object passed to the http.Request util. What to do?

@MaartendeKruijf MaartendeKruijf force-pushed the bugfix/37-fix-empty-authentication-info-check branch from ebd15be to 6df21c8 Compare March 13, 2024 12:21
@MaartendeKruijf MaartendeKruijf added this to the SOARCA 1.0 milestone Mar 13, 2024
@MaartendeKruijf MaartendeKruijf added the bug Something isn't working label Mar 13, 2024
@MaartendeKruijf MaartendeKruijf merged commit c407a2c into development Mar 13, 2024
9 checks passed
@MaartendeKruijf MaartendeKruijf deleted the bugfix/37-fix-empty-authentication-info-check branch March 13, 2024 12:26
@MaartendeKruijf MaartendeKruijf linked an issue Mar 13, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix empty authentication info check
2 participants