Class XmlUtil
- java.lang.Object
-
- com.veracode.jenkins.plugin.utils.XmlUtil
-
public class XmlUtil extends Object
The XmlUtil class contains the helpers to work with XML.
-
-
Constructor Summary
Constructors Constructor Description XmlUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
getErrorString(String xmlString)
Get the error string, if any, from a XML document.static Document
getXmlDocument(String xmlString)
Takes an XML return an creates a DOM tree.static DAScanHistory
newDAScanHistory(String detailedReportXml, com.veracode.apiwrapper.dynamicanalysis.model.client.ScanOccurrenceInfo scanOccurrenceInfo, Run<?,?> build)
Get the scan results from the detailed report and scan occurrence result.static SCAScanHistory
newSCAHistory(String detailedReportXml, long buildDate, SCAScanHistory lastSCAHistory)
Retrieve SCA results from the given Detailed Report XML.static ScanHistory
newScanHistory(String buildInfoXml, String detailedReportXml, Run<?,?> build)
Get the scan results from the detailed report and previous Jenkins builds result to compose the scan result for the current Jenkins build.static String
parseAppId(String appName, String xmlAppListResult)
Find the Application ID by its name within an XML document.static String
parseBuildId(String xmlBuildInfoResult)
Find the build ID within a XML document.static String
parseSandboxId(String sandboxName, String xmlSandboxListResult)
Find the sandbox ID by its name in an XML document.
-
-
-
Method Detail
-
newScanHistory
public static final ScanHistory newScanHistory(String buildInfoXml, String detailedReportXml, Run<?,?> build) throws Exception
Get the scan results from the detailed report and previous Jenkins builds result to compose the scan result for the current Jenkins build.- Parameters:
buildInfoXml
- aString
object - the XML returned from calling GetBuildInfo API.detailedReportXml
- aString
object - the XML returned from calling GetDetailedReport API.build
- aRun
object - the current Jenkins build.- Returns:
- a
ScanHistory
object - the info to be displayed in the Veracode post build step. - Throws:
Exception
- when an error is encountered during the operation.
-
newSCAHistory
public static final SCAScanHistory newSCAHistory(String detailedReportXml, long buildDate, SCAScanHistory lastSCAHistory) throws Exception
Retrieve SCA results from the given Detailed Report XML.- Parameters:
detailedReportXml
- aString
object - the XML returned from calling GetDetailedReport API.buildDate
- a long - the build date.lastSCAHistory
- aSCAScanHistory
object.- Returns:
- a
SCAScanHistory
object - the SCA result in the detailed report. - Throws:
Exception
- when an error is encountered during the operation.
-
newDAScanHistory
public static final DAScanHistory newDAScanHistory(String detailedReportXml, com.veracode.apiwrapper.dynamicanalysis.model.client.ScanOccurrenceInfo scanOccurrenceInfo, Run<?,?> build) throws Exception
Get the scan results from the detailed report and scan occurrence result. In addition, comparison of results to previous successful Jenkins build result.- Parameters:
detailedReportXml
- aString
object - the XML returned from calling GetDetailedReport API.scanOccurrenceInfo
- aScanOccurrenceInfo
object - analysis occurrence info returned from DA via REST API.build
- aRun
object - the Jenkins build.- Returns:
- a
DAScanHistory
object - the info to be displayed in the Veracode post build step. - Throws:
Exception
- when an error is encountered during the operation.
-
parseAppId
public static final String parseAppId(String appName, String xmlAppListResult) throws Exception
Find the Application ID by its name within an XML document.- Parameters:
appName
- aString
object - the name of an application.xmlAppListResult
- aString
object - the XML result from a GetAppList call.- Returns:
- a
String
object - the ID of the application or null if the ID is not found. - Throws:
Exception
- when given invalid parameter(s) or an error occurred when parsing the given XML.
-
parseSandboxId
public static final String parseSandboxId(String sandboxName, String xmlSandboxListResult) throws Exception
Find the sandbox ID by its name in an XML document.- Parameters:
sandboxName
- aString
object - the name of a sandbox.xmlSandboxListResult
- aString
object - the XML from the getSandboxList API.- Returns:
- a
String
object - the ID of the given sandbox or empty string if none found. - Throws:
Exception
- when given invalid parameter(s) or an error occurred when parsing the given XML.
-
getXmlDocument
public static final Document getXmlDocument(String xmlString) throws Exception
Takes an XML return an creates a DOM tree.
-
parseBuildId
public static final String parseBuildId(String xmlBuildInfoResult) throws Exception
Find the build ID within a XML document.
-
-