Beispiel #1
0
    def test_nmapFileExists_WhenNecessaryNmapFilesExistOnFilesystem_ReturnsTrue(
            self):
        def makeAllNecessaryNmapFilesExist():
            self.mockShell.directoryOrFileExists.side_effect = [
                True, True, True
            ]
            self.mockShell.isFile.side_effect = [True, True, True]

        makeAllNecessaryNmapFilesExist()
        self.assertTrue(nmapFileExists(self.mockShell, "some-nmap-session"))
Beispiel #2
0
    def test_nmapFileExists_WhenAtLeastOneNmapFileDoesNotExist_ReturnsFalse(
            self):
        def makeAtLeastOneNmapFileNotPresent():
            self.mockShell.directoryOrFileExists.side_effect = [
                True, True, True
            ]
            self.mockShell.isFile.side_effect = [True, True, False]

        makeAtLeastOneNmapFileNotPresent()
        self.assertFalse(nmapFileExists(self.mockShell, "some-nmap-session"))
Beispiel #3
0
 def __determineToolOutputFiles(self, outputFileName: str, toolOutputFolder: str):
     # check if the outputFilename exists, if not try .xml and .txt extensions
     # (different tools use different formats)
     if fileExists(self.shell, outputFileName):
         self.shell.move(outputFileName, toolOutputFolder)
     # move all the nmap files (not only the .xml)
     elif nmapFileExists(self.shell, outputFileName):
         self.nmapExporter.exportOutputToHtml(outputFileName, toolOutputFolder)
         self.shell.move(outputFileName + '.xml', toolOutputFolder)
         self.shell.move(outputFileName + '.nmap', toolOutputFolder)
         self.shell.move(outputFileName + '.gnmap', toolOutputFolder)
     elif xmlFileExists(self.shell, outputFileName):
         self.shell.move(outputFileName + '.xml', toolOutputFolder)
     elif textFileExists(self.shell, outputFileName):
         self.shell.move(outputFileName + '.txt', toolOutputFolder)