Ejemplo n.º 1
0
def file_import(importFile, mFormat, overwriteFlag, session_id=None):
    if overwriteFlag == None:
        overwriteFlag = 1

    from cairis.mio.ModelImport import importSecurityPatternsFile, importAttackPattern, importTVTypeFile, importDirectoryFile, importRequirementsFile, importRiskAnalysisFile, importUsabilityFile, importAssociationsFile, importProjectFile, importDomainValuesFile, importComponentViewFile, importSynopsesFile, importProcessesFile, importAssetsFile, importLocationsFile, importModelFile, importMisusabilityFile, importDataflowsFile, importStoriesFile

    try:
        ET.fromstring(open(importFile).read())
    except ET.ParseError as e:
        raise ARMException('Error parsing ' + importFile + ': ' + str(e))

    msgStr = ''
    if (mFormat == 'securitypattern' or mFormat == 'Security Pattern'):
        msgStr += importSecurityPatternsFile(importFile, session_id)
    elif (mFormat == 'attackpattern' or mFormat == 'Attack Pattern'):
        msgStr += importAttackPattern(importFile, session_id)
    elif (mFormat == 'tvtypes' or mFormat == 'Threat and Vulnerability Types'):
        msgStr += importTVTypeFile(importFile, int(overwriteFlag), session_id)
    elif (mFormat == 'directory'
          or mFormat == 'Threat and Vulnerability Directory'):
        msgStr += importDirectoryFile(importFile, int(overwriteFlag),
                                      session_id)
    elif (mFormat == 'requirements' or mFormat == 'Requirements'):
        msgStr += importRequirementsFile(importFile, session_id)
    elif (mFormat == 'riskanalysis' or mFormat == 'Risk Analysis'):
        msgStr += importRiskAnalysisFile(importFile, session_id)
    elif (mFormat == 'usability' or mFormat == 'Usability'):
        msgStr += importUsabilityFile(importFile, session_id)
    elif (mFormat == 'misusability' or mFormat == 'Misusability'):
        msgStr += importMisusabilityFile(importFile, session_id)
    elif (mFormat == 'associations' or mFormat == 'Associations'):
        msgStr += importAssociationsFile(importFile, session_id)
    elif (mFormat == 'project' or mFormat == 'Project data'):
        msgStr += importProjectFile(importFile, session_id)
    elif (mFormat == 'domainvalues' or mFormat == 'Domain Values'):
        msgStr += importDomainValuesFile(importFile, session_id)
    elif (mFormat == 'architecturalpattern'
          or mFormat == 'Architectural Pattern'):
        msgStr += importComponentViewFile(importFile, session_id)
    elif (mFormat == 'synopses' or mFormat == 'Synopses'):
        msgStr += importSynopsesFile(importFile, session_id)
    elif (mFormat == 'processes' or mFormat == 'Processes'):
        msgStr += importProcessesFile(importFile, session_id)
    elif (mFormat == 'assets' or mFormat == 'Assets'):
        msgStr += importAssetsFile(importFile, session_id)
    elif (mFormat == 'locations' or mFormat == 'Locations'):
        msgStr += importLocationsFile(importFile, session_id)
    elif (mFormat == 'dataflows' or mFormat == 'Dataflows'):
        msgStr += importDataflowsFile(importFile, session_id)
    elif (mFormat == 'stories' or mFormat == 'Stories'):
        msgStr += importStoriesFile(importFile, session_id)
    elif (mFormat == 'all' or mFormat == 'Model'
          or mFormat == 'Model file (.xml)'):
        msgStr += importModelFile(importFile, int(overwriteFlag), session_id)
    else:
        raise ARMException('Input model type ' + mFormat + ' not recognised')
    return 0
Ejemplo n.º 2
0
def file_import(importFile, mFormat, overwriteFlag, session_id=None):
    if overwriteFlag == None:
        overwriteFlag = 1

    if (os.access(importFile, os.R_OK)) == False:
        raise ARMException("Cannot access " + importFile)

    from cairis.mio.ModelImport import importSecurityPatternsFile, importAttackPattern, importTVTypeFile, importDirectoryFile, importRequirementsFile, importRiskAnalysisFile, importUsabilityFile, importAssociationsFile, importProjectFile, importDomainValuesFile, importComponentViewFile, importSynopsesFile, importProcessesFile, importAssetsFile, importLocationsFile, importModelFile, importMisusabilityFile, importDataflowsFile

    msgStr = ''
    if (mFormat == 'securitypattern' or mFormat == 'Security Pattern'):
        msgStr += importSecurityPatternsFile(importFile, session_id=session_id)
    elif (mFormat == 'attackpattern' or mFormat == 'Attack Pattern'):
        msgStr += importAttackPattern(importFile, session_id)
    elif (mFormat == 'tvtypes' or mFormat == 'Threat and Vulnerability Types'):
        msgStr += importTVTypeFile(importFile, int(overwriteFlag), session_id)
    elif (mFormat == 'directory'
          or mFormat == 'Threat and Vulnerability Directory'):
        msgStr += importDirectoryFile(importFile, int(overwriteFlag),
                                      session_id)
    elif (mFormat == 'requirements' or mFormat == 'Requirements'):
        msgStr += importRequirementsFile(importFile, session_id)
    elif (mFormat == 'riskanalysis' or mFormat == 'Risk Analysis'):
        msgStr += importRiskAnalysisFile(importFile, session_id)
    elif (mFormat == 'usability' or mFormat == 'Usability'):
        msgStr += importUsabilityFile(importFile, session_id)
    elif (mFormat == 'misusability' or mFormat == 'Misusability'):
        msgStr += importMisusabilityFile(importFile, session_id)
    elif (mFormat == 'associations' or mFormat == 'Associations'):
        msgStr += importAssociationsFile(importFile, session_id)
    elif (mFormat == 'project' or mFormat == 'Project data'):
        msgStr += importProjectFile(importFile, session_id)
    elif (mFormat == 'domainvalues' or mFormat == 'Domain Values'):
        msgStr += importDomainValuesFile(importFile, session_id)
    elif (mFormat == 'architecturalpattern'
          or mFormat == 'Architectural Pattern'):
        msgStr += importComponentViewFile(importFile, session_id)
    elif (mFormat == 'synopses' or mFormat == 'Synopses'):
        msgStr += importSynopsesFile(importFile, session_id)
    elif (mFormat == 'processes' or mFormat == 'Processes'):
        msgStr += importProcessesFile(importFile, session_id)
    elif (mFormat == 'assets' or mFormat == 'Assets'):
        msgStr += importAssetsFile(importFile, session_id)
    elif (mFormat == 'locations' or mFormat == 'Locations'):
        msgStr += importLocationsFile(importFile, session_id)
    elif (mFormat == 'dataflows' or mFormat == 'Dataflows'):
        msgStr += importDataflowsFile(importFile, session_id)
    elif (mFormat == 'all' or mFormat == 'Model'):
        msgStr += importModelFile(importFile, int(overwriteFlag), session_id)
    else:
        raise ARMException('Input model type ' + mFormat + ' not recognised')
    return 0
Ejemplo n.º 3
0
def file_import(importFile,mFormat,overwriteFlag,session_id = None):
  if overwriteFlag == None:
    overwriteFlag = 1

  if (os.access(importFile, os.R_OK)) == False:
    raise ARMException("Cannot access " + importFile)

  from cairis.mio.ModelImport import importSecurityPatternsFile, importAttackPattern,importTVTypeFile,importDirectoryFile,importRequirementsFile, importRiskAnalysisFile, importUsabilityFile, importAssociationsFile, importProjectFile, importDomainValuesFile, importComponentViewFile, importSynopsesFile,importProcessesFile,importAssetsFile,importLocationsFile,importModelFile,importMisusabilityFile,importDataflowsFile

  msgStr = ''
  if (mFormat == 'securitypattern' or mFormat == 'Security Pattern'):
    msgStr += importSecurityPatternsFile(importFile,session_id = session_id)
  elif (mFormat == 'attackpattern' or mFormat == 'Attack Pattern'):
    msgStr += importAttackPattern(importFile,session_id)
  elif (mFormat == 'tvtypes' or mFormat == 'Threat and Vulnerability Types'):
    msgStr += importTVTypeFile(importFile,int(overwriteFlag),session_id)
  elif (mFormat == 'directory' or mFormat == 'Threat and Vulnerability Directory'):
    msgStr += importDirectoryFile(importFile,int(overwriteFlag),session_id)
  elif (mFormat == 'requirements' or mFormat == 'Requirements'):
    msgStr += importRequirementsFile(importFile,session_id)
  elif (mFormat == 'riskanalysis' or mFormat == 'Risk Analysis'):
    msgStr += importRiskAnalysisFile(importFile,session_id)
  elif (mFormat == 'usability' or mFormat == 'Usability'):
    msgStr += importUsabilityFile(importFile,session_id)
  elif (mFormat == 'misusability' or mFormat == 'Misusability'):
    msgStr += importMisusabilityFile(importFile,session_id)
  elif (mFormat == 'associations' or mFormat == 'Associations'):
    msgStr += importAssociationsFile(importFile,session_id)
  elif (mFormat == 'project' or mFormat == 'Project data'):
    msgStr += importProjectFile(importFile,session_id)
  elif (mFormat == 'domainvalues' or mFormat == 'Domain Values'):
    msgStr += importDomainValuesFile(importFile,session_id)
  elif (mFormat == 'architecturalpattern' or mFormat == 'Architectural Pattern'):
    msgStr += importComponentViewFile(importFile,session_id)
  elif (mFormat == 'synopses' or mFormat == 'Synopses'):
    msgStr += importSynopsesFile(importFile,session_id)
  elif (mFormat == 'processes' or mFormat == 'Processes'):
    msgStr += importProcessesFile(importFile,session_id)
  elif (mFormat == 'assets' or mFormat == 'Assets'):
    msgStr += importAssetsFile(importFile,session_id)
  elif (mFormat == 'locations' or mFormat == 'Locations'):
    msgStr += importLocationsFile(importFile,session_id)
  elif (mFormat == 'dataflows' or mFormat == 'Dataflows'):
    msgStr += importDataflowsFile(importFile,session_id)
  elif (mFormat == 'all' or mFormat == 'Model'):
    msgStr += importModelFile(importFile,int(overwriteFlag),session_id)
  else:
    raise ARMException('Input model type ' + mFormat + ' not recognised')
  return 0