Skip to content

Commit 2a1f9bb

Browse files
author
Tim Bruijnzeels
authored
Merge pull request #154 from NLnetLabs/0_4_1_pre
Merge release 0.4.1
2 parents e762ace + e7ad567 commit 2a1f9bb

File tree

13 files changed

+126
-6
lines changed

13 files changed

+126
-6
lines changed

Cargo.toml

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "krill"
3-
version = "0.5.0-pre"
3+
version = "0.4.1"
44
authors = [ "The NLnet Labs RPKI team <[email protected]>" ]
55
description = "Resource Public Key Infrastructure (RPKI) daemon"
66
license = "MPL-2.0"
@@ -26,7 +26,7 @@ openssl = { version = "^0.10", features = ["v110"] }
2626
pretty = "0.5.2"
2727
rand = "^0.5"
2828
reqwest = "^0.9.17"
29-
rpki = "0.8.1"
29+
rpki = "0.8.2"
3030
serde = { version = "^1.0", features = ["derive"] }
3131
serde_json = "^1.0"
3232
syslog = "^4.0"
@@ -44,4 +44,8 @@ ignore = "^0.4"
4444

4545
[features]
4646
default = []
47-
extra-debug = [ "rpki/extra-debug" ]
47+
extra-debug = [ "rpki/extra-debug" ]
48+
49+
# Used when depending on development branches of rpki-rs or bcder
50+
#[patch.crates-io]
51+
#rpki = { git = "https://github.com/NLnetLabs/rpki-rs.git", branch = "resource-set-fix" }

