diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..027abb3b9753a47cd4a6e80063e76a9a21cbfa3f --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,18 @@ +stages: + - build + +.base: + image: + name: gcr.io/kaniko-project/executor:debug + entrypoint: [ "" ] + cache: { } + tags: + - "opencode-high" + before_script: + - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json + +build: + extends: .base + stage: build + script: + - /kaniko/executor --context "${CI_PROJECT_DIR}" --dockerfile "${CI_PROJECT_DIR}/Dockerfile" --destination "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c6e9bab49cdacaeeffd84b29ee5187ff23409108 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +# syntax=docker/dockerfile:experimental +FROM eclipse-temurin AS build +WORKDIR /workspace/app + +COPY . /workspace/app +RUN --mount=type=cache,target=/root/.gradle ./gradlew clean build -x test +RUN mkdir -p build/dependency && (cd build/dependency; jar -xf ../libs/*-SNAPSHOT.jar) + +FROM eclipse-temurin +VOLUME /tmp +ARG DEPENDENCY=/workspace/app/build/dependency +COPY --from=build ${DEPENDENCY}/BOOT-INF/lib /app/lib +COPY --from=build ${DEPENDENCY}/META-INF /app/META-INF +COPY --from=build ${DEPENDENCY}/BOOT-INF/classes /app +ENTRYPOINT ["java","-cp","app:app/lib/*","dataProvider.Application"] \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 33e63084f4af8bc602f35d463224ce57af486edd..9399a8badf4d5a6cda5fc00881af6530a5b9d816 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,13 +1,13 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { - id("org.springframework.boot") version "3.0.6" - id("io.spring.dependency-management") version "1.1.0" - id("org.jetbrains.kotlin.plugin.allopen") version "1.8.21" - kotlin("jvm") version "1.7.22" - kotlin("plugin.spring") version "1.7.22" - kotlin("plugin.jpa") version "1.7.22" - kotlin("plugin.serialization") version "1.8.21" + id("org.springframework.boot") version "3.1.1" + id("io.spring.dependency-management") version "1.1.2" + id("org.jetbrains.kotlin.plugin.allopen") version "1.9.0" + kotlin("jvm") version "1.9.0" + kotlin("plugin.spring") version "1.9.0" + kotlin("plugin.jpa") version "1.9.0" + kotlin("plugin.serialization") version "1.9.0" } allOpen { @@ -20,7 +20,7 @@ allOpen { } group = "de.fraunhofer.iem" -version = "0.0.1-SNAPSHOT" +version = "0.0.2-SNAPSHOT" java.sourceCompatibility = JavaVersion.VERSION_17 configurations { @@ -43,8 +43,8 @@ dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactive") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor") - implementation("org.gitlab4j:gitlab4j-api:6.0.0-rc.1") - implementation("org.eclipse.jgit:org.eclipse.jgit:6.5.0.202303070854-r") + implementation("org.gitlab4j:gitlab4j-api:6.0.0-rc.2") + implementation("org.eclipse.jgit:org.eclipse.jgit:6.6.0.202305301015-r") implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1") implementation("org.springframework.boot:spring-boot-starter-actuator") developmentOnly("org.springframework.boot:spring-boot-devtools") @@ -55,9 +55,9 @@ dependencies { testImplementation("org.junit.jupiter:junit-jupiter-api") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") testRuntimeOnly("com.h2database:h2") - testImplementation("com.ninja-squad:springmockk:4.0.0") + testImplementation("com.ninja-squad:springmockk:4.0.2") testImplementation("org.springframework.security:spring-security-test") - testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.1") + testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.2") } tasks.withType<KotlinCompile> { diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/WebFluxConfiguration.kt b/src/main/kotlin/de/fraunhofer/iem/dataprovider/WebFluxConfiguration.kt new file mode 100644 index 0000000000000000000000000000000000000000..1b83621ec5efeceaf23093371754ed317110eabf --- /dev/null +++ b/src/main/kotlin/de/fraunhofer/iem/dataprovider/WebFluxConfiguration.kt @@ -0,0 +1,19 @@ +package de.fraunhofer.iem.dataprovider + +import org.springframework.context.annotation.Configuration +import org.springframework.web.reactive.config.CorsRegistry +import org.springframework.web.reactive.config.EnableWebFlux +import org.springframework.web.reactive.config.WebFluxConfigurer + +@Configuration +@EnableWebFlux +class WebFluxConfiguration: WebFluxConfigurer +{ + override fun addCorsMappings(registry: CorsRegistry) + { + registry.addMapping("/**") + .allowedOrigins("*") // any host or put domain(s) here + .allowedMethods("*") // put the http verbs you want allow + .allowedHeaders("*") // put the http headers you want allow + } +} \ No newline at end of file diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/dependency/service/DependencyService.kt b/src/main/kotlin/de/fraunhofer/iem/dataprovider/dependency/service/DependencyService.kt index 6c0ccbc7ac4399968a3ee5a9708aa6efa212a90f..47a78e5fc2ac5681103a9250963800eeeb5f6047 100644 --- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/dependency/service/DependencyService.kt +++ b/src/main/kotlin/de/fraunhofer/iem/dataprovider/dependency/service/DependencyService.kt @@ -19,26 +19,4 @@ class DependencyService(private val dependencyRepository: DependencyRepository) // TODO: Refactor the type of dependencycreatdto return dependencyRepository.findByRepositories_Id(repoId).map { it.toDto() } } - -// fun getMaximalDependencyVulnerabilityScore(repoId: UUID): Pair<Int, List<DependencyEntity>> { -// val dependencies = getDependenciesForRepository(repoId) -// var highestScore = 0.0 -// dependencies.forEach { dependency -> -// dependency.vulnerabilities.forEach { vulnerability -> -// vulnerability.vulnerabilityScores.forEach { score -> -// if (score.scoringSystem != null && score.scoringSystem == VulnerabilityScoringSystemEnum.CVSSV3) { -// try { -// val severity = score.severity?.toDouble() -// if (severity != null && severity > highestScore) { -// highestScore = severity -// } -// } catch (e: Throwable) { -// logger.error("Parsing from severity to double failed. $e") -// } -// } -// } -// } -// } -// return Pair((highestScore * 10.0).toInt(), dependencies) -// } -} \ No newline at end of file +}