Skip to content

Commit 9d05cdf

Browse files
authored
Merge pull request #845 from Cosmo-Tech/DSE/further_upgrades_PROD-14136
Dse/further upgrades prod 14136
2 parents 0f75a8e + 29cbbac commit 9d05cdf

File tree

327 files changed

+8800
-19106
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

327 files changed

+8800
-19106
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,26 @@ kube-linter --config api/kubernetes/.kube-linter.yaml lint api/kubernetes/helm-c
359359
kube-linter --config api/kubernetes/.kube-linter.yaml lint api/kubernetes/csm-argo
360360
```
361361

362+
#### Vulnerability report
363+
364+
To generate a report of publicly disclosed vulnerabilities in the dependencies
365+
add your API key for the National Vulnerability Database (https://nvd.nist.gov/)
366+
as a property available to gradle. If you don't have a key get one from
367+
here: https://nvd.nist.gov/developers/request-an-api-key. Add your key in your
368+
`~/.gradle/gradle.properties` file (create the file if it does not exist)
369+
370+
```properties
371+
NVD_API_key=[key]
372+
```
373+
374+
Then run the dependency check task which can take about 10 minutes:
375+
376+
```shell
377+
./gradlew dependencyCheckAggregate
378+
```
379+
380+
an html report will be generated under `/build/reports`
381+
362382
## License
363383

364384
Copyright 2021 Cosmo Tech

build.gradle.kts

Lines changed: 35 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
import com.diffplug.gradle.spotless.SpotlessExtension
44
import com.github.jk1.license.filter.LicenseBundleNormalizer
55
import com.github.jk1.license.render.*
6-
import com.github.jk1.license.task.CheckLicenseTask
76
import com.github.jk1.license.task.ReportTask
87
import com.google.cloud.tools.jib.api.buildplan.ImageFormat.OCI
98
import com.google.cloud.tools.jib.gradle.JibExtension
109
import io.gitlab.arturbosch.detekt.Detekt
11-
import java.io.FileOutputStream
1210
import org.apache.tools.ant.filters.ReplaceTokens
1311
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
1412
import org.gradle.api.tasks.testing.logging.TestLogEvent
@@ -29,13 +27,13 @@ plugins {
2927
kotlin("jvm") version kotlinVersion
3028
kotlin("plugin.spring") version kotlinVersion apply false
3129
id("pl.allegro.tech.build.axion-release") version "1.15.5"
32-
id("com.diffplug.spotless") version "6.22.0"
33-
id("org.springframework.boot") version "3.3.6" apply false
30+
id("com.diffplug.spotless") version "6.25.0"
31+
id("org.springframework.boot") version "3.4.1" apply false
3432
id("project-report")
35-
id("org.owasp.dependencycheck") version "9.0.2"
36-
id("com.github.jk1.dependency-license-report") version "2.5"
33+
id("org.owasp.dependencycheck") version "12.0.0"
34+
id("com.github.jk1.dependency-license-report") version "2.9"
3735
id("org.jetbrains.kotlinx.kover") version "0.7.4"
38-
id("io.gitlab.arturbosch.detekt") version "1.23.6"
36+
id("io.gitlab.arturbosch.detekt") version "1.23.7"
3937
id("org.openapi.generator") version "7.8.0" apply false
4038
id("com.google.cloud.tools.jib") version "3.4.4" apply false
4139
}
@@ -50,28 +48,28 @@ version = scmVersion.version
5048

5149
// Required versions
5250
val jacksonVersion = "2.15.3"
53-
val springWebVersion = "6.1.16"
51+
val springWebVersion = "6.2.1"
5452

5553
// Implementation
5654
val kotlinJvmTarget = 21
5755
val cosmotechApiCommonVersion = "2.1.0-SNAPSHOT"
5856
val jedisVersion = "4.4.6"
59-
val springOauthVersion = "6.2.2"
60-
val redisOmSpringVersion = "0.9.1"
57+
val springOauthVersion = "6.4.2"
58+
val redisOmSpringVersion = "0.9.7"
6159
val kotlinCoroutinesCoreVersion = "1.8.1"
62-
val oktaSpringBootVersion = "3.0.5"
60+
val oktaSpringBootVersion = "3.0.7"
6361
val springDocVersion = "2.5.0"
64-
val swaggerParserVersion = "2.1.22"
62+
val swaggerParserVersion = "2.1.24"
6563
val commonsCsvVersion = "1.10.0"
6664
val apiValidationVersion = "3.0.2"
6765
val kubernetesClientVersion = "22.0.0"
6866

6967
// Checks
70-
val detektVersion = "1.23.6"
68+
val detektVersion = "1.23.7"
7169

7270
// Tests
7371
val jUnitBomVersion = "5.10.0"
74-
val mockkVersion = "1.13.8"
72+
val mockkVersion = "1.13.13"
7573
val awaitilityKVersion = "4.2.0"
7674
val testcontainersRedis = "1.6.4"
7775
val springMockkVersion = "4.0.2"
@@ -82,38 +80,33 @@ val configBuildDir = "${layout.buildDirectory.get()}/config"
8280

8381
mkdir(configBuildDir)
8482

85-
fun downloadLicenseConfigFile(name: String): String {
86-
val localPath = "$configBuildDir/$name"
87-
val f = file(localPath)
88-
f.delete()
89-
val url = "https://raw.githubusercontent.com/Cosmo-Tech/cosmotech-license/main/config/$name"
90-
logger.info("Downloading license config file from $url to $localPath")
91-
uri(url).toURL().openStream().use { it.copyTo(FileOutputStream(f)) }
92-
return localPath
93-
}
94-
95-
val licenseNormalizerPath = downloadLicenseConfigFile("license-normalizer-bundle.json")
96-
val licenseAllowedPath =
97-
if (project.properties["useLocalLicenseAllowedFile"] == "true") {
98-
"$projectDir/config/allowed-licenses.json"
99-
} else {
100-
downloadLicenseConfigFile("allowed-licenses.json")
101-
}
102-
103-
logger.info("Using licenses allowed file: $licenseAllowedPath")
104-
105-
val licenseEmptyPath = downloadLicenseConfigFile("empty-dependencies-resume.json")
106-
// Plugin uses a generated report to check the licenses in a prepation task
10783
val hardCodedLicensesReportPath = "project-licenses-for-check-license-task.json"
10884

85+
dependencyCheck{
86+
// Configure dependency check plugin. It checks for publicly disclosed
87+
// vulnerabilities in project dependencies. To use it, you need to have an
88+
// API key from the NVD (National Vulnerability Database), pass it by setting
89+
// the environment variable NVD_API_key (See project README.md: Static Code
90+
// Analysis -> Vulnerability report).
91+
nvd{
92+
apiKey = System.getenv("NVD_API_key")
93+
}
94+
}
95+
10996
licenseReport {
11097
outputDir = licenseReportDir
111-
allowedLicensesFile = file(licenseAllowedPath)
98+
allowedLicensesFile =
99+
"https://raw.githubusercontent.com/Cosmo-Tech/cosmotech-license/refs/heads/main/config/allowed-licenses.json"
100+
val bundle =
101+
"https://raw.githubusercontent.com/Cosmo-Tech/cosmotech-license/refs/heads/main/config/license-normalizer-bundle.json"
102+
112103
renderers =
113104
arrayOf<ReportRenderer>(
114105
InventoryHtmlReportRenderer("index.html"),
115106
JsonReportRenderer("project-licenses-for-check-license-task.json", false))
116-
filters = arrayOf<LicenseBundleNormalizer>(LicenseBundleNormalizer(licenseNormalizerPath, true))
107+
filters =
108+
arrayOf<LicenseBundleNormalizer>(
109+
LicenseBundleNormalizer(uri(bundle).toURL().openStream(), true))
117110
}
118111

119112
allprojects {
@@ -169,12 +162,10 @@ allprojects {
169162
licenseHeader(licenseHeaderComment)
170163
}
171164
kotlin {
172-
ktfmt("0.41")
173165
target("**/*.kt")
174166
licenseHeader(licenseHeaderComment)
175167
}
176168
kotlinGradle {
177-
ktfmt("0.41")
178169
target("**/*.kts")
179170
// licenseHeader(licenseHeaderComment, "import")
180171
}
@@ -288,9 +279,8 @@ subprojects {
288279
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:${springDocVersion}")
289280
implementation("io.swagger.parser.v3:swagger-parser-v3:${swaggerParserVersion}")
290281
implementation("org.springframework.boot:spring-boot-starter-security")
291-
implementation("org.springframework.security:spring-security-oauth2-jose:${springOauthVersion}")
292-
implementation(
293-
"org.springframework.security:spring-security-oauth2-resource-server:${springOauthVersion}")
282+
implementation("org.springframework.security:spring-security-oauth2-jose")
283+
implementation("org.springframework.security:spring-security-oauth2-resource-server")
294284
implementation("com.okta.spring:okta-spring-boot-starter:${oktaSpringBootVersion}")
295285

296286
implementation("org.apache.commons:commons-csv:$commonsCsvVersion")
@@ -558,41 +548,7 @@ extensions.configure<kotlinx.kover.gradle.plugin.dsl.KoverReportExtension> {
558548
}
559549

560550
// https://github.com/jk1/Gradle-License-Report/blob/master/README.md
561-
tasks.register<ReportTask>("generateLicenseDoc") {}
562-
563-
tasks.register<CheckLicenseTask>("validateLicense") {
564-
dependsOn("generateLicenseDoc")
565-
// Gradle task must be rerun each time to take new allowed-license into account.
566-
// Due to an issue in the plugin, we must define each module name for null licenses
567-
// to avoid false negatives in the allowed-license file.
568-
outputs.upToDateWhen { false }
569-
}
551+
tasks.register<ReportTask>(
552+
"generateLicenseDoc") {}
570553

571-
tasks.register("displayLicensesNotAllowed") {
572-
val notAllowedFile =
573-
file(
574-
buildString {
575-
append(licenseReportDir)
576-
append("/dependencies-without-allowed-license.json")
577-
})
578-
val dependenciesEmptyResumeTemplate = file(licenseEmptyPath)
579-
if (notAllowedFile.exists() && dependenciesEmptyResumeTemplate.exists()) {
580-
if (notAllowedFile.readText() != dependenciesEmptyResumeTemplate.readText()) {
581-
logger.warn("Licenses not allowed:")
582-
logger.warn(notAllowedFile.readText())
583-
logger.warn(
584-
"Please review licenses and add new license check rules in https://github.com/Cosmo-Tech/cosmotech-license")
585-
} else {
586-
logger.warn("No error in licences detected!")
587-
}
588-
}
589-
}
590554

591-
gradle.buildFinished {
592-
if (project.properties["skipLicenses"] != "true") {
593-
val validateLicenseTask = tasks.getByName("validateLicense")
594-
validateLicenseTask.run {}
595-
val displayTask = tasks.getByName("displayLicensesNotAllowed")
596-
displayTask.run {}
597-
}
598-
}

dataset/src/integrationTest/kotlin/com/cosmotech/dataset/service/DatasetServiceIntegrationTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ class DatasetServiceIntegrationTest : CsmRedisTestBase() {
477477
assertEquals(1, datasetList.size)
478478
assertEquals(datasetNotReachableByCurrentUserBecausePartOfAnotherOrganization, datasetList[0])
479479
}
480+
480481
@Test
481482
fun `test find All Datasets with wrong pagination params`() {
482483
organizationSaved = organizationApiService.registerOrganization(organization)
@@ -1108,6 +1109,7 @@ class DatasetServiceIntegrationTest : CsmRedisTestBase() {
11081109
OrganizationAccessControl(id = CONNECTED_ADMIN_USER, role = ROLE_ADMIN),
11091110
OrganizationAccessControl(id = userName, role = role))))
11101111
}
1112+
11111113
fun makeDataset(
11121114
organizationId: String = organizationSaved.id!!,
11131115
parentId: String = "",

dataset/src/integrationTest/kotlin/com/cosmotech/dataset/service/DatasetServiceRBACTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,6 +2312,7 @@ class DatasetServiceRBACTest : CsmRedisTestBase() {
23122312
ioTypes = listOf(),
23132313
id = "c-AbCdEf123")
23142314
}
2315+
23152316
fun makeDataset(
23162317
id: String,
23172318
name: String,

dataset/src/main/kotlin/com/cosmotech/dataset/DatasetApiServiceInterface.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface DatasetApiServiceInterface : DatasetApiService {
2323
/**
2424
* Find Dataset by Organization Id and Dataset Id (checking ONLY READ_PERMISSION on targeted
2525
* organization)
26+
*
2627
* @param organizationId an organization Id
2728
* @param datasetId a dataset Id
2829
* @return a Dataset or null
@@ -31,6 +32,7 @@ interface DatasetApiServiceInterface : DatasetApiService {
3132

3233
/**
3334
* Add a new entry (ou update existing one) on dataset passed in parameter
35+
*
3436
* @param organizationId an organization id
3537
* @param dataset a dataset to update
3638
* @param identity a user/application identity

dataset/src/main/kotlin/com/cosmotech/dataset/bulk/BulkQuery.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,25 @@ private constructor(
2121
private var typedBinaryEdges: Map<String, BinaryEntities> = mapOf()
2222
) {
2323
fun graphName(name: String) = apply { this.graphName = name }
24+
2425
fun first() = apply { this.begin = true }
2526

2627
fun addNodeTypeGroup(type: String, binaryEntities: BinaryEntities) = apply {
2728
if (type !in typedBinaryNodes) this.typedBinaryNodes += type to binaryEntities
2829
}
30+
2931
fun addNodeToNodeTypeGroup(type: String, node: Node) = apply {
3032
if (type in this.typedBinaryNodes) this.typedBinaryNodes[type]?.addEntity(node)
3133
}
3234

3335
fun addEdgeTypeGroup(type: String, typeEdge: BinaryEntities) = apply {
3436
if (type !in typedBinaryEdges) this.typedBinaryEdges += type to typeEdge
3537
}
38+
3639
fun addEdgeToEdgeTypeGroup(type: String, edge: Edge) = apply {
3740
if (type in this.typedBinaryEdges) this.typedBinaryEdges[type]?.addEntity(edge)
3841
}
42+
3943
// For ease, those sizes are not calculated as there are very small
4044
// GRAPH.BULK string to byteArray size
4145
// graphName string to byteArray size
@@ -73,6 +77,7 @@ private constructor(
7377

7478
private fun ByteArray.toHex(): String =
7579
joinToString(separator = "") { eachByte -> "%02x".format(eachByte) }
80+
7681
override fun toString(): String {
7782
return generateQueryArgs().joinToString(separator = " - ") { bytes -> bytes.toHex() }
7883
}

dataset/src/main/kotlin/com/cosmotech/dataset/bulk/QueryBuffer.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class QueryBuffer(val unifiedJedis: UnifiedJedis, val graphName: String) {
2727

2828
private val nodeSet: HashSet<String> = hashSetOf()
2929
private val edgeSet: HashSet<String> = hashSetOf()
30+
3031
fun addNode(type: String, id: String, properties: Map<String, Any?>) {
3132
addEntity(type, properties) {
3233
if (id in nodeSet) return@addEntity null

dataset/src/main/kotlin/com/cosmotech/dataset/service/DatasetServiceImpl.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,7 @@ class DatasetServiceImpl(
194194
dataset.takeUnless {
195195
datasetSourceType in listOf(DatasetSourceType.ADT, DatasetSourceType.AzureStorage) &&
196196
dataset.source == null
197-
}
198-
?: throw IllegalArgumentException(
199-
"Source cannot be null for source type 'ADT' or 'Storage'")
197+
} ?: throw IllegalArgumentException("Source cannot be null for source type 'ADT' or 'Storage'")
200198

201199
var twingraphId: String? = null
202200

@@ -1004,8 +1002,7 @@ class DatasetServiceImpl(
10041002
val datasetCompatibilityMap =
10051003
existingDataset.compatibility
10061004
?.associateBy { "${it.solutionKey}-${it.minimumVersion}-${it.maximumVersion}" }
1007-
?.toMutableMap()
1008-
?: mutableMapOf()
1005+
?.toMutableMap() ?: mutableMapOf()
10091006
datasetCompatibilityMap.putAll(
10101007
datasetCompatibility
10111008
.filter { it.solutionKey.isNotBlank() }

dataset/src/main/kotlin/com/cosmotech/dataset/utils/Twingraph.ext.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ enum class CsmGraphEntityType {
2828
RELATION,
2929
NODE
3030
}
31+
3132
// To support simple quoted jsonstring from ADT
3233
val jsonObjectMapper: ObjectMapper =
3334
objectMapper().configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true)
@@ -41,7 +42,8 @@ fun GraphEntity.toCsmGraphEntity(type: CsmGraphEntityType): CsmGraphEntity {
4142
val label =
4243
when (type) {
4344
CsmGraphEntityType.RELATION -> (this as Edge).relationshipType
44-
CsmGraphEntityType.NODE -> (this as Node).takeIf { it.numberOfLabels > 0 }?.getLabel(0)
45+
CsmGraphEntityType.NODE ->
46+
(this as Node).takeIf { it.numberOfLabels > 0 }?.getLabel(0)
4547
?: throw IndexOutOfBoundsException("Node has no label: $entityId")
4648
}
4749

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
The code in this repository code was Written by Gil Tene, Michael Barker,
2+
and Matt Warren, and released to the public domain, as explained at
3+
http://creativecommons.org/publicdomain/zero/1.0/
4+
5+
For users of this code who wish to consume it under the "BSD" license
6+
rather than under the public domain or CC0 contribution text mentioned
7+
above, the code found under this directory is *also* provided under the
8+
following license (commonly referred to as the BSD 2-Clause License). This
9+
license does not detract from the above stated release of the code into
10+
the public domain, and simply represents an additional license granted by
11+
the Author.
12+
13+
-----------------------------------------------------------------------------
14+
** Beginning of "BSD 2-Clause License" text. **
15+
16+
Copyright (c) 2012, 2013, 2014, 2015, 2016 Gil Tene
17+
Copyright (c) 2014 Michael Barker
18+
Copyright (c) 2014 Matt Warren
19+
All rights reserved.
20+
21+
Redistribution and use in source and binary forms, with or without
22+
modification, are permitted provided that the following conditions are met:
23+
24+
1. Redistributions of source code must retain the above copyright notice,
25+
this list of conditions and the following disclaimer.
26+
27+
2. Redistributions in binary form must reproduce the above copyright notice,
28+
this list of conditions and the following disclaimer in the documentation
29+
and/or other materials provided with the distribution.
30+
31+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
32+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
35+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
36+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
39+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
41+
THE POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)