Skip to content

bug(openapi): scan times out if swaggerfile is a very long single line #7984

@ccactus

Description

@ccactus

If a swagger file (in our cases often auto-generated), is saved as a single line, KICS freezes when trying to scan and fails to time out. Using some "pretty print" formatter allows the scan to complete even if some of the rules time out.

Expected Behavior

If a file can't be scanned because it's too large, time out early or report an error that it cannot be scanned.

Actual Behavior

Program hangs and stops reporting. Within the gitlab wrapper, several rules report as timing out. They don't report anything unless killed through input.

Steps to Reproduce the Problem

Attached is an AI generated, single line openapi spec.

multi-line.json
Run the scan with following flags:

kics scan -p /path/to/file-dir --ci --queries-path /app/bin/assets/queries --disable-full-descriptions --disable-secrets --log-level DEBUG --output-path /tmp --output-name kics --report-formats sarif --ignore-on-exit results

Attached is also the goroutine dump of killing the hanging process. The scan of the pretty print edition of the file took just over a minute to complete.
goroutine-trace.log

Specifications

  • Version: v2.1.19 and v2.1.20
  • Platform: Gitlab& docker-alpine

Metadata

Metadata

Labels

bugSomething isn't workingcommunityCommunity contributiondockerDocker queryopenapiOpenAPI queryqueryNew query feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions