Skip to content

Commit

Permalink
ralph asset factory added CIA
Browse files Browse the repository at this point in the history
  • Loading branch information
mwalkowski committed Jan 8, 2020
1 parent f39bf0f commit 4432d2e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ defusedxml==0.6.0
django-celery-results==1.0.4
django-simple-history==2.7.3
pyyaml==5.1.2
#mysqlclient==1.4.4
mysqlclient==1.4.4
gunicorn==19.9.0
7 changes: 4 additions & 3 deletions src/vmc/ralph/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

class AssetFactory:
FIELD_LIST = [field.name for field in Asset._meta.get_fields() if field]
IMPACT = {'LOW': 'L', 'MEDIUM': 'M', 'HIGH': 'H', 'NOT_DEFINED': 'N'}

@staticmethod
def process(item: dict) -> None:
Expand Down Expand Up @@ -77,20 +78,20 @@ def hostname(item: dict, _) -> str:
@staticmethod
def confidentiality_requirement(item: dict, _) -> str:
try:
return item['custom_fields']['confidentiality']
return AssetFactory.IMPACT[item['custom_fields']['confidentiality']]
except KeyError:
return Impact.NOT_DEFINED.value

@staticmethod
def integrity_requirement(item: dict, _) -> str:
try:
return item['custom_fields']['integrity']
return AssetFactory.IMPACT[item['custom_fields']['integrity']]
except KeyError:
return Impact.NOT_DEFINED.value

@staticmethod
def availability_requirement(item: dict, _) -> str:
try:
return item['custom_fields']['availability']
return AssetFactory.IMPACT[item['custom_fields']['availability']]
except KeyError:
return Impact.NOT_DEFINED.value
6 changes: 3 additions & 3 deletions src/vmc/ralph/fixtures/all_hosts_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
"processors": [],
"object_type": "datacenterasset",
"custom_fields": {
"confidentiality": "H",
"integrity": "N",
"availability": "N",
"confidentiality": "HIGH",
"integrity": "NOT_DEFINED",
"availability": "NOT_DEFINED",
"os": "Windows Server 2003"
},
"configuration_variables": {},
Expand Down

0 comments on commit 4432d2e

Please sign in to comment.