Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply-path takes a quoted string #22

Open
vincentbernat opened this issue May 16, 2020 · 2 comments
Open

apply-path takes a quoted string #22

vincentbernat opened this issue May 16, 2020 · 2 comments

Comments

@vincentbernat
Copy link
Contributor

Hey!

With the latest master, I still have issues with apply-path:

set policy-options prefix-list ipvX-bgp-neighbors apply-path "routing-instances <*> protocols bgp group <*> neighbor <*>"

Generated parser is:

            b(str("policy-options"),
                c(
                    b(a(str("prefix-list"), arg),
                        c(
                              prefix_list_items,
                            a(str("apply-path"), arg)
                        )
                    )
                )
            ),

Last arg could be replaced by quote.

XML says:

                  <xsd:element name="apply-path" minOccurs="0" type="xsd:string">
                    <xsd:annotation>
                      <xsd:documentation>Apply IP prefixes from a configuration statement</xsd:documentation>
                      <xsd:appinfo>
                        <flag>ephemeral-db-exclude</flag>
                        <flag>twig-dynamic-db-ok</flag>
                        <flag>current-product-support</flag>
                      </xsd:appinfo>
                    </xsd:annotation>
                  </xsd:element>

To me, it seems when we have an xsd:string, we should use quote | arg. In ruler.rb, all occurrences of quote | arg seems to be special case. I am fine by adding apply-path to the list, but out of curiosity, why not always use quote | arg?

@codeout
Copy link
Owner

codeout commented May 18, 2020

That's just a fail-safe. Some xsd:string in JUNOS which rejects quoted strings with white spaces like:

koji@vsrx# set routing-instances "a a" instance-type vrf
error: instance_name: 'a a': Must be a non-reserved string of 128 characters or less with no spaces.
error: statement creation failed: a a
      <xsd:element name="name">
        <xsd:annotation>
          <xsd:documentation>Routing instance name</xsd:documentation>
          <xsd:appinfo>
            <flag>mustquote</flag>
            <flag>identifier</flag>
            <flag>nokeyword</flag>
            <flag>current-product-support</flag>
            <regex-match deprecate="deprecate">!^((__.*__)|(all)|(.*[ ].*)|("")|(.{129,}))$</regex-match>
            <regex-match-error deprecate="deprecate">Must be a non-reserved string of 128 characters or less with no spaces.</regex-match-error>
            <match>
              <pattern>!^((__.*__)|(all)|(.*[ ].*)|("")|(.{129,}))$</pattern>
              <message>Must be a non-reserved string of 128 characters or less with no spaces.</message>
            </match>
              <identifier/>
          </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexType>
          <xsd:simpleContent>
            <xsd:extension base="xsd:string">
              <xsd:attribute name="key" type="xsd:string" fixed="key"/>
            </xsd:extension>
          </xsd:simpleContent>
        </xsd:complexType>
      </xsd:element>
        <!-- </name> -->

Generally speaking, single-word should always be safe while "quoted strings" shouldn't. I know <regex-match deprecate="deprecate"> could be a hint in this case and there might be something else to determine which syntax can accept "quoted strings" but it's very hard to study all xsd:string unfortunately.

@codeout
Copy link
Owner

codeout commented May 20, 2020

Just published v0.3.13 including #17 through #21. Also it will fix this issue under policy-options prefix-list xxx apply-path but I didn't translate all xsd:string into quote | arg. There are still things we need to figure out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants