| 226 | return cgi.escape(str(Snippet)) # Escape snippet to avoid breaking HTML |
| 227 | |
| 228 | def CommandDump( |
| 229 | self, CommandIntro, OutputIntro, ResourceList, PluginInfo, PreviousOutput |
| 230 | ): |
| 231 | output_list = [] |
| 232 | PluginOutputDir = self.InitPluginOutputDir(PluginInfo) |
| 233 | ResourceList = sorted(ResourceList, key=lambda x: x[0] == "Extract URLs") |
| 234 | for Name, Command in ResourceList: |
| 235 | dump_file_name = "%s.txt" % os.path.splitext(Name)[ |
| 236 | 0 |
| 237 | ] # Add txt extension to avoid wrong mimetypes |
| 238 | plugin_output = dict(PLUGIN_OUTPUT) |
| 239 | ModifiedCommand, FrameworkAbort, PluginAbort, TimeStr, RawOutput, PluginOutputDir = self.RunCommand( |
| 240 | Command, PluginInfo, PluginOutputDir |
| 241 | ) |
| 242 | plugin_output["type"] = "CommandDump" |
| 243 | plugin_output["output"] = { |
| 244 | "Name": self.GetCommandOutputFileNameAndExtension(Name)[0], |
| 245 | "CommandIntro": CommandIntro, |
| 246 | "ModifiedCommand": ModifiedCommand, |
| 247 | "RelativeFilePath": self.runner.dump_output_file( |
| 248 | dump_file_name, RawOutput, PluginInfo, relative_path=True |
| 249 | ), |
| 250 | "OutputIntro": OutputIntro, |
| 251 | "TimeStr": TimeStr, |
| 252 | } |
| 253 | plugin_output = [plugin_output] |
| 254 | # This command returns URLs for processing |
| 255 | if Name == config_handler.get_val("EXTRACT_URLS_RESERVED_RESOURCE_NAME"): |
| 256 | # The plugin_output output dict will be remade if the resource is of this type |
| 257 | plugin_output = self.LogURLsFromStr(RawOutput) |
| 258 | # TODO: Look below to handle streaming report |
| 259 | if PluginAbort: # Pass partial output to external handler: |
| 260 | raise PluginAbortException(PreviousOutput + plugin_output) |
| 261 | if FrameworkAbort: |
| 262 | raise FrameworkAbortException(PreviousOutput + plugin_output) |
| 263 | output_list += plugin_output |
| 264 | return output_list |
| 265 | |
| 266 | def LogURLsFromStr(self, RawOutput): |
| 267 | plugin_output = dict(PLUGIN_OUTPUT) |