Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom committed Oct 27, 2015
0 parents commit 0bd4f09
Show file tree
Hide file tree
Showing 10 changed files with 704 additions and 0 deletions.
108 changes: 108 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Created by .ignore support plugin (hsz.mobi)
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio

*.iml

## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:

# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries

# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml

# Gradle:
# .idea/gradle.xml
# .idea/libraries

# Mongo Explorer plugin:
# .idea/mongoSettings.xml

## File-based project format:
*.ipr
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties

48 changes: 48 additions & 0 deletions cvsslib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import enum


def make_display_name(str):
return " ".join(
s.capitalize() for s in str.lower().split("_")
)


class BaseEnum(enum.Enum):
@classmethod
def get_value_from_vector(cls, key):
key = key.lower()

for name, value in cls.__members__.items():
if name[0].lower() == key:
return value

if key == "x" and hasattr(cls, "NOT_DEFINED"):
return cls.NOT_DEFINED

raise RuntimeError("Unknown vector key {0} for {1}".format(key, cls))

@classmethod
def choices(cls):
return [(value.value, make_display_name(name)) for name, value in cls.__members__.items()]

@classmethod
def extend(cls, name, extra, doc=""):
cls = enum.Enum(
value=name,
names=cls.to_mapping(extra),
type=BaseEnum
)
cls.__doc__ = doc
return cls

@classmethod
def to_mapping(cls, extra=None):
returner = {
name: value.value
for name, value in cls.__members__.items()
}

if extra:
returner.update(extra)

return returner
5 changes: 5 additions & 0 deletions cvsslib/cvss2/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from . import enums


def calculate():
pass
102 changes: 102 additions & 0 deletions cvsslib/cvss2/enums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
from .. import BaseEnum


# Taken from https://www.first.org/cvss/v2/guide#i3.2.1

class AccessVector(BaseEnum):
LOCAL_ACCESS = 0.395
ADJACENT_NETWORK = 0.646
NETWORK_ACCESSIBLE = 1


class AccessComplexity(BaseEnum):
HIGH = 0.35
MEDIUM = 0.61
LOW = 0.71


class Authentication(BaseEnum):
MULTIPLE = 0.45
SINGLE = 0.56
NONE = 0.704


class ConfidentialityImpact(BaseEnum):
NONE = 0
PARTIAL = 0.275
COMPLETE = 0.660


class IntegrityImpact(BaseEnum):
NONE = 0
PARTIAL = 0.275
COMPLETE = 0.660


class AvailabilityImpact(BaseEnum):
NONE = 0
PARTIAL = 0.275
COMPLETE = 0.660


# Temporal:
class Exploitability(BaseEnum):
UNPROVEN = 0.85
PROOF_OF_CONCEPT = 0.9
FUNCTIONAL = 0.95
HIGH = 1
NOT_DEFINED = 1


class RemediationLevel(BaseEnum):
OFFICIAL_FIX = 0.87
TEMPORARY_FIX = 0.90
WORKAROUND = 0.95
UNAVAILABLE = 1
NOT_DEFINED = 1


class ReportConfidence(BaseEnum):
UNCONFIRMED = 0.9
UNCORROBORATED = 0.95
CONFIRMED = 1
NOT_DEFINED = 1


# Environmental
class CollateralDamagePotential(BaseEnum):
NONE = 0
LOW = 0.1
LOW_MEDIUM = 0.3
MEDIUM_HIGH = 0.4
HIGH = 0.5
NOT_DEFINED = 0


class TargetDistribution(BaseEnum):
NONE = 0
LOW = 0.25
MEDIUM = 0.75
HIGH = 1
NOT_DEFINED = 1


class ConfidentialityRequirement(BaseEnum):
LOW = 0.5
MEDIUM = 1
HIGH = 1.51
NOT_DEFINED = 1


class IntegrityRequirement(BaseEnum):
LOW = 0.5
MEDIUM = 1
HIGH = 1.51
NOT_DEFINED = 1


class AvailabilityRequirement(BaseEnum):
LOW = 0.5
MEDIUM = 1.0
HIGH = 1.51
NOT_DEFINED = 1.0
3 changes: 3 additions & 0 deletions cvsslib/cvss3/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .enums import *
from .calculations import *

Loading

0 comments on commit 0bd4f09

Please sign in to comment.