def setUpClass(cls): cairis.core.BorgFactory.initialise() importModelFile(os.environ['CAIRIS_SRC'] + '/test/webinos.xml',1) importTVTypeFile(os.environ['CAIRIS_SRC'] + '/test/OWASPTypes.xml',0) importTVTypeFile(os.environ['CAIRIS_SRC'] + '/../examples/threat_vulnerability_types/cwecapec_tv_types.xml',0) importDirectoryFile(os.environ['CAIRIS_SRC'] + '/../examples/directories/owasp_directory.xml',0) importDirectoryFile(os.environ['CAIRIS_SRC'] + '/../examples/directories/cwecapec_directory.xml',0) importDirectoryFile(os.environ['CAIRIS_SRC'] + '/test/D28TV.xml',0) importComponentViewFile(os.environ['CAIRIS_SRC'] + '/test/ContextPolicyManagement.xml',0) importAttackPattern(os.environ['CAIRIS_SRC'] + '/test/XACMLAttackPattern.xml',0) importModelFile(os.environ['CAIRIS_SRC'] + '/test/persona_synopses.xml',0)
def setUpClass(cls): cairis.core.BorgFactory.initialise() # importModelFile(os.environ['CAIRIS_SRC'] + '/../examples/exemplars/NeuroGrid/NeuroGrid.xml',1) importModelFile(os.environ['CAIRIS_SRC'] + '/test/webinos_incomplete.xml',1) importTVTypeFile(os.environ['CAIRIS_SRC'] + '/test/OWASPTypes.xml',0) importTVTypeFile(os.environ['CAIRIS_SRC'] + '/../examples/threat_vulnerability_types/cwecapec_tv_types.xml',0) importDirectoryFile(os.environ['CAIRIS_SRC'] + '/../examples/directories/owasp_directory.xml',0) importDirectoryFile(os.environ['CAIRIS_SRC'] + '/../examples/directories/cwecapec_directory.xml',0) importDirectoryFile(os.environ['CAIRIS_SRC'] + '/test/D28TV.xml',0) importComponentViewFile(os.environ['CAIRIS_SRC'] + '/test/ContextPolicyManagement.xml',0) importAttackPattern(os.environ['CAIRIS_SRC'] + '/test/XACMLAttackPattern.xml',0) importModelFile(os.environ['CAIRIS_SRC'] + '/test/misusability.xml',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
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
def setUpClass(cls): cairis.core.BorgFactory.initialise() # Uncommenting the below and commenting the other setup lines might be useful if you want to test exporting using different models # importModelFile(os.environ['CAIRIS_SRC'] + '/../examples/exemplars/NeuroGrid/NeuroGrid.xml',1) # importModelFile(os.environ['CAIRIS_SRC'] + '/../examples/exemplars/ACME_Water/ACME_Water.xml',1) importModelFile( os.environ['CAIRIS_SRC'] + '/test/webinos_incomplete.xml', 1) importTVTypeFile(os.environ['CAIRIS_SRC'] + '/test/OWASPTypes.xml', 0) importTVTypeFile( os.environ['CAIRIS_SRC'] + '/../examples/threat_vulnerability_types/cwecapec_tv_types.xml', 0) importDirectoryFile( os.environ['CAIRIS_SRC'] + '/../examples/directories/owasp_directory.xml', 0) importDirectoryFile( os.environ['CAIRIS_SRC'] + '/../examples/directories/cwecapec_directory.xml', 0) importDirectoryFile(os.environ['CAIRIS_SRC'] + '/test/D28TV.xml', 0) importComponentViewFile( os.environ['CAIRIS_SRC'] + '/test/ContextPolicyManagement.xml', 0) importAttackPattern( os.environ['CAIRIS_SRC'] + '/test/XACMLAttackPattern.xml', 0) importModelFile(os.environ['CAIRIS_SRC'] + '/test/misusability.xml', 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