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

[bugfix] Fix for NPE in xquery.functions.securitymanager.IdFunction #4671

Open
wants to merge 689 commits into
base: develop
Choose a base branch
from

Conversation

nverwer
Copy link

@nverwer nverwer commented Jan 9, 2023

Description:

This fixes a NPE in the sm:id() function, that caused problems in one of my applications.

Reference:

See #4670 .

subjectToXml(builder, context.getEffectiveUser());
builder.endElement();
final Subject effectiveUser = context.getEffectiveUser();
if (effectiveUser != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to combine the nested conditions to

if (effectiveUser != null && (
  realUser == null || !sameUserWithSameGroups(realUser, effectiveUser)
)) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally the method sameUserWithSameGroups could handle null values for both realUser and effectiveUser

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that, but to me the conditions mean different things, and I kept them separate.
Either way, the result, and maybe the bytecode, is exactly the same.

I also thought about checking for null inside sameUserWithSameGroups, which might make the intention of the code clearer.

Copy link
Member

@line-o line-o Jan 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If both are null then it should return false true.

Copy link
Member

@line-o line-o Jan 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would simplify the condition to

if (!sameUserwithSameGroups(realUser, effectiveUser)) {...}

Copy link
Author

@nverwer nverwer Jan 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:D I'll shut up until you have completed your review.

Nowadays, I prefer code that tells a story over concise code. I tend to take apart conditions like && ( || ) in my head when I read them.
But code that is robust against null (even though sameUserWithSameGroups is private) is even more important.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have combined them into one instead of brain-dumping :)

@adamretter adamretter changed the title fix for [BUG] NPE in xquery.functions.securitymanager.Idnction #4670 fix for [BUG] NPE in xquery.functions.securitymanager.IdFunction #4670 Jan 11, 2023
@adamretter adamretter changed the title fix for [BUG] NPE in xquery.functions.securitymanager.IdFunction #4670 Fix for NPE in xquery.functions.securitymanager.IdFunction Jan 11, 2023
dependabot bot and others added 26 commits May 17, 2023 04:00
Bumps commons-io from 2.11.0 to 2.12.0.

---
updated-dependencies:
- dependency-name: commons-io:commons-io
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
…ns-io-commons-io-2.12.0

build(deps): bump commons-io from 2.11.0 to 2.12.0
…le-declaration

Remove pre-1.0 syntax for variable declarations
It appears perfectly acceptable for UntypedAtomicValue.convertTo to convert to subtypes of Type.STRING as StringValue(… value, requiredType). The conversion was omitted, and the omission was breaking “castable as” for Type.NCNAME in particular.

These conversions are already acceptable for StringValue(s), and are borrowed from there.
…stable-error

[fix] castable as for untyped atomic value(s)
…-modules

Set the default `enforce-index-use` to strict for all tests
Bumps [maven-scm-plugin](https://github.com/apache/maven-scm) from 2.0.0 to 2.0.1.
- [Commits](apache/maven-scm@maven-scm-2.0.0...maven-scm-2.0.1)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-scm-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
…pache.maven.plugins-maven-scm-plugin-2.0.1

build(deps): bump maven-scm-plugin from 2.0.0 to 2.0.1
Bumps [docker-maven-plugin](https://github.com/fabric8io/docker-maven-plugin) from 0.42.1 to 0.43.0.
- [Release notes](https://github.com/fabric8io/docker-maven-plugin/releases)
- [Changelog](https://github.com/fabric8io/docker-maven-plugin/blob/master/doc/changelog.md)
- [Commits](fabric8io/docker-maven-plugin@v0.42.1...v0.43.0)

---
updated-dependencies:
- dependency-name: io.fabric8:docker-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
passing persistent nodes from XQuery to fn:transform as parameters doesn’t work.

NodeProxy objects were not being considered; dereference their nodes and use the result appropriately.
Previously this resulted in
org.exist.xquery.XPathException: java:java.lang.ClassCastException class org.exist.dom.persistent.NodeProxy cannot be cast to class org.w3c.dom.Node (org.exist.dom.persistent.NodeProxy is in unnamed module of loader 'app'; org.w3c.dom.Node is in module java.xml of loader 'bootstrap')

Now it succeeds.
xmldb:exist: URIs were not being understood / resolved  against correctly when looking for resources within the transformation code wrapping the Saxon transformer in our fn:transform implementation.

Strictly they’re not valid URIs, which is what was the fundamental problem, so we need to add some special-case XMLDBURI handling.

We also refactor just a little to pull the URI resolution code used by fn:transform into its own class in the fn:transform implementation package, and add unit tests for that extracted resolution.
…py-maven-plugin

Use newer copy-maven-plugin which does not have CVE issues with its dependencies
Bumps [maven-source-plugin](https://github.com/apache/maven-source-plugin) from 3.2.1 to 3.3.0.
- [Commits](apache/maven-source-plugin@maven-source-plugin-3.2.1...maven-source-plugin-3.3.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-source-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
just yield the relative URI unchanged, we were sticking the xmldb prefix in front.
Bumps [angus-mail](https://github.com/eclipse-ee4j/angus-mail) from 2.0.1 to 2.0.2.
- [Release notes](https://github.com/eclipse-ee4j/angus-mail/releases)
- [Commits](eclipse-ee4j/angus-mail@2.0.1...2.0.2)

---
updated-dependencies:
- dependency-name: org.eclipse.angus:angus-mail
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [maven-dependency-plugin](https://github.com/apache/maven-dependency-plugin) from 3.5.0 to 3.6.0.
- [Commits](apache/maven-dependency-plugin@maven-dependency-plugin-3.5.0...maven-dependency-plugin-3.6.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-dependency-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Tweak transformation’s CompileTimeURIResolver class to allow easier subclassing, to let unit test exercise it more easily.
…clipse.angus-angus-mail-2.0.2

build(deps): bump angus-mail from 2.0.1 to 2.0.2
Bumps [jakarta.mail-api](https://github.com/jakartaee/mail-api) from 2.1.1 to 2.1.2.
- [Release notes](https://github.com/jakartaee/mail-api/releases)
- [Commits](jakartaee/mail-api@2.1.1...2.1.2)

---
updated-dependencies:
- dependency-name: jakarta.mail:jakarta.mail-api
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
…ta.mail-jakarta.mail-api-2.1.2

build(deps): bump jakarta.mail-api from 2.1.1 to 2.1.2
adamretter and others added 16 commits September 10, 2023 13:40
…, make sure to show the namespace when there is no prefix
…oString() was being called instead of QName#getStringValue()
… whereby QName#toString() was being called instead of QName#getStringValue()
Bumps org.apache.commons:commons-compress from 1.23.0 to 1.24.0.

---
updated-dependencies:
- dependency-name: org.apache.commons:commons-compress
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
…pache.commons-commons-compress-1.24.0

build(deps): bump org.apache.commons:commons-compress from 1.23.0 to 1.24.0
Signed-off-by: Patrick Reinhart <patrick@reini.net>
Signed-off-by: Patrick Reinhart <patrick@reini.net>
…llocation-strategy

Fix a bug in Node Path equality
…cketed-element

Fix issues with Lucene Index optimisations and Matches
[bugfix] increase the maven daemon timeout
Copy link
Member

@dizzzz dizzzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK to me

dependabot bot and others added 2 commits September 13, 2023 03:04
Bumps [com.fasterxml.uuid:java-uuid-generator](https://github.com/cowtowncoder/java-uuid-generator) from 4.2.0 to 4.3.0.
- [Commits](cowtowncoder/java-uuid-generator@java-uuid-generator-4.2.0...java-uuid-generator-4.3.0)

---
updated-dependencies:
- dependency-name: com.fasterxml.uuid:java-uuid-generator
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
…asterxml.uuid-java-uuid-generator-4.3.0

build(deps): bump com.fasterxml.uuid:java-uuid-generator from 4.2.0 to 4.3.0
@reinhapa
Copy link
Member

@nverwer can you rebase this PR once again?

dependabot bot and others added 4 commits September 15, 2023 03:10
Bumps [jakarta.xml.bind:jakarta.xml.bind-api](https://github.com/eclipse-ee4j/jaxb-api) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/eclipse-ee4j/jaxb-api/releases)
- [Commits](jakartaee/jaxb-api@4.0.0...4.0.1)

---
updated-dependencies:
- dependency-name: jakarta.xml.bind:jakarta.xml.bind-api
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
…ta.xml.bind-jakarta.xml.bind-api-4.0.1

build(deps-dev): bump jakarta.xml.bind:jakarta.xml.bind-api from 4.0.0 to 4.0.1
@nverwer
Copy link
Author

nverwer commented Sep 15, 2023

@reinhapa I think that I rebased correctly. But I have to admit that I have become a bit lost in all the branches that seem relevant.

@reinhapa
Copy link
Member

reinhapa commented Sep 16, 2023

@nverwer seems something is wrong. Did you rebase your changes on the current exist/develop of eXistdb? 655 changed files in 689 commits seem to too much I guess..

@dizzzz dizzzz changed the title Fix for NPE in xquery.functions.securitymanager.IdFunction [bugfix] Fix for NPE in xquery.functions.securitymanager.IdFunction Sep 19, 2023
Copy link
Member

@reinhapa reinhapa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nverwer please do a proper rebase on the the current develop branch. Seems that you rebased on your local develop branch that is not on the same state as the current develop from eXist...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants