Skip to content
Snippets Groups Projects
Verified Commit 453e5b6f authored by Jan-Niclas Strüwer's avatar Jan-Niclas Strüwer
Browse files

applied detekt styles

parent 181b10b0
Branches
Tags
1 merge request!10Merged main back to dev
Showing
with 48 additions and 30 deletions
......@@ -3,6 +3,11 @@
<ManuallySuppressedIssues>
<ID>TooGenericExceptionCaught:ToolRunService.kt$ToolRunService$exception: Exception</ID>
<ID>SpreadOperator:DataProviderApplication.kt$(*args)</ID>
<ID>FunctionNaming:KPIRepository.kt$KPIRepository$fun findByRepository_Id(id: UUID): List&lt;KPIEntity></ID>
<ID>ConstructorParameterNaming:ToolSecretResultJson.kt$ToolSecretResultJson$@SerialName("secrets") val
tool_secrets: List&lt;ToolSecretJson> = listOf()
</ID>
<ID>SpreadOperator:OccmdService.kt$OccmdService$(execPath, *flags)</ID>
</ManuallySuppressedIssues>
<CurrentIssues/>
</SmellBaseline>
......@@ -3,6 +3,15 @@ build:
style:
WildcardImport:
active: false
ForbiddenComment:
active: false
formatting:
NoWildcardImports:
active: false
exceptions:
TooGenericExceptionCaught:
active: false
TooGenericExceptionThrown:
active: false
SwallowedException:
active: false
......@@ -4,7 +4,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.context.properties.ConfigurationPropertiesScan
import org.springframework.boot.runApplication
@SpringBootApplication
@ConfigurationPropertiesScan("de.fraunhofer.iem.dataprovider.configuration")
class DataProviderApplication
......
......@@ -7,7 +7,6 @@ import org.springframework.boot.context.properties.ConfigurationPropertiesScan
import org.springframework.validation.annotation.Validated
import java.net.URL
@ConfigurationProperties(prefix = "opencode.api")
@ConfigurationPropertiesScan
@Validated
......@@ -23,4 +22,4 @@ data class OpenCodeApiProperties(
// We want to throw here if this operations fail.
URL(basePath).toURI()
}
}
\ No newline at end of file
}
......@@ -6,7 +6,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.validation.annotation.Validated
import java.net.URL
@ConfigurationProperties(prefix = "opencode")
@Validated
data class OpenCodeGitlabApiProperties(
......
......@@ -13,7 +13,6 @@ const val API_HEADER_NOT_FOUND_MSG = "Api-Key header not found."
@Component
class ApiKeyFilter(private val securityProperties: SecurityProperties) : WebFilter {
override fun filter(exchange: ServerWebExchange, chain: WebFilterChain): Mono<Void> {
val apiKey = exchange.request.headers.getFirst(API_KEY_HEADER)
return if (apiKey == null) {
......
......@@ -6,7 +6,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.context.properties.ConfigurationPropertiesScan
import org.springframework.validation.annotation.Validated
@ConfigurationProperties(prefix = "security")
@ConfigurationPropertiesScan
@Validated
......
......@@ -14,14 +14,12 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
import org.springframework.security.crypto.password.PasswordEncoder
import org.springframework.security.web.server.SecurityWebFilterChain
const val ADMIN_ROLE: String = "ADMIN"
@Configuration
@EnableWebFluxSecurity
class SecurityConfiguration(val apiKeyFilter: ApiKeyFilter, private val securityProperties: SecurityProperties) {
@Bean
fun userDetailsService(): MapReactiveUserDetailsService {
val user: UserDetails = User
......@@ -64,5 +62,4 @@ class SecurityConfiguration(val apiKeyFilter: ApiKeyFilter, private val security
fun passwordEncoder(): PasswordEncoder {
return BCryptPasswordEncoder()
}
}
......@@ -8,7 +8,6 @@ import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RestController
@RestController
class GitlabController(private val toolRunService: ToolRunService) {
......
package de.fraunhofer.iem.dataprovider.gitlab.dto
data class RepositoryChangedDto(val projectId: Long)
......@@ -71,7 +71,6 @@ class OpenCodeGitlabApi(openCodeGitlabConfiguration: OpenCodeGitlabApiProperties
deferreds.awaitAll().count { !it.isEmpty }
}
// TODO: This should probably live somewhere else and encapsulate the logic
private fun isDefaultBranchProtected(repoId: Long, project: Project): Boolean {
return try {
val defaultBranchName = project.defaultBranch
......
package de.fraunhofer.iem.dataprovider.kpi.dto
data class KPITreeChildResponseDto(val kpi: KPITreeResponseDto, val weight: Double)
\ No newline at end of file
data class KPITreeChildResponseDto(val kpi: KPITreeResponseDto, val weight: Double)
package de.fraunhofer.iem.dataprovider.kpi.dto
data class KPITreeResponseDto(
val value: Int,
val name: String,
......@@ -10,4 +9,3 @@ data class KPITreeResponseDto(
val children: List<KPITreeChildResponseDto>,
val isEmpty: Boolean
)
......@@ -3,7 +3,6 @@ package de.fraunhofer.iem.dataprovider.kpi.dto
import de.fraunhofer.iem.dataprovider.kpi.enumeration.KpiKind
import de.fraunhofer.iem.dataprovider.kpi.strategy.KPICalculationStrategy
class KpiCalculationDto(
val kind: KpiKind,
private val calculationStrategy: KPICalculationStrategy? = null,
......@@ -52,7 +51,6 @@ class KpiCalculationDto(
}
fun toViewModel(): KPITreeResponseDto {
val children = this.hierarchyEdges.map {
val child = it.to.toViewModel()
KPITreeChildResponseDto(child, it.weight)
......
......@@ -14,7 +14,8 @@ enum class KpiKind {
return KPITreeResponseDto(
value = value,
name = "Checked in Binary",
description = "Used to assess the compliance to the OpenCoDE platform guidelines in regards of not checking in binaries.",
description = "Used to assess the compliance to the OpenCoDE " +
"platform guidelines in regards of not checking in binaries.",
children = children,
isEmpty = isEmpty
)
......@@ -45,7 +46,8 @@ enum class KpiKind {
return KPITreeResponseDto(
value = value,
name = "Vulnerability Score",
description = "A vulnerability with this score was found in the projects dependencies. Further information are not disclosed here.",
description = "A vulnerability with this score was " +
"found in the projects dependencies. Further information are not disclosed here.",
children = children,
isEmpty = isEmpty
)
......@@ -75,7 +77,9 @@ enum class KpiKind {
return KPITreeResponseDto(
value = value,
name = "Default Branch Protection",
description = "Used to assess compliance with a standard development process. For this purpose, it is examined whether the standard development branch is protected against unintentional changes.",
description = "Used to assess compliance with a standard development process." +
" For this purpose, it is examined whether the standard development" +
" branch is protected against unintentional changes.",
children = children,
isEmpty = isEmpty
)
......@@ -90,7 +94,8 @@ enum class KpiKind {
return KPITreeResponseDto(
value = value,
name = "Secrets",
description = "Used to look for suspicious strings in the repository, which might indicate leaked passwords or other secrets.",
description = "Used to look for suspicious strings in the repository," +
" which might indicate leaked passwords or other secrets.",
children = children,
isEmpty = isEmpty
)
......@@ -122,7 +127,10 @@ enum class KpiKind {
return KPITreeResponseDto(
value = value,
name = "Commit Signature Ratio",
description = "Used to assess compliance with a common and transparent development process. It is desirable that all commits are signed by their authors. Therefore, the ratio of signed commits to all commits is determined to calculate this metric.",
description = "Used to assess compliance with a common and " +
"transparent development process. It is desirable that all commits " +
"are signed by their authors. Therefore, the ratio of signed commits " +
"to all commits is determined to calculate this metric.",
children = children,
isEmpty = isEmpty
)
......@@ -137,7 +145,9 @@ enum class KpiKind {
return KPITreeResponseDto(
value = value,
name = "Process Compliance Score",
description = "Assesses the development process of the software provided. For this purpose, the development process traceable in the repository is compared with common development standards to enable an assessment.",
description = "Assesses the development process of the software provided." +
" For this purpose, the development process traceable in the repository is" +
" compared with common development standards to enable an assessment.",
children = children,
isEmpty = isEmpty
)
......@@ -152,7 +162,10 @@ enum class KpiKind {
return KPITreeResponseDto(
value = value,
name = "Process Transparency Score",
description = "Assesses the transparency resp. traceability of the development process of the provided software for external parties. For this purpose, various analyzes are performed that assess the availability of information about the software development process within the repository.",
description = "Assesses the transparency resp. traceability of the development " +
"process of the provided software for external parties. For this purpose," +
" various analyzes are performed that assess the availability of information " +
"about the software development process within the repository.",
children = children,
isEmpty = isEmpty
)
......@@ -167,7 +180,9 @@ enum class KpiKind {
return KPITreeResponseDto(
value = value,
name = "Security Score",
description = "Assesses the security of the software provided. For this purpose, various security-relevant analyzes are carried out, which, among other things, check the external dependencies or the code for vulnerabilities.",
description = "Assesses the security of the software provided. For this purpose, " +
"various security-relevant analyzes are carried out, which, among other things," +
" check the external dependencies or the code for vulnerabilities.",
children = children,
isEmpty = isEmpty
)
......@@ -182,7 +197,8 @@ enum class KpiKind {
return KPITreeResponseDto(
value = value,
name = "Maximal Dependency Vulnerability Score",
description = "This score is calculated by the following formula: 100 - (max(CVSS score) * 10). Thus, a lower value indicates a more critical vulnerability.",
description = "This score is calculated by the following formula: 100 - (max(CVSS score) * 10). " +
"Thus, a lower value indicates a more critical vulnerability.",
children = children,
isEmpty = isEmpty
)
......@@ -199,7 +215,8 @@ enum class KpiKind {
return KPITreeResponseDto(
value = value,
name = "Project Score",
description = "Assesses the project resp. the provided software in the aspects of maturity (based on quality, security and usability aspects) as well as development process.",
description = "Assesses the project resp. the provided software in the aspects of" +
" maturity (based on quality, security and usability aspects) as well as development process.",
isRoot = true,
children = children,
isEmpty = isEmpty
......
......@@ -138,6 +138,7 @@ class KPIService(
return rootKpi
}
@Suppress("MagicNumber", "LongMethod")
private fun generateKPITree(
rawValueKpis: Map<KpiKind, KpiCalculationDto> = emptyMap(),
vulnerabilityKpis: List<KpiCalculationDto> = emptyList()
......
......@@ -4,6 +4,7 @@ import de.fraunhofer.iem.dataprovider.kpi.dto.KPIHierarchyEdgeDto
class MaximumKPICalculationStrategy : KPICalculationStrategy {
// TODO: Currently it's tailored to the maximum dependency vulnerability score, this should change in the future
@Suppress("MagicNumber")
override fun calculateKPI(children: List<KPIHierarchyEdgeDto>): Int {
var maximum = 0
for (child in children) {
......
......@@ -3,6 +3,7 @@ package de.fraunhofer.iem.dataprovider.kpi.strategy
import de.fraunhofer.iem.dataprovider.kpi.dto.KPIHierarchyEdgeDto
class RatioKPICalculationStrategy : KPICalculationStrategy {
@Suppress("MagicNumber")
override fun calculateKPI(children: List<KPIHierarchyEdgeDto>): Int {
if (children.size != 2) {
throw Exception("Requires exactly two children")
......
......@@ -6,7 +6,7 @@ import org.slf4j.LoggerFactory
/**
* Utility function to get a slf4j logger.
*/
// TODO: This can later be used to create a common logger
// This can later be used to create a common logger
// configuration applicable to the whole application.
fun getLogger(forClass: Class<*>): Logger =
LoggerFactory.getLogger(forClass)
\ No newline at end of file
LoggerFactory.getLogger(forClass)
......@@ -57,7 +57,6 @@ class RepositoryController(private val repositoryService: RepositoryService, pri
this.kpiService.getKpiTreeForRepository(repositoryEntity).toViewModel()
)
return ScoreCardResponseDto(
RepositoryResponseDto(
repositoryEntity.id!!,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.