Integrating with Ant

Build Systems

You can use Veracode APIs to integrate with your Ant build server to seamlessly integrate Veracode into the existing build processes that you use in your Software Development Life Cycle (SDLC).

To integrate with an Ant build server, you use the API suite provided in the Veracode Java wrapper. The Java wrapper takes input from the command line, external tools, or existing build server integration workflows and returns a response from the Veracode Platform. You install the wrapper on the build server and it initiates communication between the build server and the Veracode Platform. The build.xml file submits Ant builds to Veracode for static scanning.

Prerequisites

Before integrating Veracode with your Ant build server, you must already have completed the following:
  • Created an application profile for each of the applications in your builds.
  • Configured the API user, ensuring you provide the IP address from which you are communicating with the Veracode Platform.
  • Downloaded the Veracode API Java wrapper.

Configuration

To integrate Veracode with your Ant build server:
  1. Set your Ant environment variables:
    1. Set the environment variables JAVA_HOME to your Java environment and ANT_HOME to the directory to which you uncompressed Ant.
    2. Add ${ANT_HOME}/bin(Unix) or %ANT_HOME%/bin (Windows) to your PATH.
    3. Verify these variables using echo%[environment variable name]%.
  2. Create a Java project with an Ant build script (build.xml) that cleans, compiles, and packages the Java source code.
  3. In the build.xml Ant build script, add a target section to your other target sections, such as clean and build. This new target section runs the Veracode API Java wrapper with arguments and values set in a property file. In addition, you can log the results and save it as a LOG file.

Scanning

To submit Ant builds for static scanning:
  1. Create a Java project with an Ant build script (build.xml) that cleans, compiles, and packages the Java source code.
  2. In the build.xml Ant build script, add a target section to your other target sections such as clean, build, etc. This new target section runs the Veracode API Java wrapper after you have set arguments and values in a property file. In addition, you can log the results and save them as a LOG file.
  3. Add the following sample target and properties sections to your Ant build script file, specifying the path to the VeracodeJavaAPI.jar file within the Java tag of the target section.
    <property file="veracode.properties" prefix="veracode"/>
    <target name="Veracode-UploadAndScan" description="Turns on debug symbols,logging. Cleans, builds, uploads binaries. Starts scan">
                <!-- Log all output to veracode.log file -->
                   <!-- Override the java compiler command and turn on debug setting -->
                   <!-- Create a time-stamp value to use for the build id -->
                   <!-- Call the Veracode Java wrapper to upload and scan -->
                   <java jar="VeracodeJavaAPI.jar" fork="true">
                           <arg line="    -action ${veracode.action} 
                                                  -vuser ${veracode.vuser} 
                                                  -vpassword ${veracode.vpassword}
                                                  -criticality ${veracode.criticality}
                                                  -createprofile ${veracode.createprofile}
                                                  -version ${current.time}
                                                  -appname ${veracode.appname}
                                                  -filepath ${veracode.filepath}"/>
                   </java>
        </target>
    
    
  4. Create a sample properties file to set the values for the arguments in the sample Ant script above.
    
           # "action" holds the veracodeAPI commands. Refer the Java Wrapper as "java -jar VeracodeJavaAPI.jar -help" for full list of commands 
    action=UploadAndScan
    
    # The "createprofile" variable is used to specify whether a new application
    # profile should be created if one does not exist with the name represented
    # by the variable "appname". If createprofile=true and the application profile already
    # exists, the binaries will be uploaded to the existing profile.
    # It can be one of true or false, holds only Boolean data type. 
    createprofile=true
    
    #The business criticality can be set to one of "VeryHigh" (default), "High", "Medium", "Low",
    # or "VeryLow". Enclose the value in quotes if it includes spaces.
    # Value Data Type -> String
    criticality="VeryHigh"
    
    # This is the name of the application profile in the Veracode Platform that the
    # binaries will be uploaded to. It is case-sensitive and must match an existing
    # application profile name if createprofile=false.
    # Value Data Type -> String
    appname="??"
    
    # Path to the final packages binary (.JAR, .WAR, .ZIP, etc). Optionally, a
    # top-level folder can be specified and the script will upload all binaries in
    # that folder if not packaged. Escape backslashes using \\ and enclose value
    # in quotes if it includes spaces.
    # Multiple files can be assigned to file path separated by space
    
    # Path Data Type -> String(s)
    filepath="C:\\...\\...\\" "C:\\..\\"
    
    # The ID of the first and the second API (-api1 and -api2)
    # base64username is the Veracode Platform username encoded in Base64
    # base64password is the Veracode Platform password encoded in Base64
    # Data Type -> String
    base64username="??"
    base64password="??"
    
    # API Username and Password
    vid="??"
    vkey="??"
    
    # Optional proxy host, port and proxy credentials for the upload script to use.
    phost="??"
    pport="??"
    puser="??"
    ppass="??"