Skip to content

Commit

Permalink
Rename save-cosv module to cosv-backend (#2924)
Browse files Browse the repository at this point in the history
* Rename save-cosv module to cosv-backend
  • Loading branch information
Cheshiriks authored Feb 20, 2024
1 parent f27f119 commit 2bfa598
Show file tree
Hide file tree
Showing 66 changed files with 120 additions and 101 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
save-api-cli: ${{ steps.calculate-dependencies.outputs.save-api-cli }}
save-backend: ${{ steps.calculate-dependencies.outputs.save-backend }}
save-cloud-common: ${{ steps.calculate-dependencies.outputs.save-cloud-common }}
save-cosv: ${{ steps.calculate-dependencies.outputs.save-cosv }}
cosv-backend: ${{ steps.calculate-dependencies.outputs.cosv-backend }}
cosv-frontend: ${{ steps.calculate-dependencies.outputs.cosv-frontend }}
save-demo: ${{ steps.calculate-dependencies.outputs.save-demo }}
save-demo-agent: ${{ steps.calculate-dependencies.outputs.save-demo-agent }}
Expand Down Expand Up @@ -66,8 +66,8 @@ jobs:
- save-backend/**
save-cloud-common:
- save-cloud-common/**
save-cosv:
- save-cosv/**
cosv-backend:
- cosv-backend/**
cosv-frontend:
- cosv-frontend/**
save-demo:
Expand Down Expand Up @@ -100,14 +100,14 @@ jobs:
authentication_service=$(( $save_cloud_common + ${{ steps.git-changed-files.outputs.authentication-service_all_changed_files_count }} ))
save_api=$(( $save_cloud_common + ${{ steps.git-changed-files.outputs.save-api_all_changed_files_count }} ))
save_cosv=$(( $save_cloud_common + ${{ steps.git-changed-files.outputs.save-cosv_all_changed_files_count }} ))
cosv_backend=$(( $save_cloud_common + ${{ steps.git-changed-files.outputs.cosv-backend_all_changed_files_count }} ))
test_analysis_core=$(( $save_cloud_common + ${{ steps.git-changed-files.outputs.test-analysis-core_all_changed_files_count }} ))
test_utils=$(( ${{ steps.git-changed-files.outputs.test-utils_all_changed_files_count }} ))
api_gateway=$(( $save_cloud_common + ${{ steps.git-changed-files.outputs.api-gateway_all_changed_files_count }} ))
save_agent=$(( $save_cloud_common + ${{ steps.git-changed-files.outputs.save-agent_all_changed_files_count }} ))
save_api_cli=$(( $save_cloud_common + $save_api + ${{ steps.git-changed-files.outputs.save-api-cli_all_changed_files_count }} ))
save_backend=$(( $save_cloud_common + $authentication_service + $test_analysis_core + $save_cosv + $test_utils + ${{ steps.git-changed-files.outputs.save-backend_all_changed_files_count }} ))
save_backend=$(( $save_cloud_common + $authentication_service + $test_analysis_core + $cosv_backend + $test_utils + ${{ steps.git-changed-files.outputs.save-backend_all_changed_files_count }} ))
cosv_frontend=$(( $save_cloud_common + $save_frontend_common + ${{ steps.git-changed-files.outputs.cosv-frontend_all_changed_files_count }} ))
save_demo=$(( $save_cloud_common + ${{ steps.git-changed-files.outputs.save-demo_all_changed_files_count }} ))
save_demo_agent=$(( $save_cloud_common + ${{ steps.git-changed-files.outputs.save-demo-agent_all_changed_files_count }} ))
Expand All @@ -123,7 +123,7 @@ jobs:
echo "save-api-cli=$save_api_cli" >> "$GITHUB_OUTPUT"
echo "save-backend=$save_backend" >> "$GITHUB_OUTPUT"
echo "save-cloud-common=$save_cloud_common" >> "$GITHUB_OUTPUT"
echo "save-cosv=$save_cosv" >> "$GITHUB_OUTPUT"
echo "cosv-backend=$cosv_backend" >> "$GITHUB_OUTPUT"
echo "cosv-frontend=$cosv_frontend" >> "$GITHUB_OUTPUT"
echo "save-demo=$save_demo" >> "$GITHUB_OUTPUT"
echo "save-demo-agent=$save_demo_agent" >> "$GITHUB_OUTPUT"
Expand Down Expand Up @@ -172,7 +172,7 @@ jobs:
'save-api',
'save-api-cli',
'save-backend',
'save-cosv',
'cosv-backend',
'cosv-frontend',
'save-demo',
'save-demo-agent',
Expand All @@ -198,8 +198,8 @@ jobs:
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.save-demo-cpg > 0 }}
- module: save-backend
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.save-backend > 0 }}
- module: save-cosv
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.save-cosv > 0 }}
- module: cosv-backend
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.cosv-backend > 0 }}
- module: cosv-frontend
do-build: ${{ github.event_name == 'push' || needs.calculate_build_flags.outputs.cosv-frontend > 0 }}
- module: save-demo
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
fail-fast: false
matrix:
module: [
'save-cosv',
'cosv-backend',
'api-gateway',
'save-frontend',
'cosv-frontend',
Expand All @@ -98,7 +98,7 @@ jobs:
'save-demo-cpg',
]
include:
- module: save-cosv
- module: cosv-backend
do-build: ${{ inputs.backend }}
- module: api-gateway
do-build: ${{ inputs.gateway }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,22 @@ fun Project.registerLiquibaseTask(profile: String) {
val registerLiquibaseTaskBackend = registerLiquibaseTask(
projectName = "save-backend",
relativeChangeLogFile = "db/db.changelog-master.xml",
profile = profile
profile = profile,
mustRunAfterTask = null,
)

val registerLiquibaseTaskDemo = registerLiquibaseTask(
projectName = "save-demo",
relativeChangeLogFile = "save-demo/db/db.changelog-demo.xml",
profile = profile
profile = profile,
mustRunAfterTask = "save-backend",
)

val registerLiquibaseTaskCosv = registerLiquibaseTask(
projectName = "save-cosv",
relativeChangeLogFile = "save-cosv/db/db.changelog-cosv.xml",
profile = profile
projectName = "cosv-backend",
relativeChangeLogFile = "cosv-backend/db/db.changelog-cosv.xml",
profile = profile,
mustRunAfterTask = "save-backend",
)
tasks.register("liquibaseUpdate") {
dependsOn(
Expand All @@ -50,11 +54,16 @@ fun Project.registerLiquibaseTask(profile: String) {
}
}

private fun Project.registerLiquibaseTask(projectName: String, relativeChangeLogFile: String, profile: String): TaskProvider<Exec> {
val taskName = "liquibaseUpdate" + projectName.split("-").map { it.capitalized() }.joinToString("")
private fun Project.registerLiquibaseTask(projectName: String, relativeChangeLogFile: String, profile: String, mustRunAfterTask: String?): TaskProvider<Exec> {
val taskName = getTaskName(projectName)
val credentials = getDatabaseCredentials(projectName, profile)

return tasks.register<Exec>(taskName) {

mustRunAfterTask?.let {
mustRunAfter(getTaskName(it))
}

val contexts = when (profile) {
"prod" -> "prod"
"dev" -> "dev"
Expand Down Expand Up @@ -82,6 +91,8 @@ private fun Project.registerLiquibaseTask(projectName: String, relativeChangeLog
}
}

private fun getTaskName(projectName: String) = "liquibaseUpdate" + projectName.split("-").map { it.capitalized() }.joinToString("")

/**
* @param profile deployment profile, used, for example, to start SQL database in dev profile only
*/
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<changeSet id="cosv-file-insert" author="nulls" context="dev">
<loadData tableName="cosv_file" separator=";" file="save-cosv/db/test-data/sqlRequests/cosv-file.csv">
<loadData tableName="cosv_file" separator=";" file="cosv-backend/db/test-data/sqlRequests/cosv-file.csv">
<column header="id" name="id" type="NUMERIC" />
<column header="identifier" name="identifier" type="varchar(250)" />
<column header="modified" name="modified" type="DATE" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<changeSet id="lnk-vulnerability-metadata-user-insert-1" author="nulls" context="dev">

<loadData tableName="lnk_vulnerability_metadata_user" encoding="UTF-8" separator=";" quotchar="&quot;" file="save-cosv/db/test-data/sqlRequests/lnk-vulnerability-metadata-user.csv">
<loadData tableName="lnk_vulnerability_metadata_user" encoding="UTF-8" separator=";" quotchar="&quot;" file="cosv-backend/db/test-data/sqlRequests/lnk-vulnerability-metadata-user.csv">
<column header="id" name="id" type="NUMERIC" />
<column header="vulnerability_metadata_id" name="vulnerability_metadata_id" type="NUMERIC" />
<column header="user_id" name="user_id" type="NUMERIC" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<changeSet id="vulnerability-metadata-insert" author="nulls" context="dev">
<loadData tableName="vulnerability_metadata" separator=";" file="save-cosv/db/test-data/sqlRequests/vulnerability-metadata.csv">
<loadData tableName="vulnerability_metadata" separator=";" file="cosv-backend/db/test-data/sqlRequests/vulnerability-metadata.csv">
<column header="id" name="id" type="bigint"/>
<column header="identifier" name="identifier" type="varchar(100)"/>
<column header="severity_num" name="severity_num" type="DECIMAL(2,1)"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<changeSet id="vulnerability-metadata-project-insert" author="nulls" context="dev">
<loadData tableName="vulnerability_metadata_project" encoding="UTF-8" separator=";" quotchar="&quot;" file="save-cosv/db/test-data/sqlRequests/vulnerability-metadata-project.csv">
<loadData tableName="vulnerability_metadata_project" encoding="UTF-8" separator=";" quotchar="&quot;" file="cosv-backend/db/test-data/sqlRequests/vulnerability-metadata-project.csv">
<column header="id" name="id" type="bigint"/>
<column header="name" name="name" type="varchar(250)"/>
<column header="url" name="url" type="varchar(250)"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.saveourtool.save.cosv
package com.saveourtool.cosv.backend

import com.saveourtool.save.cosv.configs.ConfigProperties
import com.saveourtool.cosv.backend.configs.ConfigProperties
import com.saveourtool.save.s3.DefaultS3Configuration
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
Expand All @@ -9,9 +9,12 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.Import

/**
* An entrypoint for spring for save-cosv
* An entrypoint for spring for cosv-backend
*/
@SpringBootApplication(scanBasePackages = ["com.saveourtool.save.utils", "com.saveourtool.save"])
@SpringBootApplication(scanBasePackages = [
"com.saveourtool.save",
"com.saveourtool.cosv",
])
@EnableConfigurationProperties(ConfigProperties::class)
@Import(
DefaultS3Configuration::class,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.saveourtool.save.cosv
package com.saveourtool.cosv.backend

import com.zaxxer.hikari.HikariDataSource
import org.springframework.beans.factory.annotation.Qualifier
Expand All @@ -21,7 +21,7 @@ import javax.sql.DataSource
*/
@Configuration
@ComponentScan
@EnableJpaRepositories(basePackages = ["com.saveourtool.save.cosv.repository"])
@EnableJpaRepositories(basePackages = ["com.saveourtool.cosv.backend.repository"])
class CosvConfiguration {
/**
* @param properties
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.saveourtool.save.cosv.configs
package com.saveourtool.cosv.backend.configs

import com.saveourtool.save.s3.S3OperationsProperties
import org.springframework.boot.context.properties.ConfigurationProperties
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.saveourtool.save.cosv.configs
package com.saveourtool.cosv.backend.configs

import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.boot.context.properties.ConfigurationProperties
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.saveourtool.save.cosv.controllers
package com.saveourtool.cosv.backend.controllers

import com.saveourtool.save.configs.ApiSwaggerSupport
import com.saveourtool.save.entities.Comment
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package com.saveourtool.save.cosv.controllers
package com.saveourtool.cosv.backend.controllers

import com.saveourtool.cosv.backend.service.CosvService
import com.saveourtool.save.configs.ApiSwaggerSupport
import com.saveourtool.save.configs.RequiresAuthorizationSourceHeader
import com.saveourtool.save.cosv.service.CosvService
import com.saveourtool.save.entities.cosv.CosvFileDto
import com.saveourtool.save.entities.cosv.VulnerabilityMetadataDto
import com.saveourtool.save.entities.cosv.VulnerabilityMetadataDtoWithUserAndOrganization
import com.saveourtool.save.service.OrganizationService
import com.saveourtool.save.service.UserService
import com.saveourtool.save.utils.*
import com.saveourtool.save.v1

import org.springframework.http.HttpStatus
import org.springframework.security.core.Authentication

import org.springframework.web.bind.annotation.*
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.saveourtool.save.cosv.controllers
package com.saveourtool.cosv.backend.controllers

import com.saveourtool.cosv.backend.configs.ConfigProperties
import com.saveourtool.save.authservice.utils.userId
import com.saveourtool.save.configs.ApiSwaggerSupport
import com.saveourtool.save.configs.RequiresAuthorizationSourceHeader
import com.saveourtool.save.cosv.configs.ConfigProperties
import com.saveourtool.save.domain.OrganizationSaveStatus
import com.saveourtool.save.domain.Role
import com.saveourtool.save.entities.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.saveourtool.save.cosv.controllers
package com.saveourtool.cosv.backend.controllers

import com.saveourtool.cosv.backend.configs.ConfigProperties
import com.saveourtool.cosv.backend.service.CosvService
import com.saveourtool.cosv.backend.storage.RawCosvFileStorage
import com.saveourtool.save.authservice.utils.userId
import com.saveourtool.save.configs.ApiSwaggerSupport
import com.saveourtool.save.configs.RequiresAuthorizationSourceHeader
import com.saveourtool.save.cosv.configs.ConfigProperties
import com.saveourtool.save.cosv.service.CosvService
import com.saveourtool.save.cosv.storage.RawCosvFileStorage
import com.saveourtool.save.entities.cosv.*
import com.saveourtool.save.entities.cosv.RawCosvFileDto.Companion.isDuplicate
import com.saveourtool.save.entities.cosv.RawCosvFileDto.Companion.isUploadedJsonFile
Expand All @@ -15,6 +15,7 @@ import com.saveourtool.save.service.UserService
import com.saveourtool.save.storage.concatS3Key
import com.saveourtool.save.utils.*
import com.saveourtool.save.v1

import org.reactivestreams.Publisher
import org.springframework.dao.DataIntegrityViolationException
import org.springframework.data.domain.PageRequest
Expand All @@ -31,9 +32,11 @@ import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
import reactor.core.scheduler.Schedulers
import reactor.kotlin.core.publisher.toFlux

import java.nio.ByteBuffer
import java.nio.file.Files
import java.nio.file.Path

import kotlin.io.path.*

typealias RawCosvFileDtoFlux = Flux<RawCosvFileDto>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.saveourtool.save.cosv.controllers
package com.saveourtool.cosv.backend.controllers

import com.saveourtool.cosv.backend.service.TagService
import com.saveourtool.save.configs.ApiSwaggerSupport
import com.saveourtool.save.cosv.service.TagService
import com.saveourtool.save.utils.blockingToMono
import com.saveourtool.save.v1

import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.Parameter
import io.swagger.v3.oas.annotations.Parameters
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.saveourtool.save.cosv.controllers
package com.saveourtool.cosv.backend.controllers

import com.saveourtool.cosv.backend.configs.ConfigProperties
import com.saveourtool.save.authservice.utils.SaveUserDetails
import com.saveourtool.save.authservice.utils.userId
import com.saveourtool.save.configs.RequiresAuthorizationSourceHeader
import com.saveourtool.save.cosv.configs.ConfigProperties
import com.saveourtool.save.domain.UserSaveStatus
import com.saveourtool.save.entities.User
import com.saveourtool.save.info.UserInfo
Expand All @@ -13,6 +13,7 @@ import com.saveourtool.save.service.UserService
import com.saveourtool.save.utils.*
import com.saveourtool.save.v1
import com.saveourtool.save.validation.isValidLengthName

import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.Parameter
import io.swagger.v3.oas.annotations.Parameters
Expand All @@ -21,7 +22,6 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse
import org.springframework.boot.web.reactive.function.client.WebClientCustomizer
import org.springframework.data.domain.Pageable
import org.springframework.data.repository.findByIdOrNull

import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.security.access.prepost.PreAuthorize
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.saveourtool.save.cosv.controllers
package com.saveourtool.cosv.backend.controllers

import com.saveourtool.cosv.backend.security.VulnerabilityPermissionEvaluator
import com.saveourtool.cosv.backend.service.CosvService
import com.saveourtool.cosv.backend.service.VulnerabilityMetadataDtoList
import com.saveourtool.cosv.backend.service.VulnerabilityService
import com.saveourtool.cosv.backend.utils.hasRole
import com.saveourtool.save.authservice.utils.username
import com.saveourtool.save.configs.ApiSwaggerSupport
import com.saveourtool.save.configs.RequiresAuthorizationSourceHeader
import com.saveourtool.save.cosv.security.VulnerabilityPermissionEvaluator
import com.saveourtool.save.cosv.service.CosvService
import com.saveourtool.save.cosv.service.VulnerabilityMetadataDtoList
import com.saveourtool.save.cosv.service.VulnerabilityService
import com.saveourtool.save.cosv.utils.hasRole
import com.saveourtool.save.domain.Role
import com.saveourtool.save.entities.cosv.VulnerabilityExt
import com.saveourtool.save.entities.cosv.VulnerabilityMetadataDto
Expand All @@ -20,6 +20,7 @@ import com.saveourtool.save.permission.Permission
import com.saveourtool.save.service.UserService
import com.saveourtool.save.utils.*
import com.saveourtool.save.v1

import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.responses.ApiResponse
import io.swagger.v3.oas.annotations.tags.Tag
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.saveourtool.save.cosv.event
package com.saveourtool.cosv.backend.event

import com.saveourtool.save.cosv.repository.LnkVulnerabilityMetadataUserRepository
import com.saveourtool.save.cosv.service.VulnerabilityMetadataService
import com.saveourtool.cosv.backend.repository.LnkVulnerabilityMetadataUserRepository
import com.saveourtool.cosv.backend.service.VulnerabilityMetadataService
import com.saveourtool.save.entities.Notification
import com.saveourtool.save.entities.User
import com.saveourtool.save.evententities.CommentEvent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.saveourtool.save.cosv.processor
package com.saveourtool.cosv.backend.processor

import com.saveourtool.cosv.backend.utils.toJsonArrayOrSingle
import com.saveourtool.osv4k.RawOsvSchema as RawCosvSchema
import com.saveourtool.save.cosv.utils.toJsonArrayOrSingle

import org.springframework.stereotype.Component

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.saveourtool.save.cosv.repository
package com.saveourtool.cosv.backend.repository

import com.saveourtool.save.entitiescosv.CosvFile
import com.saveourtool.save.spring.repository.BaseEntityRepository
Expand Down
Loading

0 comments on commit 2bfa598

Please sign in to comment.