rasn
rasn copied to clipboard
`rasn_snmp::v2::IpAddress` allows for !=4 byte IPs whereas the RFC does not
Section 3 of the Version 2 of the Protocol Operations for the Simple Network Management Protocol (SNMP) RFC specifies IpAddress
as the following:
IpAddress ::= [APPLICATION 0] IMPLICIT OCTET STRING (SIZE (4))
which only allows 4-byte IPv4 addresses, whereas rasn_snmp::v2::IpAddress
allows for arbitrarily sized, malformed IPs:
#[test]
fn bad_ip_address() {
let ip = IpAddress {
0: OctetString::from_static(&[255, 255, 255]),
};
assert_eq!(
rasn::ber::decode::<IpAddress>(&rasn::ber::encode(&ip).unwrap()).unwrap(),
ip
);
}
Also unrelated, but I think the type alias for rasn_smi::v2::Integer32
is incorrect as well, its currently:
pub type Integer32 = u32;
but I think it should be
pub type Integer32 = i32;
since the unsigned 32-bit integer type is already covered by Gauge
and by type alias Unsigned32
Thank you for your issue! This is a known limitation currently. Rasn only guarantees that the type is a valid ASN.1 message, and doesn't do any checks for constraints, so you can receive semantically invalid messages. This will be fixed with the addition PER which requires constraints in the codec framework in order to properly encode.