예제 #1
0
def initialise():
  b = Borg()
  b.logger = logging.getLogger('cairis')
  
  cfgFileName = ''
  try:
    cfgFileName = os.environ['CAIRIS_CFG']
  except KeyError:
    raise ARMException('CAIRIS_CFG environment variable has not been set.  Please set this to the correct location of your CAIRIS configuration file, e.g. export CAIRIS_CFG=/home/cairisuser/cairis.cnf') 

  if not os.path.exists(cfgFileName):
    raise ARMException('Unable to locate configuration file at the following location:' + cfgFileName)

  cfgFile = open(cfgFileName)
  for cfgLine in cfgFile.readlines():
    cfgTuple = cfgLine.split('=')
    cfgKey = strip(cfgTuple[0])
    cfgVal = strip(cfgTuple[1])
 
    if cfgKey == 'dbhost':
      b.dbHost = cfgVal
    elif cfgKey == 'dbport':
      b.dbPort = int(cfgVal)
    elif cfgKey == 'dbuser':
      b.dbUser = cfgVal
    elif cfgKey == 'dbpasswd':
      b.dbPasswd = cfgVal
    elif cfgKey == 'dbname':
      b.dbName = cfgVal
    elif cfgKey == 'tmp_dir': 
      b.tmpDir = cfgVal
    elif cfgKey == 'root': 
      b.cairisRoot = cfgVal
    elif cfgKey == 'default_image_dir': 
      b.imageDir = os.path.abspath(cfgVal)
  cfgFile.close()

  b.dbProxy = DatabaseProxyFactory.build()

  pSettings = b.dbProxy.getProjectSettings()
  b.fontSize = pSettings['Font Size']
  b.apFontSize = pSettings['AP Font Size']
  b.fontName = pSettings['Font Name']

  b.imageDir = b.cairisRoot + '/images' 
  b.configDir = b.cairisRoot + '/config'
  b.exampleDir = os.path.join(b.cairisRoot, 'examples')

  b.docBookDir = 'http://www.docbook.org/sgml/4.5'
  if os.path.exists('/usr/share/sgml/docbook/dtd/4.5'):
    b.docBookDir = '/usr/share/sgml/docbook/dtd/4.5'
  else:
    b.logger.warning('Unable to find DocBook schemes. Check if DocBook is correctly installed.')

  b.mainFrame = None
예제 #2
0
def initialise():
  b = Borg()
  b.logger = logging.getLogger('CAIRIS')
  
  homeDir = os.getenv("HOME")
  if homeDir is not None:
    cairisRoot = homeDir + "/CAIRIS/cairis"
  else:
    raise RuntimeError('The HOME environment variable is not defined.')
 
  cfgFileName = ''
  try:
    cfgFileName = os.environ['CAIRIS_CFG']
  except KeyError:
    cfgFileName = cairisRoot + '/cairis/config/cairis.cnf'

  if not os.path.exists(cfgFileName):
    raise IOError('''Unable to locate configuration file at the following location:
'''+cfgFileName) 

  cfgFile = open(cfgFileName)
  for cfgLine in cfgFile.readlines():
    cfgTuple = cfgLine.split('=')
    cfgKey = strip(cfgTuple[0])
    cfgVal = strip(cfgTuple[1])
 
    if cfgKey == 'dbhost':
      b.dbHost = cfgVal
    elif cfgKey == 'dbport':
      b.dbPort = int(cfgVal)
    elif cfgKey == 'dbuser':
      b.dbUser = cfgVal
    elif cfgKey == 'dbpasswd':
      b.dbPasswd = cfgVal
    elif cfgKey == 'dbname':
      b.dbName = cfgVal
    elif cfgKey == 'tmp_dir': 
      b.tmpDir = cfgVal
    elif cfgKey == 'root': 
      b.cairisRoot = cfgVal
  cfgFile.close()

  b.dbProxy = DatabaseProxyFactory.build()

  pSettings = b.dbProxy.getProjectSettings()
  b.fontSize = pSettings['Font Size']
  b.apFontSize = pSettings['AP Font Size']
  b.fontName = pSettings['Font Name']

  b.imageDir = b.cairisRoot + '/cairis/images' 
  b.configDir = b.cairisRoot + '/cairis/config'
  b.exampleDir = os.path.join(b.cairisRoot, 'examples')

  b.docBookDir = 'http://www.docbook.org/sgml/4.5'
  if os.path.exists('/usr/share/sgml/docbook/dtd/4.5'):
    b.docBookDir = '/usr/share/sgml/docbook/dtd/4.5'
  else:
    b.logger.warning('Unable to find DocBook schemes. Check if DocBook is correctly installed.')

  b.mainFrame = None
