18F / fedramp-automation

FedRAMP Automation
https://federalist-2372d2fd-fc94-42fe-bcc7-a8af4f664a51.app.cloud.gov/site/18f/fedramp-automation/
Other
16 stars 6 forks source link

XSpec error #396

Open GaryGapinski opened 2 years ago

GaryGapinski commented 2 years ago

I created two test documents. When the embedded regex assertion is uncommented, the XSpec run fails. I have contacted OxygenXML support for assistance.

Moving the regex from the assertion into a variable appears to avoid the XSpec implementation problem.

<?xml version="1.0" encoding="UTF-8"?>
<sch:schema
    queryBinding="xslt2"
    xmlns:sch="http://purl.oclc.org/dsdl/schematron"
    xmlns:sqf="http://www.schematron-quickfix.com/validator/process">
    <sch:pattern>
        <sch:rule
            context="*"
            id="regex">

            <sch:assert
                id="test1"
                test="true()">phrase</sch:assert>

            <sch:let
                name="expr"
                value="'(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))'" />
            <sch:assert
                id="test2"
                test="matches('::', $expr)">phrase</sch:assert>

            <!--<sch:assert
                id="test3"
                test="matches('::', '(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))')">phrase</sch:assert>-->

        </sch:rule>
    </sch:pattern>
</sch:schema>
<?xml version="1.0" encoding="UTF-8"?>
<x:description
    schematron="regex.sch"
    xmlns:x="http://www.jenitennison.com/xslt/xspec">
    <x:scenario
        label="regex">
        <x:context>
            <element />
        </x:context>
        <x:expect-not-assert
            id="test1"
            label="test1" />
        <x:expect-not-assert
            id="test2"
            label="test2" />
    </x:scenario>
</x:description>

_Originally posted by @GaryGapinski in https://github.com/18F/fedramp-automation/pull/387#discussion_r826995559_

GaryGapinski commented 2 years ago

See https://github.com/xspec/xspec/issues/1618.

galtm commented 2 years ago

Hi, @GaryGapinski . Thanks for the clear reproduction steps. I'm fixing this in the XSpec repo, and Oxygen will eventually pick up the fix as well. I'm glad you have a workaround while you're waiting for the fix. If you prefer not to use a variable, you can consider replacing {1,} with + in the regular expression.

galtm commented 1 year ago

Update: Although XSpec patched (#1626) the third-party "skeleton implementation" of Schematron between the released XSpec v2.2 and the future XSpec v2.3 to work around this issue, the patch has been reverted (#1713). As a result, this problem will not go away in XSpec v2.3.

@GaryGapinski : Please continue to use the workaround you found.