Improve display of SSVC in UI #2058#2165
Improve display of SSVC in UI #2058#2165Mahaboobunnisa123 wants to merge 2 commits intoaboutcode-org:mainfrom
Conversation
fdf9ef7 to
e4c0a6b
Compare
|
hi @pombredanne , Please review the PR #2165 and would happy to make any adjustments based on the feedback. Thanks! |
pombredanne
left a comment
There was a problem hiding this comment.
Thanks but please do not use AI to generate PR bodies. That's annoying.
Some questions:
- Was any of this vibe coded otherwise?
- Would there be a simpler way than to use a filter?
| try: | ||
| return saneyaml.dump(value).strip() | ||
| except Exception: | ||
| return str(value) |
There was a problem hiding this comment.
Why not keeping the pprint behavior there? And why would there be a case that raises an exception? Is the exception really needed?
| @register.filter(name="to_yaml") | ||
| def to_yaml(value): | ||
| """ | ||
| Convert a Python object (typically SSVC options) to a |
There was a problem hiding this comment.
Is this generic? if yes, remove references to SSVC.
Also why not indent? And we have similar code in SCIO https://github.com/aboutcode-org/scancode.io/blob/d6b14acbb94ecfef52b3dbe34c1cd7f5f112e4bf/scanpipe/views.py#L206C5-L206C19 with a different approach. What about using that approach instead? @tdruez FYI
| from vulnerabilities.templatetags.ssvc_filters import to_yaml | ||
|
|
||
|
|
||
| def test_to_yaml_with_ssvc_options(): |
There was a problem hiding this comment.
These tests are essentially testing the saneyaml library that is already tested. Can you test the tag instead? (I though I question using a filter is what we want here.)
| {"Mission & Well-being": "high"}, | ||
| ] | ||
| result = to_yaml(options) | ||
| assert "Exploitation: active" in result |
There was a problem hiding this comment.
I am not sure this series of asserts has a lot of value. Why not assert at once the whole "result" string?
pombredanne
left a comment
There was a problem hiding this comment.
Also your code does not pass the tests. Make sure it does before you submit a PR
|
See: your AI-generated PR text is lying as the tests do not pass. Not a happy thing. |
|
My bad. I said tests have passed but they don't. That shouldn't have happened. I'll look at the scancode.io link you shared and redo this properly. Also the docstring is too specific to SSVC and the exception handling probably isn't needed. I'll clean that up too. Could you approve the workflows so the checks can run? I won't move it out of draft until CI is actually green. Thanks! |
My Bad. I make sure it won't repeat. Thanks @pombredanne for pointing out. |
02c2826 to
4a8b41e
Compare
Signed-off-by: Mahaboobunnisa123 <mdshabbi885@gmail.com>
3ac3c98 to
0b8abaf
Compare
|
Hi @pombredanne, I have reworked this based on your review. Instead of a template filter, YAML rendering now happens in the view using saneyaml.dump(...).strip(), and the template displays the pre-rendered string. I also removed the broad exception handling and updated the tests to cover our helper output by asserting the full rendered string. |
Summary
Resolves #2058
Improve SSVC options display in the advisory detail page by rendering the SSVC options as YAML.
Changes
Render YAML in the view using saneyaml.dump(...).strip() and pass it to the template as a string.
Template displays the pre-rendered YAML string (no template filter).
Tests cover the rendering helper output and assert the full rendered YAML string.
Testing
No new dependency (uses existing saneyaml).
Local: python -m pytest vulnerabilities/tests/test_view.py (27 passed).