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

Prevent circular validation #102

Closed
fge opened this issue May 24, 2014 · 1 comment
Closed

Prevent circular validation #102

fge opened this issue May 24, 2014 · 1 comment
Labels

Comments

@fge
Copy link
Collaborator

fge commented May 24, 2014

Initial report by mail.

This schema causes problems during validation:

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "definitions": {
        "S": {
            "allOf": [
                { "type": "string", "enum": ["a"] },
                {
                    "oneOf": [
                        { "$ref": "#/definitions/S" },
                        { "type": "string", "enum": [""] }
                    ]
                },
                { "type": "string", "enum": ["b"] }
            ],
            "additionalItems": false
        }
    },
    "$ref": "#/definitions/S"
}

No problem with references here, there is no reference loop; however, during validation, for any JSON value, the path is:

-> ""
-> "/definitions/S" 
-> "/definitions/S/allOf/0" 
-> "/definitions/S/allOf/1/oneOf/0" 
-> "/definitions/S" <-- LOOP

This is currently not detected.

@fge fge added the bug label May 24, 2014
fge added a commit that referenced this issue May 24, 2014
Signed-off-by: Francis Galiegue <[email protected]>
fge added a commit that referenced this issue May 24, 2014
Signed-off-by: Francis Galiegue <[email protected]>
fge added a commit that referenced this issue May 24, 2014
The existing ValidationProcessor is not easily modifiable to fulfill the needs
highlighted by issue #102. A ThreadLocal may be used, but that would make the
code rather convoluted.

Instead, create a new InstanceValidator class with the same signature; the
ValidationProcessor (which is unique per JsonSchemaFactory) will then create an
instance of that class for each attempted schema/instance validation pair.

This means the InstanceValidator instance will be what keyword validators will
use, instead of the ValidationProcessor.

Signed-off-by: Francis Galiegue <[email protected]>
fge added a commit that referenced this issue May 24, 2014
As planned; create an instance of InstanceValidator for each schema/instance
validation pair and act on that.

Signed-off-by: Francis Galiegue <[email protected]>
@fge
Copy link
Collaborator Author

fge commented May 24, 2014

Issue is now fixed on branch v2.2.

@fge fge closed this as completed May 24, 2014
fge added a commit that referenced this issue May 24, 2014
Essential to solve bug #102

Signed-off-by: Francis Galiegue <[email protected]>
fge added a commit that referenced this issue May 25, 2014
Francis Galiegue (22):
      Bump version number
      Depend on local -SNAPSHOT
      Make test to reproduce issue #102
      SchemaContextEquivalence: remove reference to SchemaTreeEquivalence
      ValidationChain: drop use of SchemaTreeEquivalence
      Modify tests; add a message for validation loops
      ValidationProcessor: don't cache {Array,Object}SchemaSelector results anymore
      Deprecate a constructor of FullData
      New class InstanceValidator
      ValidationProcessor: receive the cached processor directly from the factory
      Fix issue #102
      Improve error message
      InstanceValidator: improve test, documentation, error message
      More documentation
      One more message change
      Depend on -core 1.2.4
      Remove obsolete API usages
      Remove deprecated API usage
      Fuse *.gradle files
      build.gradle: include Main-Class in jar
      Fill release notes
      2.2.5

Signed-off-by: Francis Galiegue <[email protected]>
fge added a commit that referenced this issue May 25, 2014
Signed-off-by: Francis Galiegue <[email protected]>
fge added a commit that referenced this issue May 25, 2014
The existing ValidationProcessor is not easily modifiable to fulfill the needs
highlighted by issue #102. A ThreadLocal may be used, but that would make the
code rather convoluted.

Instead, create a new InstanceValidator class with the same signature; the
ValidationProcessor (which is unique per JsonSchemaFactory) will then create an
instance of that class for each attempted schema/instance validation pair.

This means the InstanceValidator instance will be what keyword validators will
use, instead of the ValidationProcessor.

Signed-off-by: Francis Galiegue <[email protected]>
fge added a commit that referenced this issue May 25, 2014
As planned; create an instance of InstanceValidator for each schema/instance
validation pair and act on that.

Signed-off-by: Francis Galiegue <[email protected]>
fge added a commit that referenced this issue May 25, 2014
Essential to solve bug #102

Signed-off-by: Francis Galiegue <[email protected]>
fge added a commit that referenced this issue Oct 28, 2014
Existing code to solve issue #102 was incomplete; it failed to account for the
fact that a same instance pointer/schema URI pair may be used in a legal manner
more than once.

At the moment, yours truly only knows that the problem exists and how to solve
it, yet I fail to explain it correctly...

Signed-off-by: Francis Galiegue <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant