-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* SecHub - described concept of data encryption #3250 - Introduced sechub-encryption #3273 + update bouncy castle version #3275 - encryption implementation are now inside own gradle sub module "sechub-encryption" - refacotred sechub encryption library #3274 - implemented data encryption inside SecHub #3250 - restricted access and storage, avoid using configuration when not absolut necessary - created dedicated job message which contains unencrypted configuration at runtime. Only one message uses this one -> clear not accidently used on another code location - created migration scripts, seperated pool id generation for h2 and postgres because of binary type. Also postgres will migrate old data automatically to NoneCipher variant (means no real encryption, but admin will be able to rotate keys...) - wrote tests - introduced new usecases - new REST APIs introduced - added integration test for encryption rotation - added developer admin ui actions - auto cleanup does also auto clean old unused encryption pool data - Scheduler now only executes for accepted encryption pool ids #3250 - Updated open api file for encryption parts #3250 * PDS - implemented data encryption + documentation #3264 - NONE is default cipher encryption, means startup possible without encryption - summary log service shows encryption algorithm - handled encryption out of sync problems on PDS side and at SecHub side
- Loading branch information
Showing
326 changed files
with
10,847 additions
and
3,306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...ds/src/main/java/com/mercedesbenz/sechub/adapter/pds/PDSEncryptionOutOfSyncException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.mercedesbenz.sechub.adapter.pds; | ||
|
||
public class PDSEncryptionOutOfSyncException extends Exception { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...benz/sechub/domain/administration/encryption/AdministrationEncryptionRotationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// SPDX-License-Identifier: MIT | ||
package com.mercedesbenz.sechub.domain.administration.encryption; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import com.mercedesbenz.sechub.sharedkernel.Step; | ||
import com.mercedesbenz.sechub.sharedkernel.UserContextService; | ||
import com.mercedesbenz.sechub.sharedkernel.encryption.SecHubEncryptionData; | ||
import com.mercedesbenz.sechub.sharedkernel.encryption.SecHubEncryptionDataValidator; | ||
import com.mercedesbenz.sechub.sharedkernel.logging.AuditLogService; | ||
import com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage; | ||
import com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessageService; | ||
import com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage; | ||
import com.mercedesbenz.sechub.sharedkernel.messaging.MessageDataKeys; | ||
import com.mercedesbenz.sechub.sharedkernel.messaging.MessageID; | ||
import com.mercedesbenz.sechub.sharedkernel.usecases.encryption.UseCaseAdminStartsEncryptionRotation; | ||
|
||
@Service | ||
public class AdministrationEncryptionRotationService { | ||
|
||
@Autowired | ||
DomainMessageService domainMessageService; | ||
|
||
@Autowired | ||
SecHubEncryptionDataValidator validator; | ||
|
||
@Autowired | ||
AuditLogService auditLogService; | ||
|
||
@Autowired | ||
UserContextService userContextService; | ||
|
||
@UseCaseAdminStartsEncryptionRotation(@Step(number = 2, name = "Service call", description = "Triggers rotation of encryption via domain message")) | ||
@IsSendingAsyncMessage(MessageID.START_ENCRYPTION_ROTATION) | ||
public void rotateEncryption(SecHubEncryptionData data) { | ||
if (data == null) { | ||
throw new IllegalArgumentException("data may not be null!"); | ||
} | ||
auditLogService.log("started encryption rotation. New cipher algorithm will be: {}, datasource type:{}, datasource: {}", data.getAlgorithm(), | ||
data.getPasswordSourceType(), data.getPasswordSourceData()); | ||
|
||
String executedBy = userContextService.getUserId(); | ||
|
||
DomainMessage message = new DomainMessage(MessageID.START_ENCRYPTION_ROTATION); | ||
message.set(MessageDataKeys.SECHUB_ENCRYPT_ROTATION_DATA, data); | ||
message.set(MessageDataKeys.EXECUTED_BY, executedBy); | ||
|
||
domainMessageService.sendAsynchron(message); | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
...esbenz/sechub/domain/administration/encryption/AdministrationEncryptionStatusService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// SPDX-License-Identifier: MIT | ||
package com.mercedesbenz.sechub.domain.administration.encryption; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import com.mercedesbenz.sechub.sharedkernel.Step; | ||
import com.mercedesbenz.sechub.sharedkernel.encryption.SecHubDomainEncryptionStatus; | ||
import com.mercedesbenz.sechub.sharedkernel.encryption.SecHubEncryptionStatus; | ||
import com.mercedesbenz.sechub.sharedkernel.logging.AuditLogService; | ||
import com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage; | ||
import com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessageService; | ||
import com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessageSynchronousResult; | ||
import com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingSyncMessage; | ||
import com.mercedesbenz.sechub.sharedkernel.messaging.MessageDataKeys; | ||
import com.mercedesbenz.sechub.sharedkernel.messaging.MessageID; | ||
import com.mercedesbenz.sechub.sharedkernel.usecases.encryption.UseCaseAdminFetchesEncryptionStatus; | ||
|
||
@Service | ||
public class AdministrationEncryptionStatusService { | ||
|
||
@Autowired | ||
DomainMessageService domainMessageService; | ||
|
||
@Autowired | ||
AuditLogService auditLogService; | ||
|
||
@UseCaseAdminFetchesEncryptionStatus(@Step(number = 1, name = "Service call", description = "Services collects encryption status from domains via event bus")) | ||
public SecHubEncryptionStatus fetchStatus() { | ||
auditLogService.log("starts collecting encryption status"); | ||
|
||
SecHubEncryptionStatus sechubEncryptionStatus = new SecHubEncryptionStatus(); | ||
collectScheduleEncryptionStatus(sechubEncryptionStatus); | ||
|
||
return sechubEncryptionStatus; | ||
|
||
} | ||
|
||
@IsSendingSyncMessage(MessageID.GET_ENCRYPTION_STATUS_SCHEDULE_DOMAIN) | ||
private void collectScheduleEncryptionStatus(SecHubEncryptionStatus status) { | ||
DomainMessage message = new DomainMessage(MessageID.GET_ENCRYPTION_STATUS_SCHEDULE_DOMAIN); | ||
|
||
DomainMessageSynchronousResult result = domainMessageService.sendSynchron(message); | ||
SecHubDomainEncryptionStatus schedulerStatus = result.get(MessageDataKeys.SECHUB_DOMAIN_ENCRYPTION_STATUS); | ||
|
||
status.getDomains().add(schedulerStatus); | ||
} | ||
|
||
} |
70 changes: 70 additions & 0 deletions
70
...sbenz/sechub/domain/administration/encryption/EncryptionAdministrationRestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// SPDX-License-Identifier: MIT | ||
package com.mercedesbenz.sechub.domain.administration.encryption; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.bind.WebDataBinder; | ||
import org.springframework.web.bind.annotation.InitBinder; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.mercedesbenz.sechub.domain.administration.AdministrationAPIConstants; | ||
import com.mercedesbenz.sechub.sharedkernel.Profiles; | ||
import com.mercedesbenz.sechub.sharedkernel.RoleConstants; | ||
import com.mercedesbenz.sechub.sharedkernel.Step; | ||
import com.mercedesbenz.sechub.sharedkernel.encryption.SecHubEncryptionData; | ||
import com.mercedesbenz.sechub.sharedkernel.encryption.SecHubEncryptionDataValidator; | ||
import com.mercedesbenz.sechub.sharedkernel.encryption.SecHubEncryptionStatus; | ||
import com.mercedesbenz.sechub.sharedkernel.usecases.encryption.UseCaseAdminFetchesEncryptionStatus; | ||
import com.mercedesbenz.sechub.sharedkernel.usecases.encryption.UseCaseAdminStartsEncryptionRotation; | ||
|
||
import jakarta.annotation.security.RolesAllowed; | ||
import jakarta.validation.Valid; | ||
|
||
/** | ||
* The rest api for encryption done by a super admin. | ||
* | ||
* @author Albert Tregnaghi | ||
* | ||
*/ | ||
@RestController | ||
@EnableAutoConfiguration | ||
@RolesAllowed(RoleConstants.ROLE_SUPERADMIN) | ||
@Profile({ Profiles.TEST, Profiles.ADMIN_ACCESS }) | ||
public class EncryptionAdministrationRestController { | ||
|
||
@Autowired | ||
AdministrationEncryptionRotationService administrationEncryptionRotationService; | ||
|
||
@Autowired | ||
AdministrationEncryptionStatusService administrationStatusService; | ||
|
||
@Autowired | ||
SecHubEncryptionDataValidator encryptionDataValidator; | ||
|
||
/* @formatter:off */ | ||
@UseCaseAdminStartsEncryptionRotation(@Step(number=1,name="Rest call",description="Admin triggers rotation of encryption via REST", needsRestDoc =true)) | ||
@RequestMapping(path = AdministrationAPIConstants.API_ADMIN_ENCRYPTION_ROTATION, method = RequestMethod.POST, produces= {MediaType.APPLICATION_JSON_VALUE}) | ||
public void rotateEncryption(@RequestBody @Valid SecHubEncryptionData data) { | ||
/* @formatter:on */ | ||
administrationEncryptionRotationService.rotateEncryption(data); | ||
} | ||
|
||
/* @formatter:off */ | ||
@UseCaseAdminFetchesEncryptionStatus(@Step(number=1,name="Rest call",description="Admin fetches encryption status from domains via REST", needsRestDoc =true)) | ||
@RequestMapping(path = AdministrationAPIConstants.API_ADMIN_ENCRYPTION_STATUS, method = RequestMethod.GET, produces= {MediaType.APPLICATION_JSON_VALUE}) | ||
public SecHubEncryptionStatus fetchEncryptionStatus() { | ||
/* @formatter:on */ | ||
return administrationStatusService.fetchStatus(); | ||
} | ||
|
||
@InitBinder | ||
protected void initBinder(WebDataBinder binder) { | ||
binder.setValidator(encryptionDataValidator); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.