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

Nimma usage generates very different results #1260

Closed
nulltoken opened this issue Jun 30, 2020 · 3 comments · Fixed by #1785
Closed

Nimma usage generates very different results #1260

nulltoken opened this issue Jun 30, 2020 · 3 comments · Fixed by #1785
Assignees
Labels
released t/bug Something isn't working

Comments

@nulltoken
Copy link
Contributor

Describe the bug
5.5.0 introduces an optional rule jsonpath optimizer: nimma. It seems to not properly parse some paths.

To Reproduce

ruleset:

rules:
  read-scope-prefix-on-get:
    type: validation
    severity: warn
    recommended: true
    formats: ["oas3"]
    description: Scope should start with something
    message: Scope should start with something
    given: "$.paths.*[?(@property === 'get' || @property === 'options')].security.*.my_auth.*"
    then:
      function: pattern
      functionOptions:
        match: "^urn:"

  no-404-response:
    type: validation
    severity: info
    recommended: true
    formats: ["oas3"]
    description: Operation must not define a 404 response when no ressource identifier.
    message: The request must not define a 404 response.
    given: "$.paths[?(!@property.includes('_id}'))][?(@property === 'get' || @property === 'post' || @property === 'delete' || @property === 'options' || @property === 'patch' )].responses"
    then:
      field: "404"
      function: falsy

document:

openapi: 3.0.0

paths:
  /any/resources/{resource}:
    get:
      responses:
        "200":
          description: All is good
        "404":
          description: All is nowhere"
  /resources:
    get: &dummy-endpoint
      responses:
        "200":
          description: All is good
      security:
        - my_auth:
            - urn:something
    patch:
      <<: *dummy-endpoint
      security:
        - my_auth:
            - Urn:wrong-but-should-go-unnoticed

without nimma:

$ node -r ts-node/register -r tsconfig-paths/register src/cli/index.ts lint -r ./repro/nimma.ruleset.yaml ./repro/nimma.openapi.yaml
Missing baseUrl in compilerOptions. tsconfig-paths will be skipped
OpenAPI 3.x detected

c:/spectral/repro/nimma.openapi.yaml
 9:15  information  no-404-response  The request must not define a 404 response.

✖ 1 problem (0 errors, 0 warnings, 1 info, 0 hints)

activating nimma:

$ node -r ts-node/register -r tsconfig-paths/register src/cli/index.ts lint -r ./repro/nimma.ruleset.yaml ./repro/nimma.openapi.yaml
Missing baseUrl in compilerOptions. tsconfig-paths will be skipped
OpenAPI 3.x detected

c:/_work/spectral/repro/nimma.openapi.yaml
 23:15  warning  read-scope-prefix-on-get  Scope should start with something

✖ 1 problem (0 errors, 1 warning, 0 infos, 0 hints)

Expected behavior
Using nimma or not should not change the return results.

Environment (remove any that are not applicable):

  • Library version: develop branch
  • OS: Win10
  • Browser: N/A
@nulltoken nulltoken added the t/bug Something isn't working label Jun 30, 2020
@P0lip
Copy link
Contributor

P0lip commented Jun 30, 2020

Awesome, thanks for adding the repro.
I'll try to cover these in nimma.

FWIW, I'm thinking of adding a kind of allowslist that prevent nimma from being used for paths we are not certain about.
I expected certain inconsistences, so we could potentially cover most of oas rules for now, as they are thourughly tested, while all custom rules would not be covered.
I haven't had much time lately to work on nimma, but hopefully I find some time after I return from Holidays (after 08th of July).

@P0lip
Copy link
Contributor

P0lip commented Aug 31, 2021

Fixed by #1785 🎉
image

@stoplight-bot
Copy link
Collaborator

🎉 This issue has been resolved in version @stoplight/spectral-core-v1.5.0 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants