-
Notifications
You must be signed in to change notification settings - Fork 475
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
[BUG] Regression between 1.2.0 and 1.3.5 for undefined values #459
Comments
Possibly related: #447 |
This is an interesting one. The metadata is returned, which is potentially valuable, but the metadata says that the returned type is a string, so we would expect non-breaking behavior here. I believe this was an unexpected side-effect and indeed a regression in this case. The problem is that there is in fact a Would you be in a position to at least write a test to account for your case and then perhaps we can get @mans0954 to modify his fix to account for your new test case? We obviously need more tests around this part of the code. Thanks for reporting this with a clear example! |
Something like that ? I didn't test it.
|
@damien-git I think that reasonably captures the problem (without testing it myself). @mans0954 , would you be in a position to modify your previous fix to account for this test? |
I followed up with @mans0954 today to nudge him on this. |
Sorry, I missed this before. Will take a look. |
That test passes for me:
|
I think the assertion should be:
|
Looking at the previous implementation
There seems to me to be something flawed about this, as, as far as I can see, the type of I'm wondering if the condition should have been:
? |
@mans0954 , that is why, when I looked at the patch to this code, it seemed to make sense to me because the existing implementation just didn't. However, we still need to account for the fact that, when possible, we should return a string instead of the object that we parse out. Really, both the old and current logic are too simple to catch the three cases we're working with here:
I would agree. That, or it should have included |
Started working on this here: https://github.com/node-saml/passport-saml/tree/csh-issue-459-attr-value-regression - will try to pick it up again tomorrow if I can. My next step is to understand xml2js a bit better to see if there's a reliable way to distinguish between the three cases @cjbarth mentions. |
Actually, I think there are 4 cases - one might have both a string and child elements (at least in a general XML document) e.g. the following is valid XML:
Presumably in this case we would want to return the object rather than just a string? |
@mans0954 , I would expect in that case (Mixed Content) there would be an object returned. It would only be possible to return a string if the |
Here's one possible solution: https://github.com/node-saml/passport-saml/tree/csh-issue-459-attr-value-regression-ec which passes the tests. It uses xml2js's
The
The downside of this solution is that it requires a number of changes at other points of the |
Since we only started returning objects in 1.3.5, I'm not particularly worried about breaking that. As for the other changes, they seem to add clarity to where those properties are coming from, so I'm not against that either. My cursory glance seems to indicate that this wouldn't result in two different XML parsing patterns in the code; can you confirm that, as that would be a potential objection I would have. I should note though that we do return this raw object in passport-saml/lib/passport-saml/saml.js Line 1042 in 43465d6
passport-saml/lib/passport-saml/saml.js Line 890 in 43465d6
xml-crypto fix in too and then do the version bump?
|
The low impact option would be to change
This then passes all the tests without changing any other code or any of the return values. I've put this on a branch here: https://github.com/node-saml/passport-saml/tree/csh-issue-459-attr-value-regression-some |
This seems like the correct solution to resolve the regression, however, I am interested in hearing comments from others about the bigger change for the next semver major release. |
When the IdP sends the following attribute description:
With passport-saml 1.2.0 I get the value:
undefined
forprofile.attributeName
, as I expect. But with passport-saml 1.3.5, I get this object instead:Was that change intended, or is it a bug ? It sure broke my application when I updated passport-saml to avoid a security issue, as I did not expect to get something like that...
The text was updated successfully, but these errors were encountered: