-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ OSIDB-3434: Reusable CvssCalculator for affect fields #443
Conversation
95143c5
to
46e47e4
Compare
19fa6d0
to
af0ae1d
Compare
d03e8e3
to
80ff4b2
Compare
2a39697
to
2e39eb9
Compare
0f1e0ab
to
17ee7bd
Compare
Update:
|
@@ -27,6 +27,7 @@ const emit = defineEmits<{ | |||
'affect:revert': [value: ZodAffectType]; | |||
'affect:toggle-selection': [value: ZodAffectType]; | |||
'affect:track': [value: ZodAffectType]; | |||
'affect:updateCvss': [affect: ZodAffectType, newVector: string, newScore: null | number, cvssScoreIndex: number]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we have this event declared multiple times as is passed to multiple children, what do you guys think about exporting the type? That way is only declared once and can be used for the handler as well?
@superbuggy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sensible!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed on meeting this will be handled in an independent task/PR (OSIDB-3668)
affect.cvss_scores[cvssScoreIndex].score = newScore; | ||
} else if (newVector !== '') { | ||
affect.cvss_scores.push({ | ||
issuer: 'RH', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issuer: 'RH', | |
issuer: IssuerEnum.Rh, |
} else if (newVector !== '') { | ||
affect.cvss_scores.push({ | ||
issuer: 'RH', | ||
cvss_version: 'V3', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cvss_version: 'V3', | |
cvss_version: CVSS_V3, |
const cvssId = affect.cvss_scores[cvssScoreIndex]?.uuid; | ||
if (newVector === '' && cvssScoreIndex !== -1 && affect.uuid && cvssId) { | ||
affect.cvss_scores[cvssScoreIndex].vector = ''; | ||
affect.cvss_scores[cvssScoreIndex].score = null; | ||
affectCvssToDelete.value[affect.uuid] = cvssId; | ||
} else { | ||
if (affect.uuid && affectCvssToDelete.value[affect.uuid]) { | ||
delete affectCvssToDelete.value[affect.uuid]; | ||
} | ||
if (cvssScoreIndex !== -1) { | ||
affect.cvss_scores[cvssScoreIndex].vector = newVector; | ||
affect.cvss_scores[cvssScoreIndex].score = newScore; | ||
} else if (newVector !== '') { | ||
affect.cvss_scores.push({ | ||
issuer: 'RH', | ||
cvss_version: 'V3', | ||
comment: '', | ||
score: newScore, | ||
vector: newVector, | ||
embargoed: affect.embargoed, | ||
alerts: [], | ||
}); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this function a bit hard to follow, could you change it a bit? Maybe use an early return instead of the else
and maybe add a short comment on what each branch of the conditionals are intended to do
}, | ||
}); | ||
function affectCvss(affect: ZodAffectType) { | ||
return affect.cvss_scores.find(({ cvss_version, issuer }) => issuer === 'RH' && cvss_version === 'V3'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return affect.cvss_scores.find(({ cvss_version, issuer }) => issuer === 'RH' && cvss_version === 'V3'); | |
return affect.cvss_scores.find(({ cvss_version, issuer }) => issuer === IssuerEnum.Rh && cvss_version === CSSV_V3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need a new component only to show it on a overlay? Can't just mount the same CvssCalculator
on a div and move the div to the correct position?
The only change I see is that we are triggering an event on change, we could just trigger that event on a parent with a watch and use the same CvssCalculator
}, | ||
}); | ||
function affectCvss(affect: ZodAffectType) { | ||
return affect.cvss_scores.find(({ cvss_version, issuer }) => issuer === 'RH' && cvss_version === 'V3'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return affect.cvss_scores.find(({ cvss_version, issuer }) => issuer === 'RH' && cvss_version === 'V3'); | |
return affect.cvss_scores.find(({ cvss_version, issuer }) => issuer === IssuerEnum.Rh && cvss_version === CVSS_V3); |
c935959
to
8170bda
Compare
8170bda
to
af41930
Compare
src/components/CvssSection.vue
Outdated
@@ -23,7 +23,9 @@ const props = defineProps<{ | |||
const showAllCvss = ref(false); | |||
|
|||
const otherCvss = computed(() => props.allCvss.filter(cvssItem => | |||
(!(cvssItem.cvss_version === 'V3' && (cvssItem.issuer === IssuerEnum.Rh || cvssItem.issuer === IssuerEnum.Nist))))); | |||
( | |||
!(cvssItem.cvss_version === 'CVSS_V3' && (cvssItem.issuer === IssuerEnum.Rh || cvssItem.issuer === IssuerEnum.Nist)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!(cvssItem.cvss_version === 'CVSS_V3' && (cvssItem.issuer === IssuerEnum.Rh || cvssItem.issuer === IssuerEnum.Nist)) | |
!(cvssItem.cvss_version === CVSS_V3 && (cvssItem.issuer === IssuerEnum.Rh || cvssItem.issuer === IssuerEnum.Nist)) |
}, | ||
}); | ||
function affectCvss(affect: ZodAffectType) { | ||
return affect.cvss_scores.find(({ cvss_version, issuer }) => issuer === IssuerEnum.Rh && cvss_version === 'CVSS_V3'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return affect.cvss_scores.find(({ cvss_version, issuer }) => issuer === IssuerEnum.Rh && cvss_version === 'CVSS_V3'); | |
return affect.cvss_scores.find(({ cvss_version, issuer }) => issuer === IssuerEnum.Rh && cvss_version === CVSS_V3); |
} else if (newVector !== '') { | ||
affect.cvss_scores.push({ | ||
issuer: IssuerEnum.Rh, | ||
cvss_version: 'CVSS_V3', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cvss_version: 'CVSS_V3', | |
cvss_version: CVSS_V3, |
🔥 Remove unused class 🐛 Fix wrong element attrs
af41930
to
0b0d9ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
'background-color': hslForBackground, | ||
}; | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this just used in the buttons?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, also in the vector
@@ -0,0 +1,170 @@ | |||
<script setup lang="ts"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we change the name to CvssFactorButtons
.vue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
|
||
function reset() { | ||
cvssScore.value = null; | ||
emit('updateAffectCvss', '', null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be emit('affect:cvss:update', '', null)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As commented off thread, it needs to be discussed what convention we get into and apply it to all emits
✨ Use new CvssCalculator components
✅ Update snapshots ✅ Add overlayed calculator test suite
0b0d9ae
to
f257219
Compare
OSIDB-3434: Reusable CvssCalculator for affect fields
Checklist:
Summary:
Refactors CvssCalculator component to make it reusable in different layouts and uses it on the CVSS fields of the affect table.
Changes:
CvssCalculator
componentOverlayedCvssCalculator
componentDemo:
OSIM-CvssCalculator-OnAffects-Demo.mp4
*UPDATE:
Refactor made to reduce the width of the CVSS columns in the affect table. In order to achieve that, now it is only displayed the CVSS Score by default, and the vector in a tooltip when hovering the cell. In edit mode the CVSS Vector input has been moved into the calculator's popup div, that way the column can be kept in reduced size while supporting all the functionalities of the CVSS Calculator.
*UPDATEv2:
It has been added a padding bottom on the flaw affects section to fix some UI bugs caused on the overplayed calculator, cause part of it was outside of the section.
Normal CVSS Score display:
CVSS Vector tooltip:
Edit mode with calculator closed:
Edit mode with calculator opened:
Closes OSIDB-3434
Closes OSIDB-3511