diff --git a/als-actions/shared/src/test/scala/org/mulesoft/als/actions/definition/DefinitionFileTests.scala b/als-actions/shared/src/test/scala/org/mulesoft/als/actions/definition/DefinitionFileTests.scala index 5f29428d8a..0755d4d6d2 100644 --- a/als-actions/shared/src/test/scala/org/mulesoft/als/actions/definition/DefinitionFileTests.scala +++ b/als-actions/shared/src/test/scala/org/mulesoft/als/actions/definition/DefinitionFileTests.scala @@ -1,12 +1,12 @@ package org.mulesoft.als.actions.definition -import amf.core.internal.unsafe.PlatformSecrets +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.scalatest.flatspec.AsyncFlatSpec import org.scalatest.matchers.should.Matchers import scala.concurrent.ExecutionContext -class DefinitionFileTests extends AsyncFlatSpec with Matchers with PlatformSecrets { +class DefinitionFileTests extends AsyncFlatSpec with Matchers with AlsPlatformSecrets { override val executionContext: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global diff --git a/als-actions/shared/src/test/scala/org/mulesoft/als/actions/folding/FoldingRangesTests.scala b/als-actions/shared/src/test/scala/org/mulesoft/als/actions/folding/FoldingRangesTests.scala index 7fbef9ba74..9b0442a3df 100644 --- a/als-actions/shared/src/test/scala/org/mulesoft/als/actions/folding/FoldingRangesTests.scala +++ b/als-actions/shared/src/test/scala/org/mulesoft/als/actions/folding/FoldingRangesTests.scala @@ -2,13 +2,13 @@ package org.mulesoft.als.actions.folding import amf.core.client.common.remote.Content import amf.core.client.scala.resource.ResourceLoader -import amf.core.internal.unsafe.PlatformSecrets import org.mulesoft.amfintegration.AmfImplicits.{AmfAnnotationsImp, BaseUnitImp} import org.mulesoft.amfintegration.amfconfiguration.{ ALSConfigurationState, EditorConfiguration, EmptyProjectConfigurationState } +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.mulesoft.lsp.feature.folding.FoldingRange import org.scalatest.flatspec.AsyncFlatSpec import org.scalatest.matchers.should.Matchers @@ -16,7 +16,7 @@ import org.scalatest.matchers.should.Matchers import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.{ExecutionContext, Future} -class FoldingRangesTests extends AsyncFlatSpec with Matchers with PlatformSecrets { +class FoldingRangesTests extends AsyncFlatSpec with Matchers with AlsPlatformSecrets { override val executionContext: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global diff --git a/als-actions/shared/src/test/scala/org/mulesoft/als/actions/links/FindLinksTests.scala b/als-actions/shared/src/test/scala/org/mulesoft/als/actions/links/FindLinksTests.scala index 35815e233f..567fa0bb05 100644 --- a/als-actions/shared/src/test/scala/org/mulesoft/als/actions/links/FindLinksTests.scala +++ b/als-actions/shared/src/test/scala/org/mulesoft/als/actions/links/FindLinksTests.scala @@ -1,10 +1,10 @@ package org.mulesoft.als.actions.links -import amf.core.internal.unsafe.PlatformSecrets +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -class FindLinksTests extends AnyFlatSpec with Matchers with PlatformSecrets { +class FindLinksTests extends AnyFlatSpec with Matchers with AlsPlatformSecrets { behavior of "Find Links" // todo: find a way to test this in a simple way (currently tested in server module) diff --git a/als-actions/shared/src/test/scala/org/mulesoft/als/actions/rangeFormatting/FormattingOptionsTest.scala b/als-actions/shared/src/test/scala/org/mulesoft/als/actions/rangeFormatting/FormattingOptionsTest.scala index 2a0d740d40..0fd49b0f2b 100644 --- a/als-actions/shared/src/test/scala/org/mulesoft/als/actions/rangeFormatting/FormattingOptionsTest.scala +++ b/als-actions/shared/src/test/scala/org/mulesoft/als/actions/rangeFormatting/FormattingOptionsTest.scala @@ -1,14 +1,14 @@ package org.mulesoft.als.actions.rangeFormatting -import amf.core.internal.unsafe.PlatformSecrets import org.mulesoft.als.actions.formatting.RangeFormatting import org.mulesoft.amfintegration.ErrorsCollected +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.mulesoft.lsp.configuration.FormattingOptions import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers import org.yaml.model.YMap -class FormattingOptionsTest extends AnyFlatSpec with Matchers with PlatformSecrets { +class FormattingOptionsTest extends AnyFlatSpec with Matchers with AlsPlatformSecrets { behavior of "Formatting Options" private val baseTest = "my: \n test: lorem ipsum \n\n\n\n\n" diff --git a/als-actions/shared/src/test/scala/org/mulesoft/als/actions/selection/SelectionRangeFinderTest.scala b/als-actions/shared/src/test/scala/org/mulesoft/als/actions/selection/SelectionRangeFinderTest.scala index 07b7bdda0d..e17796ef9d 100644 --- a/als-actions/shared/src/test/scala/org/mulesoft/als/actions/selection/SelectionRangeFinderTest.scala +++ b/als-actions/shared/src/test/scala/org/mulesoft/als/actions/selection/SelectionRangeFinderTest.scala @@ -2,7 +2,6 @@ package org.mulesoft.als.actions.selection import amf.core.client.common.remote.Content import amf.core.client.scala.resource.ResourceLoader -import amf.core.internal.unsafe.PlatformSecrets import org.mulesoft.als.common.dtoTypes.Position import org.mulesoft.amfintegration.AmfImplicits.{AmfAnnotationsImp, BaseUnitImp} import org.mulesoft.amfintegration.amfconfiguration.{ @@ -10,6 +9,7 @@ import org.mulesoft.amfintegration.amfconfiguration.{ EditorConfiguration, EmptyProjectConfigurationState } +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.mulesoft.lsp.feature.common.{Range, Position => LspPosition} import org.mulesoft.lsp.feature.selectionRange.SelectionRange import org.scalatest.flatspec.AsyncFlatSpec @@ -17,7 +17,7 @@ import org.scalatest.matchers.should.Matchers import scala.concurrent.{ExecutionContext, Future} -class SelectionRangeFinderTest extends AsyncFlatSpec with Matchers with PlatformSecrets { +class SelectionRangeFinderTest extends AsyncFlatSpec with Matchers with AlsPlatformSecrets { override implicit val executionContext: ExecutionContext = ExecutionContext.Implicits.global it should "select the range on YAML map" in { diff --git a/als-common/js/src/main/scala/org/mulesoft/als/configuration/JsServerSystemConf.scala b/als-common/js/src/main/scala/org/mulesoft/als/configuration/JsServerSystemConf.scala index 70d0b01b42..fac10952d8 100644 --- a/als-common/js/src/main/scala/org/mulesoft/als/configuration/JsServerSystemConf.scala +++ b/als-common/js/src/main/scala/org/mulesoft/als/configuration/JsServerSystemConf.scala @@ -2,8 +2,8 @@ package org.mulesoft.als.configuration import amf.core.client.platform.resource.ClientResourceLoader import amf.core.client.scala.resource.ResourceLoader -import amf.core.internal.unsafe.PlatformSecrets import org.mulesoft.als.common.DirectoryResolver +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import scala.concurrent.ExecutionContext.Implicits.global import scala.scalajs.js diff --git a/als-common/shared/src/main/scala/org/mulesoft/als/common/DirectoryResolver.scala b/als-common/shared/src/main/scala/org/mulesoft/als/common/DirectoryResolver.scala index f13462dc81..f95ac13708 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/als/common/DirectoryResolver.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/als/common/DirectoryResolver.scala @@ -1,11 +1,11 @@ package org.mulesoft.als.common -import amf.core.internal.unsafe.PlatformSecrets import org.mulesoft.als.common.URIImplicits._ +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import scala.concurrent.Future -trait DirectoryResolver extends PlatformSecrets { +trait DirectoryResolver extends AlsPlatformSecrets { def exists(path: String): Future[Boolean] def readDir(path: String): Future[Seq[String]] diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/AlsSyamlSyntaxPluginHacked.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/AlsSyamlSyntaxPluginHacked.scala index 5efe9fac66..698942925c 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/AlsSyamlSyntaxPluginHacked.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/AlsSyamlSyntaxPluginHacked.scala @@ -5,12 +5,12 @@ import amf.core.client.scala.parse.AMFSyntaxParsePlugin import amf.core.client.scala.parse.document.{ParsedDocument, ParserContext, SyamlParsedDocument} import amf.core.internal.parser.domain.JsonParserFactory import amf.core.internal.plugins.syntax.SyamlSyntaxParsePlugin -import amf.core.internal.unsafe.PlatformSecrets import org.yaml.model.{YComment, YDocument, YMap, YNode} import org.yaml.parser.YamlParser import amf.core.internal.plugins.syntax.SyamlAMFErrorHandler +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets -object AlsSyamlSyntaxPluginHacked extends AMFSyntaxParsePlugin with PlatformSecrets { +object AlsSyamlSyntaxPluginHacked extends AMFSyntaxParsePlugin with AlsPlatformSecrets { override def priority: PluginPriority = HighPriority diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/ALSConfigurationState.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/ALSConfigurationState.scala index 26bb7b8227..c4828ad292 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/ALSConfigurationState.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/ALSConfigurationState.scala @@ -10,7 +10,6 @@ import amf.core.client.scala.resource.ResourceLoader import amf.core.client.scala.{AMFParseResult => AMFParsingResult} import amf.core.internal.remote.Spec.{AMF, GRAPHQL} import amf.core.internal.remote.{AmlDialectSpec, Spec} -import amf.core.internal.unsafe.PlatformSecrets import amf.graphql.client.scala.GraphQLConfiguration import amf.shapes.client.scala.config.JsonSchemaConfiguration import amf.shapes.client.scala.model.document.JsonSchemaDocument @@ -22,6 +21,7 @@ import org.mulesoft.amfintegration.ValidationProfile import org.mulesoft.amfintegration.dialect.dialects.ExternalFragmentDialect import org.mulesoft.amfintegration.dialect.dialects.metadialect.{MetaDialect, VocabularyDialect} import org.mulesoft.amfintegration.dialect.integration.BaseAlsDialectProvider +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.yaml.builder.DocBuilder import scala.concurrent.ExecutionContext.Implicits.global @@ -35,7 +35,7 @@ case class ALSConfigurationState( editorState: EditorConfigurationState, projectState: ProjectConfigurationState, editorResourceLoader: Option[ResourceLoader] -) extends PlatformSecrets { +) extends AlsPlatformSecrets { lazy val amfParseContext: AmfParseContext = AmfParseContext(getAmfConfig(false), this) diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/EditorConfiguration.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/EditorConfiguration.scala index b2c98c9e8d..f8f52e09de 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/EditorConfiguration.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/EditorConfiguration.scala @@ -8,12 +8,12 @@ import amf.core.client.scala.parse.AMFSyntaxParsePlugin import amf.core.client.scala.resource.ResourceLoader import amf.core.client.scala.validation.payload.AMFShapePayloadValidationPlugin import amf.core.internal.remote.Spec -import amf.core.internal.unsafe.PlatformSecrets import amf.graphql.client.scala.GraphQLConfiguration import amf.shapes.client.scala.config.JsonSchemaConfiguration import org.mulesoft.als.logger.Logger import org.mulesoft.amfintegration.AmfImplicits.DialectInstanceImp import org.mulesoft.amfintegration.dialect.integration.BaseAlsDialectProvider +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.mulesoft.amfintegration.vocabularies.integration.{ AlsVocabularyParsingPlugin, AlsVocabularyRegistry, @@ -144,7 +144,7 @@ object EditorConfigurationState { EditorConfigurationState(Nil, Nil, Nil, syntaxPlugin = Nil, validationPlugin = Nil) } -object EditorConfiguration extends PlatformSecrets { +object EditorConfiguration extends AlsPlatformSecrets { def apply(): EditorConfiguration = withPlatformLoaders(Seq.empty) def withPlatformLoaders(rls: Seq[ResourceLoader]): EditorConfiguration = diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/override/OverrideProfileNames.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/override/OverrideProfileNames.scala index 4377b89b44..048f8e7ecd 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/override/OverrideProfileNames.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/override/OverrideProfileNames.scala @@ -22,6 +22,7 @@ object ProfileNames { val GRAPHQL: ProfileName = GraphQLProfile val GRAPHQL_FEDERATION: ProfileName = GraphQLFederationProfile val JSONSCHEMA: ProfileName = JsonSchemaProfile + val AVROSCHEMA: ProfileName = AvroSchemaProfile lazy val specProfiles: Seq[ProfileName] = Seq( @@ -36,7 +37,8 @@ object ProfileNames { GraphQLProfile, GraphQLFederationProfile, GrpcProfile, - JsonSchemaProfile + JsonSchemaProfile, + AvroSchemaProfile ) } @@ -95,6 +97,11 @@ object JsonSchemaProfile extends ProfileName(JsonSchema.id, AMFStyle) { override def isRaml(): Boolean = false } +object AvroSchemaProfile extends ProfileName(AvroSchema.id, AMFStyle) { + override def isOas(): Boolean = false + override def isRaml(): Boolean = false +} + object ProfileName { def unapply(name: String): Option[ProfileName] = name match { @@ -108,6 +115,7 @@ object ProfileName { case GraphQLProfile.p => Some(GraphQLProfile) case GraphQLFederationProfile.p => Some(GraphQLFederationProfile) case JsonSchemaProfile.p => Some(JsonSchemaProfile) + case AvroSchemaProfile.p => Some(AvroSchemaProfile) case _ => None } @@ -129,6 +137,7 @@ object ProfileName { case GraphQL.id => GraphQLProfile case GraphQLFederation.id => GraphQLFederationProfile case JsonSchema.id => JsonSchemaProfile + case AvroSchema.id => AvroSchemaProfile case custom => new ProfileName(custom) } } diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/platform/AlsPlatformSecrets.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/platform/AlsPlatformSecrets.scala new file mode 100644 index 0000000000..62bfdb34e4 --- /dev/null +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/platform/AlsPlatformSecrets.scala @@ -0,0 +1,69 @@ +package org.mulesoft.amfintegration.platform + +import amf.core.client.common.remote.Content +import amf.core.client.scala.resource.ResourceLoader +import amf.core.internal.remote.Platform +import amf.core.internal.unsafe.PlatformBuilder +import org.mulesoft.als.logger.Logger +import org.mulesoft.common.io.FileSystem + +import scala.concurrent.{ExecutionContext, Future} +trait AlsPlatformSecrets { + private val internalPlatform: Platform = PlatformBuilder() + + val platform: Platform = new Platform { + private def overrideLoaders(implicit executionContext: ExecutionContext): Seq[ResourceLoader] = + internalPlatform.loaders().map(SecuredLoader) + + override def name: String = internalPlatform.name + + override def findCharInCharSequence(s: CharSequence)(p: Char => Boolean): Option[Char] = + internalPlatform.findCharInCharSequence(s)(p) + + override val fs: FileSystem = internalPlatform.fs + + override def loaders()(implicit executionContext: ExecutionContext): Seq[ResourceLoader] = overrideLoaders + + override def encodeURI(url: String): String = internalPlatform.encodeURI(url) + + override def decodeURI(url: String): String = internalPlatform.decodeURI(url) + + override def encodeURIComponent(url: String): String = internalPlatform.encodeURIComponent(url) + + override def decodeURIComponent(url: String): String = internalPlatform.decodeURIComponent(url) + + override def tmpdir(): String = internalPlatform.tmpdir + + override def operativeSystem(): String = internalPlatform.operativeSystem + + // no idea where this is used, but it is overriden in JvmPlatform and I am afraid to change it + override protected def customValidationLibraryHelperLocation: String = + if (name == "jvm") "classpath:validations/amf_validation.js" else super.customValidationLibraryHelperLocation + } + + private case class SecuredLoader(loader: ResourceLoader) extends ResourceLoader { + override def fetch(resource: String): Future[Content] = + loader.fetch(resource) + + override def accepts(resource: String): Boolean = + !potentialLeak(resource) && loader.accepts(resource) + + private def potentialLeak(resource: String): Boolean = + WindowsLeakRegex(resource.toLowerCase) + } +} + +protected object WindowsLeakRegex { + private def checkForLiteral(literal: String, prefix: String)(implicit resource: String): Boolean = { + val regex = s"$prefix/*$literal".r + regex.findPrefixMatchOf(resource).nonEmpty + } + + private def doubleCheckLiteral(literal: String)(implicit resource: String): Boolean = + checkForLiteral(literal, "") || checkForLiteral(literal, filePrefix) + def apply(implicit resource: String): Boolean = + doubleCheckLiteral(windowsSMB) || doubleCheckLiteral(windowsSMBEncoded) || checkForLiteral( + unixStyle, + "" + ) || checkForLiteral(unixStyle, s"$filePrefix//") +} diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/platform/package.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/platform/package.scala new file mode 100644 index 0000000000..23a44dfb2f --- /dev/null +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/platform/package.scala @@ -0,0 +1,8 @@ +package org.mulesoft.amfintegration + +package object platform { + val filePrefix = "file:" + val windowsSMB = "\\\\" // just in case because AMF sometimes tries to re-fetch a URI decoding it + val windowsSMBEncoded = "%5c%5c" + val unixStyle = "//" +} diff --git a/als-common/shared/src/test/scala/org/mulesoft/als/common/diff/FileAssertionTest.scala b/als-common/shared/src/test/scala/org/mulesoft/als/common/diff/FileAssertionTest.scala index 858dc584b7..cf526ede78 100644 --- a/als-common/shared/src/test/scala/org/mulesoft/als/common/diff/FileAssertionTest.scala +++ b/als-common/shared/src/test/scala/org/mulesoft/als/common/diff/FileAssertionTest.scala @@ -1,12 +1,12 @@ package org.mulesoft.als.common.diff -import amf.core.internal.unsafe.PlatformSecrets +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.mulesoft.common.io.{AsyncFile, FileSystem} import org.scalatest.compatible.Assertion import scala.concurrent.{ExecutionContext, Future} -trait FileAssertionTest extends PlatformSecrets { +trait FileAssertionTest extends AlsPlatformSecrets { private implicit val executionContext: ExecutionContext = ExecutionContext.Implicits.global diff --git a/als-common/shared/src/test/scala/org/mulesoft/als/common/dtoTypes/FileUtilsTest.scala b/als-common/shared/src/test/scala/org/mulesoft/als/common/dtoTypes/FileUtilsTest.scala index 0c4143821d..d291af088e 100644 --- a/als-common/shared/src/test/scala/org/mulesoft/als/common/dtoTypes/FileUtilsTest.scala +++ b/als-common/shared/src/test/scala/org/mulesoft/als/common/dtoTypes/FileUtilsTest.scala @@ -1,12 +1,12 @@ package org.mulesoft.als.common.dtoTypes import amf.core.internal.remote.Platform -import amf.core.internal.unsafe.PlatformSecrets import org.mulesoft.als.common.FileUtils import org.mulesoft.als.common.URIImplicits._ +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.scalatest.funsuite.AnyFunSuite -class FileUtilsTest extends AnyFunSuite with PlatformSecrets { +class FileUtilsTest extends AnyFunSuite with AlsPlatformSecrets { private val path = "root/drive/space in folder/file%3A" private val uri = platform.encodeURI(path) // "root/drive/space%20in%20folder/file%253A" diff --git a/als-common/shared/src/test/scala/org/mulesoft/als/common/objectintree/ObjectInTreeBaseTest.scala b/als-common/shared/src/test/scala/org/mulesoft/als/common/objectintree/ObjectInTreeBaseTest.scala index 81b1cd5eae..6e224f56c1 100644 --- a/als-common/shared/src/test/scala/org/mulesoft/als/common/objectintree/ObjectInTreeBaseTest.scala +++ b/als-common/shared/src/test/scala/org/mulesoft/als/common/objectintree/ObjectInTreeBaseTest.scala @@ -2,7 +2,6 @@ package org.mulesoft.als.common.objectintree import amf.aml.client.scala.model.document.Dialect import amf.aml.internal.metamodel.domain.DialectDomainElementModel -import amf.core.internal.unsafe.PlatformSecrets import org.mulesoft.als.common.dtoTypes.Position import org.mulesoft.als.common.{NodeBranchBuilder, ObjectInTree, ObjectInTreeBuilder} import org.mulesoft.amfintegration.AmfImplicits.BaseUnitImp @@ -12,13 +11,14 @@ import org.mulesoft.amfintegration.amfconfiguration.{ EditorConfiguration, EmptyProjectConfigurationState } +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.mulesoft.common.client.lexical.{Position => AmfPosition} import org.scalatest.compatible.Assertion import org.scalatest.matchers.should.Matchers import scala.concurrent.{ExecutionContext, Future} -case class ObjectInTreeBaseTest(instanceFile: String, dialectFile: String) extends PlatformSecrets with Matchers { +case class ObjectInTreeBaseTest(instanceFile: String, dialectFile: String) extends AlsPlatformSecrets with Matchers { protected def uriTemplate(part: String) = s"file://als-common/shared/src/test/resources/aml/$part" implicit val ec: ExecutionContext = ExecutionContext.global diff --git a/als-common/shared/src/test/scala/org/mulesoft/amfintegration/platform/WindowsSMBLeakTest.scala b/als-common/shared/src/test/scala/org/mulesoft/amfintegration/platform/WindowsSMBLeakTest.scala new file mode 100644 index 0000000000..b93c3b00f5 --- /dev/null +++ b/als-common/shared/src/test/scala/org/mulesoft/amfintegration/platform/WindowsSMBLeakTest.scala @@ -0,0 +1,36 @@ +package org.mulesoft.amfintegration.platform + +import org.scalatest.funsuite.AnyFunSuite + +class WindowsSMBLeakTest extends AnyFunSuite { + + val matches: Set[String] = Set( + "file:%5c%5ctest", + "file:/%5c%5ctest", + "file://%5c%5ctest", + "file:///%5c%5ctest", + "file:////%5c%5ctest", + "file:\\\\test", + "file:/\\\\test", + "file://\\\\test", + "file:///\\\\test", + "\\\\test", + "%5c%5ctest", + "//test", + "file:////test" + ) + + test("should not match URI without SMB leak") { + assert(!WindowsLeakRegex("file:///test/correct")) + assert(!WindowsLeakRegex("file://test/correct")) + assert(!WindowsLeakRegex("file:/test/correct")) + assert(!WindowsLeakRegex("file:test/correct")) + assert(!WindowsLeakRegex("/test/correct")) + } + + matches.foreach { resource => + test(s"should match $resource") { + assert(WindowsLeakRegex.apply(resource)) + } + } +} diff --git a/als-node-client/src/main/scala/org/mulesoft/als/nodeclient/Main.scala b/als-node-client/src/main/scala/org/mulesoft/als/nodeclient/Main.scala index 17de5456a8..c02ae787dd 100644 --- a/als-node-client/src/main/scala/org/mulesoft/als/nodeclient/Main.scala +++ b/als-node-client/src/main/scala/org/mulesoft/als/nodeclient/Main.scala @@ -1,6 +1,5 @@ package org.mulesoft.als.nodeclient -import amf.core.internal.unsafe.PlatformSecrets import amf.custom.validation.client.platform.CustomValidator import amf.custom.validation.client.platform.validator.JsCustomValidator import amf.custom.validation.internal.convert.AmfCustomValidatorClientConverters.ClientFuture @@ -9,10 +8,11 @@ import io.scalajs.nodejs.process import org.mulesoft.als.server.client.platform.AlsLanguageServerFactory import org.mulesoft.als.server.{ClientNotifierFactory, JsSerializationProps, ProtocolConnectionBinder} import org.mulesoft.als.vscode.{ProtocolConnection, ServerSocketTransport} +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets // $COVERAGE-OFF$ Incompatibility between scoverage and scalaJS -object Main extends PlatformSecrets { +object Main extends AlsPlatformSecrets { case class Options(port: Int) val DefaultOptions: Options = Options(4000) diff --git a/als-server/js/src/test/scala/org/mulesoft/als/server/AMFValidatorTest.scala b/als-server/js/src/test/scala/org/mulesoft/als/server/AMFValidatorTest.scala index 8f64d65c05..e831753444 100644 --- a/als-server/js/src/test/scala/org/mulesoft/als/server/AMFValidatorTest.scala +++ b/als-server/js/src/test/scala/org/mulesoft/als/server/AMFValidatorTest.scala @@ -7,11 +7,11 @@ import amf.core.client.platform.validation.payload.{ JsPayloadValidator, ShapeValidationConfiguration } -import amf.core.internal.unsafe.PlatformSecrets +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import scala.scalajs.js -trait AMFValidatorTest extends LanguageServerBaseTest with PlatformSecrets { +trait AMFValidatorTest extends LanguageServerBaseTest with AlsPlatformSecrets { def getAppliesFunction(fn: () => Unit): Boolean = { fn() diff --git a/als-server/js/src/test/scala/org/mulesoft/als/server/JsLanguageServerTest.scala b/als-server/js/src/test/scala/org/mulesoft/als/server/JsLanguageServerTest.scala index e5c9da8e16..b3c5750403 100644 --- a/als-server/js/src/test/scala/org/mulesoft/als/server/JsLanguageServerTest.scala +++ b/als-server/js/src/test/scala/org/mulesoft/als/server/JsLanguageServerTest.scala @@ -119,8 +119,7 @@ class JsLanguageServerTest extends AMFValidatorTest { test("Should have platform loaders as default") { val loaders = getServerResourceLoaders(js.Array()) - loaders.size should be(2) - loaders should contain allElementsOf platfromLoaders + loaders.size should be(platfromLoaders.size) } test("Should not have default platform loaders when given list isn't empty") { diff --git a/als-server/jvm/src/test/scala/org/mulesoft/als/server/AMFValidatorTest.scala b/als-server/jvm/src/test/scala/org/mulesoft/als/server/AMFValidatorTest.scala index 3eedab586b..7c0d3a1548 100644 --- a/als-server/jvm/src/test/scala/org/mulesoft/als/server/AMFValidatorTest.scala +++ b/als-server/jvm/src/test/scala/org/mulesoft/als/server/AMFValidatorTest.scala @@ -8,9 +8,9 @@ import amf.core.client.scala.validation.payload.{ ShapeValidationConfiguration, ValidatePayloadRequest } -import amf.core.internal.unsafe.PlatformSecrets +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets -trait AMFValidatorTest extends LanguageServerBaseTest with PlatformSecrets { +trait AMFValidatorTest extends LanguageServerBaseTest with AlsPlatformSecrets { case class TestValidator(fn: () => Unit) extends AMFShapePayloadValidationPlugin { override def applies(element: ValidatePayloadRequest): Boolean = { fn() diff --git a/als-server/jvm/src/test/scala/org/mulesoft/als/server/acv/AmfCustomValidationToolsTest.scala b/als-server/jvm/src/test/scala/org/mulesoft/als/server/acv/AmfCustomValidationToolsTest.scala index 3e718d8898..121ddb523f 100644 --- a/als-server/jvm/src/test/scala/org/mulesoft/als/server/acv/AmfCustomValidationToolsTest.scala +++ b/als-server/jvm/src/test/scala/org/mulesoft/als/server/acv/AmfCustomValidationToolsTest.scala @@ -1,13 +1,13 @@ package org.mulesoft.als.server.acv -import amf.core.internal.unsafe.PlatformSecrets import org.eclipse.lsp4j.{Position, Range} +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.scalatest.funsuite.AsyncFunSuite import scala.compat.java8.FutureConverters.CompletionStageOps import scala.jdk.CollectionConverters.collectionAsScalaIterableConverter -class AmfCustomValidationToolsTest extends AsyncFunSuite with PlatformSecrets { +class AmfCustomValidationToolsTest extends AsyncFunSuite with AlsPlatformSecrets { private def buildResourcePath(file: String) = s"als-server/jvm/src/test/resources/acv/$file" test("parse report into java class") { diff --git a/als-server/jvm/src/test/scala/org/mulesoft/als/server/lsp4j/Lsp4jLanguageServerDiagnosticImplTest.scala b/als-server/jvm/src/test/scala/org/mulesoft/als/server/lsp4j/Lsp4jLanguageServerDiagnosticImplTest.scala index 24de13c8f2..256826a7a4 100644 --- a/als-server/jvm/src/test/scala/org/mulesoft/als/server/lsp4j/Lsp4jLanguageServerDiagnosticImplTest.scala +++ b/als-server/jvm/src/test/scala/org/mulesoft/als/server/lsp4j/Lsp4jLanguageServerDiagnosticImplTest.scala @@ -1,17 +1,17 @@ package org.mulesoft.als.server.lsp4j import amf.core.client.common.validation.ProfileNames -import amf.core.internal.unsafe.PlatformSecrets import org.eclipse.lsp4j.ExecuteCommandParams import org.mulesoft.als.server.client.scala.LanguageServerBuilder import org.mulesoft.als.server.modules.WorkspaceManagerFactoryBuilder import org.mulesoft.als.server.protocol.LanguageServer import org.mulesoft.als.server.{Flaky, LanguageServerBaseTest, MockDiagnosticClientNotifier} +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import java.util import scala.concurrent.Future -class Lsp4jLanguageServerDiagnosticImplTest extends LanguageServerBaseTest with PlatformSecrets { +class Lsp4jLanguageServerDiagnosticImplTest extends LanguageServerBaseTest with AlsPlatformSecrets { // TODO: check if the caché on WorkspaceContentManager is used (if it can be used) // TODO: check if a new validation should be sent from WorkspaceContentCollection when "onFocus" (when the BU is already parsed) diff --git a/als-server/jvm/src/test/scala/org/mulesoft/als/server/lsp4j/LspCustomEnvironment.scala b/als-server/jvm/src/test/scala/org/mulesoft/als/server/lsp4j/LspCustomEnvironment.scala index 51e731fe3e..a9fe332ba2 100644 --- a/als-server/jvm/src/test/scala/org/mulesoft/als/server/lsp4j/LspCustomEnvironment.scala +++ b/als-server/jvm/src/test/scala/org/mulesoft/als/server/lsp4j/LspCustomEnvironment.scala @@ -3,7 +3,6 @@ package org.mulesoft.als.server.lsp4j import amf.core.client.common.remote.Content import amf.core.client.platform.resource.ClientResourceLoader import amf.core.internal.convert.CoreClientConverters._ -import amf.core.internal.unsafe.PlatformSecrets import org.eclipse.lsp4j.{DidOpenTextDocumentParams, TextDocumentItem, TraceValue} import org.mulesoft.als.configuration.ResourceLoaderConverter import org.mulesoft.als.logger.EmptyLogger @@ -11,6 +10,7 @@ import org.mulesoft.als.server.client.platform.AlsLanguageServerFactory import org.mulesoft.als.server.lsp4j.extension.AlsInitializeParams import org.mulesoft.als.server.modules.diagnostic.ALL_TOGETHER import org.mulesoft.als.server.{Flaky, MockDiagnosticClientNotifier} +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.scalatest.funsuite.AsyncFunSuite import org.scalatest.matchers.should.Matchers @@ -18,7 +18,7 @@ import java.util.concurrent.CompletableFuture import scala.collection.JavaConverters._ import scala.compat.java8.FutureConverters._ import scala.concurrent.Future -class LspCustomEnvironment extends AsyncFunSuite with Matchers with PlatformSecrets { +class LspCustomEnvironment extends AsyncFunSuite with Matchers with AlsPlatformSecrets { test("test custom environment", Flaky) { diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/ManagersFactory.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/ManagersFactory.scala index db1daa424f..71efa1c553 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/ManagersFactory.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/ManagersFactory.scala @@ -1,6 +1,5 @@ package org.mulesoft.als.server.modules -import amf.core.internal.unsafe.PlatformSecrets import amf.custom.validation.client.scala.BaseProfileValidatorBuilder import org.mulesoft.als.actions.codeactions.plugins.AllCodeActions import org.mulesoft.als.common.{DirectoryResolver, PlatformDirectoryResolver} @@ -30,6 +29,7 @@ import org.mulesoft.als.server.textsync.{DefaultTextDocumentSyncBuilder, TextDoc import org.mulesoft.als.server.workspace.{ProjectConfigurationProvider, WorkspaceManager} import org.mulesoft.amfintegration.AmfResolvedUnit import org.mulesoft.amfintegration.amfconfiguration.EditorConfiguration +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import scala.collection.mutable.ListBuffer @@ -38,7 +38,7 @@ class WorkspaceManagerFactoryBuilder( val editorConfiguration: EditorConfiguration = EditorConfiguration(), projectConfigurationProvider: Option[ProjectConfigurationProvider] = None, textDocumentSyncBuilder: Option[TextDocumentSyncBuilder] = None -) extends PlatformSecrets { +) extends AlsPlatformSecrets { Logger.withTelemetry(new TelemetryManager(clientNotifier)) diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/ProjectDiagnosticManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/ProjectDiagnosticManager.scala index 61cf3d7f68..2ea2eed9bb 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/ProjectDiagnosticManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/ProjectDiagnosticManager.scala @@ -1,11 +1,11 @@ package org.mulesoft.als.server.modules.diagnostic import amf.core.client.common.validation.ProfileNames -import amf.core.internal.unsafe.PlatformSecrets import org.mulesoft.als.common.URIImplicits.StringUriImplicits import org.mulesoft.als.server.client.platform.ClientNotifier import org.mulesoft.als.server.modules.project.NewConfigurationListener import org.mulesoft.amfintegration.amfconfiguration.ProjectConfigurationState +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import scala.collection.mutable import scala.concurrent.ExecutionContext.Implicits.global @@ -17,7 +17,7 @@ class ProjectDiagnosticManager( override protected val optimizationKind: DiagnosticNotificationsKind ) extends NewConfigurationListener with DiagnosticManager - with PlatformSecrets { + with AlsPlatformSecrets { override protected val managerName: DiagnosticManagerKind = ProjectDiagnosticKind private val filesByWorkspace: mutable.Map[String, Set[String]] = mutable.Map.empty diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/WorkspaceContentManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/WorkspaceContentManager.scala index 8d874c5889..7542ccb7c2 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/WorkspaceContentManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/WorkspaceContentManager.scala @@ -3,7 +3,6 @@ package org.mulesoft.als.server.modules.workspace import amf.aml.client.scala.model.document.{Dialect, DialectInstance} import amf.core.client.scala.model.document.{BaseUnit, ExternalFragment} import amf.core.internal.remote.Platform -import amf.core.internal.unsafe.PlatformSecrets import amf.shapes.client.scala.model.document.DataTypeFragment import org.mulesoft.als.common.URIImplicits._ import org.mulesoft.als.configuration.ProjectConfiguration @@ -14,6 +13,7 @@ import org.mulesoft.als.server.textsync.EnvironmentProvider import org.mulesoft.als.server.workspace.UnitTaskManager import org.mulesoft.amfintegration.AmfImplicits.BaseUnitImp import org.mulesoft.amfintegration.amfconfiguration.{ALSConfigurationState, AmfParseResult, ProjectConfigurationState} +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.mulesoft.exceptions.AlsException import org.mulesoft.lsp.feature.telemetry.MessageTypes @@ -33,7 +33,7 @@ class WorkspaceContentManager private ( shouldRetryExternalFragments: Boolean ) extends UnitTaskManager[ParsedUnit, CompilableUnit, NotificationKind] with WorkspaceFolderManager - with PlatformSecrets { + with AlsPlatformSecrets { def getConfigurationState: Future[ALSConfigurationState] = sync(() => diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/textsync/TextDocumentContainer.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/textsync/TextDocumentContainer.scala index ada80e9484..bc999846d3 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/textsync/TextDocumentContainer.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/textsync/TextDocumentContainer.scala @@ -2,7 +2,7 @@ package org.mulesoft.als.server.textsync import amf.core.client.common.remote.Content import amf.core.client.scala.resource.ResourceLoader -import amf.core.internal.unsafe.PlatformSecrets +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.mulesoft.lsp.Initializable import scala.collection.mutable @@ -58,7 +58,7 @@ case class TextDocumentContainer(private val uriToEditor: mutable.Map[String, Te override def initialize(): Future[Unit] = Future.successful() } -trait EnvironmentProvider extends Initializable with PlatformSecrets { +trait EnvironmentProvider extends Initializable with AlsPlatformSecrets { def getResourceLoader: ResourceLoader def openedFiles: Seq[String] def filesInMemory: Map[String, TextDocument] diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/command/IndexDialectCommandExecutor.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/command/IndexDialectCommandExecutor.scala index 76cac758bb..7392a9ee6f 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/command/IndexDialectCommandExecutor.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/command/IndexDialectCommandExecutor.scala @@ -2,10 +2,10 @@ package org.mulesoft.als.server.workspace.command import amf.apicontract.client.scala.APIConfiguration import amf.core.internal.parser.YMapOps -import amf.core.internal.unsafe.PlatformSecrets import org.mulesoft.als.server.protocol.textsync.IndexDialectParams import org.mulesoft.als.server.workspace.WorkspaceManager import org.mulesoft.amfintegration.dialect.integration.BaseAlsDialectProvider +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.yaml.model.YMap import scala.concurrent.ExecutionContext.Implicits.global @@ -17,7 +17,7 @@ import scala.concurrent.Future */ class IndexDialectCommandExecutor(workspaceManager: WorkspaceManager) extends CommandExecutor[IndexDialectParams, Unit] - with PlatformSecrets { + with AlsPlatformSecrets { override protected def buildParamFromMap(ast: YMap): Option[IndexDialectParams] = { val content: Option[String] = ast.key("content").map(e => e.value.asScalar.map(_.text).getOrElse(e.value.toString)) ast.key("uri").map(e => e.value.asScalar.map(_.text).getOrElse(e.value.toString)) match { diff --git a/als-server/shared/src/test/resources/actions/links/files/smb-leak/lib.raml b/als-server/shared/src/test/resources/actions/links/files/smb-leak/lib.raml new file mode 100644 index 0000000000..3b77d2ecf7 --- /dev/null +++ b/als-server/shared/src/test/resources/actions/links/files/smb-leak/lib.raml @@ -0,0 +1,3 @@ +#%RAML 1.0 Library +types: + t: string \ No newline at end of file diff --git a/als-server/shared/src/test/resources/actions/links/files/smb-leak/simple-relative.raml b/als-server/shared/src/test/resources/actions/links/files/smb-leak/simple-relative.raml new file mode 100644 index 0000000000..d66dd29173 --- /dev/null +++ b/als-server/shared/src/test/resources/actions/links/files/smb-leak/simple-relative.raml @@ -0,0 +1,4 @@ +#%RAML 1.0 +title: title +uses: + lib: file:////lib.raml diff --git a/als-server/shared/src/test/resources/actions/links/files/smb-leak/simple.raml b/als-server/shared/src/test/resources/actions/links/files/smb-leak/simple.raml new file mode 100644 index 0000000000..cd0bb8c22f --- /dev/null +++ b/als-server/shared/src/test/resources/actions/links/files/smb-leak/simple.raml @@ -0,0 +1,4 @@ +#%RAML 1.0 +title: title +uses: + lib: file:////als-server/shared/src/test/resources/actions/links/files/simple-uri/lib.raml diff --git a/als-server/shared/src/test/resources/actions/links/files/smb-leak/unix-path.raml b/als-server/shared/src/test/resources/actions/links/files/smb-leak/unix-path.raml new file mode 100644 index 0000000000..26d73152b8 --- /dev/null +++ b/als-server/shared/src/test/resources/actions/links/files/smb-leak/unix-path.raml @@ -0,0 +1,4 @@ +#%RAML 1.0 +title: title +uses: + lib: //lib.raml diff --git a/als-server/shared/src/test/resources/actions/links/files/smb-leak/windows-path.raml b/als-server/shared/src/test/resources/actions/links/files/smb-leak/windows-path.raml new file mode 100644 index 0000000000..4944cc2dd7 --- /dev/null +++ b/als-server/shared/src/test/resources/actions/links/files/smb-leak/windows-path.raml @@ -0,0 +1,4 @@ +#%RAML 1.0 +title: title +uses: + lib: \\lib.raml diff --git a/als-server/shared/src/test/resources/actions/links/files/smb-leak/windows-uri-combined.raml b/als-server/shared/src/test/resources/actions/links/files/smb-leak/windows-uri-combined.raml new file mode 100644 index 0000000000..221417b4a2 --- /dev/null +++ b/als-server/shared/src/test/resources/actions/links/files/smb-leak/windows-uri-combined.raml @@ -0,0 +1,4 @@ +#%RAML 1.0 +title: title +uses: + lib: file://\\lib.raml diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/LanguageServerBaseTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/LanguageServerBaseTest.scala index c962e4e490..c99d442f09 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/LanguageServerBaseTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/LanguageServerBaseTest.scala @@ -1,7 +1,6 @@ package org.mulesoft.als.server import amf.aml.client.scala.model.document.DialectInstance -import amf.core.internal.unsafe.PlatformSecrets import amf.custom.validation.client.scala.{BaseProfileValidatorBuilder, ProfileValidatorExecutor} import amf.custom.validation.internal.DummyValidatorExecutor import org.mulesoft.als.logger.Logger @@ -15,6 +14,7 @@ import org.mulesoft.als.server.protocol.configuration.AlsInitializeParams import org.mulesoft.als.server.protocol.textsync.DidFocusParams import org.mulesoft.als.server.workspace.ChangesWorkspaceConfiguration import org.mulesoft.als.server.workspace.command.Commands +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.mulesoft.lsp.configuration.WorkspaceFolder import org.mulesoft.lsp.feature.common.{TextDocumentIdentifier, TextDocumentItem, VersionedTextDocumentIdentifier} import org.mulesoft.lsp.feature.documentsymbol.{ @@ -37,7 +37,7 @@ import scala.util.Failure abstract class LanguageServerBaseTest extends AsyncFunSuite - with PlatformSecrets + with AlsPlatformSecrets with Matchers with OptionValues with ChangesWorkspaceConfiguration { diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/links/base/FindLinksBaseTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/links/base/FindLinksBaseTest.scala index 3cc6e6bb32..9146240572 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/links/base/FindLinksBaseTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/links/base/FindLinksBaseTest.scala @@ -89,4 +89,43 @@ class FindLinksBaseTest extends FindLinksTest { ) ) } + + test("smb link simple") { + runTest( + "files/smb-leak/simple.raml", + Set.empty + ) + } + + test("smb link simple-relative") { + runTest( + "files/smb-leak/simple-relative.raml", + Set.empty + ) + } + + // there are hacks in AMF (amf.core.internal.remote.Context) which result in this case working as if the file was + // "absolute" (relative to the root file), and fixes the double slash resulting in + // "file://als-server/shared/src/test/resources/actions/links/files/smb-leak/lib.raml" as a link + // this is probably not correct, but should not affect the SMB Leak as it is not a `file:////` link + ignore("smb link unix-path") { + runTest( + "files/smb-leak/unix-path.raml", + Set.empty + ) + } + + test("smb link windows-path") { + runTest( + "files/smb-leak/windows-path.raml", + Set.empty + ) + } + + test("smb link windows-uri-combined") { + runTest( + "files/smb-leak/windows-uri-combined.raml", + Set.empty + ) + } } diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/ChangesWorkspaceConfiguration.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/ChangesWorkspaceConfiguration.scala index 53bfe91a89..16be22844f 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/ChangesWorkspaceConfiguration.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/ChangesWorkspaceConfiguration.scala @@ -1,15 +1,15 @@ package org.mulesoft.als.server.workspace import amf.core.internal.remote.Platform -import amf.core.internal.unsafe.PlatformSecrets import org.mulesoft.als.server.protocol.LanguageServer import org.mulesoft.als.server.workspace.command.Commands +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.mulesoft.lsp.textsync.KnownDependencyScopes.{CUSTOM_VALIDATION, DIALECT, SEMANTIC_EXTENSION} import org.mulesoft.lsp.workspace.ExecuteCommandParams import scala.concurrent.Future -trait ChangesWorkspaceConfiguration extends PlatformSecrets { +trait ChangesWorkspaceConfiguration extends AlsPlatformSecrets { implicit private val Platform: Platform = platform def changeConfigArgs( diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceCacheTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceCacheTest.scala index d2855e0e31..e15e568692 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceCacheTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceCacheTest.scala @@ -3,7 +3,6 @@ package org.mulesoft.als.server.workspace import amf.core.client.common.remote.Content import amf.core.client.platform.resource.ResourceNotFound import amf.core.client.scala.resource.ResourceLoader -import amf.core.internal.unsafe.PlatformSecrets import org.mulesoft.als.configuration.ProjectConfiguration import org.mulesoft.als.logger.Logger import org.mulesoft.als.server.client.platform.ClientNotifier @@ -16,6 +15,7 @@ import org.mulesoft.als.server.modules.workspace.{ } import org.mulesoft.als.server.textsync.{EnvironmentProvider, TextDocumentContainer} import org.mulesoft.amfintegration.amfconfiguration.EditorConfiguration +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.mulesoft.lsp.feature.diagnostic.PublishDiagnosticsParams import org.mulesoft.lsp.feature.telemetry.TelemetryMessage import org.scalatest.funsuite.AsyncFunSuite @@ -23,7 +23,7 @@ import org.scalatest.matchers.should.Matchers import scala.concurrent.{ExecutionContext, Future} -class WorkspaceCacheTest extends AsyncFunSuite with Matchers with PlatformSecrets { +class WorkspaceCacheTest extends AsyncFunSuite with Matchers with AlsPlatformSecrets { override implicit val executionContext: ExecutionContext = ExecutionContext.Implicits.global diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceManagerWithoutDiagnosticsTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceManagerWithoutDiagnosticsTest.scala index e8750027df..a9b44d3ade 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceManagerWithoutDiagnosticsTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceManagerWithoutDiagnosticsTest.scala @@ -1,12 +1,12 @@ package org.mulesoft.als.server.workspace import amf.aml.client.scala.AMLConfiguration -import amf.core.internal.unsafe.PlatformSecrets import org.mulesoft.als.server.client.scala.LanguageServerBuilder import org.mulesoft.als.server.modules.{WorkspaceManagerFactory, WorkspaceManagerFactoryBuilder} import org.mulesoft.als.server.protocol.LanguageServer import org.mulesoft.als.server.protocol.configuration.AlsInitializeParams import org.mulesoft.als.server.{LanguageServerBaseTest, MockDiagnosticClientNotifier} +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.mulesoft.lsp.configuration.TraceKind import org.mulesoft.lsp.feature.common.TextDocumentIdentifier import org.mulesoft.lsp.feature.documentsymbol.{DocumentSymbolParams, DocumentSymbolRequestType} @@ -14,7 +14,7 @@ import org.scalatest.compatible.Assertion import scala.concurrent.{ExecutionContext, Future} -class WorkspaceManagerWithoutDiagnosticsTest extends LanguageServerBaseTest with PlatformSecrets { +class WorkspaceManagerWithoutDiagnosticsTest extends LanguageServerBaseTest with AlsPlatformSecrets { override implicit val executionContext: ExecutionContext = ExecutionContext.Implicits.global diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceParserRepositoryTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceParserRepositoryTest.scala index ea90c9d8cc..9d4169bad0 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceParserRepositoryTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceParserRepositoryTest.scala @@ -2,7 +2,6 @@ package org.mulesoft.als.server.workspace import amf.core.client.scala.AMFResult import amf.core.client.scala.model.document.BaseUnit -import amf.core.internal.unsafe.PlatformSecrets import org.mulesoft.als.server.modules.workspace.{ParsedUnit, WorkspaceParserRepository} import org.mulesoft.amfintegration.AmfImplicits.BaseUnitImp import org.mulesoft.amfintegration.amfconfiguration.{ @@ -12,13 +11,18 @@ import org.mulesoft.amfintegration.amfconfiguration.{ EmptyProjectConfigurationState } import org.mulesoft.amfintegration.dialect.dialects.ExternalFragmentDialect +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.scalatest.funsuite.AsyncFunSuite import org.scalatest.matchers.should.Matchers import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.{ExecutionContext, Future} -class WorkspaceParserRepositoryTest extends AsyncFunSuite with Matchers with PlatformSecrets with MockResourceLoader { +class WorkspaceParserRepositoryTest + extends AsyncFunSuite + with Matchers + with AlsPlatformSecrets + with MockResourceLoader { override val executionContext: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global test("Basic repository test") { diff --git a/als-structure/shared/src/test/scala/org/mulesoft/language/outline/test/OutlineTest.scala b/als-structure/shared/src/test/scala/org/mulesoft/language/outline/test/OutlineTest.scala index fe5a138ac5..99ef4a1b24 100644 --- a/als-structure/shared/src/test/scala/org/mulesoft/language/outline/test/OutlineTest.scala +++ b/als-structure/shared/src/test/scala/org/mulesoft/language/outline/test/OutlineTest.scala @@ -5,7 +5,6 @@ import amf.core.client.common.remote.Content import amf.core.client.scala.model.document.BaseUnit import amf.core.client.scala.resource.ResourceLoader import amf.core.internal.remote.Platform -import amf.core.internal.unsafe.PlatformSecrets import org.mulesoft.als.common.MarkerFinderTest import org.mulesoft.als.common.diff.FileAssertionTest import org.mulesoft.amfintegration.amfconfiguration.{ @@ -13,12 +12,13 @@ import org.mulesoft.amfintegration.amfconfiguration.{ EditorConfiguration, EmptyProjectConfigurationState } +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.scalatest.compatible.Assertion import org.scalatest.funsuite.AsyncFunSuite import scala.concurrent.{ExecutionContext, Future} -trait OutlineTest[T] extends AsyncFunSuite with FileAssertionTest with PlatformSecrets with MarkerFinderTest { +trait OutlineTest[T] extends AsyncFunSuite with FileAssertionTest with AlsPlatformSecrets with MarkerFinderTest { implicit override def executionContext: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global diff --git a/als-suggestions/jvm/src/test/scala/org/mulesoft/als/suggestions/client/jvm/JvmSuggestionsTest.scala b/als-suggestions/jvm/src/test/scala/org/mulesoft/als/suggestions/client/jvm/JvmSuggestionsTest.scala index d78322144a..07f1a19bcc 100644 --- a/als-suggestions/jvm/src/test/scala/org/mulesoft/als/suggestions/client/jvm/JvmSuggestionsTest.scala +++ b/als-suggestions/jvm/src/test/scala/org/mulesoft/als/suggestions/client/jvm/JvmSuggestionsTest.scala @@ -3,7 +3,6 @@ package org.mulesoft.als.suggestions.client.jvm import amf.core.client.common.remote.Content import amf.core.client.scala.resource.ResourceLoader import amf.core.internal.remote.FileNotFound -import amf.core.internal.unsafe.PlatformSecrets import org.mulesoft.als.common.DirectoryResolver import org.mulesoft.als.configuration.AlsConfiguration import org.mulesoft.als.suggestions.client.Suggestions @@ -13,12 +12,13 @@ import org.mulesoft.amfintegration.amfconfiguration.{ EditorConfiguration, EmptyProjectConfigurationState } +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.scalatest.funsuite.AsyncFunSuite import org.scalatest.matchers.should.Matchers import scala.concurrent.{ExecutionContext, Future} -class JvmSuggestionsTest extends AsyncFunSuite with Matchers with PlatformSecrets with AccessBundle { +class JvmSuggestionsTest extends AsyncFunSuite with Matchers with AlsPlatformSecrets with AccessBundle { override implicit val executionContext: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global // TODO: AMF is having trouble with "file:/" prefix (it transforms it in "file:///") diff --git a/als-suggestions/shared/src/test/scala/org/mulesoft/als/suggestions/PathTest.scala b/als-suggestions/shared/src/test/scala/org/mulesoft/als/suggestions/PathTest.scala index 69c4f2d1e9..2dafcb4e73 100644 --- a/als-suggestions/shared/src/test/scala/org/mulesoft/als/suggestions/PathTest.scala +++ b/als-suggestions/shared/src/test/scala/org/mulesoft/als/suggestions/PathTest.scala @@ -3,7 +3,6 @@ package org.mulesoft.als.suggestions import amf.core.client.common.remote.Content import amf.core.client.scala.resource.ResourceLoader import amf.core.internal.remote.FileNotFound -import amf.core.internal.unsafe.PlatformSecrets import org.mulesoft.als.common.DirectoryResolver import org.mulesoft.als.suggestions.plugins.aml.AMLPathCompletionPlugin import org.mulesoft.amfintegration.amfconfiguration.{ @@ -11,13 +10,14 @@ import org.mulesoft.amfintegration.amfconfiguration.{ EditorConfiguration, EmptyProjectConfigurationState } +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.scalatest.Assertion import org.scalatest.funsuite.AsyncFunSuite import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.{ExecutionContext, Future} -class PathTest extends AsyncFunSuite with PlatformSecrets { +class PathTest extends AsyncFunSuite with AlsPlatformSecrets { override val executionContext: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global diff --git a/als-suggestions/shared/src/test/scala/org/mulesoft/als/suggestions/test/BaseSuggestionsForTest.scala b/als-suggestions/shared/src/test/scala/org/mulesoft/als/suggestions/test/BaseSuggestionsForTest.scala index 7285906739..114e07599e 100644 --- a/als-suggestions/shared/src/test/scala/org/mulesoft/als/suggestions/test/BaseSuggestionsForTest.scala +++ b/als-suggestions/shared/src/test/scala/org/mulesoft/als/suggestions/test/BaseSuggestionsForTest.scala @@ -1,19 +1,19 @@ package org.mulesoft.als.suggestions.test import amf.core.client.scala.resource.ResourceLoader -import amf.core.internal.unsafe.PlatformSecrets import org.mulesoft.als.common.{AmfConfigurationPatcher, MarkerFinderTest, PlatformDirectoryResolver} import org.mulesoft.als.configuration.AlsConfiguration import org.mulesoft.als.suggestions.client.Suggestions import org.mulesoft.als.suggestions.test.core.AccessBundle import org.mulesoft.amfintegration.amfconfiguration.ALSConfigurationState +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.mulesoft.lsp.feature.completion.CompletionItem import upickle.default.write import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Future -trait BaseSuggestionsForTest extends PlatformSecrets with MarkerFinderTest with AccessBundle { +trait BaseSuggestionsForTest extends AlsPlatformSecrets with MarkerFinderTest with AccessBundle { protected val dr = new PlatformDirectoryResolver(platform) diff --git a/als-suggestions/shared/src/test/scala/org/mulesoft/als/suggestions/test/core/CoreTest.scala b/als-suggestions/shared/src/test/scala/org/mulesoft/als/suggestions/test/core/CoreTest.scala index 218530459a..56d642bd58 100644 --- a/als-suggestions/shared/src/test/scala/org/mulesoft/als/suggestions/test/core/CoreTest.scala +++ b/als-suggestions/shared/src/test/scala/org/mulesoft/als/suggestions/test/core/CoreTest.scala @@ -2,7 +2,6 @@ package org.mulesoft.als.suggestions.test.core import amf.core.client.common.remote.Content import amf.core.client.scala.resource.ResourceLoader -import amf.core.internal.unsafe.PlatformSecrets import org.mulesoft.als.common.{MarkerFinderTest, PlatformDirectoryResolver} import org.mulesoft.als.configuration.AlsConfiguration import org.mulesoft.als.suggestions.client.Suggestions @@ -11,13 +10,14 @@ import org.mulesoft.amfintegration.amfconfiguration.{ EditorConfiguration, EmptyProjectConfigurationState } +import org.mulesoft.amfintegration.platform.AlsPlatformSecrets import org.mulesoft.lsp.feature.completion.CompletionItem import org.scalatest.Assertion import org.scalatest.funsuite.AsyncFunSuite import scala.concurrent.{ExecutionContext, Future} -trait CoreTest extends AsyncFunSuite with PlatformSecrets with MarkerFinderTest with AccessBundle { +trait CoreTest extends AsyncFunSuite with AlsPlatformSecrets with MarkerFinderTest with AccessBundle { implicit override def executionContext: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global diff --git a/dependencies.properties b/dependencies.properties index a6d85244a7..20a410e6a1 100644 --- a/dependencies.properties +++ b/dependencies.properties @@ -1,5 +1,5 @@ -version=6.2.2 -amf=5.5.3 +version=6.2.3 +amf=5.5.4 amf.custom-validator.js=1.7.2 -amf.custom-validator-scalajs=0.5.13 +amf.custom-validator-scalajs=0.5.14 amf-antlr-parsers=0.7.25