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

Improved error codes in case of security exception #1753

Merged
merged 1 commit into from
Jun 20, 2023

Conversation

vmmusings
Copy link
Member

@vmmusings vmmusings commented Jun 19, 2023

Description

Currently all the security exceptions related to datasource APIs are thrown as internal server errors.
With this change, the error message will respect the status received from upstream core service/plugins.

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@codecov
Copy link

codecov bot commented Jun 19, 2023

Codecov Report

Merging #1753 (80c251e) into main (7525bb1) will decrease coverage by 0.09%.
The diff coverage is 0.00%.

@@             Coverage Diff              @@
##               main    #1753      +/-   ##
============================================
- Coverage     97.33%   97.25%   -0.09%     
+ Complexity     4408     4406       -2     
============================================
  Files           388      388              
  Lines         10939    10944       +5     
  Branches        773      774       +1     
============================================
- Hits          10648    10644       -4     
- Misses          284      294      +10     
+ Partials          7        6       -1     
Flag Coverage Δ
sql-engine 97.25% <0.00%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...earch/sql/datasources/exceptions/ErrorMessage.java 0.00% <0.00%> (ø)
...ql/datasources/rest/RestDataSourceQueryAction.java 0.00% <0.00%> (ø)

... and 1 file with indirect coverage changes

Signed-off-by: Vamsi Manohar <reddyvam@amazon.com>
Copy link
Collaborator

@Yury-Fridlyand Yury-Fridlyand left a comment

Choose a reason for hiding this comment

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

LGFM but CI fails

@vmmusings
Copy link
Member Author

LGFM but CI fails

CI Failures are unrelated to the above changes.
Integ tests issue: #1754

@vmmusings vmmusings merged commit bb020ac into opensearch-project:main Jun 20, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 20, 2023
Signed-off-by: Vamsi Manohar <reddyvam@amazon.com>
(cherry picked from commit bb020ac)
@Yury-Fridlyand
Copy link
Collaborator

Yury-Fridlyand commented Jun 20, 2023

CI failed due to lack of jacoco coverage and UT failure!

* What went wrong:
Execution failed for task ':opensearch:test'.
> There were failing tests. See the report at: file:///home/runner/work/sql/sql/opensearch/build/reports/tests/test/index.html

@vmmusings
Copy link
Member Author

@Yury-Fridlyand UT failures are due to ML-Commons. I have verified by running without my commit before merging.
These lines are not configured under Jacoco and it won't cause build failure.

I have added unit tests but it requires opensearch.test framework and it is disrupting the mockito runtime libraries and causing issues in all the existing test cases. Covering with integ tests is not possible as the error scenario requires security plugin. I have created an issue to #1754 handle this.

Added new issue for jacoco coverage of rest handlers: #1756

@Yury-Fridlyand
Copy link
Collaborator

If your PR requires other changes to have CI passed, do it in scope of this PR or in another PR BEFORE merging this one.

@Yury-Fridlyand
Copy link
Collaborator

Appealing to your experience @dblock, can we leave this as is and hope for a coming fix or this PR should be reverted?

@vmmusings
Copy link
Member Author

Would like to hear his thoughts. I will try to fix ML commons error. If I could not, i will raise a revert PR by EOD.

@vmmusings
Copy link
Member Author

vmmusings commented Jun 20, 2023

The error is due to opensearch-project/OpenSearch#8035
The below mentioned class is removed in the above PR.

Caused by: java.lang.NoClassDefFoundError: org/opensearch/core/common/io/stream/BaseStreamOutput
	at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3402)
	at java.base/java.lang.Class.getDeclaredMethods(Class.java:2504)
	at net.bytebuddy.description.method.MethodList$ForLoadedMethods.<init>(MethodList.java:152)
	at net.bytebuddy.description.type.TypeDescription$ForLoadedType.getDeclaredMethods(TypeDescription.java:8940)
	at net.bytebuddy.dynamic.scaffold.InstrumentedType$Factory$Default$1.represent(InstrumentedType.java:438)
	at net.bytebuddy.ByteBuddy.redefine(ByteBuddy.java:886)
	at net.bytebuddy.ByteBuddy.redefine(ByteBuddy.java:861)
	at org.mockito.internal.creation.bytebuddy.InlineBytecodeGenerator.transform(InlineBytecodeGenerator.java:390)
	at java.instrument/java.lang.instrument.ClassFileTransformer.transform(ClassFileTransformer.java:244)
	at java.instrument/sun.instrument.TransformerManager.transform(TransformerManager.java:188)
	at java.instrument/sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:541)
	at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
	at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:169)
	at org.mockito.internal.creation.bytebuddy.InlineBytecodeGenerator.triggerRetransformation(InlineBytecodeGenerator.java:281)
	... 113 more
Caused by: java.lang.ClassNotFoundException: org.opensearch.core.common.io.stream.BaseStreamOutput
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
	... 128 more

@Yury-Fridlyand Yury-Fridlyand mentioned this pull request Jun 21, 2023
6 tasks
acarbonetto pushed a commit to Bit-Quill/opensearch-project-sql that referenced this pull request Jun 22, 2023
vmmusings added a commit that referenced this pull request Jun 27, 2023
Signed-off-by: Vamsi Manohar <reddyvam@amazon.com>
(cherry picked from commit bb020ac)
vmmusings added a commit to vmmusings/sql that referenced this pull request Jul 5, 2023
…t#1753)

Signed-off-by: Vamsi Manohar <reddyvam@amazon.com>
(cherry picked from commit bb020ac)
vmmusings added a commit to vmmusings/sql that referenced this pull request Jul 11, 2023
…t#1753)

Signed-off-by: Vamsi Manohar <reddyvam@amazon.com>
(cherry picked from commit bb020ac)
vmmusings added a commit that referenced this pull request Jul 11, 2023
Signed-off-by: Vamsi Manohar <reddyvam@amazon.com>
(cherry picked from commit bb020ac)
vmmusings added a commit that referenced this pull request Jul 11, 2023
Signed-off-by: Vamsi Manohar <reddyvam@amazon.com>
(cherry picked from commit bb020ac)
(cherry picked from commit ee62371)
vmmusings added a commit that referenced this pull request Jul 11, 2023
…1849)

Signed-off-by: Vamsi Manohar <reddyvam@amazon.com>
(cherry picked from commit bb020ac)
(cherry picked from commit ee62371)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants