Skip to content

Metaschema Validation Has Findings For Valid Component #209

@lstanden

Description

@lstanden

Describe the bug

Valid XML component-definitions are returning findings.

Add the following to src/test/resources/content/component-def.xml

<?xml version="1.0" encoding="UTF-8"?>
<component-definition xmlns="http://csrc.nist.gov/ns/oscal/1.0"
         uuid="6c5149e8-f3a6-437c-8035-025e9b5fc0bc">
    <metadata>
        <title>Test Component Definition</title>
        <last-modified>2023-11-30T01:01:01Z</last-modified>
        <version>1.0</version>
        <oscal-version>1.1.1</oscal-version>
    </metadata>
    <component uuid="849e5b94-5ccb-49c4-97ab-56ac391a8b37" type="service">
        <title>Test Service</title>
        <description></description>
        <protocol uuid="d25e47d8-b5da-475f-854b-6ce292fefaa7" name="http">
            <port-range start="80" end="80" transport="TCP"/>
        </protocol>
    </component>
</component-definition>

Add the following test function to src/test/java/gov/nist/secauto/oscal/java/ExamplesTest.java:

    @Test
    void testComponentDefinition() throws IOException {
        OscalBindingContext bindingContext = OscalBindingContext.instance();
        IBoundLoader loader = bindingContext.newBoundLoader();

        IDocumentNodeItem nodeItem = loader.loadAsNodeItem(ObjectUtils.notNull(Paths.get("src/test/resources/content/component-def.xml")));

        DynamicContext dynamicContext = new StaticContext().newDynamicContext();
        dynamicContext.setDocumentLoader(loader);

        FindingCollectingConstraintValidationHandler handler = new FindingCollectingConstraintValidationHandler();
        DefaultConstraintValidator validator = new DefaultConstraintValidator(dynamicContext, handler);

        validator.validate(nodeItem);
        validator.finalizeValidation();

        assertTrue(handler.isPassing());
        assertTrue(handler.getFindings().isEmpty());
    }

The following log output is shown:

16:38:41.827 [main] WARN  gov.nist.secauto.metaschema.model.common.constraint.LoggingConstraintValidationHandler.logConstraint(LoggingConstraintValidationHandler.java:121) - WARNING: (/component-definition/component[1]/protocol[1]/port-range[1]) A start port exists, but an end point does not. To define a single port, the start and end should be the same value.
16:38:41.831 [main] WARN  gov.nist.secauto.metaschema.model.common.constraint.LoggingConstraintValidationHandler.logConstraint(LoggingConstraintValidationHandler.java:121) - WARNING: (/component-definition/component[1]/protocol[1]/port-range[1]) An end point exists, but a start port does not. To define a single port, the start and end should be the same value.

Who is the bug affecting?

Anyone trying to validate component-definitions. Presumably this applies to other OSCAL types too.

What is affected by this bug?

Findings are returned despite valid input. Doesn't matter if the input is JSON, YAML, or XML.

When does this occur?

See example

How do we replicate the issue?

Please see detailed unit test above.

Expected behavior (i.e. solution)

This particular example should return no findings, as it meets all the metaschema requirements.

Other Comments

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Needs Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions