Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
coutoPL committed May 6, 2024
2 parents b3dc9a0 + 983b568 commit 6fdbb62
Show file tree
Hide file tree
Showing 17 changed files with 129 additions and 28 deletions.
1 change: 1 addition & 0 deletions ci/supported-es-versions/es7x.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
7.17.21
7.17.20
7.17.19
7.17.18
Expand Down
1 change: 1 addition & 0 deletions ci/supported-es-versions/es8x.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
8.13.3
8.13.2
8.13.1
8.13.0
Expand Down
2 changes: 1 addition & 1 deletion es717x/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
latestSupportedEsVersion=7.17.20
latestSupportedEsVersion=7.17.21
2 changes: 1 addition & 1 deletion es813x/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
latestSupportedEsVersion=8.13.2
latestSupportedEsVersion=8.13.3
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
publishedPluginVersion=1.57.1
pluginVersion=1.57.1
publishedPluginVersion=1.57.2
pluginVersion=1.57.2
pluginName=readonlyrest

org.gradle.jvmargs=-Xmx6144m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package tech.beshu.ror.tools.core.patches
import just.semver.SemVer
import tech.beshu.ror.tools.core.patches.base.SimpleEsPatch
import tech.beshu.ror.tools.core.patches.internal.RorPluginDirectory
import tech.beshu.ror.tools.core.patches.internal.filePatchers.{ElasticsearchJarPatchCreator, XPackSecurityJarPatchCreator}
import tech.beshu.ror.tools.core.patches.internal.filePatchers.{ElasticsearchJarPatchCreator, OptionalXPackSecurityJarPatchCreator, XPackSecurityJarPatchCreator}
import tech.beshu.ror.tools.core.patches.internal.modifiers.bytecodeJars.{DeactivateSecurityActionFilter, DeactivateSecurityServerTransportInterceptor, DummyAuthorizeInAuthorizationService, RepositoriesServiceAvailableForClusterServiceForAnyTypeOfNode}

import scala.language.postfixOps
Expand All @@ -29,7 +29,7 @@ private[patches] class Es68xPatch(rorPluginDirectory: RorPluginDirectory, esVers
new ElasticsearchJarPatchCreator(
new RepositoriesServiceAvailableForClusterServiceForAnyTypeOfNode(esVersion)
),
new XPackSecurityJarPatchCreator(
new OptionalXPackSecurityJarPatchCreator(
DeactivateSecurityActionFilter,
DeactivateSecurityServerTransportInterceptor,
DummyAuthorizeInAuthorizationService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package tech.beshu.ror.tools.core.patches
import just.semver.SemVer
import tech.beshu.ror.tools.core.patches.base.SimpleEsPatch
import tech.beshu.ror.tools.core.patches.internal.RorPluginDirectory
import tech.beshu.ror.tools.core.patches.internal.filePatchers.{ElasticsearchJarPatchCreator, XPackCoreJarPatchCreator, XPackSecurityJarPatchCreator}
import tech.beshu.ror.tools.core.patches.internal.filePatchers._
import tech.beshu.ror.tools.core.patches.internal.modifiers.bytecodeJars._

import scala.language.postfixOps
Expand All @@ -30,11 +30,11 @@ private[patches] class Es70xPatch(rorPluginDirectory: RorPluginDirectory, esVers
new RepositoriesServiceAvailableForClusterServiceForAnyTypeOfNode(esVersion),
new SnapshotsServiceAvailableForClusterServiceForAnyTypeOfNode(esVersion)
),
new XPackCoreJarPatchCreator(
new OptionalXPackCoreJarPatchCreator(
AlwaysGrantApplicationPermission,
GetAuthenticationFromHeaderWhenMissingInTransient
),
new XPackSecurityJarPatchCreator(
new OptionalXPackSecurityJarPatchCreator(
DeactivateSecurityActionFilter,
DeactivateSecurityServerTransportInterceptor,
new MockAuthorizationInfoInAuthorizationService(esVersion),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* This file is part of ReadonlyREST.
*
* ReadonlyREST is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ReadonlyREST is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ReadonlyREST. If not, see http://www.gnu.org/licenses/
*/
package tech.beshu.ror.tools.core.patches

import just.semver.SemVer
import tech.beshu.ror.tools.core.patches.base.SimpleEsPatch
import tech.beshu.ror.tools.core.patches.internal.RorPluginDirectory
import tech.beshu.ror.tools.core.patches.internal.filePatchers._
import tech.beshu.ror.tools.core.patches.internal.modifiers.bytecodeJars._

import scala.language.postfixOps

private[patches] class Es711xPatch(rorPluginDirectory: RorPluginDirectory, esVersion: SemVer)
extends SimpleEsPatch(rorPluginDirectory, esVersion,
new ElasticsearchJarPatchCreator(
new RepositoriesServiceAvailableForClusterServiceForAnyTypeOfNode(esVersion),
new SnapshotsServiceAvailableForClusterServiceForAnyTypeOfNode(esVersion)
),
new XPackCoreJarPatchCreator(
AlwaysGrantApplicationPermission,
GetAuthenticationFromHeaderWhenMissingInTransient
),
new XPackSecurityJarPatchCreator(
DeactivateSecurityActionFilter,
DeactivateSecurityServerTransportInterceptor,
new MockAuthorizationInfoInAuthorizationService(esVersion),
DummyAuthorizeInAuthorizationService
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ object EsPatch {
case esVersion if esVersion >= es830 => new Es83xPatch(rorPluginDirectory, esVersion)
case esVersion if esVersion >= es800 => new Es80xPatch(rorPluginDirectory, esVersion)
case esVersion if esVersion >= es71713 => new Es717xPatch(rorPluginDirectory, esVersion)
case esVersion if esVersion >= es7110 => new Es711xPatch(rorPluginDirectory, esVersion)
case esVersion if esVersion >= es700 => new Es70xPatch(rorPluginDirectory, esVersion)
case esVersion if esVersion >= es680 => new Es68xPatch(rorPluginDirectory, esVersion)
case esVersion => new EsNotRequirePatch(esVersion)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,28 @@ import tech.beshu.ror.tools.core.patches.internal.modifiers.FileModifier

import scala.language.postfixOps

private [patches] abstract class FilePatch(rorPluginDirectory: RorPluginDirectory,
fileToPatchPath: Path,
patchingSteps: Iterable[FileModifier]) {
private [patches] abstract class FilePatch(val fileToPatchPath: Path) {
def backup(): Unit
def patch(): Unit
def restore(): Unit
}

def backup(): Unit = {
private [patches] abstract class FileModifiersBasedPatch(val rorPluginDirectory: RorPluginDirectory,
override val fileToPatchPath: Path,
patchingSteps: Iterable[FileModifier])
extends FilePatch(fileToPatchPath) {

override def backup(): Unit = {
rorPluginDirectory.backup(fileToPatchPath)
}

def patch(): Unit = {
override def patch(): Unit = {
patchingSteps.foreach { step =>
step(fileToPatchPath toIO)
}
}

def restore(): Unit = {
override def restore(): Unit = {
rorPluginDirectory.restore(fileToPatchPath)
}
}
Expand All @@ -53,4 +60,23 @@ private [patches] class MultiFilePatch(filePatches: FilePatch*) {
def restore(): Unit = {
filePatches.foreach(_.restore())
}
}

private [patches] class OptionalFilePatchDecorator[FP <: FilePatch](underlying: FP)
extends FilePatch(underlying.fileToPatchPath) {

private val chosenFilePatch = {
if(os.exists(fileToPatchPath)) underlying
else NoOpFilePatch
}

override def backup(): Unit = chosenFilePatch.backup()
override def patch(): Unit = chosenFilePatch.patch()
override def restore(): Unit = chosenFilePatch.restore()
}

private [patches] object NoOpFilePatch extends FilePatch(os.root){
override def backup(): Unit = ()
override def patch(): Unit = ()
override def restore(): Unit = ()
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package tech.beshu.ror.tools.core.patches.internal.filePatchers

import just.semver.SemVer
import tech.beshu.ror.tools.core.patches.internal.modifiers.FileModifier
import tech.beshu.ror.tools.core.patches.internal.{FilePatch, RorPluginDirectory}
import tech.beshu.ror.tools.core.patches.internal.{FileModifiersBasedPatch, FilePatch, RorPluginDirectory}

private[patches] class ElasticsearchJarPatchCreator(patchingSteps: FileModifier*)
extends FilePatchCreator[ElasticsearchJarPatch] {
Expand All @@ -31,7 +31,7 @@ private[patches] class ElasticsearchJarPatchCreator(patchingSteps: FileModifier*
private[patches] class ElasticsearchJarPatch(rorPluginDirectory: RorPluginDirectory,
esVersion: SemVer,
patchingSteps: Iterable[FileModifier])
extends FilePatch(
extends FileModifiersBasedPatch(
rorPluginDirectory = rorPluginDirectory,
fileToPatchPath = rorPluginDirectory.esDirectory.libPath / s"elasticsearch-${esVersion.render}.jar",
patchingSteps = patchingSteps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package tech.beshu.ror.tools.core.patches.internal.filePatchers

import just.semver.SemVer
import tech.beshu.ror.tools.core.patches.internal.modifiers.FileModifier
import tech.beshu.ror.tools.core.patches.internal.{FilePatch, RorPluginDirectory}
import tech.beshu.ror.tools.core.patches.internal.{FileModifiersBasedPatch, FilePatch, RorPluginDirectory}

private[patches] class RorSecurityPolicyPatchCreator(patchingSteps: FileModifier*)
extends FilePatchCreator[RorSecurityPolicyPatch] {
Expand All @@ -30,7 +30,7 @@ private[patches] class RorSecurityPolicyPatchCreator(patchingSteps: FileModifier

private[patches] class RorSecurityPolicyPatch(rorPluginDirectory: RorPluginDirectory,
patchingSteps: Iterable[FileModifier])
extends FilePatch(
extends FileModifiersBasedPatch(
rorPluginDirectory = rorPluginDirectory,
fileToPatchPath = rorPluginDirectory.securityPolicyPath,
patchingSteps = patchingSteps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,34 @@
package tech.beshu.ror.tools.core.patches.internal.filePatchers

import just.semver.SemVer
import tech.beshu.ror.tools.core.patches.internal.{FilePatch, RorPluginDirectory}
import tech.beshu.ror.tools.core.patches.internal.modifiers.FileModifier
import tech.beshu.ror.tools.core.patches.internal.{FileModifiersBasedPatch, OptionalFilePatchDecorator, RorPluginDirectory}

private[patches] class XPackCoreJarPatchCreator(patchingSteps: FileModifier*)
extends FilePatchCreator[XPackCoreJarPatch] {

override def create(rorPluginDirectory: RorPluginDirectory,
esVersion: SemVer): XPackCoreJarPatch =
esVersion: SemVer): XPackCoreJarPatch = {
new XPackCoreJarPatch(rorPluginDirectory, esVersion, patchingSteps)
}
}

private[patches] class OptionalXPackCoreJarPatchCreator(patchingSteps: FileModifier*)
extends FilePatchCreator[OptionalFilePatchDecorator[XPackCoreJarPatch]] {

override def create(rorPluginDirectory: RorPluginDirectory,
esVersion: SemVer): OptionalFilePatchDecorator[XPackCoreJarPatch] = {
new OptionalFilePatchDecorator(
new XPackCoreJarPatch(rorPluginDirectory, esVersion, patchingSteps)
)
}
}

private[patches] class XPackCoreJarPatch(rorPluginDirectory: RorPluginDirectory,
esVersion: SemVer,
patchingSteps: Iterable[FileModifier])
extends FilePatch(
esVersion: SemVer,
patchingSteps: Iterable[FileModifier],
)
extends FileModifiersBasedPatch(
rorPluginDirectory = rorPluginDirectory,
fileToPatchPath = rorPluginDirectory.esDirectory.modulesPath / "x-pack-core" / s"x-pack-core-${esVersion.render}.jar",
patchingSteps = patchingSteps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package tech.beshu.ror.tools.core.patches.internal.filePatchers

import just.semver.SemVer
import tech.beshu.ror.tools.core.patches.internal.modifiers.FileModifier
import tech.beshu.ror.tools.core.patches.internal.{FilePatch, RorPluginDirectory}
import tech.beshu.ror.tools.core.patches.internal.{FileModifiersBasedPatch, FilePatch, RorPluginDirectory}

private[patches] class XPackIlmJarPatchCreator(patchingSteps: FileModifier*)
extends FilePatchCreator[XPackIlmJarPatch] {
Expand All @@ -31,7 +31,7 @@ private[patches] class XPackIlmJarPatchCreator(patchingSteps: FileModifier*)
private[patches] class XPackIlmJarPatch(rorPluginDirectory: RorPluginDirectory,
esVersion: SemVer,
patchingSteps: Iterable[FileModifier])
extends FilePatch(
extends FileModifiersBasedPatch(
rorPluginDirectory = rorPluginDirectory,
fileToPatchPath = rorPluginDirectory.esDirectory.modulesPath / "x-pack-ilm" / s"x-pack-ilm-${esVersion.render}.jar",
patchingSteps = patchingSteps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package tech.beshu.ror.tools.core.patches.internal.filePatchers

import just.semver.SemVer
import tech.beshu.ror.tools.core.patches.internal.modifiers.FileModifier
import tech.beshu.ror.tools.core.patches.internal.{FilePatch, RorPluginDirectory}
import tech.beshu.ror.tools.core.patches.internal.{FileModifiersBasedPatch, FilePatch, OptionalFilePatchDecorator, RorPluginDirectory}

private[patches] class XPackSecurityJarPatchCreator(patchingSteps: FileModifier*)
extends FilePatchCreator[XPackSecurityJarPatch] {
Expand All @@ -28,10 +28,21 @@ private[patches] class XPackSecurityJarPatchCreator(patchingSteps: FileModifier*
new XPackSecurityJarPatch(rorPluginDirectory, esVersion, patchingSteps)
}

private[patches] class OptionalXPackSecurityJarPatchCreator(patchingSteps: FileModifier*)
extends FilePatchCreator[OptionalFilePatchDecorator[XPackSecurityJarPatch]] {

override def create(rorPluginDirectory: RorPluginDirectory,
esVersion: SemVer): OptionalFilePatchDecorator[XPackSecurityJarPatch] = {
new OptionalFilePatchDecorator(
new XPackSecurityJarPatch(rorPluginDirectory, esVersion, patchingSteps)
)
}
}

private[patches] class XPackSecurityJarPatch(rorPluginDirectory: RorPluginDirectory,
esVersion: SemVer,
patchingSteps: Iterable[FileModifier])
extends FilePatch(
extends FileModifiersBasedPatch(
rorPluginDirectory = rorPluginDirectory,
fileToPatchPath = rorPluginDirectory.esDirectory.modulesPath / "x-pack-security" / s"x-pack-security-${esVersion.render}.jar",
patchingSteps = patchingSteps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ private [patches] trait FileModifier {

def apply(file: File): Unit
}

private [patches] object NoOpFileModifier extends FileModifier {
override def apply(file: File): Unit = ()
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ object EsUtil {
val es810: SemVer = SemVer.unsafeParse("8.1.0")
val es800: SemVer = SemVer.unsafeParse("8.0.0")
val es71713: SemVer = SemVer.unsafeParse("7.17.13")
val es7110: SemVer = SemVer.unsafeParse("7.11.0")
val es790: SemVer = SemVer.unsafeParse("7.9.0")
val es780: SemVer = SemVer.unsafeParse("7.8.0")
val es700: SemVer = SemVer.unsafeParse("7.0.0")
Expand Down

0 comments on commit 6fdbb62

Please sign in to comment.