@@ -611,14 +611,17 @@ def get_from_vector(vector: str) -> 'VulnerabilityScoreSource':
611611 Always returns an instance of `VulnerabilityScoreSource`. `VulnerabilityScoreSource.OTHER` is
612612 returned if the scheme is not obvious or known to us.
613613 """
614+ if vector .startswith ('CVSS:4.0' ):
615+ return VulnerabilityScoreSource .CVSS_V4
616+ if vector .startswith ('CVSS:3.1' ):
617+ return VulnerabilityScoreSource .CVSS_V3_1
614618 if vector .startswith ('CVSS:3.' ):
615619 return VulnerabilityScoreSource .CVSS_V3
616- elif vector .startswith ('CVSS:2.' ):
620+ if vector .startswith ('CVSS:2.' ):
617621 return VulnerabilityScoreSource .CVSS_V2
618- elif vector .startswith ('OWASP' ):
622+ if vector .startswith ('OWASP' ):
619623 return VulnerabilityScoreSource .OWASP
620- else :
621- return VulnerabilityScoreSource .OTHER
624+ return VulnerabilityScoreSource .OTHER
622625
623626 def get_localised_vector (self , vector : str ) -> str :
624627 """
@@ -630,15 +633,15 @@ def get_localised_vector(self, vector: str) -> str:
630633 Returns:
631634 The vector without any scheme prefix as a `str`.
632635 """
633- if self == VulnerabilityScoreSource .CVSS_V3 and vector .startswith ('CVSS:3 .' ):
634- return re .sub ('^CVSS:3\\ . \ \ d/?' , '' , vector )
635-
636- if self == VulnerabilityScoreSource . CVSS_V2 and vector .startswith ('CVSS:2 .' ):
637- return re .sub ('^CVSS:2 \\ . \ \ d/?' , '' , vector )
638-
639- if self == VulnerabilityScoreSource . OWASP and vector . startswith ( 'OWASP' ):
640- return re . sub ( '^ OWASP/?' , '' , vector )
641-
636+ if self is VulnerabilityScoreSource .CVSS_V4 and vector .startswith ('CVSS:4 .' ):
637+ return re .sub (r '^CVSS:3\. \d/?' , '' , vector )
638+ if ( self is VulnerabilityScoreSource . CVSS_V3_1 or self is VulnerabilityScoreSource . CVSS_V3 ) \
639+ and vector .startswith ('CVSS:3 .' ):
640+ return re .sub (r '^CVSS:3\. \d/?' , '' , vector )
641+ if self is VulnerabilityScoreSource . CVSS_V2 and vector . startswith ( 'CVSS:2.' ):
642+ return re . sub ( r'^CVSS:2\.\d/?' , '' , vector )
643+ if self is VulnerabilityScoreSource . OWASP and vector . startswith ( ' OWASP' ):
644+ return re . sub ( r'^OWASP/?' , '' , vector )
642645 return vector
643646
644647 def get_value_pre_1_4 (self ) -> str :
0 commit comments