Skip to content

Commit 0bd4f09

Browse files
author
Tom
committed
Initial commit
0 parents  commit 0bd4f09

10 files changed

+704
-0
lines changed

.gitignore

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Python template
3+
# Byte-compiled / optimized / DLL files
4+
__pycache__/
5+
*.py[cod]
6+
*$py.class
7+
8+
# C extensions
9+
*.so
10+
11+
# Distribution / packaging
12+
.Python
13+
env/
14+
build/
15+
develop-eggs/
16+
dist/
17+
downloads/
18+
eggs/
19+
.eggs/
20+
lib/
21+
lib64/
22+
parts/
23+
sdist/
24+
var/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.coverage
43+
.coverage.*
44+
.cache
45+
nosetests.xml
46+
coverage.xml
47+
*,cover
48+
49+
# Translations
50+
*.mo
51+
*.pot
52+
53+
# Django stuff:
54+
*.log
55+
56+
# Sphinx documentation
57+
docs/_build/
58+
59+
# PyBuilder
60+
target/
61+
### JetBrains template
62+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
63+
64+
*.iml
65+
66+
## Directory-based project format:
67+
.idea/
68+
# if you remove the above rule, at least ignore the following:
69+
70+
# User-specific stuff:
71+
# .idea/workspace.xml
72+
# .idea/tasks.xml
73+
# .idea/dictionaries
74+
75+
# Sensitive or high-churn files:
76+
# .idea/dataSources.ids
77+
# .idea/dataSources.xml
78+
# .idea/sqlDataSources.xml
79+
# .idea/dynamic.xml
80+
# .idea/uiDesigner.xml
81+
82+
# Gradle:
83+
# .idea/gradle.xml
84+
# .idea/libraries
85+
86+
# Mongo Explorer plugin:
87+
# .idea/mongoSettings.xml
88+
89+
## File-based project format:
90+
*.ipr
91+
*.iws
92+
93+
## Plugin-specific files:
94+
95+
# IntelliJ
96+
/out/
97+
98+
# mpeltonen/sbt-idea plugin
99+
.idea_modules/
100+
101+
# JIRA plugin
102+
atlassian-ide-plugin.xml
103+
104+
# Crashlytics plugin (for Android Studio and IntelliJ)
105+
com_crashlytics_export_strings.xml
106+
crashlytics.properties
107+
crashlytics-build.properties
108+

cvsslib/__init__.py

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import enum
2+
3+
4+
def make_display_name(str):
5+
return " ".join(
6+
s.capitalize() for s in str.lower().split("_")
7+
)
8+
9+
10+
class BaseEnum(enum.Enum):
11+
@classmethod
12+
def get_value_from_vector(cls, key):
13+
key = key.lower()
14+
15+
for name, value in cls.__members__.items():
16+
if name[0].lower() == key:
17+
return value
18+
19+
if key == "x" and hasattr(cls, "NOT_DEFINED"):
20+
return cls.NOT_DEFINED
21+
22+
raise RuntimeError("Unknown vector key {0} for {1}".format(key, cls))
23+
24+
@classmethod
25+
def choices(cls):
26+
return [(value.value, make_display_name(name)) for name, value in cls.__members__.items()]
27+
28+
@classmethod
29+
def extend(cls, name, extra, doc=""):
30+
cls = enum.Enum(
31+
value=name,
32+
names=cls.to_mapping(extra),
33+
type=BaseEnum
34+
)
35+
cls.__doc__ = doc
36+
return cls
37+
38+
@classmethod
39+
def to_mapping(cls, extra=None):
40+
returner = {
41+
name: value.value
42+
for name, value in cls.__members__.items()
43+
}
44+
45+
if extra:
46+
returner.update(extra)
47+
48+
return returner

cvsslib/cvss2/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from . import enums
2+
3+
4+
def calculate():
5+
pass

cvsslib/cvss2/enums.py

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
from .. import BaseEnum
2+
3+
4+
# Taken from https://www.first.org/cvss/v2/guide#i3.2.1
5+
6+
class AccessVector(BaseEnum):
7+
LOCAL_ACCESS = 0.395
8+
ADJACENT_NETWORK = 0.646
9+
NETWORK_ACCESSIBLE = 1
10+
11+
12+
class AccessComplexity(BaseEnum):
13+
HIGH = 0.35
14+
MEDIUM = 0.61
15+
LOW = 0.71
16+
17+
18+
class Authentication(BaseEnum):
19+
MULTIPLE = 0.45
20+
SINGLE = 0.56
21+
NONE = 0.704
22+
23+
24+
class ConfidentialityImpact(BaseEnum):
25+
NONE = 0
26+
PARTIAL = 0.275
27+
COMPLETE = 0.660
28+
29+
30+
class IntegrityImpact(BaseEnum):
31+
NONE = 0
32+
PARTIAL = 0.275
33+
COMPLETE = 0.660
34+
35+
36+
class AvailabilityImpact(BaseEnum):
37+
NONE = 0
38+
PARTIAL = 0.275
39+
COMPLETE = 0.660
40+
41+
42+
# Temporal:
43+
class Exploitability(BaseEnum):
44+
UNPROVEN = 0.85
45+
PROOF_OF_CONCEPT = 0.9
46+
FUNCTIONAL = 0.95
47+
HIGH = 1
48+
NOT_DEFINED = 1
49+
50+
51+
class RemediationLevel(BaseEnum):
52+
OFFICIAL_FIX = 0.87
53+
TEMPORARY_FIX = 0.90
54+
WORKAROUND = 0.95
55+
UNAVAILABLE = 1
56+
NOT_DEFINED = 1
57+
58+
59+
class ReportConfidence(BaseEnum):
60+
UNCONFIRMED = 0.9
61+
UNCORROBORATED = 0.95
62+
CONFIRMED = 1
63+
NOT_DEFINED = 1
64+
65+
66+
# Environmental
67+
class CollateralDamagePotential(BaseEnum):
68+
NONE = 0
69+
LOW = 0.1
70+
LOW_MEDIUM = 0.3
71+
MEDIUM_HIGH = 0.4
72+
HIGH = 0.5
73+
NOT_DEFINED = 0
74+
75+
76+
class TargetDistribution(BaseEnum):
77+
NONE = 0
78+
LOW = 0.25
79+
MEDIUM = 0.75
80+
HIGH = 1
81+
NOT_DEFINED = 1
82+
83+
84+
class ConfidentialityRequirement(BaseEnum):
85+
LOW = 0.5
86+
MEDIUM = 1
87+
HIGH = 1.51
88+
NOT_DEFINED = 1
89+
90+
91+
class IntegrityRequirement(BaseEnum):
92+
LOW = 0.5
93+
MEDIUM = 1
94+
HIGH = 1.51
95+
NOT_DEFINED = 1
96+
97+
98+
class AvailabilityRequirement(BaseEnum):
99+
LOW = 0.5
100+
MEDIUM = 1.0
101+
HIGH = 1.51
102+
NOT_DEFINED = 1.0

cvsslib/cvss3/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .enums import *
2+
from .calculations import *
3+

0 commit comments

Comments
 (0)