Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Commit

Permalink
fixed indentation errors
Browse files Browse the repository at this point in the history
Signed-off-by: Glenda Garcia <[email protected]>
  • Loading branch information
glenda1015 committed Aug 22, 2023
1 parent 0132c26 commit 2473792
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -761,4 +761,4 @@ $RECYCLE.BIN/
# End of https://www.toptal.com/developers/gitignore/api/node,yarn,intellij,pycharm,webstorm,python,django,macos,windows,linux

# Emacs backups
*~
*~
12 changes: 9 additions & 3 deletions src/triage/models/assertion.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@


class AssertionsPerPackage(models.Model):
""" All assertions of a Package"""
"""All assertions of a Package"""

total_assertions = models.PositiveIntegerField()
package_name = models.CharField(max_length=100)
package_uuid = models.UUIDField(unique=True)
Expand All @@ -20,10 +21,15 @@ def save(self, *args, **kwargs):


class Assertion(models.Model):
""" An assertion of a package """
"""An assertion of a package"""

assertion_uuid = models.UUIDField(db_index=True, default=uuid.uuid4, editable=False)
assertion_name = models.CharField(max_length=100, default=None)
assertions_per_package = models.ForeignKey(to="AssertionsPerPackage", on_delete=models.CASCADE, default=None)
assertions_per_package = models.ForeignKey(
to="AssertionsPerPackage",
on_delete=models.CASCADE,
default=None,
)

def __str__(self):
return f"Assertion: {self.assertion_name}"
8 changes: 6 additions & 2 deletions src/triage/util/finding_importers/sarif_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ def add_assertion(self, assertion_data) -> bool:
for assertion_found in assertion_data:
assertion = Assertion()
assertion.assertion_uuid = assertion_found.get("uuid")
assertion.assertion_name = self.normalize_assertion_name(assertion_found.get("generator").get("name"))
assertion.assertion_name = self.normalize_assertion_name(
assertion_found.get("generator").get("name"),
)
assertion.assertions_per_package = package_assertions
assertion.save()

Expand All @@ -210,7 +212,9 @@ def add_assertion(self, assertion_data) -> bool:
def normalize_assertion_name(self, name: str) -> str:
"""Normalizes the assertion name."""
parts = name.split(".") # Split the name into parts using dot as delimiter
last_part = parts[-1] # Get the last part of the split result which is the actual name
last_part = parts[
-1
] # Get the last part of the split result which is the actual name
formatted_name = last_part.replace("_", " ").title() # Format the name
return formatted_name

Expand Down

0 comments on commit 2473792

Please sign in to comment.