Skip to content
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

Add weakness in unique content ID in advisories #1245

Merged

Conversation

TG1999
Copy link
Contributor

@TG1999 TG1999 commented Jul 24, 2023

The NVD importer is failing to import due to this problem, since all other data is identical except weaknesses which is a new field on advisory, NVD importer is not able to create advisories.

@TG1999 TG1999 requested a review from pombredanne July 24, 2023 04:58
@TG1999 TG1999 force-pushed the add_weakness_in_models_unique_constraints branch 2 times, most recently from 19f28e8 to 0b83e49 Compare July 24, 2023 05:05
Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

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

Thanks... some minor nits for your consideration! You can apply or ignore.

},
)
except Exception as e:
logger.error(f"Error while processing {data!r} with aliases {data.aliases!r}: {e}")
Copy link
Member

Choose a reason for hiding this comment

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

Are you getting every data you need to debug with this message?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for pointing this, I missed the representation for error message.

@@ -836,7 +836,7 @@ class Meta:

def save(self, *args, **kwargs):
checksum = hashlib.md5()
for field in (self.summary, self.affected_packages, self.references):
for field in (self.summary, self.affected_packages, self.references, self.weaknesses):
Copy link
Member

Choose a reason for hiding this comment

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

Why not dumping only once?

key_data = [self.summary, self.affected_packages, self.references, self.weaknesses]
dumped = json.dumps(key_data, separators=(",", ":")).encode("utf-8")
checksum = hashlib.md5(dumped)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will change the checksum IMO, we should do it separately as a migration first and then change the function on models.

@TG1999 TG1999 force-pushed the add_weakness_in_models_unique_constraints branch from 0b83e49 to ef42bde Compare July 24, 2023 18:05
@TG1999 TG1999 merged commit 96bd222 into aboutcode-org:main Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants