I have a python web application that accepts a http URL to a PDF file from the URL. As part of what the application does, it needs to convert the PDF into a TIFF image using ghost script. And for this, the PDF needs to be saved locally. So to do this I use urllib
like this:
testfile = urllib.URLopener()
pdf_destination = os.path.join(self.options.storefolder, self.options.uniquecode+".pdf")
testfile.retrieve(pdfurl, pdf_destination) //Fortify vuln. found here
This works ok, however, Fortify SCA gives a critical vulnerability of "Path Manipulation". Is there a way to resolve this? Should I just ensure that pdfurl
contains a valid pdf file name? or is there a better way to resolve this?