@@ -224,7 +224,14 @@ def list_vulnerabilities():
224
224
def vulnerability (vuln_id ):
225
225
"""Vulnerability page."""
226
226
vuln = osv_get_by_id (vuln_id )
227
- return render_template ('vulnerability.html' , vulnerability = vuln )
227
+
228
+ if utils .is_prod ():
229
+ api_url = 'api.osv.dev'
230
+ else :
231
+ api_url = 'api.test.osv.dev'
232
+
233
+ return render_template (
234
+ 'vulnerability.html' , vulnerability = vuln , api_url = api_url )
228
235
229
236
230
237
@blueprint .route ('/<potential_vuln_id>' )
@@ -242,6 +249,28 @@ def vulnerability_redirector(potential_vuln_id):
242
249
return None
243
250
244
251
252
+ @blueprint .route ('/<potential_vuln_id>.json' )
253
+ @blueprint .route ('/vulnerability/<potential_vuln_id>.json' )
254
+ def vulnerability_json_redirector (potential_vuln_id ):
255
+ """Convenience redirector for /VULN-ID.json and /vulnerability/VULN-ID.json to
256
+ https://api.osv.dev/v1/vulns/VULN-ID.
257
+ """
258
+ if not _VALID_VULN_ID .match (potential_vuln_id ):
259
+ abort (404 )
260
+ return None
261
+
262
+ vuln = osv_get_by_id (potential_vuln_id )
263
+ if not vuln :
264
+ abort (404 )
265
+ return None
266
+
267
+ if utils .is_prod ():
268
+ api_url = 'api.osv.dev'
269
+ else :
270
+ api_url = 'api.test.osv.dev'
271
+ return redirect (f'https://{ api_url } /v1/vulns/{ potential_vuln_id } ' )
272
+
273
+
245
274
def bug_to_response (bug , detailed = True ):
246
275
"""Convert a Bug entity to a response object."""
247
276
response = osv .vulnerability_to_dict (
0 commit comments