#3 Use django app to query cve-search and display cve-ids - #4
Conversation
| data = api.output_cve_id(name=product) | ||
| return HttpResponse(data) | ||
|
|
||
| def product_ver(request, product, ver): |
There was a problem hiding this comment.
Why using version in the api module and ver here?
Always prefer to use easy to read and unambiguous variable name.
Also be consistent with your naming within the codebase, if the content is the same, use the same name.
def product_ver(request, product, ver):
->
def product_version(request, product, version):
There was a problem hiding this comment.
I had primarily done it to sort of create a little differentiation, b/w what's being passed and what it is being checked to. But, your point is more valid. 😄
There was a problem hiding this comment.
sort of create a little differentiation should be avoided, consistency first! :)
|
|
||
| import vulncode_app.api_data as api | ||
|
|
||
| def product(request, product): |
There was a problem hiding this comment.
You are using package in the api_data module and product here, any particular reason?
There was a problem hiding this comment.
Somewhat in contrast to cve-search. I'll switch 'em to package.
| extracted_data = api.extract_fields(raw_data, fields_names, version=True) | ||
|
|
||
| return JsonResponse({'cve_id':api.ids,'summary':api.summary,'cvss':api.cvss}) | ||
| return HttpResponse(json.dumps(extracted_data)) |
There was a problem hiding this comment.
@pombredanne I had changed the data structure of the data, from lists to dictionary and this is sort of what I had implemented. The ordering works fine, but I think the HttpResponse ignores the indentation specified at the time of the JSON dump.
I had tried that before, but it didn't seem to work.
Do you think an alternate approach should be used here?
pombredanne
left a comment
There was a problem hiding this comment.
Do not commit .pyc and pycache_ fields
Add license headers.... and a few other points: use imperative style in your docstrings (Retrun rather than Returns)
| @@ -0,0 +1,3 @@ | |||
| { | |||
There was a problem hiding this comment.
Do not commit the .cache dir: it should be removed and the git ignored.
| @@ -0,0 +1,120 @@ | |||
| """ | |||
Signed-off-by: Thomas Druez <tdruez@nexb.com>
Signed-off-by:Kartik Sibal <kartiksibal@gmail.com>
Signed-off-by: Kartik Sibal <kartiksibal@gmail.com>
…nto django_app
Signed-off-by: Kartik Sibal <kartiksibal@gmail.com>
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
Signed-off-by: Kartik Sibal kartiksibal@gmail.com