-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use rpki-commons 1.37 [b509ba55d] * Fix/refactor tests. [b41f163a7] * Fix item search [12d3eda96] * Cleanup imports [74c8184cf] * Make GDPR end-point unauthorized [31af300e6] * Revert jdk-17 changes as HSM library fails on jdk-17 [c7e2bbb12] * Add checks for partOfRegistry [c6dafd599] * Fix broken test [fe1de272f] * Address review items [4f4857a70] * chore(deps): update dependency net.jqwik:jqwik to v1.8.3 [680c6ccbe] * chore(deps): update dependency io.sentry:sentry-bom to v6.34.0 [fc5f0581f] * Add more integration tests [998f4501f] * chore(deps): update dependency io.freefair.lombok:io.freefair.lombok.gradle.plugin to v8.6 [79969c3b3] * Add integration tests, fixes [ad36a87eb] * Use Lombok [a3b447ca4] * Make the test a but fancier [d378f8c83] * Code smell [707d8810a] * Naming [40c0526f9] * Change API to resemble existing CR API [6941b5fb1] * Add /api/gdpr to return some emails we store [9fcef4181] * Fix parallel GC option for java-17 [3079d441e] * Update default `JAVA_HOME` to pick java 17 [c9f4415b4] * Fix `toList` derived types [4149a7177] * chore(deps): update dependency commons-io:commons-io to v2.15.1 [580b1831b] * chore(deps): update dependency org.eclipse.jgit:org.eclipse.jgit to v5.13.3.202401111512-r [054280668] * Use latest gradle version [c2bc852f7] * Newest gradle version [e6b2436d7] * Low-handing Java 17 changes [55ab0558a] * Toolchain is needed once [33ae3a25f] * Switch to Java 17 [93ff32071] * chore(deps): update dependency commons-codec:commons-codec to v1.16.1 [69f1bba79] * Ensure tag from request is copied to response [341eb31a6] * Add test cases where publisher request contains a tag [9f0729640]
- Loading branch information
RPKI Team at RIPE NCC
committed
Mar 4, 2024
1 parent
ac2259e
commit 50451ac
Showing
24 changed files
with
431 additions
and
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
ext { | ||
rpki_commons_version = '1.36' | ||
spring_boot_version = '2.7.16' | ||
rpki_commons_version = '1.37' | ||
spring_boot_version = '2.7.18' | ||
} |
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
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
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
118 changes: 118 additions & 0 deletions
118
src/main/java/net/ripe/rpki/rest/service/GdprService.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,118 @@ | ||
package net.ripe.rpki.rest.service; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.*; | ||
import lombok.extern.slf4j.Slf4j; | ||
import net.ripe.rpki.domain.alerts.RoaAlertConfigurationRepository; | ||
import net.ripe.rpki.domain.audit.CommandAuditService; | ||
import net.ripe.rpki.server.api.dto.RoaAlertSubscriptionData; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Scope; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import javax.ws.rs.core.MediaType; | ||
import java.util.*; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
@Slf4j | ||
@Scope("prototype") | ||
@RestController | ||
@RequestMapping(path = "/api/public/gdpr", produces = MediaType.APPLICATION_JSON) | ||
@Tag(name = "/api/public/gdpr", description = "Return personal data according to GDPR") | ||
public class GdprService { | ||
private final CommandAuditService commandAuditService; | ||
private final RoaAlertConfigurationRepository roaAlertConfigurationRepository; | ||
|
||
@Autowired | ||
public GdprService(CommandAuditService commandAuditService, | ||
RoaAlertConfigurationRepository roaAlertConfigurationRepository) { | ||
this.commandAuditService = commandAuditService; | ||
this.roaAlertConfigurationRepository = roaAlertConfigurationRepository; | ||
} | ||
|
||
@PostMapping("/investigate") | ||
@Operation(summary = "Search if one or more email addresses are present in RPKI core. Endpoint called by Controlroom.") | ||
public GdprInvestigationResult investigate(@RequestBody GdprRequest req) { | ||
var subscriptionEmails = new HashMap<String, List<String>>(); | ||
var reports = new ArrayList<GdprReport>(); | ||
var partOfRegistry = new AtomicBoolean(false); | ||
|
||
req.emails.stream().distinct().forEach(email -> { | ||
roaAlertConfigurationRepository.findByEmail(email).forEach(rac -> { | ||
RoaAlertSubscriptionData subscriptionOrNull = rac.getSubscriptionOrNull(); | ||
if (subscriptionOrNull != null) { | ||
subscriptionOrNull.getEmails().forEach(email1 -> | ||
subscriptionEmails.compute(email1, (e, caNames) -> { | ||
if (caNames == null) { | ||
caNames = new ArrayList<>(1); | ||
} | ||
caNames.add(rac.getCertificateAuthority().getName().getName()); | ||
return caNames; | ||
})); | ||
} | ||
}); | ||
|
||
var caNames = subscriptionEmails.get(email); | ||
if (caNames != null) { | ||
var cas = String.join(", ", caNames); | ||
reports.add(new GdprReport("Subscription", | ||
"Subscribed '" + email + "' for alerts for the CA(s) " + cas, (long) caNames.size())); | ||
} | ||
|
||
Map<String, Long> mentionsInSummary = commandAuditService.findMentionsInSummary(email); | ||
if (!mentionsInSummary.isEmpty()) { | ||
partOfRegistry.set(true); | ||
} | ||
mentionsInSummary.forEach((commandType, mentionCount) -> | ||
reports.add(new GdprReport( | ||
commandType, | ||
"'" + email + "' found in the history of commands of type " + commandType, | ||
mentionCount))); | ||
}); | ||
|
||
if (req.id != null) { | ||
Map<String, Long> mentionsInSummary = commandAuditService.findMentionsInSummary(req.id.toString()); | ||
if (!mentionsInSummary.isEmpty()) { | ||
partOfRegistry.set(true); | ||
} | ||
mentionsInSummary.forEach((commandType, mentionCount) -> | ||
reports.add(new GdprReport( | ||
commandType, | ||
"'" + req.id + "' found in the history of commands of type " + commandType, | ||
mentionCount))); | ||
} | ||
|
||
return new GdprInvestigationResult( | ||
reports, | ||
reports.stream().anyMatch(r -> r.getOccurrences() > 0), | ||
partOfRegistry.get()); | ||
} | ||
|
||
@Builder | ||
@Getter | ||
public static class GdprReport { | ||
private final String name; | ||
private final String description; | ||
private final Long occurrences; | ||
} | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class GdprRequest { | ||
private UUID id; | ||
private List<String> emails; | ||
} | ||
|
||
@Builder | ||
@Getter | ||
public static class GdprInvestigationResult { | ||
private List<GdprReport> reports; | ||
private Boolean anyMatch; | ||
private Boolean partOfRegistry; | ||
} | ||
} |
Oops, something went wrong.