From 6e09f1e7672d2a823f7f2be86d40053ee2a6d1d6 Mon Sep 17 00:00:00 2001 From: Rob Cowart Date: Sat, 13 Dec 2025 09:34:57 +0100 Subject: [PATCH 1/2] fix validator not checking discovery_attribute --- pkg/def/definitions.go | 1 + pkg/def/object.go | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/def/definitions.go b/pkg/def/definitions.go index 0178d1d..66ced12 100644 --- a/pkg/def/definitions.go +++ b/pkg/def/definitions.go @@ -1,3 +1,4 @@ +// Package def provides the definitions that are to be validated. package def import ( diff --git a/pkg/def/object.go b/pkg/def/object.go index 74d45ac..a91384e 100644 --- a/pkg/def/object.go +++ b/pkg/def/object.go @@ -16,7 +16,16 @@ type Object struct { } func (o Object) Validate() error { - return validate(o, "schemas/object.json") + if err := validate(o, "schemas/object.json"); err != nil { + return err + } + // Validate discovery_attribute exists in attributes + if o.DiscoveryAttribute != "" { + if _, ok := o.Attributes[o.DiscoveryAttribute]; !ok { + return fmt.Errorf("discovery_attribute %q not found in attributes", o.DiscoveryAttribute) + } + } + return nil } func (o Object) Kind() string { From 3c6f1ca2a6b80d602f6980fc13529f0d52b97a4a Mon Sep 17 00:00:00 2001 From: Rob Cowart Date: Sat, 13 Dec 2025 09:35:43 +0100 Subject: [PATCH 2/2] fix discovery_attribute of various BGP MIBs --- object_groups/ietf/bgp.yml | 1 + object_groups/test.yml | 28 +++++++++++++++++++++++++ objects/cumulus/CUMULUS-BGPUN-MIB.yml | 2 +- objects/cumulus/CUMULUS-BGPVRF-MIB.yml | 4 ++-- objects/ietf/BGP4-MIB.yml | 2 +- objects/juniper/BGP4-V2-MIB-JUNIPER.yml | 2 +- 6 files changed, 34 insertions(+), 5 deletions(-) diff --git a/object_groups/ietf/bgp.yml b/object_groups/ietf/bgp.yml index cb3db80..097ffd6 100644 --- a/object_groups/ietf/bgp.yml +++ b/object_groups/ietf/bgp.yml @@ -3,3 +3,4 @@ ietf_bgp: # BGP - BGP4-MIB::bgp - BGP4-MIB::bgpPeerEntry + - BGP4-MIB::bgp4PathAttrEntry diff --git a/object_groups/test.yml b/object_groups/test.yml index 67d8cc6..a08ff64 100644 --- a/object_groups/test.yml +++ b/object_groups/test.yml @@ -37,6 +37,7 @@ all: - ADSL-LINE-MIB::adslAturChanPerfDataEntry - BGP4-MIB::bgp - BGP4-MIB::bgpPeerEntry + - BGP4-MIB::bgp4PathAttrEntry - BRIDGE-MIB::dot1dBase - BRIDGE-MIB::dot1dBasePortEntry - BRIDGE-MIB::dot1dStp @@ -342,6 +343,33 @@ all: - ANDOVER-CONTROLS-MIB::accSystem # APC + - CPDU-MIB::cPDU + - CPDU-MIB::pduNamePlateEntry + - CPDU-MIB::pduUnitConfigEntry + - CPDU-MIB::pduUnitPropertiesEntry + - CPDU-MIB::pduUnitStatusEntry + - CPDU-MIB::pduUnitPsEntry + - CPDU-MIB::pduInputPhaseConfigEntry + - CPDU-MIB::pduInputPhasePropertiesEntry + - CPDU-MIB::pduInputPhaseStatusEntry + - CPDU-MIB::pduCircuitBreakerConfigEntry + - CPDU-MIB::pduCircuitBreakerPropertiesEntry + - CPDU-MIB::pduCircuitBreakerStatusEntry + - CPDU-MIB::pduOutletSwitchedConfigEntry + - CPDU-MIB::pduOutletSwitchedPropertiesEntry + - CPDU-MIB::pduOutletSwitchedStatusEntry + - CPDU-MIB::pduOutletSwitchedControlEntry + - CPDU-MIB::pduOutletMeteredConfigEntry + - CPDU-MIB::pduOutletMeteredPropertiesEntry + - CPDU-MIB::pduOutletMeteredStatusEntry + - CPDU-MIB::pduExternalSensorNamePlateEntry + - CPDU-MIB::pduExternalSensorConfigEntry + - CPDU-MIB::pduExternalSensorStatusEntry + - CPDU-MIB::pduUnitSmartCabinetEntry + - CPDU-MIB::pduUnitSmartCabinetControl + - CPDU-MIB::pduUnitSmartCabinetLockStateEntry + - CPDU-MIB::pduEhandleEntry + - CPDU-MIB::pduEhandleControlEntry - PowerNet-MIB::upsBasicBattery - PowerNet-MIB::upsAdvBattery - PowerNet-MIB::upsAdvBatteryActualVoltageEntry diff --git a/objects/cumulus/CUMULUS-BGPUN-MIB.yml b/objects/cumulus/CUMULUS-BGPUN-MIB.yml index 0ae19e1..4ee4f51 100644 --- a/objects/cumulus/CUMULUS-BGPUN-MIB.yml +++ b/objects/cumulus/CUMULUS-BGPUN-MIB.yml @@ -139,7 +139,7 @@ CUMULUS-BGPUN-MIB::bgp4PathAttrEntry: oid: .1.3.6.1.4.1.40310.4.5.1.1 name: bgp.path_attr.peer.ip.addr syntax: IpAddressNoSuffix - discovery_attribute: bgp4PathAttrIpAddrPrefixLen + discovery_attribute: bgp4PathAttrOrigin attributes: bgp4PathAttrOrigin: oid: .1.3.6.1.4.1.40310.4.5.1.4 diff --git a/objects/cumulus/CUMULUS-BGPVRF-MIB.yml b/objects/cumulus/CUMULUS-BGPVRF-MIB.yml index 9eda3b3..6600c93 100644 --- a/objects/cumulus/CUMULUS-BGPVRF-MIB.yml +++ b/objects/cumulus/CUMULUS-BGPVRF-MIB.yml @@ -14,7 +14,7 @@ CUMULUS-BGPVRF-MIB::bgpPeerEntry: oid: .1.3.6.1.4.1.40310.7.3.1.1.27 name: cumulus.bgpPeerIfindex syntax: IntegerAsID - discovery_attribute: bgpPeerIdType + discovery_attribute: bgpPeerIdentifier attributes: bgpPeerIdentifier: oid: .1.3.6.1.4.1.40310.7.3.1.1.1 @@ -146,7 +146,7 @@ CUMULUS-BGPVRF-MIB::bgp4PathAttrEntry: oid: .1.3.6.1.4.1.40310.7.5.1.1 name: bgp.path_attr.peer.ip.addr syntax: IpAddressNoSuffix - discovery_attribute: bgp4PathAttrIpAddrPrefixLen + discovery_attribute: bgp4PathAttrOrigin attributes: bgp4PathAttrOrigin: oid: .1.3.6.1.4.1.40310.7.5.1.4 diff --git a/objects/ietf/BGP4-MIB.yml b/objects/ietf/BGP4-MIB.yml index 7948f20..afd5268 100644 --- a/objects/ietf/BGP4-MIB.yml +++ b/objects/ietf/BGP4-MIB.yml @@ -149,7 +149,7 @@ BGP4-MIB::bgp4PathAttrEntry: oid: .1.3.6.1.2.1.15.6.1.1 name: bgp.path_attr.peer.ip.addr syntax: IpAddressNoSuffix - discovery_attribute: bgp4PathAttrIpAddrPrefixLen + discovery_attribute: bgp4PathAttrOrigin attributes: bgp4PathAttrOrigin: oid: .1.3.6.1.2.1.15.6.1.4 diff --git a/objects/juniper/BGP4-V2-MIB-JUNIPER.yml b/objects/juniper/BGP4-V2-MIB-JUNIPER.yml index abae455..21a05be 100644 --- a/objects/juniper/BGP4-V2-MIB-JUNIPER.yml +++ b/objects/juniper/BGP4-V2-MIB-JUNIPER.yml @@ -1,7 +1,7 @@ BGP4-V2-MIB-JUNIPER::jnxBgpM2BaseScalars: mib: BGP4-V2-MIB-JUNIPER object: jnxBgpM2BaseScalars - discovery_attribute: jnxBgpM2AsSize + discovery_attribute: jnxBgpM2LocalAs attributes: jnxBgpM2LocalAs: oid: .1.3.6.1.4.1.2636.5.1.1.1.5