Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat|fix] : SDE backend : Hotfix 3.2 with pcf submodel : rel-2.3.0 #68

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 4 additions & 37 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,58 +28,25 @@ on:
# Trigger manually

jobs:
analyze-config:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@master
with:
scan-type: "config"
exit-code: "1"
hide-progress: false
format: "sarif"
output: "trivy-results1.sarif"
severity: "CRITICAL,HIGH"

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: "trivy-results1.sarif"

analyze-product-dft-backend:
analyze-config:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Run Trivy vulnerability scanner
if: always()
uses: aquasecurity/trivy-action@master
uses: aquasecurity/[email protected]
with:
# Path to Docker image
image-ref: "tractusx/managed-simple-data-exchanger-backend:latest"
format: "sarif"
output: "trivy-results.sarif"
exit-code: "1"
severity: "CRITICAL,HIGH"
vuln-type: "os,library"

- name: Upload Trivy scan results to GitHub Security tab
if: always()
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: "trivy-results.sarif"

sarif_file: "trivy-results.sarif"
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [2.3.0] - 2023-11-21
### Added
- Added oauth security for sde public api.
- BPN url add API path.
### Fixed
- DT use refactor and PCF issue fix.
- Correct dataplane endpoint for digital twin.
- DSP endpoint path for digital-twin edc url.
- trivy worklow fix.

## [2.2.0] - 2023-09-20
### Added
- Pcf model schema and model registration.
Expand Down Expand Up @@ -224,7 +234,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Compliance with Catena-X Guidelines
- Integration with Digital Twin registry service.

[unreleased]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/v2.2.0...main
[unreleased]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/v2.3.0...main
[2.3.0]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/v2.2.0...v2.3.0
[2.2.0]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/v2.1.1...v2.2.0
[2.1.1]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/v2.1.0...v2.1.1
[2.1.0]: https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/compare/v2.0.11...v2.1.0
Expand Down
2 changes: 1 addition & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ maven/mavencentral/jakarta.annotation/jakarta.annotation-api/2.1.1, EPL-2.0 OR G
maven/mavencentral/jakarta.inject/jakarta.inject-api/2.0.1, Apache-2.0, approved, clearlydefined
maven/mavencentral/jakarta.persistence/jakarta.persistence-api/3.1.0, EPL-2.0 OR BSD-3-Clause AND (EPL-2.0 OR BSD-3-Clause AND BSD-3-Clause), approved, #7696
maven/mavencentral/jakarta.transaction/jakarta.transaction-api/2.0.1, EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0, approved, #7697
maven/mavencentral/jakarta.validation/jakarta.validation-api/3.0.2, Apache-2.0, approved, clearlydefined
maven/mavencentral/jakarta.validation/jakarta.validation-api/3.0.2, Apache-2.0, approved, ee4j.validation
maven/mavencentral/jakarta.xml.bind/jakarta.xml.bind-api/4.0.0, BSD-3-Clause, approved, ee4j.jaxb
maven/mavencentral/net.bytebuddy/byte-buddy-agent/1.14.4, Apache-2.0, approved, #7164
maven/mavencentral/net.bytebuddy/byte-buddy/1.14.4, Apache-2.0 AND BSD-3-Clause, approved, #7163
Expand Down
6 changes: 3 additions & 3 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ For more details, please refer configuration section from [README.md](README.md)
```
### RUN SDE Backend Locally
#### Prerequisites
- JDK18
- Postgres 11.9.13
- JDK17
- Postgres 12.12.10

#### Steps
1. Clone the GitHub Repository - https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend.
2. Get your instance of postgres running (Create **dftdb** new database).
3. Setup your project environment to JDK 18.
3. Setup your project environment to JDK 17.
4. Provide require application configuration in application.properties as specified in step configuration.properties.
5. Start the SDE spring boot application from your IDE using main class or use spring CLI.

Expand Down
2 changes: 1 addition & 1 deletion NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ SPDX-License-Identifier: Apache-2.0
The project maintains the following source code repositories
in the GitHub organization https://github.com/eclipse-tractusx:

* https://github.com/eclipse-tractusx/dft-backend
* https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend


## Third-party Content
Expand Down
40 changes: 38 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ Listed below are configuration keys needed to get the `sde-backend` up and runni
| digital-twins.authentication.clientSecret | X | your secrete | Digital twin registry secrete |
| digital-twins.authentication.grantType | X | client_credentials | Default value, no need to change |
| edc.hostname | X | https://example.provider-connector.com | Your EDC provider connector url |
| edc.managementpath | X | default | edc provider management path |
| edc.apiKeyHeader | X | x-api-key | Your connector api key |
| edc.apiKey | X | yourpass | Your connector apikey value |
| edc.consumer.hostname | X | https://example.consumer-connector.com | Your EDC consumer connector |
| edc.consumer.apikeyheader | X | x-api-key | Your connector api key |
| edc.consumer.apikey | X | yourpass | Your connector apikey value |
| edc.consumer.datauri | X | /api/v1/ids/data | IDS endpoint path |
| edc.consumer.protocol.path | X | default | edc consumer protocol path |
| edc.consumer.managementpath | X | default | edc consumer management path |
| dft.hostname | X | https://example.sdehost.com | Your SDE hostname |
| dft.apiKeyHeader | X | API_KEY | Your default key |
| dft.apiKey | X | yourpass | Your default key password |
Expand All @@ -77,7 +80,22 @@ Listed below are configuration keys needed to get the `sde-backend` up and runni
| connector.discovery.clientId | X | default | client ID for connector discovery |
| connector.discovery.clientSecret | X | default | password for connector discovery |
| portal.backend.hostname | X | default | Portal backend svc URL based on BPN|
| springdoc.api-docs.path | X | /api-docs | swagger API path |
| springdoc.api-docs.path | X | default | swagger API path |
| bpndiscovery.hostname | X | default | bpn discovery hostname |
| discovery.authentication.url | X | default | discovery authentication url |
| discovery.clientId | X | default | discovery clientId |
| discovery.clientSecret | X | default | discovery clientSecret |
| discovery.grantType | X | default | discovery grantType |
| partner.pool.hostname | X | default | partner pool hostname |
| partner.pool.authentication.url | X | default | partner pool authentication url |
| partner.pool.clientId | X | default | partner pool clientId |
| partner.pool.clientSecret | X | default | partner pool clientSecret |
| partner.pool.grantType | X | default | partner pool grantType |
| portal.backend.hostname | X | default | portal backend hostname |
| portal.backend.authentication.url | X | default | portal authentication url |
| portal.backend.clientId | X | default | portal clientId |
| portal.backend.clientSecret | X | default | portal clientSecret |
| portal.backend.grantType | X | default | portal grantType |

#### Example Configuration/application.properties

Expand Down Expand Up @@ -170,6 +188,24 @@ portal.backend.authentication.url=default
portal.backend.clientId=default
portal.backend.clientSecret=default
portal.backend.grantType=default
bpndiscovery.hostname=default
discovery.authentication.url=default
discovery.clientId=default
discovery.clientSecret=default
discovery.grantType=default
edc.consumer.protocol.path=default
edc.consumer.managementpath=default
edc.managementpath=default
partner.pool.hostname=default
partner.pool.authentication.url=default
partner.pool.clientId=default
partner.pool.clientSecret=default
partner.pool.grantType=default
portal.backend.hostname=default
portal.backend.authentication.url=default
portal.backend.clientId=default
portal.backend.clientSecret=default
portal.backend.grantType=default
```

The above configuration we can use as for different deployment as specified here [InstallationGuide.md](InstallationGuide.md)
Expand Down Expand Up @@ -329,7 +365,7 @@ Eclipse Tractus-X product(s) installed within the image:
- Project license: [Apache License, Version 2.0] https://github.com/eclipse-tractusx/managed-simple-data-exchanger-backend/blob/main/LICENSE

