예제 #1
0
def setupDocBookConfig():
  b = Borg()
  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.')
예제 #2
0
def json_serialize(obj, pretty_printing=False, session_id=None):
    """
    Serializes the Python object to a JSON serialized string.
    :param obj: The object to be serialized
    :type obj: object
    :param pretty_printing: Defines if the string needs to be pretty printed
    :type pretty_printing: bool
    :param session_id: The user's session ID
    :type session_id: int
    :return: Returns a JSON serialized string of the object
    """
    b = Borg()
    if session_id is None:
        session_id = session.get('session_id', None)

    s = b.get_settings(session_id)
    if s is not None:
        pretty_printing = s.get('jsonPrettyPrint', False)

    if pretty_printing:
        json_string = dumps(loads(serialize(obj)), indent=4)
    else:
        json_string = serialize(obj)

    for key in conv_terms:
        json_string = json_string.replace(key, conv_terms[key])

    return json_string
예제 #3
0
def importSecurityPatterns(importFile, session_id=None):
  parser = xml.sax.make_parser()
  handler = SecurityPatternContentHandler()
  parser.setContentHandler(handler)
  parser.setEntityResolver(handler)
  parser.parse(importFile)
  taps = handler.assets()
  spps = handler.patterns()
  noOfTaps = len(taps)
  noOfSpps = len(spps)

  b = Borg()
  db_proxy = b.get_dbproxy()

  msgStr = 'No patterns imported'
  if (noOfTaps > 0):
    tapId = 0;
    db_proxy.deleteSecurityPattern(-1)
    db_proxy.deleteTemplateAsset(-1)
    for tap in taps:
      tap.setId(tapId)
      db_proxy.addTemplateAsset(tap)
      tapId += 1

    if (noOfSpps > 0):
      spId = 0;
      db_proxy.deleteSecurityPattern(-1)
      for sp in spps:
        sp.setId(spId)
        db_proxy.addSecurityPattern(sp)
        spId += 1
      msgStr =  'Imported ' + str(noOfTaps) + ' template assets and ' + str(noOfSpps) + ' security patterns'
  return msgStr
예제 #4
0
def get_fonts(session_id=None):
    """
    Validates that the fonts to output the SVG models are properly set up
    :param session_id: The session ID provided by the user
    :return: The font name, font size and AP font name
    :rtype : str,str,str
    :raise CairisHTTPError: Raises a CairisHTTPError when the database could not be properly set up
    """
    if session_id is not None:
        b = Borg()
        settings = b.get_settings(session_id)
        fontName = settings.get('fontName', None)
        fontSize = settings.get('fontSize', None)
        apFontName = settings.get('apFontSize', None)

        if fontName is None or fontSize is None or apFontName is None:
            raise CairisHTTPError(
                status_code=httplib.BAD_REQUEST,
                message='The method is not callable without setting up the project settings.'
            )
        elif isinstance(fontName, str) and isinstance(fontSize, str) and isinstance(apFontName, str):
            return fontName, fontSize, apFontName
        else:
            raise CairisHTTPError(
                status_code=httplib.BAD_REQUEST,
                message='The database connection was not properly set up. Please try to reset the connection.'
            )
    else:
        raise CairisHTTPError(
            status_code=httplib.BAD_REQUEST,
            message='The method is not callable without setting up the project settings.'
        )
예제 #5
0
def importComponentViewData(view, session_id):
  b = Borg()
  db_proxy = b.get_dbproxy(session_id)

  db_proxy.addComponentView(view)
  msgStr = 'Imported architectural pattern'
  return msgStr
예제 #6
0
def importSecurityPatterns(importFile, session_id=None):
    parser = xml.sax.make_parser()
    handler = SecurityPatternContentHandler()
    parser.setContentHandler(handler)
    parser.setEntityResolver(handler)
    parser.parse(importFile)
    taps = handler.assets()
    spps = handler.patterns()
    noOfTaps = len(taps)
    noOfSpps = len(spps)

    b = Borg()
    db_proxy = b.get_dbproxy()

    msgStr = 'No patterns imported'
    if (noOfTaps > 0):
        tapId = 0
        db_proxy.deleteSecurityPattern(-1)
        db_proxy.deleteTemplateAsset(-1)
        for tap in taps:
            tap.setId(tapId)
            db_proxy.addTemplateAsset(tap)
            tapId += 1

        if (noOfSpps > 0):
            spId = 0
            db_proxy.deleteSecurityPattern(-1)
            for sp in spps:
                sp.setId(spId)
                db_proxy.addSecurityPattern(sp)
                spId += 1
            msgStr = 'Imported ' + str(
                noOfTaps) + ' template assets and ' + str(
                    noOfSpps) + ' security patterns'
    return msgStr
예제 #7
0
def importComponentViewData(view, session_id):
    b = Borg()
    db_proxy = b.get_dbproxy(session_id)

    db_proxy.addComponentView(view)
    msgStr = 'Imported architectural pattern'
    return msgStr
예제 #8
0
    def get_dbproxy(self, session_id):
        """
        Searches the MySQLDatabaseProxy instance associated with the session ID.
        :param
            session_id: The session ID
        :type
            session_id: str
        :rtype
            MySQLDatabaseProxy
        :return
            The MySQLDatabaseProxy instance associated with the session ID
        :raise
            CairisHTTPError
        """
        if session_id:
            b = Borg()
            db_proxy = b.get_dbproxy(session_id)

            if db_proxy is None:
                raise CairisHTTPError(
                    status_code=httplib.CONFLICT,
                    message='The database connection could not be created.')
            elif isinstance(db_proxy, MySQLDatabaseProxy):
                db_proxy.reconnect(session_id=session_id)
                return db_proxy
            else:
                raise CairisHTTPError(
                    status_code=httplib.CONFLICT,
                    message=
                    'The database connection was not properly set up. Please try to reset the connection.'
                )
        else:
            raise MissingParameterHTTPError(param_names=['session_id'])
예제 #9
0
def json_serialize(obj, pretty_printing=False, session_id=None):
    """
    Serializes the Python object to a JSON serialized string.
    :param obj: The object to be serialized
    :type obj: object
    :param pretty_printing: Defines if the string needs to be pretty printed
    :type pretty_printing: bool
    :param session_id: The user's session ID
    :type session_id: int
    :return: Returns a JSON serialized string of the object
    """
    b = Borg()
    if session_id is None:
        session_id = session.get('session_id', None)

    s = b.get_settings(session_id)
    if s is not None:
        pretty_printing = s.get('jsonPrettyPrint', False)

    if pretty_printing:
        json_string = dumps(loads(serialize(obj)), indent=4)
    else:
        json_string = serialize(obj)

    for key in conv_terms:
        json_string = json_string.replace(key, conv_terms[key])

    return json_string
예제 #10
0
    def get_dbproxy(self, session_id):
        """
        Searches the MySQLDatabaseProxy instance associated with the session ID.
        :param
            session_id: The session ID
        :type
            session_id: str
        :rtype
            MySQLDatabaseProxy
        :return
            The MySQLDatabaseProxy instance associated with the session ID
        :raise
            CairisHTTPError
        """
        if session_id:
            b = Borg()
            db_proxy = b.get_dbproxy(session_id)

            if db_proxy is None:
                raise CairisHTTPError(
                    status_code=httplib.CONFLICT,
                    message='The database connection could not be created.'
                )
            elif isinstance(db_proxy, MySQLDatabaseProxy):
                db_proxy.reconnect(session_id=session_id)
                return db_proxy
            else:
                raise CairisHTTPError(
                    status_code=httplib.CONFLICT,
                    message='The database connection was not properly set up. Please try to reset the connection.'
                )
        else:
            raise MissingParameterHTTPError(
                param_names=['session_id']
            )
예제 #11
0
def initialiseDesktopSettings():
  b = Borg()
  pSettings = b.dbProxy.getProjectSettings()
  b.fontSize = pSettings['Font Size']
  b.apFontSize = pSettings['AP Font Size']
  b.fontName = pSettings['Font Name']
  b.mainFrame = None
예제 #12
0
 def __init__(self, commands):
     Borg.__init__(self)
     self._commands = commands
     self._serializer_id_to_index = {}
     self._serializer_type_to_id = {}
     self._serializers = []
     self._deserializer_id_to_index = {}
     self._deserializers = []
예제 #13
0
def setPort(port):
    logger.info('Applying web port...')
    b = Borg()
    if port == 0:
        if not hasattr(b, 'webPort'):
            b.webPort = 7071
    else:
        b.webPort = port
예제 #14
0
 def __init__(self, writeResponseFn):
     Borg.__init__(self)
     self._writeResponseFn = writeResponseFn
     self._serializer_id_to_index = {}
     self._serializer_type_to_id = {}
     self._serializers = []
     self._deserializer_id_to_index = {}
     self._deserializers = []
예제 #15
0
def setPort(port):
    logger.info('Applying web port...')
    b = Borg()
    if port == 0:
        if not hasattr(b, 'webPort'):
            b.webPort = 7071
    else:
        b.webPort = port
예제 #16
0
def importProcesses(docs, codes, memos, quotations, codeNetworks, processes,
                    ics, intentions, contributions, session_id):
    noOfDocs = len(docs)
    noOfCodes = len(codes)
    noOfMemos = len(memos)
    noOfQuotations = len(quotations)
    noOfCNs = len(codeNetworks)
    noOfProcs = len(processes)
    noOfICs = len(ics)
    noOfIntentions = len(intentions)
    noOfContributions = len(contributions)

    b = Borg()
    db_proxy = b.get_dbproxy(session_id)

    for dp in docs:
        db_proxy.addInternalDocument(dp)

    for cp in codes:
        db_proxy.addCode(cp)

    for mp in memos:
        db_proxy.addMemo(mp)

    for q in quotations:
        db_proxy.addQuotation(q)

    # Necessary because adding document memos currently overwrites the existing memo text
    for mp in memos:
        db_proxy.updateMemo(mp)

    for cn in codeNetworks:
        personaName = cn[0]
        rtName = cn[1]
        fromCode = cn[2]
        toCode = cn[3]
        db_proxy.addCodeRelationship(personaName, fromCode, toCode, rtName)

    for p in processes:
        db_proxy.addImpliedProcess(p)

    for ic in ics:
        db_proxy.addImpliedCharacteristic(ic)

    for intention in intentions:
        db_proxy.addIntention(intention)

    for contribution in contributions:
        db_proxy.addContribution(contribution)

    msgStr = 'Imported ' + str(noOfDocs) + ' internal documents, ' + str(
        noOfCodes) + ' codes, ' + str(noOfMemos) + ' memos, ' + str(
            noOfQuotations) + ' quotations, ' + str(
                noOfCNs) + ' code relationships, ' + str(
                    noOfProcs) + ' implied processes, ' + str(
                        noOfIntentions) + ' intentions, and ' + str(
                            noOfContributions) + ' contributions.'
    return msgStr
예제 #17
0
 def __init__(self, session_id):
   b = Borg()
   self.dbProxy = b.get_dbproxy(session_id)
   self.configDir = b.configDir
   self.theCharacteristicSynopses = []
   self.theReferenceSynopses = []
   self.theStepSynopses = []
   self.theReferenceContributions = []
   self.theUseCaseContributions = []
예제 #18
0
def importRequirements(dpParameterSet,goalParameterSet,obsParameterSet,reqParameterSet,cmParameterSet, session_id):
  b = Borg()
  db_proxy = b.get_dbproxy(session_id)

  dpCount = 0
  for dpParameters in dpParameterSet:
    objtId = db_proxy.existingObject(dpParameters.name(),'domainproperty')
    if objtId == -1:
      db_proxy.addDomainProperty(dpParameters)
    else:
      dpParameters.setId(objtId)
      db_proxy.updateDomainProperty(dpParameters)
    dpCount += 1

  goalCount = 0
  for goalParameters in goalParameterSet:
    objtId = db_proxy.existingObject(goalParameters.name(),'goal')
    if objtId == -1:
      db_proxy.addGoal(goalParameters)
    else:
      goalParameters.setId(objtId)
      db_proxy.updateGoal(goalParameters)
    goalCount += 1

  obsCount = 0
  for obsParameters in obsParameterSet:
    objtId = db_proxy.existingObject(obsParameters.name(),'obstacle')
    if objtId == -1:
      db_proxy.addObstacle(obsParameters)
    else:
      obsParameters.setId(objtId)
      db_proxy.updateObstacle(obsParameters)
    obsCount += 1

  reqCount = 0
  for req,refName,refType in reqParameterSet:
    objtId = db_proxy.existingObject(req.name(),'requirement')
    if objtId == -1:
      isAsset = True
      if (refType == 'environment'):
        isAsset = False
      db_proxy.addRequirement(req,refName,isAsset)
    else:
      db_proxy.updateRequirement(req)
    reqCount += 1

  cmCount = 0
  for cmParameters in cmParameterSet:
    objtId = db_proxy.existingObject(cmParameters.name(),'countermeasure')
    if objtId == -1:
      db_proxy.addCountermeasure(cmParameters)
    else:
      cmParameters.setId(objtId)
      db_proxy.updateCountermeasure(cmParameters)
    cmCount += 1
  msgStr = 'Imported ' + str(dpCount) + ' domain properties, ' + str(goalCount) + ' goals, ' + str(obsCount) + ' obstacles, ' + str(reqCount) + ' requirements, and ' + str(cmCount) + ' countermeasures.'
  return msgStr
예제 #19
0
def setupDocBookConfig():
    b = Borg()
    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.'
        )
예제 #20
0
 def __init__(self, session_id):
     b = Borg()
     self.dbProxy = b.get_dbproxy(session_id)
     self.configDir = b.configDir
     self.theCharacteristicSynopses = []
     self.theReferenceSynopses = []
     self.theStepSynopses = []
     self.theReferenceContributions = []
     self.theUseCaseContributions = []
예제 #21
0
def validate_proxy(session, id, request=None, conf=None):
    """
    Validates that the DB proxy object is properly set up
    :param session: The session object of the request
    :param id: The session ID provided by the user
    :param conf: A dictionary containing configuration settings for direct authenrication
    :return: The MySQLDatabaseProxy object associated to the session
    :rtype : MySQLDatabaseProxy
    :raise CairisHTTPError: Raises a CairisHTTPError when the database could not be properly set up
    """

    if session is not None:
        session_id = session.get('session_id', -1)
    else:
        session_id = None

    if conf is not None:
        if isinstance(conf, dict):
            try:
                db_proxy = MySQLDatabaseProxy(host=conf['host'], port=conf['port'], user=conf['user'], passwd=conf['passwd'], db=conf['db'])
                if db_proxy is not None:
                    return db_proxy
                else:
                    raise CairisHTTPError(
                        status_code=httplib.CONFLICT,
                        message='The database connection could not be created.'
                    )
            except DatabaseProxyException:
                raise CairisHTTPError(
                    status_code=httplib.BAD_REQUEST,
                    message='The provided settings are invalid and cannot be used to create a database connection'
                )

    if not (session_id is None and id is None):
        if id is None:
            id = session_id
        b = Borg()
        db_proxy = b.get_dbproxy(id)

        if db_proxy is None:
            raise CairisHTTPError(
                status_code=httplib.CONFLICT,
                message='The database connection could not be created.'
            )
        elif isinstance(db_proxy, MySQLDatabaseProxy):
            return db_proxy
        else:
            raise CairisHTTPError(
                status_code=httplib.CONFLICT,
                message='The database connection was not properly set up. Please try to reset the connection.'
            )
    else:
        raise CairisHTTPError(
            status_code=httplib.BAD_REQUEST,
            message='The session is neither started or no session ID is provided with the request.'
        )
예제 #22
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'])
예제 #23
0
def setStaticDir(static_dir):
    logger.info('Setting static web content directory...')
    b = Borg()
    try:
        os.listdir(static_dir)
    except EnvironmentError as ex:
        logger.warning('The directory for static web content is not readable: %s' % ex.strerror)
        logger.warning('Static content may not be available')

    b.staticDir = os.path.abspath(static_dir)
  def __init__(self, session_id=None):
    b = Borg()
    self.dbProxy = b.get_dbproxy(session_id)
    self.configDir = b.configDir
    self.theManualAssociations = set([])
    self.theGoalAssociations = []
    self.theDependencyAssociations = []

    self.resetManualAssociationAttributes()
    self.resetGoalAssociationAttributes()
    self.resetDependencyAssociationAttributes()
예제 #25
0
def setStaticDir(static_dir):
    logger.info('Setting static web content directory...')
    b = Borg()
    try:
        os.listdir(static_dir)
    except EnvironmentError as ex:
        logger.warning(
            'The directory for static web content is not readable: %s' %
            ex.strerror)
        logger.warning('Static content may not be available')

    b.staticDir = os.path.abspath(static_dir)
예제 #26
0
def importDomainValues(tvValues, rvValues, cvValues, svValues, lvValues,
                       capValues, motValues, session_id):
    noOfTvs = len(tvValues)
    noOfRvs = len(rvValues)
    noOfCvs = len(cvValues)
    noOfSvs = len(svValues)
    noOfLvs = len(lvValues)
    noOfCapVs = len(capValues)
    noOfMotVs = len(motValues)

    b = Borg()
    db_proxy = b.get_dbproxy(session_id)

    tId = 0
    if (noOfTvs > 0):
        for tvp in tvValues:
            tvp.setId(tId)
            db_proxy.updateValueType(tvp)
            tId += 1
    tId = 1
    if (noOfRvs > 0):
        for rvp in rvValues:
            rvp.setId(tId)
            db_proxy.updateValueType(rvp)
            tId += 1
    tId = 0
    if (noOfCvs > 0):
        for cvp in cvValues:
            cvp.setId(tId)
            db_proxy.updateValueType(cvp)
            tId += 1
    tId = 0
    if (noOfSvs > 0):
        for svp in svValues:
            svp.setId(tId)
            db_proxy.updateValueType(svp)
            tId += 1
    tId = 0
    if (noOfLvs > 0):
        for lvp in lvValues:
            lvp.setId(tId)
            db_proxy.updateValueType(lvp)
            tId += 1
    if (noOfCapVs > 0):
        for capvp in capValues:
            db_proxy.addValueType(capvp)
    if (noOfMotVs > 0):
        for motvp in motValues:
            db_proxy.addValueType(motvp)

    msgStr = 'Imported domain values'
    return msgStr
예제 #27
0
def setLoglevel(log_level):
    b = Borg()
    logger.info('Applying log level...')

    log_level = log_level.lower()
    if log_level == 'verbose':
        realLevel = logging.INFO
    elif log_level == 'debug':
        realLevel = logging.DEBUG
    else:
        realLevel = logging.WARNING

    b.logLevel = realLevel
예제 #28
0
def setLoglevel(log_level):
    b = Borg()
    logger.info('Applying log level...')

    log_level = log_level.lower()
    if log_level == 'verbose':
        realLevel = logging.INFO
    elif log_level == 'debug':
        realLevel = logging.DEBUG
    else:
        realLevel = logging.WARNING

    b.logLevel = realLevel
예제 #29
0
def importDomainValues(tvValues,rvValues,cvValues,svValues,lvValues,capValues,motValues, session_id):
  noOfTvs = len(tvValues)
  noOfRvs = len(rvValues)
  noOfCvs = len(cvValues)
  noOfSvs = len(svValues)
  noOfLvs = len(lvValues)
  noOfCapVs = len(capValues)
  noOfMotVs = len(motValues)
 
  b = Borg()
  db_proxy = b.get_dbproxy(session_id)

  tId = 0
  if (noOfTvs > 0):
    for tvp in tvValues:
      tvp.setId(tId)
      db_proxy.updateValueType(tvp)
      tId += 1
  tId =1
  if (noOfRvs > 0):
    for rvp in rvValues:
      rvp.setId(tId)
      db_proxy.updateValueType(rvp)
      tId += 1
  tId = 0
  if (noOfCvs > 0):
    for cvp in cvValues:
      cvp.setId(tId)
      db_proxy.updateValueType(cvp)
      tId += 1
  tId = 0
  if (noOfSvs > 0):
    for svp in svValues:
      svp.setId(tId)
      db_proxy.updateValueType(svp)
      tId += 1
  tId = 0
  if (noOfLvs > 0):
    for lvp in lvValues:
      lvp.setId(tId)
      db_proxy.updateValueType(lvp)
      tId += 1
  if (noOfCapVs > 0):
    for capvp in capValues:
      db_proxy.addValueType(capvp)
  if (noOfMotVs > 0):
    for motvp in motValues:
      db_proxy.addValueType(motvp)

  msgStr = 'Imported domain values'
  return msgStr
예제 #30
0
def importProcesses(docs,codes,memos,quotations,codeNetworks,processes,ics,intentions,contributions, session_id):
  noOfDocs = len(docs)
  noOfCodes = len(codes)
  noOfMemos = len(memos)
  noOfQuotations = len(quotations)
  noOfCNs = len(codeNetworks)
  noOfProcs = len(processes)
  noOfICs = len(ics)
  noOfIntentions = len(intentions)
  noOfContributions = len(contributions)

  b = Borg()
  db_proxy = b.get_dbproxy(session_id)

  for dp in docs:
    db_proxy.addInternalDocument(dp)

  for cp in codes:
    db_proxy.addCode(cp)

  for mp in memos:
    db_proxy.addMemo(mp)

  for q in quotations:
    db_proxy.addQuotation(q)

  # Necessary because adding document memos currently overwrites the existing memo text
  for mp in memos:
    db_proxy.updateMemo(mp)

  for cn in codeNetworks:
    personaName = cn[0]
    rtName = cn[1]
    fromCode = cn[2]
    toCode = cn[3]
    db_proxy.addCodeRelationship(personaName,fromCode,toCode,rtName)

  for p in processes:
    db_proxy.addImpliedProcess(p)

  for ic in ics:
    db_proxy.addImpliedCharacteristic(ic)

  for intention in intentions:
    db_proxy.addIntention(intention)

  for contribution in contributions:
    db_proxy.addContribution(contribution)

  msgStr = 'Imported ' + str(noOfDocs) + ' internal documents, ' + str(noOfCodes) + ' codes, ' + str(noOfMemos) + ' memos, ' + str(noOfQuotations) + ' quotations, ' + str(noOfCNs) + ' code relationships, ' + str(noOfProcs) + ' implied processes, ' + str(noOfIntentions) + ' intentions, and ' + str(noOfContributions) + ' contributions.'
  return msgStr
예제 #31
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'])
예제 #32
0
    def onDeleteQuotation(self, evt):
        if (self.theSelectedIdx == -1):
            errorText = 'No quote selected'
            errorLabel = 'Delete Quotation'
            dlg = wx.MessageDialog(self, errorText, errorLabel, wx.OK)
            dlg.ShowModal()
            dlg.Destroy()
        else:
            codeName = self.GetItemText(self.theSelectedIdx)
            atItem = self.GetItem(self.theSelectedIdx, 1)
            atName = atItem.GetText()
            aItem = self.GetItem(self.theSelectedIdx, 2)
            aName = aItem.GetText()
            qTxtItem = self.GetItem(self.theSelectedIdx, 4)
            qTxt = qTxtItem.GetText()
            startIdx, endIdx, synopsis, label = self.theQuoteIndices[(codeName,
                                                                      atName,
                                                                      aName,
                                                                      qTxt)]

            b = Borg()
            b.dbProxy.deleteQuotation(codeName, atName, aName, startIdx,
                                      endIdx)
            del self.theQuoteIndices[(codeName, atName, aName, qTxt)]
            self.DeleteItem(self.theSelectedIdx)
예제 #33
0
    def __init__(self, parent, winId):
        CodingTextCtrl.__init__(self, parent, winId)
        b = Borg()
        self.dbProxy = b.dbProxy
        self.theTaskName = ''
        self.theEnvironmentName = ''

        self.theDimMenu = wx.Menu()
        self.theDimMenu.Append(armid.NARCTRL_MENUGOAL_ID, 'Refining Goal')
        self.theDimMenu.Append(armid.NARCTRL_MENUOBSTACLE_ID,
                               'Refining Obstacle')
        self.theDimMenu.Append(armid.NARCTRL_MENUREQUIREMENT_ID,
                               'Refining Requirement')
        self.theDimMenu.AppendMenu(armid.BVNTC_MENU_CODING, 'Coding',
                                   self.codingMenu)

        self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)
        wx.EVT_MENU(self.theDimMenu, armid.NARCTRL_MENUGOAL_ID, self.onGoal)
        wx.EVT_MENU(self.theDimMenu, armid.NARCTRL_MENUOBSTACLE_ID,
                    self.onObstacle)
        wx.EVT_MENU(self.theDimMenu, armid.NARCTRL_MENUREQUIREMENT_ID,
                    self.onRequirement)
        self.goalItem = self.theDimMenu.FindItemById(armid.NARCTRL_MENUGOAL_ID)
        self.goalItem.Enable(False)
        self.reqItem = self.theDimMenu.FindItemById(
            armid.NARCTRL_MENUREQUIREMENT_ID)
        self.reqItem.Enable(False)
        self.obsItem = self.theDimMenu.FindItemById(
            armid.NARCTRL_MENUOBSTACLE_ID)
        self.obsItem.Enable(False)
예제 #34
0
    def __init__(self, parent):
        wx.Dialog.__init__(self,
                           parent,
                           armid.RESPONSECOST_ID,
                           'Add Response Cost',
                           style=wx.DEFAULT_DIALOG_STYLE | wx.MAXIMIZE_BOX
                           | wx.THICK_FRAME | wx.RESIZE_BORDER,
                           size=(400, 100))
        b = Borg()
        self.dbProxy = b.dbProxy
        self.theResponseName = ''
        self.theResponseCost = ''
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        responseList = self.dbProxy.getDimensionNames('response')
        mainSizer.Add(
            WidgetFactory.buildComboSizerList(
                self, 'Response', (87, 30),
                armid.RESPONSECOST_COMBORESPONSE_ID, responseList), 0,
            wx.EXPAND)
        mainSizer.Add(
            WidgetFactory.buildComboSizerList(self, 'Cost', (87, 30),
                                              armid.RESPONSECOST_COMBOCOST_ID,
                                              ['Low', 'Medium', 'High']), 0,
            wx.EXPAND)
        mainSizer.Add(
            WidgetFactory.buildAddCancelButtonSizer(
                self, armid.RESPONSECOST_BUTTONADD_ID), 0, wx.ALIGN_CENTER)
        self.SetSizer(mainSizer)

        wx.EVT_BUTTON(self, armid.RESPONSECOST_BUTTONADD_ID, self.onAdd)
예제 #35
0
    def __init__(self, parent, personaName, codeNet):
        BasePanel.__init__(self, parent, armid.CODENETWORK_ID)
        b = Borg()
        self.dbProxy = b.dbProxy
        self.theCodeNetwork = codeNet

        self.theViewMenu = wx.Menu()
        self.theViewMenu.Append(armid.CNV_MENU_ADD_ID, 'Add')
        self.theViewMenu.Append(armid.CNV_MENU_EDIT_ID, 'Edit')
        wx.EVT_MENU(self, armid.CNV_MENU_ADD_ID, self.onAddRelationship)
        wx.EVT_MENU(self, armid.CNV_MENU_EDIT_ID, self.onEditRelationship)

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        personas = self.dbProxy.getDimensionNames('persona')
        mainSizer.Add(
            self.buildComboSizerList('Persona', (87, 30),
                                     armid.CODENETWORK_COMBOPERSONA_ID,
                                     personas), 0, wx.EXPAND)

        cnBox = wx.StaticBox(self, -1, 'Code Network')
        cnSizer = wx.StaticBoxSizer(cnBox, wx.HORIZONTAL)
        mainSizer.Add(cnSizer, 1, wx.EXPAND)
        self.codeNetView = CodeNetworkView(self,
                                           armid.CODENETWORK_IMAGENETWORK_ID)
        self.codeNetView.Bind(wx.EVT_RIGHT_DOWN, self.onRightDown)
        self.codeNetView.reloadImage()
        cnSizer.Add(self.codeNetView, 1, wx.EXPAND)

        self.personaCtrl = self.FindWindowById(
            armid.CODENETWORK_COMBOPERSONA_ID)
        self.personaCtrl.SetValue(personaName)
        self.personaCtrl.Bind(wx.EVT_COMBOBOX, self.onPersonaChange)
        self.SetSizer(mainSizer)
    def __init__(self,
                 objt,
                 environmentName,
                 builder,
                 goalIndicator,
                 gName,
                 reqIndicator=False):
        self.window = builder.get_object("GoalRefinementNodeDialog")
        b = Borg()
        self.dbProxy = b.dbProxy
        self.theEnvironmentName = environmentName
        self.decorator = NDImplementationDecorator(builder)
        self.reqIndicator = reqIndicator

        refTypes = ['and', 'or']
        goals = self.dbProxy.environmentGoals(self.theEnvironmentName)
        if (self.reqIndicator == True):
            refTypes = ['and']
            goals = self.dbProxy.getDimensionNames('requirement')

        self.decorator.updateComboCtrl("goalRefNameCtrl", goals, '')
        self.decorator.updateComboCtrl("goalRefinementCtrl", refTypes, '')
        self.decorator.updateButtonLabel("goalRefinementOkButton", "Create")
        self.window.resize(350, 200)
        self.goalIndicator = goalIndicator
        self.inputGoalName = gName
예제 #37
0
def get_logger():
    b = Borg()
    log = logging.getLogger('cairisd')
    log.setLevel(logging.INFO)

    try:
        log = b.logger
    except AttributeError:
        b.logger = log
        try:
            log.setLevel(b.logLevel)
            b.logger.setLevel(b.logLevel)
        except AttributeError:
            b.logLevel = logging.INFO

    return log
예제 #38
0
 def __init__(self, associations, envName, conceptName='', cfSet=False):
     self.theAssociations = associations
     self.theEnvironmentName = envName
     self.theConceptName = conceptName
     b = Borg()
     self.dbProxy = b.dbProxy
     self.fontName = b.fontName
     self.fontSize = b.fontSize
     self.theGraph = pydot.Dot()
     self.theGraph.set_graph_defaults(rankdir='LR')
     if (cfSet == True):
         self.theGraph.set_node_defaults(shape='ellipse',
                                         colorscheme='set14',
                                         color='1',
                                         fontname=self.fontName,
                                         fontsize=self.fontSize,
                                         style='filled')
     else:
         self.theGraph.set_node_defaults(shape='rectangle',
                                         colorscheme='spectral3',
                                         color='1',
                                         fontname=self.fontName,
                                         fontsize=self.fontSize)
     self.theGraph.set_edge_defaults(arrowhead='vee')
     self.cfSet = cfSet
     self.theClusters = {}
     self.theEdges = []
     self.theGraphName = b.tmpDir + '/concept.dot'
