diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index d6f31172..2b778395 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -1,2 +1,5 @@ # initial scalafmt 0cd7f5aaffad9b813955d73cf0afee2be445782e + +# Scala Steward: Reformat with scalafmt 3.8.2 +1f7736d5edc8cf5fa9e680e0d3bfb017f4f04b9d diff --git a/.scalafmt.conf b/.scalafmt.conf index 463c08a0..7eff6346 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = 3.7.17 +version = 3.8.2 runner.dialect = Scala213Source3 maxColumn = 100 indent.defnSite = 2 diff --git a/build.sbt b/build.sbt index b1825fe6..ed69d53c 100644 --- a/build.sbt +++ b/build.sbt @@ -8,11 +8,11 @@ lazy val UnitTest = config("ut").extend(Test) lazy val commonConfigs = Seq(ItTest, UnitTest) -val libatsVersion = "2.6.5-39-g05e9ed4-SNAPSHOT" +val libatsVersion = "2.6.6" lazy val commonDeps = libraryDependencies ++= { - val scalaTestV = "3.2.18" - lazy val catsV = "2.10.0" + val scalaTestV = "3.2.19" + lazy val catsV = "2.12.0" lazy val akkaHttpV = "10.5.2" lazy val enumeratumV = "1.7.3" diff --git a/cli/build.sbt b/cli/build.sbt index 0ca544cf..d2f32c80 100644 --- a/cli/build.sbt +++ b/cli/build.sbt @@ -6,6 +6,6 @@ libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.5.6" libraryDependencies += "io.circe" %% "circe-generic-extras" % "0.14.3" -libraryDependencies += "io.circe" %% "circe-literal" % "0.14.7" % Test +libraryDependencies += "io.circe" %% "circe-literal" % "0.14.8" % Test fork := true diff --git a/keyserver/src/main/scala/com/advancedtelematic/tuf/keyserver/db/Schema.scala b/keyserver/src/main/scala/com/advancedtelematic/tuf/keyserver/db/Schema.scala index d1565337..2cf8d11c 100644 --- a/keyserver/src/main/scala/com/advancedtelematic/tuf/keyserver/db/Schema.scala +++ b/keyserver/src/main/scala/com/advancedtelematic/tuf/keyserver/db/Schema.scala @@ -43,16 +43,10 @@ object Schema { def uniqueRepoIdRoleTypeIdx = index("key_gen_requests_unique_idx", (repoId, roleType), unique = true) - override def * = ( - id, - repoId, - status, - roleType, - keySize, - keyType, - threshold, - description - ) <> ((KeyGenRequest.apply _).tupled, KeyGenRequest.unapply) + override def * = (id, repoId, status, roleType, keySize, keyType, threshold, description) <> ( + (KeyGenRequest.apply _).tupled, + KeyGenRequest.unapply + ) } @@ -66,14 +60,10 @@ object Schema { def publicKey = column[TufKey]("public_key") def privateKey = column[EncryptedColumn[TufPrivateKey]]("private_key") - override def * = ( - id, - repoId, - roleType, - keyType, - publicKey, - privateKey.decrypted - ) <> ((Key.apply _).tupled, Key.unapply) + override def * = (id, repoId, roleType, keyType, publicKey, privateKey.decrypted) <> ( + (Key.apply _).tupled, + Key.unapply + ) } @@ -88,15 +78,15 @@ object Schema { def pk = primaryKey("pk_signed_root_roles", (repoId, version)) private def content_parsed = content <> - ({ c => SignedPayload(c.signatures, c.signed.as[RootRole].valueOr(throw _), c.signed) }, - (x: SignedPayload[RootRole]) => Some(JsonSignedPayload(x.signatures, x.json))) - - override def * = ( - repoId, - content_parsed, - expiresAt, - version - ) <> ((SignedRootRole.apply _).tupled, SignedRootRole.unapply) + ( + { c => SignedPayload(c.signatures, c.signed.as[RootRole].valueOr(throw _), c.signed) }, + (x: SignedPayload[RootRole]) => Some(JsonSignedPayload(x.signatures, x.json)) + ) + + override def * = (repoId, content_parsed, expiresAt, version) <> ( + (SignedRootRole.apply _).tupled, + SignedRootRole.unapply + ) } diff --git a/libtuf-server/src/main/scala/com/advancedtelematic/libtuf_server/data/Marshalling.scala b/libtuf-server/src/main/scala/com/advancedtelematic/libtuf_server/data/Marshalling.scala index 0e37fd18..7f95fcf8 100644 --- a/libtuf-server/src/main/scala/com/advancedtelematic/libtuf_server/data/Marshalling.scala +++ b/libtuf-server/src/main/scala/com/advancedtelematic/libtuf_server/data/Marshalling.scala @@ -9,7 +9,12 @@ import com.advancedtelematic.libtuf.crypt.CanonicalJson.* import com.advancedtelematic.libtuf.data.ClientDataType.DelegatedRoleName import com.advancedtelematic.libtuf.data.TufCodecs import com.advancedtelematic.libtuf.data.TufDataType.TargetFormat.TargetFormat -import com.advancedtelematic.libtuf.data.TufDataType.{JsonSignedPayload, RoleType, TargetFormat, ValidKeyId} +import com.advancedtelematic.libtuf.data.TufDataType.{ + JsonSignedPayload, + RoleType, + TargetFormat, + ValidKeyId +} import com.advancedtelematic.libtuf_server.repo.server.Errors import scala.util.Try diff --git a/libtuf/build.sbt b/libtuf/build.sbt index 45c3a067..8add7ebc 100644 --- a/libtuf/build.sbt +++ b/libtuf/build.sbt @@ -10,6 +10,6 @@ libraryDependencies ++= { "com.softwaremill.sttp.client" %% "async-http-client-backend-future" % "2.3.0", "org.slf4j" % "slf4j-api" % "1.7.16" % "provided", "com.azure" % "azure-storage-blob" % "12.26.1", - "com.azure" % "azure-identity" % "1.12.2" + "com.azure" % "azure-identity" % "1.13.0" ) } diff --git a/project/build.sbt b/project/build.sbt index 24835b55..eff82c05 100644 --- a/project/build.sbt +++ b/project/build.sbt @@ -1,3 +1,3 @@ -libraryDependencies += "com.amazonaws" % "aws-java-sdk-s3" % "1.12.743" +libraryDependencies += "com.amazonaws" % "aws-java-sdk-s3" % "1.12.751" libraryDependencies += "org.apache.commons" % "commons-compress" % "1.26.2" diff --git a/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/data/RepoCodecs.scala b/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/data/RepoCodecs.scala index 20774417..0f1759ee 100644 --- a/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/data/RepoCodecs.scala +++ b/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/data/RepoCodecs.scala @@ -1,6 +1,11 @@ package com.advancedtelematic.tuf.reposerver.data -import com.advancedtelematic.tuf.reposerver.data.RepoDataType.{AddDelegationFromRemoteRequest, AggregatedPackage, DelegationInfo, Package} +import com.advancedtelematic.tuf.reposerver.data.RepoDataType.{ + AddDelegationFromRemoteRequest, + AggregatedPackage, + DelegationInfo, + Package +} import com.advancedtelematic.libtuf.data.ClientCodecs.* import com.advancedtelematic.libats.codecs.CirceRefined.* import com.advancedtelematic.libats.http.HttpCodecs.* diff --git a/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/db/Repository.scala b/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/db/Repository.scala index debd85f4..509f1f47 100644 --- a/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/db/Repository.scala +++ b/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/db/Repository.scala @@ -459,7 +459,6 @@ protected[db] class DelegationRepository()(implicit db: Database, ec: ExecutionC Schema.delegations.filter(_.repoId === repoId).result } - def persistAll(repoId: RepoId, roleName: DelegatedRoleName, content: JsonSignedPayload, diff --git a/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/db/Schema.scala b/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/db/Schema.scala index cbe973a1..7c7c5191 100644 --- a/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/db/Schema.scala +++ b/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/db/Schema.scala @@ -40,14 +40,10 @@ object Schema { def pk = primaryKey("delegated_items_pk", (repoId, roleName, filename)) - override def * = ( - repoId, - filename, - roleName, - checksum, - length, - custom - ) <> ((DelegatedTargetItem.apply _).tupled, DelegatedTargetItem.unapply) + override def * = (repoId, filename, roleName, checksum, length, custom) <> ( + (DelegatedTargetItem.apply _).tupled, + DelegatedTargetItem.unapply + ) } @@ -65,15 +61,10 @@ object Schema { def pk = primaryKey("target_items_pk", (repoId, filename)) - override def * = ( - repoId, - filename, - uri, - checksum, - length, - custom, - storageMethod - ) <> ((TargetItem.apply _).tupled, TargetItem.unapply) + override def * = (repoId, filename, uri, checksum, length, custom, storageMethod) <> ( + (TargetItem.apply _).tupled, + TargetItem.unapply + ) } @@ -90,15 +81,10 @@ object Schema { def pk = primaryKey("signed_role_pk", (repoId, roleType)) - override def * = ( - repoId, - roleType, - content, - checksum, - length, - version, - expiresAt - ) <> ((DbSignedRole.apply _).tupled, DbSignedRole.unapply) + override def * = (repoId, roleType, content, checksum, length, version, expiresAt) <> ( + (DbSignedRole.apply _).tupled, + DbSignedRole.unapply + ) } @@ -153,15 +139,11 @@ object Schema { def pk = primaryKey("delegations_pk", (repoId, roleName)) - override def * = ( - repoId, - roleName, - content, - remoteUri, - lastFetched, - remoteHeaders, - friendlyName - ) <> ((DbDelegation.apply _).tupled, DbDelegation.unapply) + override def * = + (repoId, roleName, content, remoteUri, lastFetched, remoteHeaders, friendlyName) <> ( + (DbDelegation.apply _).tupled, + DbDelegation.unapply + ) } diff --git a/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/delegations/DelegationsManagement.scala b/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/delegations/DelegationsManagement.scala index 47b5c4bf..f2e3c97f 100644 --- a/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/delegations/DelegationsManagement.scala +++ b/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/delegations/DelegationsManagement.scala @@ -112,16 +112,16 @@ class DelegationsManagement()(implicit val db: Database, val ec: ExecutionContex validateDelegationMetadataSignatures(targetsRole, delegation, delegationMetadata) .valueOr(err => throw Errors.PayloadSignatureInvalid(err)) - val validatedDelegationsRole = validateDelegationTargetPaths(targetsRole, roleName, delegationMetadata) - .valueOr(err => throw Errors.InvalidDelegatedTarget(err)) + val validatedDelegationsRole = + validateDelegationTargetPaths(targetsRole, roleName, delegationMetadata) + .valueOr(err => throw Errors.InvalidDelegatedTarget(err)) val items = validatedDelegationsRole.signed.targets.map { case (filename, clientTargetItem) => - val checksums = clientTargetItem.hashes.map { case (method, hash) => Checksum(method, hash) } - if(checksums.isEmpty) + if (checksums.isEmpty) throw Errors.InvalidDelegatedTarget(NonEmptyList.of("targets checksum cannot be empty")) DelegatedTargetItem( diff --git a/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/http/CustomParameters.scala b/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/http/CustomParameters.scala index 903188c7..c162f9f5 100644 --- a/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/http/CustomParameters.scala +++ b/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/http/CustomParameters.scala @@ -5,7 +5,12 @@ import akka.http.scaladsl.server.{Directive, Directives} import akka.http.scaladsl.unmarshalling.PredefinedFromStringUnmarshallers.CsvSeq import com.advancedtelematic.libtuf.data.ClientDataType.TargetCustom import com.advancedtelematic.libtuf.data.TufDataType.TargetFormat.TargetFormat -import com.advancedtelematic.libtuf.data.TufDataType.{HardwareIdentifier, TargetFormat, TargetName, TargetVersion} +import com.advancedtelematic.libtuf.data.TufDataType.{ + HardwareIdentifier, + TargetFormat, + TargetName, + TargetVersion +} import io.circe.* import akka.http.scaladsl.unmarshalling.* import akka.http.scaladsl.util.FastFuture diff --git a/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/http/NamespaceExtractor.scala b/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/http/NamespaceExtractor.scala index a84db212..46aabdec 100644 --- a/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/http/NamespaceExtractor.scala +++ b/reposerver/src/main/scala/com/advancedtelematic/tuf/reposerver/http/NamespaceExtractor.scala @@ -69,4 +69,5 @@ object NamespaceRepoId { def apply(namespaceValidation: NamespaceValidation, findNsRepoFn: Namespace => Future[RepoId]) = namespaceValidation.extractor.flatMap(ns => UserRepoId(ns, findNsRepoFn)) + } diff --git a/reposerver/src/test/scala/com/advancedtelematic/tuf/reposerver/http/RepoTargetsResourceSpec.scala b/reposerver/src/test/scala/com/advancedtelematic/tuf/reposerver/http/RepoTargetsResourceSpec.scala index ffe919a4..3c423545 100644 --- a/reposerver/src/test/scala/com/advancedtelematic/tuf/reposerver/http/RepoTargetsResourceSpec.scala +++ b/reposerver/src/test/scala/com/advancedtelematic/tuf/reposerver/http/RepoTargetsResourceSpec.scala @@ -251,7 +251,9 @@ class RepoTargetsResourceSpec status shouldBe StatusCodes.NoContent } - Get(apiUriV2(s"user_repo/search?sortBy=filename&sortDirection=asc")).namespaced ~> routes ~> check { + Get( + apiUriV2(s"user_repo/search?sortBy=filename&sortDirection=asc") + ).namespaced ~> routes ~> check { status shouldBe StatusCodes.OK val result = responseAs[PaginationResult[Package]] @@ -262,7 +264,9 @@ class RepoTargetsResourceSpec result.values.map(_.filename.value) shouldBe Seq("mypath/mytargetName", "zotherpackage") } - Get(apiUriV2(s"user_repo/search?sortBy=filename&sortDirection=desc")).namespaced ~> routes ~> check { + Get( + apiUriV2(s"user_repo/search?sortBy=filename&sortDirection=desc") + ).namespaced ~> routes ~> check { status shouldBe StatusCodes.OK val result = responseAs[PaginationResult[Package]] @@ -497,7 +501,9 @@ class RepoTargetsResourceSpec status shouldBe StatusCodes.NoContent } - Get(apiUriV2(s"user_repo/grouped-search?sortBy=name&sortDirection=asc")).namespaced ~> routes ~> check { + Get( + apiUriV2(s"user_repo/grouped-search?sortBy=name&sortDirection=asc") + ).namespaced ~> routes ~> check { status shouldBe StatusCodes.OK val values = responseAs[PaginationResult[AggregatedPackage]].values values should have size 2 diff --git a/reposerver/src/test/scala/com/advancedtelematic/tuf/reposerver/util/NamespaceSpecOps.scala b/reposerver/src/test/scala/com/advancedtelematic/tuf/reposerver/util/NamespaceSpecOps.scala index c101a65d..f0b093db 100644 --- a/reposerver/src/test/scala/com/advancedtelematic/tuf/reposerver/util/NamespaceSpecOps.scala +++ b/reposerver/src/test/scala/com/advancedtelematic/tuf/reposerver/util/NamespaceSpecOps.scala @@ -4,7 +4,11 @@ import akka.http.scaladsl.model.{HttpRequest, StatusCodes} import akka.http.scaladsl.model.headers.RawHeader import com.advancedtelematic.libats.data.DataType.Namespace import com.advancedtelematic.libtuf.data.TufDataType.RepoId -import com.advancedtelematic.tuf.reposerver.util.NamespaceSpecOps.{NamespaceTag, Namespaced, withRandomNamepace} +import com.advancedtelematic.tuf.reposerver.util.NamespaceSpecOps.{ + withRandomNamepace, + NamespaceTag, + Namespaced +} import io.circe.Json import org.scalactic.source.Position import org.scalatest.Tag