Skip to main content

Executing the Scan

Use the following procedure to execute the scan along with the build target.

To execute the scan, do the following:

  1. Run the following command:

    ant <targetname> 
    • For example, you might enter:

    • ant compile

  2. To execute the scan along with any target of the build lifecycle, apply the plugin inside the target in the build.xml of the Ant application as follows:

    <taskdef name="codeinsightantplugin" classname="com.ant.plugin.CodeInsightAntPlugIn"
    classpath="" classpathref="" />

    <codeinsightantplugin fnciServer="<SERVER_URL>"
    fnciauthtoken="<BEARER_SERVER_TOKEN_VALUE>"
    fnciprojectname="<CODE_INSIGHT_PROJECT_NAME>"
    scanDirs="<DIRECTORIES_TO_BE_SCANNED_IN_RELATION_TO_BASE_APPLICATION_PROJECT>"
    alias="<SCAN-AGENT_ALIAS>"
    pluginRootPath="<PLUGIN_ROOT_PATH>"
    pluginProjectName="<APPLICATION_PROJECT_TO_SCAN>"
    plugindescription="<APPLICATION_DESCRIPTION>"
    pluginPathPrefix="<PLUGIN_PATH_PREFIX>" />
    </codeinsightantplugin>

  • See descriptions of these settings in Installing and Configuring the Gradle Plugin.

    note

    The Ant plugin project name can not include the ampersand (&) character.

    • The following is a description of the scan settings used to apply the plugin:

    • fnciServer—(Required) The hosted server where the Code Insight application is running.

    • fnciAuthToken—(Required) The JSON Web Token (JWT) used to authorize user access to the Code Insight functionality. Generate this token using the Code Insight Web UI and then copy and paste it here. Be sure to include the command “Bearer” followed by the token value, as in the example:

    • Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInVzZXJJZCI6MSwia

    • For more information about generating this token, see Providing an Authorization Token.

    • fnciProjectName—(Required) The name of the Code Insight project existing on the Code Insight server to contain the scan results.

    • scanDirs—Each path to be scanned relative to the base directory of the Ant project. For example, if the base directory for the Ant project is D:/worksapce/project and you want to scan the directory D:/worksapce/project/build, specify "/build" for the value here. If multiple paths are to be scanned, separate them with commas: "/build,/build2". To indicate that all paths under the base directory are to be scanned, enter "." for the value.

    • alias—A name that you define for the scan-agent plugin. The alias is used to represent the “container” (scan root) under which all the files scanned in this instance will be listed in the API output and in the file tree in the Analysis Workbench. This name must be unique within the project.

    • pluginRootPath—(Required) The path where the plugin will be launched, usually the root of the application. An example value is D:\\test\\Ant_test\\Ant_application. This field is required.

    • pluginProjectName—(Required) The name of Ant-based application whose codebase you want to scan.

    • pluginDescription—A description of the application to display on the Summary tab for the project in Code Insight.

    • pluginPathPrefix—The Code Insight server path (for example, demo_workspace/) used as a prefix for codebase file locations, as listed on the Associated Files tab for an inventory item in the Code Insight user interface. For example, demo_workspace/. This field is optional.

Note About “classpath”

Although specifying taskdef.classpath is not mandatory, you should set the path id of the javac task as the Classpathref in the codeinsightantplugin taskdef. If the application does not have a javac path-id defined in the build.xml, you must define one new path id referring to all compile time dependencies and use this as Classpathref. See the following example:

<path id= "cp" <fileset dir="lib">
<include name="*.jar" />
</fileset>
</path>

In this case, use "cp" as the Classpathref in the taskdef.