예제 #39
0
    def __init__(self, parent):
        BasePanel.__init__(self, parent, armid.INTERFACELISTDIALOG_ID)
        b = Borg()
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        ifList = b.dbProxy.getDimensionNames('interface')
        mainSizer.Add(
            self.buildComboSizerList('Name', (87, 30),
                                     armid.INTERFACELISTDIALOG_COMBONAME_ID,
                                     ifList), 0, wx.EXPAND)
        mainSizer.Add(
            self.buildComboSizerList('Type', (87, 30),
                                     armid.INTERFACELISTDIALOG_COMBOTYPE_ID,
                                     ['provided', 'required']), 0, wx.EXPAND)
        metricsSizer = wx.BoxSizer(wx.HORIZONTAL)
        mainSizer.Add(metricsSizer, 0, wx.EXPAND)
        arList = b.dbProxy.getDimensionNames('access_right')
        pList = b.dbProxy.getDimensionNames('privilege')
        metricsSizer.Add(
            self.buildComboSizerList(
                'Access Right', (87, 30),
                armid.INTERFACELISTDIALOG_COMBOACCESSRIGHT_ID, arList), 1,
            wx.EXPAND)
        metricsSizer.Add(
            self.buildComboSizerList(
                'Privilege', (87, 30),
                armid.INTERFACELISTDIALOG_COMBOPRIVILEGE_ID, pList), 1,
            wx.EXPAND)

        mainSizer.Add(wx.StaticText(self, -1, ''), 1, wx.EXPAND)
        mainSizer.Add(self.buildCommitButtonSizer(wx.ID_OK, True), 0,
                      wx.CENTER)
        self.SetSizer(mainSizer)
예제 #40
0
  def onCommit(self,evt):
    commitLabel = 'Update quotation'

    codeCtrl = self.FindWindowById(armid.QUOTATION_TEXTCODE_ID)
    atCtrl = self.FindWindowById(armid.QUOTATION_TEXTARTIFACTTYPE_ID)
    anCtrl = self.FindWindowById(armid.QUOTATION_TEXTARTIFACTNAME_ID)
    srcCtrl = self.FindWindowById(armid.QUOTATION_TEXTSOURCE_ID)
    synCtrl = self.FindWindowById(armid.QUOTATION_TEXTSYNOPSIS_ID)
    lblCtrl = self.FindWindowById(armid.QUOTATION_TEXTLABEL_ID)

    codeName = codeCtrl.GetValue()
    atName = atCtrl.GetValue()
    aName = anCtrl.GetValue()
    synopsis = synCtrl.GetValue()
    label = lblCtrl.GetValue()
    
    startIdx,endIdx = srcCtrl.GetSelection()
    if (startIdx == endIdx):
      dlg = wx.MessageDialog(self,'Selection must be made',commitLabel,wx.OK) 
      dlg.ShowModal()
      dlg.Destroy()
      return
    elif startIdx == self.theOldStartIdx and endIdx == self.theOldEndIdx:
      self.EndModal(wx.ID_CLOSE)
    b = Borg()
    b.dbProxy.updateQuotation(codeName,atName,aName,self.theOldStartIdx,self.theOldEndIdx,startIdx,endIdx,synopsis,label)
    self.EndModal(armid.QUOTATION_BUTTONCOMMIT_ID)
예제 #41
0
 def __init__(self, objt, environmentName, dupProperty,
              overridingEnvironment, builder):
     self.window = builder.get_object("ObstacleNodeDialog")
     b = Borg()
     self.dbProxy = b.dbProxy
     self.theEnvironmentName = environmentName
     self.theObstacleAssociation = None
     self.theObstacleId = -1
     self.decorator = NDImplementationDecorator(builder)
     obstacleCategories = self.dbProxy.getDimensionNames(
         'obstacle_category_type')
     self.obstacleAssociations = []
     self.subObstacleAssociations = []
     if (objt == None):
         self.decorator.updateComboCtrl("obstacleCategoryCtrl",
                                        obstacleCategories, '')
         self.decorator.updateButtonLabel("obstacleOkButton", "Create")
         self.isCreate = True
     else:
         self.theObstacleId = objt.id()
         envProperty = objt.environmentProperty(self.theEnvironmentName)
         self.obstacleAssociations = envProperty.goalRefinements()
         self.subObstacleAssociations = envProperty.subGoalRefinements()
         self.decorator.updateTextCtrl("obstacleNameCtrl", objt.name())
         self.decorator.updateComboCtrl(
             "obstacleCategoryCtrl", obstacleCategories,
             objt.category(environmentName, dupProperty))
         self.decorator.updateMLTextCtrl(
             "obstacleDefinitionCtrl",
             objt.definition(environmentName, dupProperty))
         self.decorator.updateButtonLabel("obstacleOkButton", "Update")
         self.isCreate = False
     self.window.resize(350, 600)
예제 #42
0
def build(threatName, vulnerabilityName, dbProxy=None):
    if (dbProxy == None):
        b = Borg()
        dbProxy = b.dbProxy

    envNames = dbProxy.riskEnvironments(threatName, vulnerabilityName)
    threatId = dbProxy.getDimensionId(threatName, 'threat')
    vulId = dbProxy.getDimensionId(vulnerabilityName, 'vulnerability')

    envList = []
    for envName in envNames:
        mcEnv = MisuseCaseEnvironmentProperties(envName)

        mcEnv.theRiskRating = RiskRating(
            threatName, vulnerabilityName, envName,
            dbProxy.riskRating(threatName, vulnerabilityName, envName))
        envId = dbProxy.getDimensionId(envName, 'environment')
        mcEnv.theLikelihood = dbProxy.threatLikelihood(threatId, envId)
        mcEnv.theSeverity = dbProxy.vulnerabilitySeverity(vulId, envId)
        mcEnv.theAttackers = dbProxy.threatAttackers(threatId, envId)

        threatenedAssets = dbProxy.threatenedAssets(threatId, envId)
        vulnerableAssets = dbProxy.vulnerableAssets(vulId, envId)
        mcEnv.theObjective = objectiveText(vulnerableAssets, threatenedAssets)
        mcEnv.theAssets = set(threatenedAssets + vulnerableAssets)
        envList.append(mcEnv)
    mc = MisuseCase(-1, '', envList, '')
    mc.theThreatName = threatName
    mc.theVulnerabilityName = vulnerabilityName
    return mc
예제 #43
0
 def __init__(self, modCombo, isAsset=True):
     b = Borg()
     self.dbProxy = b.dbProxy
     self.modCombo = modCombo
     self.isAsset = isAsset
     modName = self.modCombo.GetValue()
     self.reqs = self.dbProxy.getOrderedRequirements(modName, isAsset)
예제 #44
0
def detectText(response):
    goalCategory = 'Detect'
    riskName = response.risk()
    b = Borg()
    thrName, vulName = b.dbProxy.riskComponents(riskName)
    riskGoalName = goalCategory + riskName
    thrGoalName = goalCategory + thrName
    vulGoalName = goalCategory + vulName
    detPoint = (response.environmentProperties()[0]).detectionPoint()
    riskGoalDef = 'The system shall detect risk ' + riskName
    thrGoalDef = 'The system shall detect threat ' + thrName
    vulGoalDef = 'The system shall detect vulnerability ' + vulName
    if (detPoint == 'Before'):
        riskGoalDef += ' before '
        thrGoalDef += ' before '
        vulGoalDef += ' before '
    if (detPoint == 'At'):
        riskGoalDef += ' during '
        thrGoalDef += ' during '
        vulGoalDef += ' during '
    if (detPoint == 'After'):
        riskGoalDef += ' after '
        thrGoalDef += ' after '
        vulGoalDef += ' after '
    riskGoalDef += 'its occurrence.'
    thrGoalDef += 'its occurrence.'
    vulGoalDef += 'its occurrence.'
    return [(riskGoalName, riskGoalDef, goalCategory),
            (thrGoalName, thrGoalDef, goalCategory),
            (vulGoalName, vulGoalDef, goalCategory)]
예제 #45
0
 def __init__(self, parent):
     wx.Panel.__init__(self, parent, armid.STEPSYNOPSIS_ID)
     b = Borg()
     self.dbProxy = b.dbProxy
     mainSizer = wx.BoxSizer(wx.VERTICAL)
     mainSizer.Add(
         WidgetFactory.buildTextSizer(self, 'Synopsis', (87, 30),
                                      armid.STEPSYNOPSIS_TEXTSYNOPSIS_ID),
         0, wx.EXPAND)
     actorSizer = wx.BoxSizer(wx.HORIZONTAL)
     mainSizer.Add(actorSizer, 0, wx.EXPAND)
     actorSizer.Add(
         WidgetFactory.buildComboSizerList(
             self, 'Actor Type', (87, 30),
             armid.STEPSYNOPSIS_COMBOACTORTYPE_ID, ['asset', 'role']), 1,
         wx.EXPAND)
     actorSizer.Add(
         WidgetFactory.buildComboSizerList(
             self, 'Actor', (87, 30), armid.STEPSYNOPSIS_COMBOACTORNAME_ID,
             ['']), 1, wx.EXPAND)
     mainSizer.Add(wx.StaticText(self, -1, ''), 1, wx.EXPAND)
     mainSizer.Add(
         WidgetFactory.buildCommitButtonSizer(
             self, armid.STEPSYNOPSIS_BUTTONCOMMIT_ID, True), 0,
         wx.ALIGN_CENTER)
     self.SetSizer(mainSizer)
     wx.EVT_COMBOBOX(self, armid.STEPSYNOPSIS_COMBOACTORTYPE_ID,
                     self.onActorType)
예제 #46
0
 def __init__(self, cvName):
     componentxdot.ComponentDotWindow.__init__(self, '', cvName)
     self.widget.connect('clicked', self.on_url_clicked)
     self.widget.connect('button_press_event', self.onClick)
     b = Borg()
     directoryPrefix = b.imageDir + '/'
     self.set_icon_from_file(directoryPrefix + 'component_view.png')
예제 #47
0
  def __init__(self, session_id=None):
    b = Borg()
    self.dbProxy = b.get_dbproxy(session_id)
    self.configDir = b.configDir
    self.theDomainProperties = []
    self.theGoals = []
    self.theObstacles = []
    self.theRequirements = []
    self.theCountermeasures = []

    self.resetDomainPropertyAttributes()
    self.resetGoalAttributes()
    self.resetObstacleAttributes()
    self.resetRequirementAttributes()
    self.resetGoalAttributes()
    self.resetCountermeasureAttributes()
예제 #48
0
def importModelFile(importFile, isOverwrite=1, session_id=None):
  b = Borg()
  db_proxy = b.get_dbproxy(session_id)

  modelTxt = ''
  if isOverwrite == 1:
    db_proxy.clearDatabase(session_id)
    modelTxt += importTVTypeFile(importFile, session_id=session_id) + '  '
  modelTxt += importDomainValuesFile(importFile, session_id=session_id) + ' '
  modelTxt += importProjectFile(importFile, session_id=session_id) + ' '
  modelTxt += importRiskAnalysisFile(importFile, session_id=session_id) + ' '
  modelTxt += importUsabilityFile(importFile, session_id=session_id) + ' '
  modelTxt += importRequirementsFile(importFile, session_id=session_id) + ' '
  modelTxt += importAssociationsFile(importFile, session_id=session_id) + ' '
  modelTxt += importSynopsesFile(importFile, session_id=session_id)
  return modelTxt
예제 #49
0
def reactText(response):
    goalCat = 'React'
    riskName = response.risk()
    b = Borg()
    thrName, vulName = b.dbProxy.riskComponents(riskName)

    riskGoalName = goalCat + riskName
    thrGoalName = goalCat + thrName
    vulGoalName = goalCat + vulName
    detMechs = (response.environmentProperties()[0]).detectionMechanisms()
    riskGoalDef = 'The system shall react to an occurrence of ' + riskName + ' detected by '
    thrGoalDef = 'The system shall react to an occurrence of ' + thrName + ' detected by '
    vulGoalDef = 'The system shall react to an occurrence of ' + vulName + ' detected by '
    if (len(detMechs) == 1):
        riskGoalDef += ' detection mechanism ' + detMechs[0] + '.'
        thrGoalDef += ' detection mechanism ' + detMechs[0] + '.'
        vulGoalDef += ' detection mechanism ' + detMechs[0] + '.'
    else:
        riskGoalDef += ' detection mechanisms '
        thrGoalDef += ' detection mechanisms '
        vulGoalDef += ' detection mechanisms '
        for idx, dm in enumerate(detMechs):
            riskGoalDef += dm
            thrGoalDef += dm
            vulGoalDef += dm
            if (idx != (len(detMechs) - 1)):
                riskGoalDef += ', '
                thrGoalDef += ', '
                vulGoalDef += ', '
    return [(riskGoalName, riskGoalDef, goalCat),
            (thrGoalName, thrGoalDef, goalCat),
            (vulGoalName, vulGoalDef, goalCat)]
예제 #50
0
def importAssets(valueTypes,assets, session_id):
  b = Borg()
  db_proxy = b.get_dbproxy(session_id)

  vtCount = 0
  taCount = 0

  for vtParameters in valueTypes:
    vtId = db_proxy.existingObject(vtParameters.name(),vtParameters.type())
    if vtId == -1:
      db_proxy.addValueType(vtParameters)
      vtCount += 1
  for taParameters in assets:
    taId = db_proxy.existingObject(taParameters.name(),'template_asset')
    if taId == -1:
      db_proxy.addTemplateAsset(taParameters)
      taCount += 1
  return 'Imported ' + str(vtCount) + ' value types, and ' + str(taCount) + ' template assets.'
예제 #51
0
def importDirectoryFile(importFile,isOverwrite=1, session_id=None):
  parser = xml.sax.make_parser()
  handler = DirectoryContentHandler()
  parser.setContentHandler(handler)
  parser.setEntityResolver(handler)
  parser.parse(importFile)
  vulDir,threatDir = handler.directories()
  vdSize = len(vulDir)
  tdSize = len(threatDir)
  b = Borg()
  db_proxy = b.get_dbproxy(session_id)

  if (vdSize > 0):
    db_proxy.addVulnerabilityDirectory(vulDir,isOverwrite)
  if (tdSize > 0):
    db_proxy.addThreatDirectory(threatDir,isOverwrite)
  msgStr = 'Imported ' + str(vdSize) + ' template vulnerabilities and ' + str(tdSize) + ' template threats.'
  return msgStr
예제 #52
0
def importAssociations(maParameterSet,gaParameterSet,depParameterSet, session_id):
  b = Borg()
  db_proxy = b.get_dbproxy(session_id)

  maCount = 0
  for tTable,fromId,toId,refType in maParameterSet:
    db_proxy.addTrace(tTable,fromId,toId,refType)
    maCount += 1
  gaCount = 0
  for gaParameters in gaParameterSet:
    db_proxy.addGoalAssociation(gaParameters)
    gaCount += 1
  depCount = 0
  for depParameters in depParameterSet:
    db_proxy.addDependency(depParameters)
    depCount += 1
  msgStr = 'Imported ' + str(maCount) + ' manual associations, ' + str(gaCount) + ' goal associations, and ' + str(depCount) + ' dependency associations.'
  return msgStr
예제 #53
0
def importTVTypes(vulTypes,threatTypes,isOverwrite, session_id):
  b = Borg()
  db_proxy = b.get_dbproxy(session_id)

  noOfVts = len(vulTypes)
  noOfTts = len(threatTypes)
  if (noOfVts > 0):
    if (isOverwrite):
      db_proxy.deleteVulnerabilityType(-1)
    for vt in vulTypes:
      db_proxy.addValueType(vt)
  if (noOfTts > 0):
    if (isOverwrite):
      db_proxy.deleteThreatType(-1)
    for tt in threatTypes:
      db_proxy.addValueType(tt)
  msgStr = 'Imported ' + str(noOfVts) + ' vulnerability types and ' + str(noOfTts) + ' threat types.'
  return msgStr
예제 #54
0
def importSynopses(charSyns,refSyns,stepSyns,refConts,ucConts, session_id):
  b = Borg()
  db_proxy = b.get_dbproxy(session_id)

  for cs in charSyns:
    db_proxy.addCharacteristicSynopsis(cs)
  for rs in refSyns:
    db_proxy.addReferenceSynopsis(rs)
  for ucName,envName,stepNo,synName,aType,aName in stepSyns:
    db_proxy.addStepSynopsis(ucName,envName,stepNo,synName,aType,aName)
  db_proxy.conn.commit()
  for rc in refConts:
    db_proxy.addReferenceContribution(rc)
  for uc in ucConts:
    db_proxy.addUseCaseContribution(uc)

  msgStr = 'Imported ' + str(len(charSyns)) + ' characteristic synopses, ' + str(len(refSyns)) + ' reference synopses, ' + str(len(stepSyns)) + ' step synopses, ' + str(len(refConts)) + ' reference contributions, and ' + str(len(ucConts)) + ' use case contributions.'
  return msgStr
예제 #55
0
def importProjectData(pSettings,envParameterSet, session_id):
  b = Borg()
  db_proxy = b.get_dbproxy(session_id)

  if (pSettings != None):
    db_proxy.updateSettings(pSettings[0],pSettings[1],pSettings[2],pSettings[3],pSettings[4],pSettings[5],pSettings[6],pSettings[7])
  envCount = 0
  for envParameters in envParameterSet:
    objtId = db_proxy.existingObject(envParameters.name(),'environment')
    if objtId == -1:
      db_proxy.addEnvironment(envParameters)
    else:
      envParameters.setId(objtId)
      db_proxy.updateEnvironment(envParameters)
    envCount += 1
  msgText = 'Imported ' + str(envCount) + ' environments'
  if (pSettings != None):
    msgText += ', and project settings'
    msgText += '.'
  return msgText
  def __init__(self, session_id=None):
    self.thePatternName = ''
    self.theLikelihood = ''
    self.theSeverity = ''
    self.theObstacles = []
    self.theObstacleAssociations = []
    self.inIntent = 0
    self.theIntent = ''
    self.theMotivations = []
    self.theEnvironment = ''
    self.theAttack = ''
    self.theExploit = ''
    self.theAttackObstacle = ''
    self.theExploitObstacle = ''
    self.theParticipants = []
    self.theTargets = []
    self.theExploits = []
    self.inConsequences = 0
    self.theConsequences = ''
    self.inImplementation = 0
    self.theImplementation = ''
    self.inKnownUses = 0
    self.theKnownUses = ''
    self.inRelatedPatterns = 0
    self.theRelatedPatterns = ''
    b = Borg()
    self.configDir = b.configDir
    self.dbProxy = b.get_dbproxy(session_id)

    self.theObstacleParameters = []
    self.theObstacleAssociationParameters = []
    self.theAssetParameters = []
    self.theAttackerParameters = []
    self.theVulnerabilityParameters = None
    self.theThreatParameters = None
    self.theRiskParameters = None

    self.resetObstacleElements()
    self.resetObstacleAssociationElements()
    self.resetMotivationElements()
    self.resetParticipantElements()
예제 #57
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))
예제 #58
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()
예제 #59
0
def setUnitTesting(setting=False):
    logger.info('Setting unit testing property...')
    b = Borg()
    b.unit_testing = setting