Skip to main content

Swagger-UI Detector

GitHub

Description

Get versions of many Swagger-UIs specified in a URL list.

But first, ensure access to a local swagger-ui github repository (either point to a path or let the script clone it).

Detection method is basically from the official source

For each URL, the script attempts to detect a version:

  • for major version 2 or less, try searching swagger-ui.js file
  • for major version 3 or more, search swagger-ui-bundle.js for a git reference and get version from local swagger-ui github repository.

Once the version is detected, report vulnerabilities associated with that version (source of data: SNYK).

Outputs to stdout, logs to stderr.

Installation

Use the package manager pip to install swagger-ui-detector.

pip install swagger-ui-detector 

Usage

Usage: swagger-ui-detector [OPTIONS]

Options:
  --swagger-ui-repo TEXT        Local repository containing swagger-ui
                                [default: ./swagger-ui]
  --swagger-ui-git-source TEXT  GIT URL of swagger-ui  
				[default: https://github.com/swagger-api/swagger-ui]
  --url-list TEXT               File containing URLs pointing to swagger-uis
  --snyk-url TEXT               Snyk URL containing swagger-ui vulnerabilities
				[default: https://snyk.io/vuln/npm:swagger-ui]
  --get-repo                    Boolean, specifies whether to get the swagger-ui repo from github  
				[default: True]
  --one-line                    Boolean, whether to print one line of output per URL.  
				[default: False]
  --help                        Show this message and exit.

Examples:

Simple example:

> swagger-ui-detector --url-list http4kswag.txt

2022-06-13 15:25:23,523 [INFO] Directory for swagger-ui repo already exists.
2022-06-13 15:25:23,523 [INFO] Directory is not empty.
2022-06-13 15:25:23,525 [INFO] Directory is a valid swagger-ui dir with remote https://github.com/swagger-api/swagger-ui
2022-06-13 15:25:23,525 [INFO] Using local swagger-ui repository at ./swagger-ui
2022-06-13 15:25:23,525 [INFO] Load vulnerabilities from https://snyk.io/vuln/npm:swagger-ui ...
2022-06-13 15:25:23,903 [INFO] Loaded 14 vulnerabilities.
2022-06-13 15:25:23,903 [INFO] Got 2 URLs to try...

URL https://www.http4k.org/openapi3/ - [OK] Version v4.11.1
---------
This swagger-ui is not vulnerable.

2022-06-13 15:25:24,475 [INFO] Status: 95%, estimated 0s left.

URL https://demo.thingsboard.io/swagger-ui/ - [VULNERABLE] Version v3.52.5
---------

This swagger-ui is vulnerable to:
  - [User Interface (UI) Misrepresentation of Critical Information](https://snyk.io/vuln/SNYK-JS-SWAGGERUI-2314885)

2022-06-13 15:25:26,028 [INFO] Done.

Redirect logs:

> swagger-ui-detector --url-list http4kswag.txt 2>/dev/null

URL https://www.http4k.org/openapi3/ - [OK] Version v4.11.1
---------
This swagger-ui is not vulnerable.


URL https://demo.thingsboard.io/swagger-ui/ - [VULNERABLE] Version v3.52.5
---------

This swagger-ui is vulnerable to:
  - [User Interface (UI) Misrepresentation of Critical Information](https://snyk.io/vuln/SNYK-JS-SWAGGERUI-2314885)

One-line output:

> swagger-ui-detector --url-list http4kswag.txt --one-line 2>/dev/null

URL https://www.http4k.org/openapi3/ - [OK] Version v4.11.1
URL https://demo.thingsboard.io/swagger-ui/ - [VULNERABLE] Version v3.52.5

Redirect output:

> swagger-ui-detector --url-list http4kswag.txt 1>swagger-detected.log

2022-06-13 15:27:36,267 [INFO] Directory for swagger-ui repo already exists.
2022-06-13 15:27:36,267 [INFO] Directory is not empty.
2022-06-13 15:27:36,269 [INFO] Directory is a valid swagger-ui dir with remote https://github.com/swagger-api/swagger-ui
2022-06-13 15:27:36,270 [INFO] Using local swagger-ui repository at ./swagger-ui
2022-06-13 15:27:36,270 [INFO] Load vulnerabilities from https://snyk.io/vuln/npm:swagger-ui ...
2022-06-13 15:27:36,682 [INFO] Loaded 14 vulnerabilities.
2022-06-13 15:27:36,682 [INFO] Got 2 URLs to try...
2022-06-13 15:27:37,085 [INFO] Status: 95%, estimated 0s left.
2022-06-13 15:27:39,424 [INFO] Done.

Metadata

Release files for swagger-ui-detector 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swagger-ui-detector 1.0.0
File Size Uploaded Provenance Actions
swagger-ui-detector-1.0.0.tar.gz 20.7 kB Without provenance Details for swagger-ui-detector-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for swagger-ui-detector 1.0.0
File Interpreter ABI Platform Actions
swagger_ui_detector-1.0.0-py3-none-any.whl Python 3 none any Details for swagger_ui_detector-1.0.0-py3-none-any.whl

Total release size: 41.8 kB

Release files / swagger-ui-detector-1.0.0.tar.gz

Download URL swagger-ui-detector-1.0.0.tar.gz
Size 20.7 kB
Tags Source
SHA-256 checksum
How to use checksums
84e87a2407ae672bec1436f5dafdd73fad5fcc0b821d352d482e798294b8b1e8
BLAKE2b-256 checksum
How to use checksums
b4e4c9e43a51ca8514e856dfd1b6595579371515cd7490d16f8001d675a3fcdd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.2

Release files / swagger_ui_detector-1.0.0-py3-none-any.whl

Download URL swagger_ui_detector-1.0.0-py3-none-any.whl
Size 21.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d2e5a428998538457652550620498eaf975e9f805952d5fd60baa139516f9d95
BLAKE2b-256 checksum
How to use checksums
240b3946ae1d4c66014557017bc04f2cac63b90d04aaca1d83be2f90d4fb1ca1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.2

Security for swagger-ui-detector 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page