codeout / junoser

PEG parser for JUNOS configuration.
MIT License
69 stars 11 forks source link

Element in XSD turned into just "arg" #19

Closed vincentbernat closed 4 years ago

vincentbernat commented 4 years ago

Hey!

From config-18.1.xsd, I have:

  <xsd:element name="l3vpn-composite-nexthop" minOccurs="0">
    <xsd:annotation>
      <xsd:documentation>Enable composite nexthop for l3vpn</xsd:documentation>
      <xsd:appinfo>
        <flag>nokeyword</flag>
        <flag>prune-lcc</flag>
        <flag>hidden-from-cli</flag>
        <products>
          <product>t640</product>
          <product>t320</product>
          <product>TX Matrix</product>
          <product>m320</product>
          <product>m120</product>
          <product>mx960</product>
          <product>mx480</product>
          <product>mx240</product>
          <product>txp</product>
          <product>mx80</product>
          <product>mx80-48t</product>
          <product>mx5-t</product>
          <product>mx10-t</product>
          <product>mx40-t</product>
          <product>mx80-t</product>
          <product>mx80-p</product>
          <product>acx1000</product>
          <product>acx2000</product>
          <product>acx4000</product>
          <product>mx2020</product>
          <product>mx2010</product>
          <product>ex9204</product>
          <product>ex9208</product>
          <product>ex9214</product>
          <product>mx104</product>
          <product>acx2100</product>
          <product>acx2200</product>
          <product>acx1100</product>
          <product>vmx</product>
          <product>vrr</product>
          <product>acx500-o-poe-dc</product>
          <product>acx500-o-poe-ac</product>
          <product>acx500-o-dc</product>
          <product>acx500-o-ac</product>
          <product>acx500-dc</product>
          <product>acx500-ac</product>
          <product>acx5048</product>
          <product>acx5096</product>
          <product>mx2008</product>
          <product>mxtsr80</product>
          <product>mx10001</product>
          <product>mx10002</product>
          <product>ex9251</product>
        </products>
        <deprecated>
          <cause>The feature is obsolete</cause>
          <remediation>Discontinue using this knob</remediation>
        </deprecated>
    </xsd:appinfo>
  </xsd:annotation>
  <xsd:complexType>
    <xsd:sequence>
      <xsd:choice minOccurs="0" maxOccurs="unbounded">
        <xsd:element ref="undocumented" minOccurs="0"/>
        <xsd:element ref="junos:comment" minOccurs="0"/>
      </xsd:choice>
    </xsd:sequence>
  </xsd:complexType>
</xsd:element>

This element is turned in rule.rb as just arg and it mostly break the whole block (as anything could match).

vincentbernat commented 4 years ago

It seems the issue is because of <flag>nokeyword</flag>. So, it could be a bug from Juniper. I don't know if there would be a way to detect this kind of cases.

codeout commented 4 years ago

Yes, it was likely that this was Juniper bug. (We can see it was fixed in 18.3R1.9 xsd, by the way)

  <xsd:element name="l3vpn-composite-nexthop" minOccurs="0">
    <xsd:annotation>
      <xsd:documentation>Enable composite nexthop for l3vpn</xsd:documentation>
      <xsd:appinfo>
        <flag>prune-lcc</flag>
        <flag>current-product-support</flag>
        <flag>hidden-from-cli</flag>
        <products>

I'm afraid that it's difficult to detect this kind of bugs automatically as Juniper people may mark any element as nokeyword unexpectedly, without any specific rule.

vincentbernat commented 4 years ago

Ok, so not much to do here!