+
Skip to content

Conversation

keshav-space
Copy link
Member

@keshav-space keshav-space commented Nov 6, 2024

  • Add a severities field to both AffectedByPackageRelatedVulnerability and Vulnerability.
  • Add url field to VulnerabilitySeverity and remove reference relationship.
  • Create migrations to remove corrupted suse scores and enable reprocessing of old suse advisories on the next import cycle.
  • Populate the new url field in VulnerabilitySeverity using references, set the severity-vulnerablity relationship from the old model.
  • Update UI, API, APIv2, importer/pipeline, and export command to use the new model.
  • Use new severity model for risk calculation
  • Use optimized queryset in risk pipeline

Resolves #1597

@keshav-space keshav-space changed the title Refactor severity score model and fix incorrect suses scores Refactor severity score model and fix incorrect suse scores Nov 6, 2024
@keshav-space keshav-space self-assigned this Nov 7, 2024
@keshav-space keshav-space force-pushed the 1597-refactor-vulnerability-severity branch from 193628e to 84a3a93 Compare November 11, 2024 14:11
- Add 'severities' field to AffectedByPackageRelatedVulnerability.
- Add 'severities' field to Vulnerability.
- Add 'url' field to VulnerabilitySeverity.
- Data migration to remove corrupted SUSE scores.
- Data migration to populate new VulnerabilitySeverity url field using reference.
- Data migration to populate Vulnerability 'severities' M2M relationship.
- Delete VulnerabilitySeverity reference field.

Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
- Prefetch related vulnerability, severities, references, and exploits
  for better performance

Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
@keshav-space keshav-space force-pushed the 1597-refactor-vulnerability-severity branch from 84a3a93 to 4107451 Compare November 11, 2024 16:02
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
model = VulnerabilitySeverity
fields = ["url", "value", "scoring_system", "scoring_elements", "published_at"]

def to_representation(self, instance):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need to_representation method here? if published_at is None, let it be sent as None

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this just to preserve the response structure we're already using in APIv2 https://github.com/aboutcode-org/vulnerablecode/blob/8a68c97dfa369ad048de3ece14cc1b3cf40591cc/vulnerabilities/api_v2.py#L16C33-L16C64.

IMO yes we should simpy send None when we don't have published date.

Copy link
Contributor

@TG1999 TG1999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!


return data

def get_references(self, vulnerability):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: Why we are having a method here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our old API, references used to contain the nested severity, as severity and reference were related through a foreignkey relationship. In our new model we have dissociated reference and severity. To ensure we maintain compatibility for existing users of old API we're manually crafting the references to include the relevant severity.

Signed-off-by: Keshav Priyadarshi <git@keshav.space>
@keshav-space keshav-space merged commit 8bca5cc into main Nov 13, 2024
9 checks passed
@keshav-space keshav-space deleted the 1597-refactor-vulnerability-severity branch November 13, 2024 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project
Status: Validated

Development

Successfully merging this pull request may close these issues.

Incorrect severity score due to identical Reference URLs

3 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载