Search in sources :

Example 21 with ValidationRun

use of net.ripe.rpki.validator3.domain.ValidationRun in project rpki-validator-3 by RIPE-NCC.

the class TrustAnchorController method validationResults.

@GetMapping(path = "/{id}/validation-run")
public ResponseEntity<ApiResponse<ValidationRunResource>> validationResults(@PathVariable long id, HttpServletResponse response, Locale locale) throws IOException {
    TrustAnchor trustAnchor = trustAnchorRepository.get(id);
    ValidationRun validationRun = validationRunRepository.findLatestCompletedForTrustAnchor(trustAnchor).orElseThrow(() -> new EmptyResultDataAccessException("latest validation run for trust anchor " + id, 1));
    response.sendRedirect(linkTo(methodOn(ValidationRunController.class).get(validationRun.getId(), locale)).toString());
    return null;
}
Also used : ValidationRun(net.ripe.rpki.validator3.domain.ValidationRun) TrustAnchorValidationRun(net.ripe.rpki.validator3.domain.TrustAnchorValidationRun) TrustAnchor(net.ripe.rpki.validator3.domain.TrustAnchor) EmptyResultDataAccessException(org.springframework.dao.EmptyResultDataAccessException) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 22 with ValidationRun

use of net.ripe.rpki.validator3.domain.ValidationRun in project rpki-validator-3 by RIPE-NCC.

the class RrdpService method doStoreRepository.

private void doStoreRepository(RpkiRepository rpkiRepository, RpkiRepositoryValidationRun validationRun) {
    final Notification notification = rrdpClient.readStream(rpkiRepository.getRrdpNotifyUri(), rrdpParser::notification);
    log.info("The local serial is '{}' and the latest serial is {}", rpkiRepository.getRrdpSerial(), notification.serial);
    if (notification.sessionId.equals(rpkiRepository.getRrdpSessionId())) {
        if (rpkiRepository.getRrdpSerial().compareTo(notification.serial) <= 0) {
            try {
                final List<Delta> deltas = notification.deltas.parallelStream().filter(d -> d.getSerial().compareTo(rpkiRepository.getRrdpSerial()) > 0).sorted(Comparator.comparing(DeltaInfo::getSerial)).map(di -> readDelta(notification, di)).collect(Collectors.toList());
                verifyDeltaSerials(deltas, notification, rpkiRepository);
                deltas.forEach(d -> {
                    storeDelta(d, validationRun);
                    rpkiRepository.setRrdpSerial(rpkiRepository.getRrdpSerial().add(BigInteger.ONE));
                });
            } catch (RrdpException e) {
                log.info("Processing deltas failed {}, falling back to snapshot processing.", e.getMessage());
                ValidationCheck validationCheck = new ValidationCheck(validationRun, rpkiRepository.getRrdpNotifyUri(), ValidationCheck.Status.WARNING, ErrorCodes.RRDP_FETCH_DELTAS, e.getMessage());
                validationRun.addCheck(validationCheck);
                readSnapshot(rpkiRepository, validationRun, notification);
            }
        }
    } else {
        log.info("Repository has session id '{}' but the downloaded version has session id '{}', fetching the snapshot", rpkiRepository.getRrdpSessionId(), notification.sessionId);
        readSnapshot(rpkiRepository, validationRun, notification);
    }
}
Also used : RpkiRepository(net.ripe.rpki.validator3.domain.RpkiRepository) Arrays(java.util.Arrays) CertificateRepositoryObject(net.ripe.rpki.commons.crypto.CertificateRepositoryObject) Transactional(javax.transaction.Transactional) RpkiRepositoryValidationRun(net.ripe.rpki.validator3.domain.RpkiRepositoryValidationRun) Hex(net.ripe.rpki.validator3.util.Hex) RpkiObject(net.ripe.rpki.validator3.domain.RpkiObject) Autowired(org.springframework.beans.factory.annotation.Autowired) Collectors(java.util.stream.Collectors) CertificateRepositoryObjectFactory(net.ripe.rpki.commons.crypto.util.CertificateRepositoryObjectFactory) ErrorCodes(net.ripe.rpki.validator3.domain.ErrorCodes) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) ByteArrayInputStream(java.io.ByteArrayInputStream) RpkiObjects(net.ripe.rpki.validator3.domain.RpkiObjects) Service(org.springframework.stereotype.Service) ValidationResult(net.ripe.rpki.commons.validation.ValidationResult) Optional(java.util.Optional) BigInteger(java.math.BigInteger) Sha256(net.ripe.rpki.validator3.util.Sha256) Either(fj.data.Either) Comparator(java.util.Comparator) ValidationCheck(net.ripe.rpki.validator3.domain.ValidationCheck) ValidationCheck(net.ripe.rpki.validator3.domain.ValidationCheck)

Example 23 with ValidationRun

use of net.ripe.rpki.validator3.domain.ValidationRun in project rpki-validator-3 by RIPE-NCC.

the class RrdpService method addRpkiObject.

private void addRpkiObject(RpkiRepositoryValidationRun validationRun, String uri, DeltaPublish deltaPublish, final byte[] existingHash) {
    final Either<ValidationResult, RpkiObject> maybeRpkiObject = createRpkiObject(uri, deltaPublish.getContent());
    if (maybeRpkiObject.isLeft()) {
        validationRun.addChecks(maybeRpkiObject.left().value());
    } else {
        RpkiObject object = maybeRpkiObject.right().value();
        if (existingHash == null || !Arrays.equals(object.getSha256(), existingHash)) {
            validationRun.addRpkiObject(object);
            rpkiObjectRepository.add(object);
        } else {
            log.debug("The object added is the same {}", object);
        }
        log.debug("Added to database {}", object);
    }
}
Also used : RpkiObject(net.ripe.rpki.validator3.domain.RpkiObject) ValidationResult(net.ripe.rpki.commons.validation.ValidationResult)

Aggregations

TrustAnchor (net.ripe.rpki.validator3.domain.TrustAnchor)16 RpkiObject (net.ripe.rpki.validator3.domain.RpkiObject)15 RpkiRepository (net.ripe.rpki.validator3.domain.RpkiRepository)15 ValidationCheck (net.ripe.rpki.validator3.domain.ValidationCheck)14 IntegrationTest (net.ripe.rpki.validator3.IntegrationTest)13 Test (org.junit.Test)13 RpkiObjects (net.ripe.rpki.validator3.domain.RpkiObjects)12 RrdpRepositoryValidationRun (net.ripe.rpki.validator3.domain.RrdpRepositoryValidationRun)11 TestObjects (net.ripe.rpki.validator3.TestObjects)9 ValidationResult (net.ripe.rpki.commons.validation.ValidationResult)7 Transactional (javax.transaction.Transactional)6 ErrorCodes (net.ripe.rpki.validator3.domain.ErrorCodes)5 TrustAnchorValidationRun (net.ripe.rpki.validator3.domain.TrustAnchorValidationRun)5 Hex (net.ripe.rpki.validator3.util.Hex)5 Sha256 (net.ripe.rpki.validator3.util.Sha256)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 BigInteger (java.math.BigInteger)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 RpkiRepositoryValidationRun (net.ripe.rpki.validator3.domain.RpkiRepositoryValidationRun)4