Changelog.md

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
Please see [here](https://github.com/NLnetLabs/krill/projects?query=is%3Aopen+sort%3Aname-asc)
44
for planned releases.
55

6+
## 0.4.1 'Fogo de Krill'
7+
8+
This release fixes two issues:
9+
* Certain resource sets were handled incorrectly (#152)
10+
* Krill should not allow impossible max length values for ROAs (#153)
11+
12+
We recommend that all users upgrade to this release. There were no configuration or data model
13+
changes introduced, so the binary can just be used to replace any installed 0.4.0 release.
14+
615
## 0.4.0 'The Krill Factor'
716

817
This release focuses on stabilising the API and internal data format, which allows upgrades to

doc/openapi.yaml

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
openapi: "3.0.2"
22
info:
33
title: Krill RPKI Server API
4-
version: 0.4.0
4+
version: 0.4.1
55
description: |
66
# Introduction
77
Welcome to the documentation for the Krill server API, a JSON based
@@ -942,6 +942,7 @@ paths:
942942
- $ref: '#/components/schemas/InvalidROADeltaAddingDefinitionAlreadyPresent'
943943
- $ref: '#/components/schemas/InvalidROADeltaRemovingUnknownDefinition'
944944
- $ref: '#/components/schemas/InvalidROADeltaNotAllResourcesHeld'
945+
- $ref: '#/components/schemas/InvalidROADeltaInvalidMaxLength'
945946
'403':
946947
$ref: '#/components/responses/Forbidden'
947948
'404':
@@ -1495,6 +1496,18 @@ components:
14951496
msg:
14961497
type: string
14971498
example: 'Invalid ROA delta: not all resources held.'
1499+
InvalidROADeltaInvalidMaxLength:
1500+
type: object
1501+
required:
1502+
- code
1503+
- msg
1504+
properties:
1505+
code:
1506+
type: integer
1507+
enum: [2404]
1508+
msg:
1509+
type: string
1510+
example: 'Invalid ROA definition: max length not legal for prefix.'
14981511
CAHandleAlreadyInUse:
14991512
type: object
15001513
required:
@@ -1617,6 +1630,12 @@ components:
16171630
application/json:
16181631
schema:
16191632
$ref: '#/components/schemas/InvalidROADeltaNotAllResourcesHeld'
1633+
InvalidROADeltaInvalidMaxLength:
1634+
description: 'Invalid ROA delta: not all resources held.'
1635+
content:
1636+
application/json:
1637+
schema:
1638+
$ref: '#/components/schemas/InvalidROADeltaInvalidMaxLength'
16201639
GetCA:
16211640
description: Success.
16221641
content:

src/commons/api/ca.rs

+16
Original file line numberDiff line numberDiff line change
@@ -1949,4 +1949,20 @@ mod test {
19491949

19501950
assert_eq!(ncc_id_pem.pem(), ncc_id_openssl_pem);
19511951
}
1952+
1953+
#[test]
1954+
fn test_resource_set_intersection() {
1955+
let child_resources_json =
1956+
include_str!("../../../test-resources/resources/child_resources.json");
1957+
let child_resources: ResourceSet = serde_json::from_str(child_resources_json).unwrap();
1958+
1959+
let parent_resources_json =
1960+
include_str!("../../../test-resources/resources/parent_resources.json");
1961+
let parent_resouces: ResourceSet = serde_json::from_str(parent_resources_json).unwrap();
1962+
1963+
let intersection = parent_resouces.intersection(&child_resources);
1964+
1965+
assert_eq!(intersection, child_resources);
1966+
}
1967+
19521968
}

src/commons/api/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@ pub enum ErrorCode {
339339
#[display(fmt = "Invalid ROA delta: not all resources held.")]
340340
RoaUpdateInvalidResources,
341341

342+
#[display(fmt = "Invalid ROA definition: max length not legal for prefix")]
343+
RoaUpdateInvalidMaxlength,
344+
342345
// 2500s General CA issues
343346
#[display(fmt = "Unknown CA.")]
344347
UnknownCa,
@@ -410,6 +413,7 @@ impl From<usize> for ErrorCode {
410413
2401 => ErrorCode::RoaUpdateInvalidDuplicate,
411414
2402 => ErrorCode::RoaUpdateInvalidMissing,
412415
2403 => ErrorCode::RoaUpdateInvalidResources,
416+
2404 => ErrorCode::RoaUpdateInvalidMaxlength,
413417

414418
// 2500s -> General CA issues
415419
2501 => ErrorCode::DuplicateCa,
@@ -469,6 +473,7 @@ impl Into<ErrorResponse> for ErrorCode {
469473
ErrorCode::RoaUpdateInvalidDuplicate => 2401,
470474
ErrorCode::RoaUpdateInvalidMissing => 2402,
471475
ErrorCode::RoaUpdateInvalidResources => 2403,
476+
ErrorCode::RoaUpdateInvalidMaxlength => 2404,
472477

473478
// general krill ca errors
474479
ErrorCode::DuplicateCa => 2501,
@@ -524,7 +529,7 @@ mod tests {
524529
test_code(n)
525530
}
526531

527-
for n in 2401..2404 {
532+
for n in 2401..2405 {
528533
test_code(n)
529534
}
530535

src/commons/api/roas.rs

+38
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ impl RoaDefinition {
4242
pub fn max_length(&self) -> Option<u8> {
4343
self.max_length
4444
}
45+
46+
pub fn max_length_valid(&self) -> bool {
47+
if let Some(max_length) = self.max_length {
48+
match self.prefix {
49+
TypedPrefix::V4(_) => max_length >= self.prefix.addr_len() && max_length <= 32,
50+
TypedPrefix::V6(_) => max_length >= self.prefix.addr_len() && max_length <= 128,
51+
}
52+
} else {
53+
true
54+
}
55+
}
4556
}
4657

4758
impl FromStr for RoaDefinition {
@@ -446,4 +457,31 @@ mod tests {
446457
parse_ser_de_print_definition("2001:db8::/32-48 => 64496");
447458
}
448459

460+
#[test]
461+
fn roa_max_length() {
462+
fn valid_max_length(s: &str) {
463+
let def = RoaDefinition::from_str(s).unwrap();
464+
assert!(def.max_length_valid())
465+
}
466+
467+
fn invalid_max_length(s: &str) {
468+
let def = RoaDefinition::from_str(s).unwrap();
469+
assert!(!def.max_length_valid())
470+
}
471+
472+
valid_max_length("192.168.0.0/16 => 64496");
473+
valid_max_length("192.168.0.0/16-16 => 64496");
474+
valid_max_length("192.168.0.0/16-24 => 64496");
475+
valid_max_length("192.168.0.0/16-32 => 64496");
476+
valid_max_length("2001:db8::/32 => 64496");
477+
valid_max_length("2001:db8::/32-32 => 64496");
478+
valid_max_length("2001:db8::/32-48 => 64496");
479+
valid_max_length("2001:db8::/32-128 => 64496");
480+
481+
invalid_max_length("192.168.0.0/16-15 => 64496");
482+
invalid_max_length("192.168.0.0/16-33 => 64496");
483+
invalid_max_length("2001:db8::/32-31 => 64496");
484+
invalid_max_length("2001:db8::/32-129 => 64496");
485+
}
486+
449487
}

src/constants.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pub const KRILL_VERSION: &str = "0.4.0";
1+
pub const KRILL_VERSION: &str = "0.4.1";
22
pub const KRILL_SERVER_APP: &str = "Krill";
33
pub const KRILL_CLIENT_APP: &str = "Krill Client";
44

src/daemon/ca/certauth.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,12 @@ impl<S: Signer> CertAuth<S> {
13641364
self.routes.authorizations().cloned().collect();
13651365

13661366
for auth in added {
1367+
if !auth.max_length_valid() {
1368+
return Err(Error::AuthorisationInvalidMaxlength(
1369+
auth,
1370+
self.handle.clone(),
1371+
));
1372+
}
13671373
if current_auths.contains(&auth) {
13681374
return Err(Error::AuthorisationAlreadyPresent(
13691375
auth,

src/daemon/ca/error.rs

+7
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ pub enum Error {
9090
#[display(fmt = "User tries to re-add authorization '{}' for CA '{}'", _0, _1)]
9191
AuthorisationAlreadyPresent(RouteAuthorization, Handle),
9292

93+
#[display(
94+
fmt = "Invalid max length for prefix in authorization: '{}' for CA '{}",
95+
_0,
96+
_1
97+
)]
98+
AuthorisationInvalidMaxlength(RouteAuthorization, Handle),
99+
93100
#[display(
94101
fmt = "User tries to add authorization '{}' for resource not held by CA '{}'",
95102
_0,

src/daemon/endpoints.rs

+1
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ impl ToErrorCode for ca::Error {
783783
ca::Error::AuthorisationAlreadyPresent(_, _) => ErrorCode::RoaUpdateInvalidDuplicate,
784784
ca::Error::AuthorisationUnknown(_, _) => ErrorCode::RoaUpdateInvalidMissing,
785785
ca::Error::AuthorisationNotEntitled(_, _) => ErrorCode::RoaUpdateInvalidResources,
786+
ca::Error::AuthorisationInvalidMaxlength(_, _) => ErrorCode::RoaUpdateInvalidMaxlength,
786787
ca::Error::NewRepoUpdateNoChange => ErrorCode::NewRepoNoChange,
787788
ca::Error::NewRepoUpdateNotResponsive(_) => ErrorCode::NewRepoNoResponse,
788789
_ => ErrorCode::CaServerError,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"asn": "AS10906, AS11284, AS11644, AS11752, AS12136, AS14026, AS14650, AS22548, AS26162, AS53035, AS61580",
3+
"v4": "45.6.52.0/22, 45.184.144.0/22, 45.227.0.0/22, 168.181.20.0/22, 187.16.192.0/19, 189.76.96.0/19, 200.160.0.0/20, 200.189.40.0/22, 200.192.104.0/24, 200.192.108.0/22, 200.192.232.0/22, 200.194.128.0/19, 200.219.130.0/23, 200.219.138.0-200.219.141.255, 200.219.143.0-200.219.148.255, 200.219.154.0-200.219.157.255, 200.219.158.0/23, 200.229.248.0/23",
4+
"v6": "2001:12f8::/48, 2001:12f8:2::-2001:12f8:d:ffff:ffff:ffff:ffff:ffff, 2001:12fe::/31, 2801:80:1700::/40, 2801:80:1e00::/40"
5+
}

test-resources/resources/parent_resources.json

+5
Large diffs are not rendered by default.

tests/ca_roas.rs

+5
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,10 @@ fn ca_roas() {
8383
ca_roll_activate(&child);
8484
wait_for_key_roll_complete(&child);
8585
wait_for_published_objects(&child, &[crl_file, mft_file, route3_file]);
86+
87+
let route_invalid_length = RoaDefinition::from_str("10.0.0.0/24-33 => 64496").unwrap();
88+
let mut updates = RoaDefinitionUpdates::empty();
89+
updates.add(route_invalid_length);
90+
ca_route_authorizations_update_expect_error(&child, updates);
8691
});
8792
}

0 commit comments

Comments
 (0)