Skip to content

Commit d159a9c

Browse files
committed
add image scan for test and publish workflows
1 parent 905755f commit d159a9c

File tree

6 files changed

+480
-203
lines changed

6 files changed

+480
-203
lines changed

.github/workflows/publish.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,25 @@ jobs:
4646
username: ${{ github.actor }}
4747
password: ${{ secrets.GITHUB_TOKEN }}
4848

49-
# Build and push the Docker image
49+
# Build the Docker image locally
50+
- name: Build local image for scanning
51+
uses: docker/build-push-action@v6
52+
with:
53+
context: .
54+
load: true
55+
tags: ghcr.io/kleis-technology/cloud-assess/cloud-assess-app:scan-tmp
56+
57+
- name: Run Trivy vulnerability scanner
58+
uses: aquasecurity/trivy-action@master
59+
with:
60+
image-ref: 'ghcr.io/kleis-technology/cloud-assess/cloud-assess-app:scan-tmp'
61+
format: 'table'
62+
exit-code: '1' # Fail the pipeline if vulnerabilities are found
63+
ignore-unfixed: true
64+
vuln-type: 'library'
65+
severity: 'CRITICAL,HIGH'
66+
67+
# If scan passes, Build and push the actual multi-platform images
5068
- name: Build and push Docker image
5169
uses: docker/build-push-action@v6
5270
with:

.github/workflows/test.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,13 @@ jobs:
4242
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4343
run: ./gradlew test
4444

45+
- name: Run Trivy vulnerability scanner (Repo scan)
46+
uses: aquasecurity/trivy-action@master
47+
with:
48+
scan-type: 'fs' # 'fs'
49+
scan-ref: '.'
50+
vuln-type: 'library'
51+
ignore-unfixed: true
52+
format: 'table'
53+
exit-code: '1' # Fail the pipeline if vulnerabilities are found
54+
severity: 'CRITICAL,HIGH'

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ From the root of the git repository, run
7272
./gradlew build
7373
```
7474

75+
To update a library and update the gradle.lockfile
76+
77+
```bash
78+
./gradlew dependencies --write-locks
79+
```
80+
7581
To run the server locally
7682

7783
```bash

build.gradle.kts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
22

33
plugins {
44
id("maven-publish")
5-
id("org.springframework.boot") version "3.2.4"
5+
id("org.springframework.boot") version "3.5.10"
66
id("io.spring.dependency-management") version "1.1.3"
77
kotlin("jvm") version "1.8.22"
88
kotlin("plugin.spring") version "1.8.22"
@@ -34,7 +34,6 @@ dependencies {
3434
implementation("ch.kleis.lcaac:core:$lcaacVersion")
3535
implementation("ch.kleis.lcaac:grammar:$lcaacVersion")
3636

37-
3837
implementation("org.springframework.boot:spring-boot-starter")
3938
implementation("org.jetbrains.kotlin:kotlin-reflect")
4039
implementation("org.springframework.boot:spring-boot-starter-web")
@@ -95,9 +94,19 @@ openApiGenerate {
9594
"EntryValueDto" to " org.cloud_assess.dto.EntryValueDto",
9695
"ParameterValueDto" to "org.cloud_assess.dto.ParameterValueDto",
9796
))
97+
// generate only the API and the DTO (and not the supporting files such as the pom.xml that has no usage and outdated libraries)
98+
globalProperties.set(mapOf(
99+
"apis" to "",
100+
"models" to "",
101+
"supportingFiles" to "ApiUtil.kt"
102+
))
98103
}
99104

100105
openApiValidate {
101106
inputSpec.set("$rootDir/openapi/api.yaml")
102107
recommend.set(true)
103108
}
109+
110+
dependencyLocking {
111+
lockAllConfigurations()
112+
}

0 commit comments

Comments
 (0)