NETCONF A. Elhassany Internet-Draft Swisscom Intended status: Standards Track 17 March 2024 Expires: 18 September 2024 Validating anydata in YANG Library context draft-aelhassany-anydata-validation-01 Abstract This document describes a method to use YANG Library [RFC8525] to validate YANG data nodes that are children of an "anydata" data node. Status of This Memo This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet- Drafts is at https://datatracker.ietf.org/drafts/current/. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." This Internet-Draft will expire on 18 September 2024. Copyright Notice Copyright (c) 2024 IETF Trust and the persons identified as the document authors. All rights reserved. This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/ license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Revised BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Revised BSD License. Elhassany Expires 18 September 2024 [Page 1] Internet-Draft anydata validation March 2024 Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 1.1. Requirements Language . . . . . . . . . . . . . . . . . . 3 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 3 3. Validating "anydata" Data Tree . . . . . . . . . . . . . . . 3 4. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 4 5. Security Considerations . . . . . . . . . . . . . . . . . . . 4 6. References . . . . . . . . . . . . . . . . . . . . . . . . . 4 6.1. Normative References . . . . . . . . . . . . . . . . . . 4 6.2. Informative References . . . . . . . . . . . . . . . . . 4 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 5 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 5 1. Introduction YANG [RFC7950] defines the "anydata" statement to represent an unknown set of YANG nodes for which the data model is not known at module design time. However, YANG [RFC7950] left the verification of the "anydata" tree open to be done using external means. Several IETF models, e.g., [RFC8526], [RFC9144], [RFC8639], [RFC8641], and [RFC8040], use "anydata" in their definitions. Current YANG implementations accept syntactically valid YANG data nodes as children of an "anydata" node but do not check the data type of these data nodes against a YANG schema. This creates a real problem for any consumer of these models when validating all leaves of the YANG data tree. For instance, a YANG-Push receiver described in [I-D.netana-nmop-yang-kafka-integration] is not able to fully validate the messages streamed by network nodes. YANG Schema Mount [RFC8528] allows mounting complete data models at implementation and run time. While powerful, schema mount cannot address use cases where the user selects an arbitrary subset of an instantiated data tree, such as YANG-Push [RFC8641]. A current proposed approach, YANG Full Include YANG Full Include [I-D.jouqui-netmod-yang-full-include], complements YANG Schema Mount and applies at design time, yet cannot address dynamic filtering of an instantiated YANG data tree. This document propeses using the YANG Library [RFC8525] to define the context in which anydata trees are validated. This would require the YANG tooling to implement an optional flag that enables a flag for validating "anydata" subtrees in the context of a YANG Library. Elhassany Expires 18 September 2024 [Page 2] Internet-Draft anydata validation March 2024 1.1. Requirements Language The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here. 2. Terminology This document uses the terminology defined in YANG [RFC7950] for schema node and schema tree but refines data node and data tree to be more precise. * data node: A node in the schema tree that can be instantiated in a data tree. One of container, leaf, leaf-list, list, anydata, and anyxml. This document does not change how YANG handles anyxml data nodes. * instantiated data node: an instantiated instance of a data node that contains before fully qualified name (module namespace + identifier) for the data node and the data modeled within YANG. * instantiated data tree: is what YANG [RFC7950] defines as "data tree". Adding the term "instantiated" precisely indicates that this tree is an instance of specific data modeled with YANG. * data tree: a tree of data nodes (with no values). 3. Validating "anydata" Data Tree The current YANG encodings, XML, JSON, and CBOR, encode instantiated data nodes with fully qualified name using the module's namespace and a local name. The module's namespace can be either explicit or assumed from a default namespace defined in the top data tree. This document introduces a new YANG validation option: anydata- subtree-validation. In this mode, a YANG data parser MUST accept a YANG Library as input along the YANG data file. When this option is enabled, any instantiated data node (NodeB) that is a child of anydata node (NodeA) is accepted to be valid only if (i) the qualified name of the node NodeB is found in one of the data trees defined by the YANG library AND (ii) the instantiated data tree rooted by NodeB is valid incomplete instantiated data tree according to the data node of NodeB. Elhassany Expires 18 September 2024 [Page 3] Internet-Draft anydata validation March 2024 The first condition ensures the completeness of the YANG Library, and no subtree can be included as a child of anydata node unless a schema is defined for all the children of anydata subtree and specified in the YANG Library. The second condition applies a regular YANG validation against the subtree of anydata, considering that the subtree of anydata could be generated using an XPath [RFC8641] or a subtree filter [RFC6241]. Thus, the validator MUST consider this subtree incomplete and ignore any missing leaves. 4. IANA Considerations This memo includes no request to IANA. 5. Security Considerations TBD 6. References 6.1. Normative References [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997, . [RFC7950] Bjorklund, M., Ed., "The YANG 1.1 Data Modeling Language", RFC 7950, DOI 10.17487/RFC7950, August 2016, . [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017, . [RFC8525] Bierman, A., Bjorklund, M., Schoenwaelder, J., Watsen, K., and R. Wilton, "YANG Library", RFC 8525, DOI 10.17487/RFC8525, March 2019, . 6.2. Informative References [I-D.jouqui-netmod-yang-full-include] Quilbeuf, J., Claise, B., and T. Joubert, "YANG Full Embed", Work in Progress, Internet-Draft, draft-jouqui- netmod-yang-full-include-01, 4 March 2024, . Elhassany Expires 18 September 2024 [Page 4] Internet-Draft anydata validation March 2024 [I-D.netana-nmop-yang-kafka-integration] Graf, T. and A. Elhassany, "An Architecture for YANG-Push to Apache Kafka Integration", Work in Progress, Internet- Draft, draft-netana-nmop-yang-kafka-integration-01, 16 March 2024, . [RFC6241] Enns, R., Ed., Bjorklund, M., Ed., Schoenwaelder, J., Ed., and A. Bierman, Ed., "Network Configuration Protocol (NETCONF)", RFC 6241, DOI 10.17487/RFC6241, June 2011, . [RFC8040] Bierman, A., Bjorklund, M., and K. Watsen, "RESTCONF Protocol", RFC 8040, DOI 10.17487/RFC8040, January 2017, . [RFC8526] Bjorklund, M., Schoenwaelder, J., Shafer, P., Watsen, K., and R. Wilton, "NETCONF Extensions to Support the Network Management Datastore Architecture", RFC 8526, DOI 10.17487/RFC8526, March 2019, . [RFC8528] Bjorklund, M. and L. Lhotka, "YANG Schema Mount", RFC 8528, DOI 10.17487/RFC8528, March 2019, . [RFC8639] Voit, E., Clemm, A., Gonzalez Prieto, A., Nilsen-Nygaard, E., and A. Tripathy, "Subscription to YANG Notifications", RFC 8639, DOI 10.17487/RFC8639, September 2019, . [RFC8641] Clemm, A. and E. Voit, "Subscription to YANG Notifications for Datastore Updates", RFC 8641, DOI 10.17487/RFC8641, September 2019, . [RFC9144] Clemm, A., Qu, Y., Tantsura, J., and A. Bierman, "Comparison of Network Management Datastore Architecture (NMDA) Datastores", RFC 9144, DOI 10.17487/RFC9144, December 2021, . Acknowledgements The authors would like to thank Jean Quilbeuf, Thomas Graf, Benoit Claise, and Alex Huang Feng for their review and valuable comments. Author's Address Elhassany Expires 18 September 2024 [Page 5] Internet-Draft anydata validation March 2024 Ahmed Elhassany Swisscom Binzring 17 CH- Zuerich 8045 Switzerland Email: ahmed.elhassany@swisscom.com Elhassany Expires 18 September 2024 [Page 6]