Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
add sqlite import
  • Loading branch information
adamcrosby committed Mar 24, 2013
1 parent 5648247 commit 8a6a52c
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions control-import.py
@@ -1,6 +1,10 @@
#!/usr/bin/env python
#!/usr/bin/env python

import sys, sqlalchemy
from sqlalchemy.exc import IntegrityError
from database import db_session, init_db
from model import Control

import sys

reload(sys)
sys.setdefaultencoding('utf-8')
Expand All @@ -13,29 +17,37 @@
importFile = controlsXML.getroot()

iaControls = importFile.findall("{%s}IACONTROL" % xmlns)
init_db()

for control in iaControls:
title = control.find("{%s}CONTROL_NUMBER" % xmlns).get('title')
number = control.find("{%s}CONTROL_NUMBER" % xmlns).text
MACs = [mac.text for mac in control.findall("{%s}MACCONF/{%s}MAC" % (xmlns, xmlns))]
CONFs = [conf.text for conf in control.findall("{%s}MACCONF/{%s}CONF" % (xmlns, xmlns))]
name = control.find("{%s}CONTROL_NAME" % xmlns).text
if name != title:
print "number: %s" % number



c = Control()
c.title = control.find("{%s}CONTROL_NUMBER" % xmlns).get('title')
c.number = control.find("{%s}CONTROL_NUMBER" % xmlns).text
c.MAC = '|'.join([mac.text for mac in control.findall("{%s}MACCONF/{%s}MAC" % (xmlns, xmlns))])
c.CONF = '|'.join([conf.text for conf in control.findall("{%s}MACCONF/{%s}CONF" % (xmlns, xmlns))])
c.name = control.find("{%s}CONTROL_NAME" % xmlns).text
c.subjectArea = control.find("{%s}SUBJECT_AREA" % xmlns).text
c.impactCode = control.find("{%s}IMPACT_CODE" % xmlns).text
c.description = control.find("{%s}DESCRIPTION" % xmlns).text
c.threat = control.find("{%s}THREAT" % xmlns).text
c.guidance = control.find("{%s}GENERAL_IMPLEMENTATION_GUIDANCE" % xmlns).text
c.references = control.find("{%s}SYSTEM_SPECIFIC_GUIDANCE_RESOURCES" % xmlns).text


db_session.add(c)
db_session.commit()


test = """
test = u"""
<IMPORT_FILE xmlns="urn:FindingImport">
<IACONTROL>
<CONTROL_NUMBER title="Alternate Site Designation">COAS-1</CONTROL_NUMBER>
<MACCONF>
<MAC>MACIII</MAC>
</MACCONF>
<CONTROL_NAME>Alternate Site Designation</CONTROL_NAME>
datestr = benchmark.find("{%s}status" % xmlns).get("date")
"""
<SUBJECT_AREA>Continuity</SUBJECT_AREA>
<IMPACT_CODE>High</IMPACT_CODE>
<DESCRIPTION>An alternate site is identified that permits the restoration of all mission or business essential functions.</DESCRIPTION>
<THREAT>Environmental disasters, organized disruptions, loss of utilities/services, equipment or system failures, and serious information security incidents are potential events that could disrupt mission or business essential functions.  A recovery strategy should be developed to include an alternate site to mitigate the impact of disruptive events.</THREAT>
<GENERAL_IMPLEMENTATION_GUIDANCE/><SYSTEM_SPECIFIC_GUIDANCE_RESOURCES/>"""

0 comments on commit 8a6a52c

Please sign in to comment.