Skip to content

Commit 895a9ed

Browse files
authored
Merge pull request #3756 from mercedes-benz/develop
Merge `develop` into `master` for release
2 parents d93df81 + 5b0f941 commit 895a9ed

Some content is hidden

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

53 files changed

+839
-239
lines changed

.github/workflows/github-action-scan.yml

+11-3
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,22 @@ jobs:
2929
steps:
3030
- name: Checkout
3131
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
32-
32+
33+
- name: Cache Node.js modules
34+
uses: actions/cache@v2
35+
with:
36+
path: ~/.npm
37+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
38+
restore-keys: |
39+
${{ runner.os }}-node-
40+
3341
- name: Use Node.js
3442
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
3543
with:
3644
node-version: 22
3745

38-
- name: Clean install
39-
run: npm ci
46+
- name: Install
47+
run: npm install
4048

4149
- name: Build
4250
run: npm run build

.github/workflows/gradle.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
run: ./gradlew :sechub-cli:buildGo :sechub-cli:testGo
7070

7171
- name: Build Server, DAUI and generate OpenAPI file
72-
run: ./gradlew ensureLocalhostCertificate build generateOpenapi buildDeveloperAdminUI -x :sechub-cli:build
72+
run: ./gradlew ensureLocalhostCertificate build generateOpenapi -x :sechub-cli:build
7373

7474
- name: Generate and build Java projects related to SecHub Java API
7575
run: ./gradlew :sechub-api-java:build :sechub-systemtest:build :sechub-pds-tools:buildPDSToolsCLI -Dsechub.build.stage=api-necessary

.github/workflows/release-client-server-pds.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ jobs:
173173
# Build SecHub Server + PDS
174174
# ----------------------
175175
- name: Build Server and PDS artifacts
176-
run: ./gradlew ensureLocalhostCertificate build generateOpenapi buildDeveloperAdminUI -x :sechub-cli:build
176+
run: ./gradlew ensureLocalhostCertificate build generateOpenapi -x :sechub-cli:build
177177

178178
# ----------------------
179179
# Build API Java publish
@@ -330,7 +330,7 @@ jobs:
330330
mkdir server-release-artifacts
331331
# Collect release artifacts
332332
cp sechub-server/build/libs/sechub-server-${{ inputs.server-version }}.jar \
333-
sechub-developertools/build/libs/sechub-developer-admin-ui-${{ inputs.server-version }}.jar \
333+
sechub-developertools/build/libs/sechub-developertools-${{ inputs.server-version }}.jar \
334334
server-release-artifacts/
335335
cp sechub-doc/build/docs/asciidoc/sechub-architecture.pdf \
336336
server-release-artifacts/sechub-architecture-${{ inputs.server-version }}.pdf

.github/workflows/release-pds-tools.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
# Build SecHub PDS-Tools
9797
# ----------------------
9898
- name: Build Server, DAUI and generate OpenAPI file
99-
run: ./gradlew ensureLocalhostCertificate build generateOpenapi buildDeveloperAdminUI -x :sechub-integrationtest:test -x :sechub-cli:build
99+
run: ./gradlew ensureLocalhostCertificate build generateOpenapi -x :sechub-integrationtest:test -x :sechub-cli:build
100100

101101
- name: Generate and build Java projects related to SecHub Java API
102102
run: ./gradlew :sechub-api-java:build :sechub-systemtest:build :sechub-pds-tools:buildPDSToolsCLI -Dsechub.build.stage=api-necessary

continous-integration-multibranch-pipeline.jenkins

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pipeline {
5757
// We do NOT build sechub-integrationtest
5858
// Reason: because we do NOT want to have the integration tests executed, otherwise gradle will not execute them
5959
// on integration phase again (because nothing has changed, so gradle will cache the results which are ignored ...
60-
callGradleWrapper("ensureLocalhostCertificate build generateOpenapi buildDeveloperAdminUI -x :sechub-cli:build -Psechub.test.wiremock.https_port=${env.SECHUB_TEST_WIREMOCK_HTTPS_PORT} -Psechub.test.wiremock.http_port=${env.SECHUB_TEST_WIREMOCK_HTTP_PORT} --console=plain")
60+
callGradleWrapper("ensureLocalhostCertificate build generateOpenapi -x :sechub-cli:build -Psechub.test.wiremock.https_port=${env.SECHUB_TEST_WIREMOCK_HTTPS_PORT} -Psechub.test.wiremock.http_port=${env.SECHUB_TEST_WIREMOCK_HTTP_PORT} --console=plain")
6161
callGradleWrapper(":sechub-api-java:build :sechub-systemtest:build :sechub-pds-tools:buildPDSToolsCLI -Dsechub.build.stage=api-necessary --console=plain")
6262
}
6363
}

docs/latest/sechub-developer-quickstart-guide.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1939,7 +1939,7 @@ <h3 id="run-integration-tests-from-intellij-ide">5.2. Run Integration Tests From
19391939
</div>
19401940
<div class="listingblock">
19411941
<div class="content">
1942-
<pre>./gradlew ensureLocalhostCertificate build generateOpenapi buildDeveloperAdminUI -x :sechub-cli:build</pre>
1942+
<pre>./gradlew ensureLocalhostCertificate build generateOpenapi -x :sechub-cli:build</pre>
19431943
</div>
19441944
</div>
19451945
<div class="listingblock">

github-actions/scan/README.adoc

+38-13
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,29 @@ The following variables take priority over the configuration file:
9494
If no custom `sechub.json` is provided, it will be generated from the remaining specified variables and used. However, if a custom `sechub.json` is provided, no separate configuration will be created, meaning the remaining set variables will essentially be ignored.
9595
====
9696

97-
=== Outputs
97+
=== Use SecHub results in GitHub workflows
9898

99-
The following table lists the output variables available after this SecHub GitHub Action has completed:
99+
==== GitHub Output
100+
Because of problems with GitHub outputs (see https://github.com/mercedes-benz/sechub/issues/3481 ) SecHub no longer supports outputs but provides environment variables instead.
101+
102+
==== Environment variables
103+
The following table lists the environment variables containing result data after this SecHub GitHub Action has completed:
100104

101105
[cols="20%,40%,40%"]
102106
|===
103-
| Output Name | Description | Expected Values
107+
| Environment variable | Description | Expected Values
104108

105-
| scan-trafficlight | The color of the traffic light reported by SecHub if the scan ran successfully, otherwise `FAILURE`. | One of `GREEN`, `YELLOW`, `RED`, or `FAILURE`.
106-
| scan-findings-count | The total number of findings reported by SecHub. Returns 0 if the scan didn't complete. | 0
107-
| scan-findings-high | The number of high-level findings reported by SecHub. | 0
108-
| scan-findings-medium | The number of medium-level findings reported by SecHub. | 0
109-
| scan-findings-low | The number of low-level findings reported by SecHub. | 0
110-
| scan-readable-summary| A human-readable summary of the scan outcome, including the traffic light color, findings count, and their distribution. | For example, `SecHub scan could not be executed` if an error occurred. Otherwise, i.e. `SecHub reported traffic light color YELLOW with 15 findings, categorized as follows: MEDIUM (8), LOW (7)`
109+
| SECHUB_OUTPUT_SCAN_TRAFFICLIGHT | The color of the traffic light reported by SecHub if the scan ran successfully, otherwise `FAILURE`. | One of `GREEN`, `YELLOW`, `RED`, or `FAILURE`.
110+
| SECHUB_OUTPUT_SCAN_FINDINGS_COUNT | The total number of findings reported by SecHub. Returns 0 if the scan didn't complete. | 0
111+
| SECHUB_OUTPUT_SCAN_FINDINGS_HIGH | The number of high-level findings reported by SecHub. | 0
112+
| SECHUB_OUTPUT_SCAN_FINDINGS_MEDIUM | The number of medium-level findings reported by SecHub. | 0
113+
| SECHUB_OUTPUT_SCAN_FINDINGS_LOW | The number of low-level findings reported by SecHub. | 0
114+
| SECHUB_OUTPUT_SCAN_READABLE_SUMMARY| A human-readable summary of the scan outcome, including the traffic light color, findings count, and their distribution. | For example, `SecHub scan could not be executed` if an error occurred. Otherwise, i.e. `SecHub reported traffic light color YELLOW with 15 findings, categorized as follows: MEDIUM (8), LOW (7)`
111115

112116
|===
113117

114118

115-
You can access them after the action has run with `${{ steps.<step-id>.outputs.<output-name> }}`
119+
You can access them after the action has run with `${{ env.<environment-variable-name> }}`
116120

117121
=== Build
118122

@@ -129,6 +133,16 @@ npm run build
129133

130134
This runs the ncc compiler and transpiles the files from the src folder into the `dist/` folder.
131135

136+
=== Deployment
137+
A GitHub action needs a transpiled `index.js` to be used as an action from workflows.
138+
139+
As long as we do not provide a new index.js the old action is still in usage, even when the source code has
140+
changed. If we do not build the file and commit and push it to git repository, the action will not
141+
be available!
142+
143+
The complete deployment process is automated by `.github/workflows/release-github-action.yml` which will create a
144+
PR which will do all necessary steps.
145+
132146
=== Test
133147

134148
==== Unit tests
@@ -142,10 +156,19 @@ npm run test
142156

143157
==== Integration-Test
144158
As a precondition to run the integration tests locally you have to
159+
execute `01-start.sh $secHubServerVersion $sechubServerPortNr $pdsVersion $pdsPortN`
160+
inside the integration test folder.
145161

146-
- execute `__test__/01-start.sh $secHubServerVersion $sechubServerPortNr $pdsVersion $pdsPortNr`
162+
An example:
163+
164+
[source,bash]
165+
----
166+
# Next lines will start a SecHub server of version 2.4.0 and a PDS with version 2.1.0
167+
cd ./github-actions/scan/__test__/integrationtest
168+
./01-start.sh 2.4.0 8443 2.1.0 8444
169+
----
147170

148-
TIP: You can also start a SecHub server and a PDS (both in integration test mode) instead of using the `01-start` script.
171+
TIP: You can also start a SecHub server and a PDS from IDE (both in integration test mode) instead of using the `01-start` script.
149172

150173
After the script has been executed, you can execute integration tests multiple times via following command:
151174

@@ -176,7 +199,9 @@ In this setup the tests can be executed from sidebar and from links created insi
176199

177200
[TIP]
178201
====
179-
Unfortunately, the Jest UI integration works only for npm script "test". But to handle integration tests different (the tests shall only be executed when all is build and servers are started) they are not executed by "test" script.
202+
Unfortunately, the Jest UI integration works only for npm script "test".
203+
But to handle integration tests different (the tests shall only be executed
204+
when all is built and servers are started) they are not executed by "test" script.
180205
181206
If you want to **debug an integration test**, there is a temporary workaround necessary while you debug the test:
182207

github-actions/scan/__test__/client-version-helper.test.ts

+16
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@
33
import { getClientVersion } from '../src/client-version-helper';
44
import axios from 'axios';
55
import MockAdapter from 'axios-mock-adapter';
6+
import * as core from '@actions/core';
7+
8+
jest.mock('@actions/core');
9+
10+
const mockDebug = core.debug as jest.MockedFunction<typeof core.debug>;
11+
12+
const debugEnabled = false;
13+
14+
beforeEach(() => {
15+
mockDebug.mockImplementation((message: string | Error) => {
16+
if (debugEnabled) {
17+
console.log(`Debug: ${message}`);
18+
}
19+
});
20+
mockDebug.mockClear();
21+
});
622

723
describe('getClientVersion', function () {
824

github-actions/scan/__test__/configuration-builder.test.ts

+13-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ import { SecHubConfigurationModelBuilderData } from '../src/configuration-builde
66

77
jest.mock('@actions/core');
88

9-
function dumpModel(model: SecHubConfigurationModel){
9+
const debugEnabled = false;
10+
11+
function logDebug(model: SecHubConfigurationModel){
12+
if (! debugEnabled){
13+
return;
14+
}
1015
const json = JSON.stringify(model, null, 2); // pretty printed output
1116

1217
console.log('json='+json);
@@ -34,7 +39,7 @@ describe('configuration-builder', function() {
3439
const model= configBuilder.createSecHubConfigurationModel(builderData);
3540

3641
/* test */
37-
dumpModel(model);
42+
logDebug(model);
3843

3944
expect(model.apiVersion).toEqual('1.0');
4045

@@ -66,7 +71,7 @@ describe('configuration-builder', function() {
6671
const model= configBuilder.createSecHubConfigurationModel(builderData);
6772

6873
/* test */
69-
dumpModel(model);
74+
logDebug(model);
7075

7176
expect(model.apiVersion).toEqual('1.0');
7277

@@ -101,7 +106,7 @@ describe('configuration-builder', function() {
101106
const model= configBuilder.createSecHubConfigurationModel(builderData);
102107

103108
/* test */
104-
dumpModel(model);
109+
logDebug(model);
105110

106111
expect(model.apiVersion).toEqual('1.0');
107112

@@ -138,7 +143,7 @@ describe('configuration-builder', function() {
138143
const model= configBuilder.createSecHubConfigurationModel(builderData);
139144

140145
/* test */
141-
dumpModel(model);
146+
logDebug(model);
142147

143148
expect(model.apiVersion).toEqual('1.0');
144149

@@ -172,7 +177,7 @@ describe('configuration-builder', function() {
172177
const model= configBuilder.createSecHubConfigurationModel(builderData);
173178

174179
/* test */
175-
dumpModel(model);
180+
logDebug(model);
176181

177182
expect(model.apiVersion).toEqual('1.0');
178183

@@ -206,7 +211,7 @@ describe('configuration-builder', function() {
206211
const model= configBuilder.createSecHubConfigurationModel(builderData);
207212

208213
/* test */
209-
dumpModel(model);
214+
logDebug(model);
210215

211216
expect(model.apiVersion).toEqual('1.0');
212217

@@ -241,7 +246,7 @@ describe('configuration-builder', function() {
241246
const model= configBuilder.createSecHubConfigurationModel(builderData);
242247

243248
/* test */
244-
dumpModel(model);
249+
logDebug(model);
245250

246251
expect(model.apiVersion).toEqual('1.0');
247252

github-actions/scan/__test__/init-scan.test.ts

+16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ import {initReportFormats, initSecHubJson} from '../src/init-scan';
55
jest.mock('./../src/configuration-builder');
66
import {SecHubConfigurationModelBuilderData, createSecHubConfigJsonFile} from '../src/configuration-builder';
77

8+
import * as core from '@actions/core';
9+
10+
jest.mock('@actions/core');
11+
12+
const mockInfo = core.info as jest.MockedFunction<typeof core.info>;
13+
14+
const debugEnabled = false;
15+
16+
beforeEach(() => {
17+
mockInfo.mockImplementation((message: string | Error) => {
18+
if (debugEnabled) {
19+
console.log(`Info: ${message}`);
20+
}
21+
});
22+
mockInfo.mockClear();
23+
});
824

925
describe('initSecHubJson', function () {
1026
it('throws error if configPath is set, but file does not exist', function () {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-License-Identifier: MIT
2+
import * as outputHelper from '../src/output-helper';
3+
import * as core from '@actions/core';
4+
5+
jest.mock('@actions/core');
6+
7+
describe('storeOutput', () => {
8+
const mockedCore = core as jest.Mocked<typeof core>;
9+
10+
it('test-key shall set SECHUB_OUTPUT_TEST_KEY', () => {
11+
/* execute */
12+
outputHelper.storeOutput('test-key', 'test value1');
13+
14+
/* test */
15+
expect(mockedCore.exportVariable).toBeCalledWith('SECHUB_OUTPUT_TEST_KEY', 'test value1');
16+
});
17+
18+
});

0 commit comments

Comments
 (0)