**Used base image**
- [eclipse-temurin:19-jdk-jammy](https://github.com/adoptium/containers)
- [eclipse-temurin:17.0.9_9-jdk-jammy](https://github.com/adoptium/containers)
- Official Eclipse Temurin DockerHub page: https://hub.docker.com/_/eclipse-temurin
- Eclipse Temurin Project: https://projects.eclipse.org/projects/adoptium.temurin
- Additional information about the Eclipse Temurin images: https://github.com/docker-library/repo-info/tree/master/repos/eclipse-temurin
Expand Down
9 changes: 3 additions & 6 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,17 @@ COPY ../pom.xml ./pom.xml
# copy your other files
COPY ../modules ./modules

# build for release
RUN mvn clean install

# our final base image

FROM eclipse-temurin:19-jdk-jammy
FROM eclipse-temurin:17.0.9_9-jdk-jammy

ARG USERNAME=sdeuser
ARG USER_UID=1001
ARG USER_GID=$USER_UID

# Create the user

RUN useradd -rm -d /home/sdeuser -s /bin/bash -u $USER_UID -U $USERNAME
RUN useradd -m -d /home/sdeuser -s /bin/bash -u $USER_UID -U $USERNAME


USER $USERNAME
Expand All @@ -52,6 +49,6 @@ WORKDIR /home/user/sdeuser/sdeapp
COPY --from=build modules/sde-core/target/*.jar ./app.jar

EXPOSE 8080
# set the startup command to run your binary

# set the startup command to run your binary
CMD ["java", "-jar", "./app.jar","--spring.config.location=file:/app/configuration.properties"]
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ public void setFieldValue(ObjectNode rowjObject, String ele, JsonObject jObject,

fieldValue = fieldValue.trim();

if (isNumberTypeField(jObject, fieldValue))
rowjObject.put(ele, Double.parseDouble(fieldValue));
else if (isDateFormatField(jObject)) {
if (isNumberTypeField(jObject)) {
if (fieldValue.isBlank()) {
rowjObject.putNull(ele);
} else {
rowjObject.put(ele, Double.parseDouble(fieldValue));
}
} else if (isDateFormatField(jObject)) {

if (fieldValue.isBlank())
fieldValue = null;
Expand All @@ -57,12 +61,10 @@ private boolean isDateFormatField(JsonObject jObject) {
return jObject.get("format") != null && "date-time".equals(jObject.get("format").getAsString());
}

private boolean isNumberTypeField(JsonObject jObject, String fieldValue) {

if (fieldValue != null && !fieldValue.isBlank() && jObject.get("type") != null
&& jObject.get("type").isJsonArray()) {
private boolean isNumberTypeField(JsonObject jObject) {
JsonElement jsonElement = JsonParser.parseString("number");
if (jObject.get("type") != null && jObject.get("type").isJsonArray()) {
JsonArray types = jObject.get("type").getAsJsonArray();
JsonElement jsonElement = JsonParser.parseString("number");
return types.contains(jsonElement);
}
return false;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
@EnableMethodSecurity(prePostEnabled = true)
public class SecurityConfig {

private static final String[] PUBLIC_URL = { "/ping", "/cache/**", "/*/public/**", "/api-docs/**", "/swagger-ui/**",
private static final String[] PUBLIC_URL = { "/ping", "/cache/**", "/api-docs/**", "/swagger-ui/**",
"*/swagger-ui/**", "/actuator/health/readiness", "/actuator/health/liveness", "/v3/api-docs/**" };

@Value("${keycloak.clientid}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public ProcessReportPageResponse listAllProcessReports(int page, int size) {
.findAll(PageRequest.of(page, size, Sort.by(Sort.Direction.DESC, "startDate")));
List<ProcessReport> processReports = result.get().map(mapper::mapFrom).toList();
return ProcessReportPageResponse.builder().items(processReports).pageSize(result.getSize())
.pageNumber(result.getNumber()).totalItems(result.getTotalElements()).build();
.page(result.getNumber()).totalItems(result.getTotalElements()).build();
}

public ProcessReport getProcessReportById(String id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
@NoArgsConstructor
public class ProcessReportPageResponse {

private int pageNumber;
private int page;
private int pageSize;
private long totalItems;
private List<ProcessReport> items;
Expand Down
2 changes: 2 additions & 0 deletions modules/sde-core/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ edc.hostname=
edc.managementpath=/data/v2
edc.apiKeyHeader=
edc.apiKey=
edc.dsp.endpointpath=/api/v1/dsp
edc.dataplane.endpointpath=/api/public

## EDC Consumer
edc.consumer.hostname=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.eclipse.tractusx.sde.edc.entities.request.policies.Operator;
import org.eclipse.tractusx.sde.edc.entities.request.policies.PolicyConstraintBuilderService;
import org.eclipse.tractusx.sde.edc.facilitator.ContractNegotiateManagementHelper;
import org.eclipse.tractusx.sde.edc.facilitator.EDRRequestHelper;
import org.eclipse.tractusx.sde.edc.gateways.database.ContractNegotiationInfoRepository;
import org.eclipse.tractusx.sde.edc.model.contractoffers.ContractOfferRequestFactory;
import org.eclipse.tractusx.sde.edc.model.request.ConsumerRequest;
Expand Down Expand Up @@ -89,6 +90,9 @@ class ConsumerControlPanelServiceTest {

@MockBean
private ContractOfferRequestFactory contractOfferRequestFactory;

@MockBean
private EDRRequestHelper eDRRequestHelper;

@Test
void testQueryOnDataOfferEmpty() throws Exception {
Expand Down
Loading