GithubHelp home page GithubHelp logo

Comments (3)

tillig avatar tillig commented on June 9, 2024

We just ran into a similar issue where we have a property required on one of our objects.

from portman.

tillig avatar tillig commented on June 9, 2024

Doing some research on where/how to fix this. For a property named required I see the exception during test generation looks like this:

/Users/tillig/specification/node_modules/@apideck/portman/dist/application/Fuzzer.js:497
                var requiredFuzz = node.required.map(function (req) { return "" + requiredPath + req; });
                                                 ^

TypeError: node.required.map is not a function
    at Object.<anonymous> (/Users/tillig/specification/node_modules/@apideck/portman/dist/application/Fuzzer.js:497:50)
    at walker (/Users/tillig/specification/node_modules/traverse/index.js:150:16)
    at /Users/tillig/specification/node_modules/traverse/index.js:171:17
    at Array.forEach (<anonymous>)
    at forEach (/Users/tillig/specification/node_modules/traverse/index.js:19:30)
    at walker (/Users/tillig/specification/node_modules/traverse/index.js:166:4)
    at /Users/tillig/specification/node_modules/traverse/index.js:171:17
    at Array.forEach (<anonymous>)
    at forEach (/Users/tillig/specification/node_modules/traverse/index.js:19:30)
    at walker (/Users/tillig/specification/node_modules/traverse/index.js:166:4)
    at /Users/tillig/specification/node_modules/traverse/index.js:171:17
    at Array.forEach (<anonymous>)
    at forEach (/Users/tillig/specification/node_modules/traverse/index.js:19:30)
    at walker (/Users/tillig/specification/node_modules/traverse/index.js:166:4)
    at /Users/tillig/specification/node_modules/traverse/index.js:171:17
    at Array.forEach (<anonymous>)

Working backwards, I can see that things start happening right around line 854 in Fuzzer.analyzeFuzzJsonSchema with the required issue happening specifically at line 888.

I'm not entirely sure how to fix that yet, but it looks like there are similar sections in there for other reserved words like minimum, maxiumum, maxLength, minLength, and nullable.

from portman.

tillig avatar tillig commented on June 9, 2024

Looks like a failing Jest test is something like:

  it('should analyse JSON schema of request body with properties named after reserved words for fuzz detection', async () => {
    // Analyse JSON schema with properties that use reserved words
    const schema = {
      properties: {
        nullable: {
          type: 'object',
          properties: {
            required: {
              type: 'object',
              properties: {
                minimum: {
                  type: 'object',
                  required: ['maxLength'],
                  properties: {
                    maxLength: {
                      type: 'number',
                      example: 1,
                      minimum: 1,
                      maximum: 100,
                      minLength: 1,
                      maxLength: 5
                    }
                  }
                }
              }
            }
          }
        }
      }
    } as OpenAPIV3.SchemaObject

    const result = fuzzer.analyzeFuzzJsonSchema(schema)
    expect(result).toMatchSnapshot()
  })

from portman.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.