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

Route ROA checker #1416

Merged
merged 55 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
111a76c
feat: create new warning for roas check and test for legacy
MiguelAHM Mar 27, 2024
2a78606
feat: add test for REST API calls and little refactor to specify rest…
MiguelAHM Mar 27, 2024
88a4b53
feat: fix ITs
MiguelAHM Mar 28, 2024
bafe2de
feat: add more tests
MiguelAHM Mar 28, 2024
e5493f1
feat: create the validator
MiguelAHM Mar 28, 2024
39b5818
feat: fix compile error due to previous code
MiguelAHM Mar 28, 2024
0b0fb2a
feat: renaming and deleting white spaces
MiguelAHM Mar 28, 2024
61db61e
feat: fix tests according to last changes
MiguelAHM Mar 28, 2024
c44316d
feat: fix conflicts
MiguelAHM Apr 3, 2024
c27dd40
feat: remove already migrated classes
MiguelAHM Apr 3, 2024
2db7bc5
feat: change generator by validator
MiguelAHM Apr 3, 2024
607a329
Merge branch 'master' into DB-5291-flag-route-roa-validator
MiguelAHM Apr 3, 2024
ea8abb6
feat: fix compilation errors
MiguelAHM Apr 3, 2024
095701f
feat: increase testperformance to 3s
MiguelAHM Apr 4, 2024
f386982
feat: put timeout back to 2s and fix compilation issue in whoisFixture
MiguelAHM Apr 4, 2024
24cbc26
feat: fix compilation issues
MiguelAHM Apr 4, 2024
14b95be
feat: fix ITs
MiguelAHM Apr 4, 2024
f45fc79
feat: refactor messages and PR comments
MiguelAHM Apr 4, 2024
e844ec2
feat: fix ITs
MiguelAHM Apr 5, 2024
169397b
feat: refactor
MiguelAHM Apr 5, 2024
ad5c241
Merge branch 'master' into DB-5291-flag-route-roa-validator
MiguelAHM Apr 5, 2024
72e3c34
feat: rename
MiguelAHM Apr 5, 2024
43b4b86
Merge branch 'master' into DB-5291-flag-route-roa-validator
MiguelAHM Apr 5, 2024
4f24215
feat: rename
MiguelAHM Apr 5, 2024
da65fed
Merge branch 'master' into DB-5291-flag-route-roa-validator
MiguelAHM Apr 8, 2024
4059fd4
Return 404 on invalid NRTMv4 notification file path (#1422)
maggarwal13 Apr 8, 2024
c40ee90
Merge branch 'master' into DB-5291-flag-route-roa-validator
MiguelAHM Apr 8, 2024
d58fe00
feat: fix logger issue (#1427)
MiguelAHM Apr 9, 2024
04c8bc3
Merge branch 'master' into DB-5291-flag-route-roa-validator
MiguelAHM Apr 9, 2024
ce0a9ee
remove_unused_code (#1429)
maggarwal13 Apr 9, 2024
11d66b2
Revert changes to thread configuration in tests (#1415)
eshryane Apr 9, 2024
af967b6
Handle Multiple Delivery Status Notification Failure Responses for th…
MiguelAHM Apr 10, 2024
83f0ab3
Merge branch 'master' into DB-5291-flag-route-roa-validator
MiguelAHM Apr 10, 2024
76d9535
Fix tests (#1433)
maggarwal13 Apr 10, 2024
56dbc2e
reduce mariadb innodb memory usage to 1GB (#1439)
eshryane Apr 11, 2024
a610dcb
Set memory limit for test elasticsearch instance (#1436)
fmurodov Apr 11, 2024
a4ca185
Merge branch 'master' into DB-5291-flag-route-roa-validator
MiguelAHM Apr 11, 2024
6bcf6f4
feat: renaming, revert ErrorMessages changes, change the query flag, …
MiguelAHM Apr 11, 2024
5590d8f
Merge branch 'master' into DB-5291-flag-route-roa-validator
MiguelAHM Apr 11, 2024
2aa2f02
feat: use a queryParameter instead of queryFlag
MiguelAHM Apr 11, 2024
ce6770c
feat: add stopwatch to monitor the performance of RPKI service
MiguelAHM Apr 12, 2024
f7b54de
feat: add missing return
MiguelAHM Apr 12, 2024
3d54e92
feat: rpki service should be a @Service and RpkiRoaChecker a componen…
MiguelAHM Apr 12, 2024
c9afd37
Merge branch 'master' into DB-5291-flag-route-roa-validator
MiguelAHM Apr 12, 2024
490defd
feat: remove unused imports
MiguelAHM Apr 12, 2024
2369c73
Merge branch 'master' into DB-5291-flag-route-roa-validator
MiguelAHM Apr 15, 2024
1c91ba6
feat: ignore roa update if there is an error with the call
MiguelAHM Apr 15, 2024
0b0912b
feat: align errormessages name with objectmessages, same format
MiguelAHM Apr 15, 2024
43a9df9
feat: fix lookup case, when roa-checker is not a parameter
MiguelAHM Apr 15, 2024
0594bc7
Merge branch 'master' into DB-5291-flag-route-roa-validator
MiguelAHM Apr 15, 2024
fe2692f
feat: pass the type as parameter for the message and create two test …
MiguelAHM Apr 15, 2024
b877d56
Merge branch 'master' into DB-5291-flag-route-roa-validator
MiguelAHM Apr 15, 2024
89cf578
Merge branch 'master' into DB-5291-flag-route-roa-validator
MiguelAHM Apr 16, 2024
482b831
feat: return different messages per use case; origin fail, prefix len…
MiguelAHM Apr 16, 2024
353bfc1
feat: change warning message
MiguelAHM Apr 16, 2024
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package net.ripe.db.whois.api.rest;

import com.google.common.collect.Lists;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.StreamingOutput;
import net.ripe.db.whois.api.rest.client.StreamingException;
import net.ripe.db.whois.api.rest.domain.Link;
import net.ripe.db.whois.api.rest.domain.Parameters;
Expand Down Expand Up @@ -29,10 +33,6 @@
import org.springframework.stereotype.Component;

import javax.annotation.Nullable;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.StreamingOutput;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
Expand Down Expand Up @@ -193,6 +193,7 @@ private void streamObject(@Nullable final RpslObject rpslObject) {
whoisObjectServerMapper.mapAbuseContact(whoisObject, parameters, rpslObject);
whoisObjectServerMapper.mapManagedAttributes(whoisObject, parameters, rpslObject);
whoisObjectServerMapper.mapResourceHolder(whoisObject, parameters, rpslObject);
whoisObjectServerMapper.mapObjectInfoMessages(whoisObject, parameters, rpslObject);

if (streamingMarshal instanceof StreamingMarshalTextPlain) {
streamingMarshal.writeArray(rpslObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
import net.ripe.db.whois.api.rest.domain.WhoisObject;
import net.ripe.db.whois.api.rest.domain.WhoisVersion;
import net.ripe.db.whois.api.rest.search.AbuseContactSearch;
import net.ripe.db.whois.common.search.ManagedAttributeSearch;
import net.ripe.db.whois.api.rest.search.ResourceHolderSearch;
import net.ripe.db.whois.api.rest.search.RestApiInfoMessageValidator;
import net.ripe.db.whois.common.domain.serials.Operation;
import net.ripe.db.whois.common.rpsl.RpslAttribute;
import net.ripe.db.whois.common.rpsl.RpslObject;
import net.ripe.db.whois.common.search.ManagedAttributeSearch;
import net.ripe.db.whois.query.domain.DeletedVersionResponseObject;
import net.ripe.db.whois.query.domain.VersionResponseObject;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -28,16 +29,20 @@ public class WhoisObjectServerMapper {
private final AbuseContactSearch abuseContactSearch;
private final ManagedAttributeSearch managedAttributeSearch;

private final List<RestApiInfoMessageValidator> infoMessageValidators;

@Autowired
public WhoisObjectServerMapper(
final WhoisObjectMapper whoisObjectMapper,
final ResourceHolderSearch resourceHolderSearch,
final AbuseContactSearch abuseContactSearch,
final ManagedAttributeSearch managedAttributeSearch) {
final ManagedAttributeSearch managedAttributeSearch,
final List<RestApiInfoMessageValidator> infoMessageValidators) {
this.whoisObjectMapper = whoisObjectMapper;
this.resourceHolderSearch = resourceHolderSearch;
this.abuseContactSearch = abuseContactSearch;
this.managedAttributeSearch = managedAttributeSearch;
this.infoMessageValidators = infoMessageValidators;
}

public List<WhoisVersion> mapVersions(final List<DeletedVersionResponseObject> deleted, final List<VersionResponseObject> versions) {
Expand Down Expand Up @@ -71,6 +76,12 @@ public void mapAbuseContact(final WhoisObject whoisObject, final Parameters para
}
}

public void mapObjectInfoMessages(final WhoisObject whoisObject, final Parameters parameters, final RpslObject rpslObject){
final List<String> infoMessagesFormatted = Lists.newArrayList();
infoMessageValidators.forEach(infoMessageValidator -> infoMessageValidator.validate(rpslObject, parameters, infoMessagesFormatted));
whoisObject.setObjectInfoMessages(infoMessagesFormatted);
}

public void mapManagedAttributes(final WhoisObject whoisObject, final Parameters parameters, final RpslObject rpslObject) {
if (Boolean.TRUE.equals(parameters.getManagedAttributes())) {
whoisObject.setManaged(managedAttributeSearch.isCoMaintained(rpslObject));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package net.ripe.db.whois.api.rest.search;

import net.ripe.db.whois.api.rest.domain.Parameters;
import net.ripe.db.whois.common.rpsl.RpslObject;

import java.util.List;

public interface RestApiInfoMessageValidator {
MiguelAHM marked this conversation as resolved.
Show resolved Hide resolved

void validate(final RpslObject rpslObject, final Parameters parameters, final List<String> messages);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package net.ripe.db.whois.api.rest.search;

import com.google.common.collect.ImmutableList;
import net.ripe.db.whois.api.rest.domain.Flag;
import net.ripe.db.whois.api.rest.domain.Flags;
import net.ripe.db.whois.api.rest.domain.Parameters;
import net.ripe.db.whois.common.rpsl.ObjectType;
import net.ripe.db.whois.common.rpsl.RpslObject;
import net.ripe.db.whois.query.QueryMessages;
import net.ripe.db.whois.query.rpki.Roa;
import net.ripe.db.whois.query.rpki.RpkiDataProvider;
import net.ripe.db.whois.query.rpki.RpkiService;
import net.ripe.db.whois.query.rpki.WhoisRoaChecker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.List;

import static net.ripe.db.whois.query.QueryFlag.ROA_VALIDATION;

@Component
public class RpkiRoaValidator implements RestApiInfoMessageValidator {

private static final ImmutableList<ObjectType> TYPES = ImmutableList.of(ObjectType.ROUTE, ObjectType.ROUTE6);
private final boolean isRoaChecker;

private final RpkiDataProvider rpkiDataProvider;

@Autowired
public RpkiRoaValidator(@Value("${roa.validator.available:false}") boolean isRoaChecker, final RpkiDataProvider dataProvider) {
this.isRoaChecker = isRoaChecker;
this.rpkiDataProvider = dataProvider;
}

@Override
public void validate(final RpslObject rpslObject, final Parameters parameters, final List<String> messages) {
if (!canProceed(rpslObject, parameters)){
return;
}
validateRoa(rpslObject, messages);
}

private boolean canProceed(final RpslObject rpslObject, final Parameters parameters){
return isRoaChecker && hasRoaValidationFlag(parameters.getFlags()) && TYPES.contains(rpslObject.getType());
}

private boolean hasRoaValidationFlag(Flags flags){
return flags.getFlags().contains(new Flag(ROA_VALIDATION));
}

private void validateRoa(final RpslObject rpslObject, final List<String> messages){
final Roa rpkiRoa = new WhoisRoaChecker(new RpkiService(rpkiDataProvider)).validateAndGetInvalidRoa(rpslObject);

if (rpkiRoa != null){
messages.add(QueryMessages.roaRouteConflicts(rpkiRoa.getAsn()).getFormattedText());
}
}
}
Loading