Skip to content

Commit

Permalink
feat(CVSS2, CVSS3): add methods to fetch isolated temporal and enviro…
Browse files Browse the repository at this point in the history
…nmental vectors
  • Loading branch information
fqlenos committed Sep 28, 2024
1 parent e5c64e0 commit 5dfd6a1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cvss/cvss2.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,28 @@ def rh_vector(self):
"""
return str(self.scores()[0]) + "/" + self.clean_vector()

def temporal_vector(self):
"""
Returns the temporal vector from the full CVSS vector.
Returns:
(str): Temporal CVSS vector.
"""
return "/".join(
[metric + ":" + self.metrics.get(metric, "ND") for metric in TEMPORAL_METRICS]
)

def environmental_vector(self):
"""
Returns the environmental vector from the full CVSS vector.
Returns:
(str): Environmental CVSS vector.
"""
return "/".join(
[metric + ":" + self.metrics.get(metric, "ND") for metric in ENVIRONMENTAL_METRICS]
)

def as_json(self, sort=False, minimal=False):
"""
Returns a dictionary formatted with attribute names and values defined by the official
Expand Down
22 changes: 22 additions & 0 deletions cvss/cvss3.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,28 @@ def rh_vector(self):
"""
return str(self.scores()[0]) + "/" + self.clean_vector()

def temporal_vector(self):
"""
Returns the temporal vector from the full CVSS vector.
Returns:
(str): Temporal CVSS vector.
"""
return "/".join(
[metric + ":" + self.metrics.get(metric, "X") for metric in TEMPORAL_METRICS]
)

def environmental_vector(self):
"""
Returns the environmental vector from the full CVSS vector.
Returns:
(str): Environmental CVSS vector.
"""
return "/".join(
[metric + ":" + self.metrics.get(metric, "X") for metric in ENVIRONMENTAL_METRICS]
)

def as_json(self, sort=False, minimal=False):
"""
Returns a dictionary formatted with attribute names and values defined by the official
Expand Down

0 comments on commit 5dfd6a1

Please sign in to comment.