diff --git a/.github/workflows/build_package.yml b/.github/workflows/build_package.yml index 61c47c9603..36d2e4951e 100644 --- a/.github/workflows/build_package.yml +++ b/.github/workflows/build_package.yml @@ -72,7 +72,7 @@ jobs: echo ResetPasswordUrlEnabled=true >> obp-api/src/main/resources/props/test.default.props echo consents.allowed=true >> obp-api/src/main/resources/props/test.default.props - MAVEN_OPTS="-Xmx3G -Xss2m" mvn package + MAVEN_OPTS="-Xmx3G -Xss2m" mvn clean package -Pprod - name: Build the Docker image run: | echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin docker.io diff --git a/obp-api/pom.xml b/obp-api/pom.xml index 2ac5abb1ad..714d8986c2 100644 --- a/obp-api/pom.xml +++ b/obp-api/pom.xml @@ -13,7 +13,17 @@ obp-api war Open Bank Project API - + + src/main/webapp/WEB-INF/web.xml + + + + prod + + src/main/resources/web.xml + + + org.sonatype.oss.groups.public @@ -563,6 +573,9 @@ org.apache.maven.plugins maven-war-plugin 2.6 + + ${webXmlPath} + org.apache.maven.plugins diff --git a/obp-api/src/main/resources/web.xml b/obp-api/src/main/resources/web.xml new file mode 100644 index 0000000000..5cc8b066d4 --- /dev/null +++ b/obp-api/src/main/resources/web.xml @@ -0,0 +1,42 @@ + + + + + + + LiftFilter + Lift Filter + The Filter that intercepts lift calls + net.liftweb.http.LiftFilter + + + + + LiftFilter + /* + + + + + + true + true + + + + + + + diff --git a/obp-api/src/main/scala/code/api/util/APIUtil.scala b/obp-api/src/main/scala/code/api/util/APIUtil.scala index f952728491..4bf30c6810 100644 --- a/obp-api/src/main/scala/code/api/util/APIUtil.scala +++ b/obp-api/src/main/scala/code/api/util/APIUtil.scala @@ -782,7 +782,7 @@ object APIUtil extends MdcLoggable with CustomJsonFormats{ // redirectUrl = http%3A%2F%2Flocalhost%3A8016%3Foauth_token%3DEBRZBMOPDXEUGGJP421FPFGK01IY2DGM5O3TLVSK%26oauth_verifier%3D63461 // URLDecoder.decode(urlString,"UTF-8")-->http://localhost:8016?oauth_token=EBRZBMOPDXEUGGJP421FPFGK01IY2DGM5O3TLVSK&oauth_verifier=63461 val regex = - """((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(:[0-9]+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)""".r + """((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(:[0-9]+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_\/]*)#?(?:[\w]*))?)""".r val decodeUrlValue = URLDecoder.decode(urlString, "UTF-8").trim() decodeUrlValue match { case regex(_*) if (decodeUrlValue.length <= 2048) => true diff --git a/obp-api/src/main/scala/code/util/Helper.scala b/obp-api/src/main/scala/code/util/Helper.scala index 55f359d4a1..cb09e79c7a 100644 --- a/obp-api/src/main/scala/code/util/Helper.scala +++ b/obp-api/src/main/scala/code/util/Helper.scala @@ -485,7 +485,7 @@ object Helper extends Loggable { result.asInstanceOf[Box[String]].filter(APIUtil.checkMediumString(_)==SILENCE_IS_GOLDEN) } if(resultAfterChecked.isEmpty) { - logger.debug(s"ObpS.${methodName} validation failed. The input key is: ${if (args.length>0)args.apply(0) else ""}, value is:$result") + logger.debug(s"ObpS.${methodName} validation failed. (resultAfterChecked.isEmpty A) The input key is: ${if (args.length>0)args.apply(0) else ""}, value is:$result") } resultAfterChecked } else if (methodName.equals("uri") && result.isInstanceOf[String]){ @@ -493,14 +493,14 @@ object Helper extends Loggable { if(resultAfterChecked.isDefined) { resultAfterChecked.head }else{ - logger.debug(s"ObpS.${methodName} validation failed. The value is:$result") + logger.debug(s"ObpS.${methodName} validation failed (NOT resultAfterChecked.isDefined). The value is:$result") resultAfterChecked.getOrElse("") } } else if (methodName.equals("uriAndQueryString") && result.isInstanceOf[Box[String]] && result.asInstanceOf[Box[String]].isDefined || methodName.equals("queryString") && result.isInstanceOf[Box[String]]&&result.asInstanceOf[Box[String]].isDefined){ val resultAfterChecked = result.asInstanceOf[Box[String]].filter(APIUtil.basicUriAndQueryStringValidation(_)) if(resultAfterChecked.isEmpty) { - logger.debug(s"ObpS.${methodName} validation failed. The value is:$result") + logger.debug(s"ObpS.${methodName} validation failed. (resultAfterChecked.isEmpty B) The value is:$result") } resultAfterChecked } else { diff --git a/obp-api/src/main/webapp/WEB-INF/web.xml b/obp-api/src/main/webapp/WEB-INF/web.xml index cfb85e0874..16bd7588d3 100644 --- a/obp-api/src/main/webapp/WEB-INF/web.xml +++ b/obp-api/src/main/webapp/WEB-INF/web.xml @@ -1,42 +1,42 @@ + PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" + "web-app_2_3.dtd"> - - LiftFilter - Lift Filter - The Filter that intercepts lift calls - net.liftweb.http.LiftFilter - - - - - LiftFilter - /* - - - - - - true - true - - - - - - + + LiftFilter + Lift Filter + The Filter that intercepts lift calls + net.liftweb.http.LiftFilter + + + + + LiftFilter + /* + + + + + + + + + + + + + diff --git a/obp-api/src/test/scala/code/util/APIUtilTest.scala b/obp-api/src/test/scala/code/util/APIUtilTest.scala index 76b037409a..44b3544956 100644 --- a/obp-api/src/test/scala/code/util/APIUtilTest.scala +++ b/obp-api/src/test/scala/code/util/APIUtilTest.scala @@ -697,6 +697,15 @@ class APIUtilTest extends FeatureSpec with Matchers with GivenWhenThen with Prop APIUtil.getObpFormatOperationId("OBPv3.0.0-getCoreAccountById") should be ("OBPv3.0.0-getCoreAccountById") APIUtil.getObpFormatOperationId("xxx") should be ("xxx") } + + feature("test APIUtil.basicUrlValidation method") { + val testString1 = "https%3A%2F%2Fapisandbox.openbankproject.com%2Foauth%2Fauthorize%3Fnext%3D%2Fen%2Fusers%2Fmyuser%26oauth_token%3DWTOBT2YRCTMI1BCCF4XAIKRXPLLZDZPFAIL5K03Z%26oauth_verifier%3D45381" + val testString2 = "http%3A%2F%2Flocalhost%3A8016%3Foauth_token%3DEBRZBMOPDXEUGGJP421FPFGK01IY2DGM5O3TLVSK%26oauth_verifier%3D63461" + + APIUtil.basicUrlValidation(testString1) should be (true) + APIUtil.basicUrlValidation(testString2) should be (true) + + } feature("test APIUtil.getBankIdAccountIdPairsFromUserAuthContexts method") {