Skip to content

Commit f84d7c5

Browse files
authored
api-reference/json: document vulnerabilities in responses (#10431)
* api-reference/json: document `vulnerabilities` in responses * api-reference/json: clarify `vulnerabilities` response
1 parent dc6753d commit f84d7c5

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

docs/api-reference/json.rst

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,17 @@ Project
158158
"yanked": false,
159159
"yanked_reason": null
160160
}
161-
]
161+
],
162+
"vulnerabilities": []
162163
}
163164
164165
:statuscode 200: no error
165166

167+
On this endpoint, the ``vulnerabilities`` array provides a listing for
168+
any known vulnerabilities in the most recent release (none, for the example
169+
above). Use the release-specific endpoint documented below for precise
170+
control over this field.
171+
166172
Release
167173
-------
168174

@@ -260,7 +266,45 @@ Release
260266
}
261267
]
262268
},
263-
"urls": []
269+
"urls": [],
270+
"vulnerabilities": []
264271
}
265272
266273
:statuscode 200: no error
274+
275+
Known vulnerabilities
276+
~~~~~~~~~~~~~~~~~~~~~
277+
278+
In the example above, the combination of the requested project and version
279+
had no `known vulnerabilities <https://github.com/pypa/advisory-db>`_.
280+
An example of a response for a project with known vulnerabilities is
281+
provided below, with unrelated fields collapsed for readability.
282+
283+
.. code:: http
284+
285+
GET /pypi/Django/3.0.2/json HTTP/1.1
286+
Host: pypi.org
287+
Accept: application/json
288+
289+
{
290+
"info": {},
291+
"last_serial": 12089094,
292+
"releases": {},
293+
"urls": [],
294+
"vulnerabilities": [
295+
{
296+
"aliases": [
297+
"CVE-2021-3281"
298+
],
299+
"details": "In Django 2.2 before 2.2.18, 3.0 before 3.0.12, and 3.1 before 3.1.6, the django.utils.archive.extract method (used by \"startapp --template\" and \"startproject --template\") allows directory traversal via an archive with absolute paths or relative paths with dot segments.",
300+
"fixed_in": [
301+
"2.2.18",
302+
"3.0.12",
303+
"3.1.6"
304+
],
305+
"id": "PYSEC-2021-9",
306+
"link": "https://osv.dev/vulnerability/PYSEC-2021-9",
307+
"source": "osv"
308+
},
309+
]
310+
}

0 commit comments

Comments
 (0)