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

bug(openapi): false positive - wrongly required items for string type #7020

Open
UncleGoogle opened this issue Apr 22, 2024 · 4 comments
Open
Labels
appsec bug Something isn't working community Community contribution openapi OpenAPI query query New query feature

Comments

@UncleGoogle
Copy link

UncleGoogle commented Apr 22, 2024

In the openapi v2 docs we can see this

Required if type is "array"

so in this example parameters are valid (talking about "inner" itemes"):

openapi: 3.0.3
paths:
  /v1/sourceTypes:
    delete:
      description: 'XXX'
      tags:
      - data_sources
      - v1
      produces:
      - application/json
      consumes:
      - application/json
      parameters:
      - name: ids
        in: query
        required: true
        type: array
        items:
          type: string
        description: ''
      responses:
        200:
          description: Successful Response
          schema:
            type: string
          headers: {}

Expected Behavior

No error

Actual Behavior

error 5e5ecb9d-04b5-4e4f-b5a5-6ee04279b275 is raised with descriprtion:

            "name": "OpenAPI Object should contain all of its required fields",
            "description": "items is missing required fields",

Specifications

  • Version: GitLab kics analyzer v4.1.13
@UncleGoogle UncleGoogle added bug Something isn't working community Community contribution labels Apr 22, 2024
@github-actions github-actions bot added query New query feature openapi OpenAPI query labels Apr 22, 2024
@gabriel-cx
Copy link
Collaborator

Hi @UncleGoogle ,

Thank you for your inputs!
Our internal AppSec team will check it soon.
We will keep you updated.

(APPSEC-2558)

@gabriel-cx
Copy link
Collaborator

gabriel-cx commented May 17, 2024

@UncleGoogle KICS is not scanning the code sample you provided, seems like it's an invalid one (we also checked it by using this tool).
Kindly provide a valid openapi file so we can have a better look into it.

@UncleGoogle
Copy link
Author

Hi @gabriel-cx . Sure, I've extracted full example:

swagger: '2.0'
info:
  title: Example API
  version: '1.0'
schemes:
- https
produces:
- application/json
paths:
  /v1/dataSourceTypes:
    get:
      tags:
      - data_sources
      parameters:
      - name: limit
        in: query
        required: false
        default: 300
        type: integer
        format: int32
        description: ''
      - name: offset
        in: query
        required: false
        type: integer
        format: int32
        description: ''
      - name: order_field
        in: query
        required: false
        type: string
        description: ''
      - name: order_direction
        in: query
        required: false
        enum:
        - ASC
        - DESC
        type: string
        description: ''
      responses:
        200:
          description: Successful Response
          schema:
            type: string
          headers: {}
        408:
          description: Backend call time-out
          schema:
            type: string
          headers: {}
    delete:
      tags:
      - data_sources
      deprecated: false
      produces:
      - application/json
      consumes:
      - application/json
      parameters:
      - name: ids
        in: query
        required: true
        type: array
        items:
          type: string
        description: ''
      - name: recursive
        in: query
        required: false
        type: boolean
        description: ''
      responses:
        200:
          description: Successful Response
          schema:
            type: string
          headers: {}
        404:
          description: DataSource ID not found
          schema:
            type: string
          headers: {}
        408:
          description: Backend call time-out
          schema:
            type: string
          headers: {}

@gabriel-cx
Copy link
Collaborator

Hi @UncleGoogle ,

Thank you!!
We will analyze your inputs and we will keep you updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
appsec bug Something isn't working community Community contribution openapi OpenAPI query query New query feature
Projects
None yet
Development

No branches or pull requests

2 participants