-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Rethrow NoSuchFileException if encountering an invalid symlink when checking file entitlements #124483
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
Rethrow NoSuchFileException if encountering an invalid symlink when checking file entitlements #124483
Conversation
…hecking file entitlements
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
|
The test failure is interesting, in the non modular case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good. Left only 1 question really, and 1 optional (if possible) improvement.
This is going to conflict massively with #124429, lets see who gets in first :)
| try { | ||
| checkFileRead(callerClass, path, false); | ||
| } catch (NoSuchFileException e) { | ||
| assert false : "NoSuchFileException should only be thrown when following links"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the right approach for where we are now; if we go forward with the idea of moving towards exceptions already in the method contract (e.g. IOExceptions for File operations) we will revisit this with all the other methods
...-plugin/src/main/java/org/elasticsearch/entitlement/qa/test/RestEntitlementsCheckAction.java
Outdated
Show resolved
Hide resolved
|
|
||
| // path | ||
| void checkPathToRealPath(Class<?> callerClass, Path that, LinkOption... options); | ||
| void checkPathToRealPath(Class<?> callerClass, Path that, LinkOption... options) throws NoSuchFileException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly for future work: should we add a check that we match the target method's checked exceptions? We would not like to use an incorrect exception type by mistake, it might end up with another "VerifyError"-style problem again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC the throws clause doesn't affect bytecode, so it can't cause a verification error. It's only there for javac.
...lement/qa/src/javaRestTest/java/org/elasticsearch/entitlement/qa/AbstractEntitlementsIT.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…hecking file entitlements (elastic#124483) This will rethrow the `NoSuchFileException` when encountering an invalid symbolic link when following links during file (read) entitlement checks. Relates to elastic#124133 (ES-11019)
…hecking file entitlements (elastic#124483) This will rethrow the `NoSuchFileException` when encountering an invalid symbolic link when following links during file (read) entitlement checks. Relates to elastic#124133 (ES-11019)
…hecking file entitlements (elastic#124483) This will rethrow the `NoSuchFileException` when encountering an invalid symbolic link when following links during file (read) entitlement checks. Relates to elastic#124133 (ES-11019)
…hecking file entitlements (elastic#124483) This will rethrow the `NoSuchFileException` when encountering an invalid symbolic link when following links during file (read) entitlement checks. Relates to elastic#124133 (ES-11019)
…hecking file entitlements (elastic#124483) This will rethrow the `NoSuchFileException` when encountering an invalid symbolic link when following links during file (read) entitlement checks. Relates to elastic#124133 (ES-11019)
This will rethrow the
NoSuchFileExceptionwhen encountering an invalid symbolic link when following links during file (read) entitlement checks.Relates to #124133 (ES-11019)