django-DefectDojo icon indicating copy to clipboard operation
django-DefectDojo copied to clipboard

fortify fpr instead of xml

Open schdief opened this issue 1 year ago • 10 comments

Scanner Name currently defect dojo expects a xml report for fortify "Fortify Scan - Import Findings from XML file format", the default report format is the fpr file, this should be used instead

Sample File fpr, had to zip it to upload it fortify_sast_front_end_20240220_629_9_1361_6018341.zip

schdief avatar Feb 20 '24 07:02 schdief

Hi @schdief, I guess fpr format is the wrong format to be able to parse within DefectDojo as it looks to me that fpr file formats can't be parsed in a decent way. If I open your pfr file in vscode, I can't view the content.

What is your opinion @mtesauro ? Can we close this?

manuel-sommer avatar Feb 20 '24 10:02 manuel-sommer

@manuel-sommer the fpr is a zip itself, you can just unzip it and then parse it (audit.fvdl)

image

we currently parse it ourselves like this with kotlin:

 fun parseFortifyArchive(inputStream: InputStream): Pair<FortifyTestResult, List<String>> {
            var report: FortifyTestResult? = null
            val suppressions: MutableList<String> = mutableListOf()
            ZipInputStream(inputStream).use { zipInputStream ->
                generateSequence { zipInputStream.nextEntry }
                    .filter { entry -> entry.name.matches(Regex(".*filters/.*txt|audit.fvdl")) }
                    .mapNotNull { entry ->
                        when {
                            entry.name.endsWith("fvdl") -> parseFortifyXML(
                                zipInputStream.bufferedReader().readText()
                            )

                            entry.name.endsWith(".txt") -> zipInputStream.bufferedReader().readText()
                                .split("\n")
                                .filter { (!it.startsWith("#")) && it.isNotEmpty() }

                            else -> null
                        }
                    }.forEach {
                        @Suppress("UNCHECKED_CAST") //Only ever adds strings
                        when (it) {
                            is FortifyTestResult -> report = it
                            is List<*> -> suppressions.addAll(it as List<String>)
                        }
                    }
            }
            report?.let {
                return it to suppressions.toList()
            }
            throw NoSuchElementException("Couldn't parse audit.fvdl.")
        }

schdief avatar Feb 20 '24 12:02 schdief

Hi @schdief, what benefit does this change introduce? Is xml export of Fortify not available anymore or is relevant information missing in the xml export?

manuel-sommer avatar Feb 20 '24 14:02 manuel-sommer

@manuel-sommer the xml report can only be generated with the legacy fortify reporter (page 26): https://www.microfocus.com/documentation/fortify-static-code-analyzer-and-tools/2310/SCA_Apps_Tools_23.1.0.pdf, as the current reporter can not export xml (page 23): https://www.microfocus.com/documentation/fortify-static-code-analyzer-and-tools/2310/SCA_Apps_Tools_23.1.0.pdf

additionally, the result of a fortify scan is a fpr file, so creating a xml report, is an additional step, that requires configuration, consumes resources and takes time

lastly the fpr format is also used outside of CI/CD pipelines to manage fortify vulnerabilities inside fortify ssc, keeping the format will help the teams to switch to defect dojo

schdief avatar Feb 20 '24 14:02 schdief

Got it, thank you for the insights @schdief . One more question: the relevant file to parse within fdr is always audit.fvdl ?

manuel-sommer avatar Feb 20 '24 14:02 manuel-sommer

Got it, thank you for the insights @schdief . One more question: the relevant file to parse within fdr is always audit.fvdl ?

yes, that is the one we are currently processing to automatically check the report for critical or high CVEs

schdief avatar Feb 20 '24 14:02 schdief

I started with a PR @schdief, but it is not yet finished.

manuel-sommer avatar Feb 20 '24 17:02 manuel-sommer

Hi @schdief, I guess fpr format is the wrong format to be able to parse within DefectDojo as it looks to me that fpr file formats can't be parsed in a decent way. If I open your pfr file in vscode, I can't view the content.

@manuel-sommer Fortify FPR files are 'parse-able' after you de-compress them into the various files inside the compressed .fpr file. I think the reason this hasn't had a parser created for it is that:

  • .fpr files are more 'interesting' to parse since you have to decompress the file before you can even parse anything
  • XML is rather easy to parse and we had examples provided by the community
  • I know I've asked community members who've put in issues for .fpr support over the years for a sample but this is the first time I'm aware where one was provided.

So, I don't see any problem with the current Fortify parser being updated to handle .fpr files ~ or ~ creating a new parser just for .fpr Fortify files now that we have a sample we can work from.

@schdief Thanks for providing a sample, that's very critical for adding a parser especially with commercial tools.

mtesauro avatar Feb 21 '24 05:02 mtesauro

@schdief: How can I translate the Default Severity to DefectDojo severity ranking (Low, Medium, High, Critical) ?

manuel-sommer avatar Feb 23 '24 13:02 manuel-sommer

@schdief could you please review the PR if all required information is within the findings?

manuel-sommer avatar Feb 23 '24 13:02 manuel-sommer

@schdief: How can I translate the Default Severity to DefectDojo severity ranking (Low, Medium, High, Critical) ?

this is our current implementation

            val severity = when {
                (impact >= 2.5) and (likelihood >= 2.5) -> Severity.CRITICAL
                (impact >= 2.5) and (likelihood < 2.5) -> Severity.HIGH
                (impact < 2.5) and (likelihood >= 2.5) -> Severity.MEDIUM
                (impact < 2.5) and (likelihood < 2.5) -> Severity.LOW
                else -> Severity.UNKNOWN

schdief avatar Feb 26 '24 06:02 schdief

Done, thank you for the input.

manuel-sommer avatar Feb 26 '24 07:02 manuel-sommer

Could we close this issue please @schdief and @mtesauro ?

manuel-sommer avatar Feb 29 '24 08:02 manuel-sommer

Could we close this issue please @schdief and @mtesauro ?

yeah sure, thanks a lot for implementing it that fast ❤️ The next release will be on March 4th, right? will it be part of that?

schdief avatar Feb 29 '24 09:02 schdief

@schdief Correct it will be part of 2.32.0 which will happen early next week - likely Monday.

mtesauro avatar Feb 29 '24 15:02 mtesauro

I tried to use the import of fpr-reports, but i get some internal server error. Can you have a look at my issue: https://github.com/DefectDojo/django-DefectDojo/issues/9958

ArsArmandi avatar May 02 '24 08:05 ArsArmandi