예제 #3
0
def initialiseCairisDbSettings(cfgDict):
    b = Borg()
    b.dbHost = cfgDict['dbhost']
    b.dbPort = int(cfgDict['dbport'])
    b.dbUser = cfgDict['dbuser']
    b.dbPasswd = cfgDict['dbpasswd']
    b.dbName = cfgDict['dbname']
    b.tmpDir = cfgDict['tmp_dir']
    b.cairisRoot = cfgDict['root']
    b.imageDir = os.path.abspath(cfgDict['default_image_dir'])
예제 #4
0
def initialiseCairisDbSettings(cfgDict):
  b = Borg()
  b.dbHost = cfgDict['dbhost']
  b.dbPort = int(cfgDict['dbport'])
  b.dbUser = cfgDict['dbuser']
  b.dbPasswd = cfgDict['dbpasswd']
  b.dbName = cfgDict['dbname']
  b.tmpDir = cfgDict['tmp_dir']
  b.cairisRoot = cfgDict['root']
  b.imageDir = os.path.abspath(cfgDict['default_image_dir'])
예제 #5
0
def initialise():
  cfgDict = parseConfigFile()
  initialiseCairisDbSettings(cfgDict)

  b = Borg()
  b.runmode = 'desktop'
  b.logger = logging.getLogger('cairis_gui')
  b.imageDir = b.cairisRoot + '/images' 
  b.configDir = b.cairisRoot + '/config'
  setupDocBookConfig()

  b.dbProxy = DatabaseProxyFactory.build()
  initialiseDesktopSettings()
예제 #6
0
def dInitialise():
  cfgDict = parseConfigFile()
  initialiseCairisDbSettings(cfgDict)

  b = Borg()
  b.runmode = 'web'
  b.logger = logging.getLogger('cairisd')
  b.imageDir = os.path.join(b.cairisRoot,'images')
  b.configDir = os.path.join(b.cairisRoot,'config')

  b.uploadDir = cfgDict['upload_dir']
  try:
    b.webPort = int(cfgDict['web_port'])
  except TypeError, ex:
    b.logger.error(str(ex.message))
예제 #7
0
파일: BorgFactory.py 프로젝트: nix4/CAIRIS
def initialise():
  b = Borg()
  cairisRoot = '/home/irisuser/CAIRIS/cairis'
  homeDir = os.getenv("HOME")
  if homeDir is not None:
    cairisRoot = homeDir + "/CAIRIS/cairis"
 
  cfgFileName = ''
  try:
    cfgFileName = os.environ['CAIRIS_CFG']
  except KeyError:
    cfgFileName = cairisRoot + '/cairis/config/cairis.cnf'    

  cfgFile = open(cfgFileName)
  for cfgLine in cfgFile.readlines():
    cfgTuple = cfgLine.split('=')
    cfgKey = strip(cfgTuple[0])
    cfgVal = strip(cfgTuple[1])
 
    if cfgKey == 'dbhost':
      b.dbHost = cfgVal
    elif cfgKey == 'dbport':
      b.dbPort = int(cfgVal)
    elif cfgKey == 'dbuser':
      b.dbUser = cfgVal
    elif cfgKey == 'dbpasswd':
      b.dbPasswd = cfgVal
    elif cfgKey == 'dbname':
      b.dbName = cfgVal
    elif cfgKey == 'tmp_dir': 
      b.tmpDir = cfgVal
    elif cfgKey == 'root': 
      b.cairisRoot = cfgVal
  cfgFile.close()

  b.dbProxy = DatabaseProxyFactory.build()

  pSettings = b.dbProxy.getProjectSettings()
  b.fontSize = pSettings['Font Size']
  b.apFontSize = pSettings['AP Font Size']
  b.fontName = pSettings['Font Name']

  b.imageDir = b.cairisRoot + '/cairis/images' 
  b.configDir = b.cairisRoot + '/cairis/config'

  b.mainFrame = None
예제 #8
0
def initialise():
  b = Borg()
  b.runmode = 'desktop'
  b.logger = logging.getLogger('cairisd')
  
  homeDir = os.getenv("HOME")
  if homeDir is not None:
    cairisRoot = homeDir + "/CAIRIS/cairis"
  else:
    raise RuntimeError('The HOME environment variable is not defined.')
 
  cfgFileName = ''
  try:
    cfgFileName = os.environ['CAIRIS_CFG']
  except KeyError:
    cfgFileName = cairisRoot + '/cairis/config/cairis.cnf'

  if not os.path.exists(cfgFileName):
    raise IOError('''Unable to locate configuration file at the following location:
'''+cfgFileName) 

  cfgFile = open(cfgFileName)
  for cfgLine in cfgFile.readlines():
    cfgTuple = cfgLine.split('=')
    cfgKey = strip(cfgTuple[0])
    cfgVal = strip(cfgTuple[1])
 
    if cfgKey == 'dbhost':
      b.dbHost = cfgVal
    elif cfgKey == 'dbport':
      b.dbPort = int(cfgVal)
    elif cfgKey == 'dbuser':
      b.dbUser = cfgVal
    elif cfgKey == 'dbpasswd':
      b.dbPasswd = cfgVal
    elif cfgKey == 'dbname':
      b.dbName = cfgVal
    elif cfgKey == 'tmp_dir': 
      b.tmpDir = cfgVal
    elif cfgKey == 'root':
      if os.path.exists(cfgVal): 
         b.cairisRoot = cfgVal
      else:
         print('The root directory of CAIRIS specified in the config file is invalid.\nSpecified path: %s' % cfgVal)
         exit(6)
  cfgFile.close()

  b.dbProxy = DatabaseProxyFactory.build()

  pSettings = b.dbProxy.getProjectSettings()
  b.fontSize = pSettings['Font Size']
  b.apFontSize = pSettings['AP Font Size']
  b.fontName = pSettings['Font Name']

  b.imageDir = b.cairisRoot + '/cairis/images' 
  b.configDir = b.cairisRoot + '/cairis/config'
  b.exampleDir = os.path.join(b.cairisRoot, 'examples')

  b.docBookDir = 'http://www.docbook.org/sgml/4.5'
  if os.path.exists('/usr/share/sgml/docbook/dtd/4.5'):
    b.docBookDir = '/usr/share/sgml/docbook/dtd/4.5'
  else:
    b.logger.warning('Unable to find DocBook schemes. Check if DocBook is correctly installed.')

  b.mainFrame = None
예제 #9
0
    parser.add_argument('modelFile',help='model file to import')
    parser.add_argument('--type',dest='modelFormat',help='model type to import.  One of securitypattern, attackpattern, tvtypes, directory, requirements, riskanalysis, usability, project, domainvalues, architecturalpattern, associations, synopses, processes, assets, locations or all')
    parser.add_argument('--overwrite',dest='isOverwrite',help='Where appropriate, overwrite an existing CAIRIS model with this model')
    parser.add_argument('--image_dir',dest='imageDir',help='Where appropriate, directory for model images (overwrites default_image_dir value in cairis.cnf)')
    args = parser.parse_args() 
    mFormat = args.modelFormat
    importFile = args.modelFile
    overwriteFlag = args.isOverwrite
    if overwriteFlag == None:
      overwriteFlag = 1

    BorgFactory.initialise()
    b = Borg()

    if args.imageDir != None:
      b.imageDir = os.path.abspath(args.imageDir)
   
    msgStr = ''
    if (mFormat == 'securitypattern'):
      msgStr += importSecurityPatterns(importFile)
    if (mFormat == 'attackpattern'):
      msgStr += importAttackPattern(importFile)
    elif (mFormat == 'tvtypes'):
      msgStr += importTVTypeFile(importFile,int(overwriteFlag))
    elif (mFormat == 'directory'):
      msgStr += importDirectoryFile(importFile,int(overwriteFlag))
    elif (mFormat == 'requirements'):
      msgStr += importRequirementsFile(importFile)
    elif (mFormat == 'riskanalysis'):
      msgStr += importRiskAnalysisFile(importFile)
    elif (mFormat == 'usability'):