def compareAlgorithms(databaseDirectoryPath, algorithm1, algorithm2, yaraRulesPath = None, scoringParametersPath = None):
    htmlList = pagefetch.readHTMLListFromDatabaseDir(databaseDirectoryPath)
    firstResults = pagechecker.checkWebpages(htmlList, algorithm1, yaraRulesPath, scoringParametersPath)
    secondResults = pagechecker.checkWebpages(htmlList, algorithm2, yaraRulesPath, scoringParametersPath)
    displayResults(firstResults, algorithm1)
    displayResults(secondResults, algorithm2)
    compareResults(firstResults, secondResults, algorithm1, algorithm2)
def analyzeAllAlgorithms(databaseDirectoryPath, yaraRulesPath, scoringParametersPath, analysisResultsPath, expectedResultsPath = None):
    htmlList = pagefetch.readHTMLListFromDatabaseDir(databaseDirectoryPath)
    
    staticHeuristicsResults = pagechecker.checkWebpages(htmlList,'static heuristics')
    scoringMechanismResults = pagechecker.checkWebpages(htmlList,'scoring mechanism', scoringParametersPath = scoringParametersPath)
    yaraRulesResults = pagechecker.checkWebpages(htmlList,'yara rules', yaraRulesPath = yaraRulesPath)
    if expectedResultsPath is not None:
        expectedResults = loadExpectedResults(expectedResultsPath)
        expectedStatistics = expectedResultsStatistics(expectedResults)
    else:
        expectedResults = None
        expectedStatistics = None
	
    staticStatistics = resultsStatistics(staticHeuristicsResults, expectedResults)
    scoringStatistics = resultsStatistics(scoringMechanismResults, expectedResults)
    yaraStatistics = resultsStatistics(yaraRulesResults, expectedResults)
    
    allResults = generateCsvReport(staticHeuristicsResults, scoringMechanismResults, yaraRulesResults, expectedResults, staticStatistics, scoringStatistics, yaraStatistics, expectedStatistics)
    writeResultToFile(analysisResultsPath, allResults)  	
def staticHeuristicsDatabaseTest(connectionString, databaseName, collectionName, numberOfPages, offset = 0, expectedResultsPath = None):
    pagefetch.setMongoConnection(connectionString, databaseName, collectionName)
    htmlList = pagefetch.fetchMongoHTMLSet(numberOfPages, offset)
    checkResult = pagechecker.checkWebpages(htmlList,'static heuristics')
    displayResults(checkResult, 'static heuristics', expectedResultsPath)
def yaraRulesURLListTest(urlList, yaraRulesPath):
    htmlList = pagefetch.fetchRawHTMLList(urlList)
    checkResult = pagechecker.checkWebpages(htmlList,'yara rules', yaraRulesPath = yaraRulesPath)
    displayResults(checkResult, 'yara rules')
def scoringMechanismURLListTest(urlList, scoringParametersPath):
    htmlList = pagefetch.fetchRawHTMLList(urlList)
    checkResult = pagechecker.checkWebpages(htmlList,'scoring mechanism', scoringParametersPath = scoringParametersPath)
    displayResults(checkResult, 'scoring mechanism')
def staticHeuristicsURLListTest(urlList):
    htmlList = pagefetch.fetchRawHTMLList(urlList)
    checkResult = pagechecker.checkWebpages(htmlList,'static heuristics')
    displayResults(checkResult, 'static heuristics')
def yaraRulesDirectoryTest(directoryPath, yaraRulesPath):
    htmlList = pagefetch.readHTMLListFromDir(directoryPath)
    checkResult = pagechecker.checkWebpages(htmlList,'yara rules', yaraRulesPath = yaraRulesPath)
    displayResults(checkResult, 'yara rules')
def scoringMechanismDirectoryTest(directoryPath, scoringParametersPath):
    htmlList = pagefetch.readHTMLListFromDir(directoryPath)
    checkResult = pagechecker.checkWebpages(htmlList,'scoring mechanism', scoringParametersPath = scoringParametersPath)
    displayResults(checkResult, 'scoring mechanism')
def staticHeuristicsDirectoryTest(directoryPath):
    htmlList = pagefetch.readHTMLListFromDir(directoryPath)
    checkResult = pagechecker.checkWebpages(htmlList,'static heuristics')
    displayResults(checkResult, 'static heuristics')
def yaraRulesDatabaseTest(connectionString, databaseName, collectionName, numberOfPages, yaraRulesPath, offset = 0, expectedResultsPath = None):
    pagefetch.setMongoConnection(connectionString, databaseName, collectionName)
    htmlList = pagefetch.fetchMongoHTMLSet(numberOfPages, offset)
    checkResult = pagechecker.checkWebpages(htmlList,'yara rules', yaraRulesPath = yaraRulesPath)
    displayResults(checkResult, 'yara rules', expectedResultsPath)
def scoringMechanismDatabaseTest(connectionString, databaseName, collectionName, numberOfPages, scoringParametersPath, offset = 0, expectedResultsPath = None):
    pagefetch.setMongoConnection(connectionString, databaseName, collectionName)
    htmlList = pagefetch.fetchMongoHTMLSet(numberOfPages, offset)
    checkResult = pagechecker.checkWebpages(htmlList,'scoring mechanism', scoringParametersPath = scoringParametersPath)
    displayResults(checkResult, 'scoring mechanism', expectedResultsPath)