/
Dexter CLI

Dexter CLI

Contents

1. Installation

1.1 JRE Installation 

1.2 Download Dexter CLI

  • You need to download the following zip file : [ Dexter Download Page ]

  • The downloaded file should be unzipped into a directory wherever you want to put it in.

  • example:

    Dexter-cli HOME
    ###### Windows CLI(32 or 64 bit)
    C:/dexter-cli_#.#.#_64
    ###### LINUX CLI 
    /usr/local/share/dexter-cli_#.#.#_64
    
    ###### You have already run Dexter-daemon in local, you can find "dexter_cfg.json" file as below path.
    ###### Dexter-Daemon
    %DEXTER_DAEMON_INSTALLATION_DIR%\dexter-daemon_#.#.#_64\dexter-home\bin
  • Folders and files after unzip:

    Dexter Home
    Sub Folder
    File
    Description
    dexter-cli_#.#.#_32/64

    It is the Dexter CLI Home folder. It must be defined in the dexter_cfg.json file.

    bin
    The Executable files are in this folder.


    create-user.batIt is an executable file for account creation on Windows OS.


    create-user.shIt is an executable file for account creation on Linux.


    dexter-executor.jarIt contains the Dexter CLI components. (jar file) It is dexter-executor to find bugs in file


    dexter_cfg.jsonThis file is used by dexter-executor_#.#.#.jar to define the scope of analysis.


    dexter_cfg.json.helpIt is an example file of dexter_cfg.json. You can refer to this file to write the dexter_cfg.json file.


    dexter.batIt is an executable file for windows OS.


    dexter.shIt is an executable file for LINUX OS. You have to change the file mode before executing it.


    dexter2.batIt is an executable file with run command option for windows OS.


    dexter2.shIt is an executable file with run command option for LINUX OS. You have to change the file mode before executing it.

    plugin
    This folder contains plug-in files for the static analysis.


    dexter-cppcheck_#.#.#.jarIt is dexter-cppcheck to find bugs in file


    dexter-findbugs_#.#.#.jarIt is dexter-findbugs to find bugs in file

2. Configuration

2.1 Configuration Definition

[ Caution ]

The maximum file size which can be analyze is 2megabytes. Dexter-cli do not analyzed by File size( > 2MB) to improve performance.

β–Ά A large files can be difficult for co-workers to modify code and for developers to understand.

  • To execute Dexter CLI, the only thing you have to do is to define the dexter_cfg.json file.

  • You may need to remove the "headerDir" lines into the dexter-cfg.json file if you don't want to analysis with "headerDir".
    • If you will forgot remove "headerDir" line in dexter-cfg.json file, below log will appear in the command line.
    • Message β–· β˜… ERROR : there is no header folder : (see ../log/dexter-executor.log file for more information)
  • Please refer to the following sample: dexter_cfg.json setting for C/C++ and Java language
    • C/C++ example:

      C/C++
      {
          "dexterHome":"C:/dexter-cli_#.#.#_64",
          "dexterServerIp":"123.123.123.123",
          "dexterServerPort":"4982"
          "projectName":"ProjectName",
          "projectFullPath":"C:/PRJ/workspace/MyProject",
          "sourceDir":["C:/PRJ/workspace/MyProject/src/test"],
          "headerDir":["C:/PRJ/workspace/MyProject/src/"],    										// [Caution] If there is no need a header file to analyze, you must remove this line.
          "sourceEncoding":"UTF-8",
          "libDir":[],
          "binDir":"",
          "modulePath":"",
          "fileName":["main.cpp"],
          "type":"FILE"
      }
    • Java example:

      JAVA
      {
          "dexterHome":"C:/dexter-cli_#.#.#_64",
          "dexterServerIp":"123.123.123.123",
          "dexterServerPort":"4982",
          "projectName":"ProjectName",
          "projectFullPath":"C:/PRJ/workspace/MyProject",
          "sourceDir":["C:/PRJ/workspace/MyProject/src/java"],
          "headerDir":[],   																			// [Caution] If there is no need a header file to analyze, you must remove this line.
          "sourceEncoding":"UTF-8",
          "libDir":["C:/PRJ/workspace/MyProject/lib1","C:/PRJ/workspace/MyProject/lib2"],
          "binDir":"C:/PRJ/workspace/MyProject/bin",
          "type":"FILE",
          "modulePath":"package1.package2",
          "fileName":["Test1.java","Test2.java"]
      }

       

Note : These attributes are case-sensitive.

      • dexterHome : It is the unzipped folder for a Dexter CLI zip file such as "C:/dexter-cli_#.#.#_32/64.zip".
      • dexterServerIp : It is your Dexter Server Host IP. If you aren't have Dexter Server, you can run Asynchronous Analysis with '-a' option.
      • dexterServerPort : It is your Dexter Server Port. If you aren't have Dexter Server, you can run Asynchronous Analysis with '-a' option.
      • projectName : It is your logical project name.
      • projectFullPath : It is a root folder path of your project.
      • sourceDir :[Mandatory properties] It is a source folder path of your project. You can add multiple source code paths by using comma(,).
      • headerDir: If you use C or C++ source file, you have to add "headerDir" mandatory.
      • sourceEncoding : It is your source code's encoding. If there are no specific reasons, you should use 'UTF-8'.
      • libDir : In Java, you can add jar files in this folder.
      • binDir : In Java, it is the output folder for java source code files. it contains *.class files.
      • type : It is the scope unit to analyze - FILE | PROJECT | SNAPSHOT, not PACKAGE.
        • FILE : It is only for a file or files under a specific package folder (packageName attribute).
        • FOLDER : it is for a special folder or folders. If you run analysis by this mode, defects's author is "admin" in Dexter WEB.
        • PROJECT : It is for whole files of a project. If you run analysis by this mode, defects's author is "admin" in Dexter WEB.
        • SNAPSHOT : It is the same as the PROJECT value. Also, it creates data to be used in the analysis of defect trends. If you run analysis by this mode, defects's author is "admin" in Dexter WEB.
      • modulePath : It is possible to use the modulePath only if the 'type' attribute is FILE or PROJECT.
      • fileName : It is possible to use the fileName only if the 'type' attribute is FILE. You can add multiple files by using comma(,).
        • If you run static analysis with dexter CLI for only one of the file, you must put in "[]" . (ex :["filename.java"] )
  • 2.2 More Configuration Samples

  • You can make a list of a target file or files to analyze


  • You can analyze a whole project

    dexter_cfg.json (PROJECT)
    {
        "dexterHome":"C:/dexter-cli_#.#.#_64",
        "dexterServerIp":"123.123.123.123",
        "dexterServerPort":"4982",
        "projectName":"ProjectName",
        "projectFullPath":"C:/PRJ/workspace/MyProject/src/test",
        "sourceDir":["C:/PRJ/workspace/MyProject/src/test/src"],
        "headerDir":["C:/PRJ/workspace/MyProject/src/test/src"],									// [Caution] If there is no need a header file to analyze, you must remove this line.
        "sourceEncoding":"UTF-8",
        "libDir":[],
        "binDir":"",
        "type":"PROJECT"
    }
  • You can make a snapshot of a special day to analyze changes

    dexter_cfg.json (SNAPSHOT)
    {
        "dexterHome":"C:/dexter-cli_#.#.#_64",
        "dexterServerIp":"123.123.123.123",
        "dexterServerPort":"4982",
        "projectName":"ProjectName",
        "projectFullPath":"C:/PRJ/workspace/MyProject",
        "sourceDir":["C:/PRJ/workspace/MyProject/src/test","C:/PRJ/workspace/MyProject/src/java"],
        "headerDir":[],																					// [Caution] If there is no need a header file to analyze, you must remove this line.
        "sourceEncoding":"UTF-8",
        "libDir":["C:/PRJ/workspace/MyProject/lib1","C:/PRJ/workspace/MyProject/lib2"],
        "binDir":"C:/PRJ/workspace/MyProject/bin",
        "type":"SNAPSHOT",
    }
  • 3. Run

  • If you don't have Dexter account, you need to run account creation file via create-user.bat/sh.
  • example:

    ###### EXAMPLE COMMAND : create-user.bat gildong.hong pa$$word localhost 4982
    ###### Windows : 
    C:/dexter-cli_#.#.#_64 > create-user.bat SINGLE_ID PASSWORD SERVER_IP SERVER_PORT
    ###### LINUX 
    root@linux:~# create-user.sh SINGLE_ID PASSWORD SERVER_IP SERVER_PORT
  • example:

    ###### EXAMPLE LOG 
    C:\dexter_v#.#.#\bin>create-user.bat gildong.hong pa$$word localhost 4982
    C:\dexter_v#.#.#\bin>java -Xms256m -Xmx786m -XX:MaxPermSize=256m -jar dexter-executor.jar -c -u gildong.hong -p pa$$word -h localhost -o 4982  // This is automatically execute command.
    ===== Starting Dexter Analysis =====
    Your account is created: gildong.hong
  • After configuring the dexter_cfg.json file, you can run Dexter CLI for static analysis.

  • example:

    ###### Windows
    C:\> cd dexter-cli_#.#.#_64\bin
    C:\dexter_cli_64_#.#.#\bin> dexter.bat my_id my_password
    (If you use 32bit OS, folder name can be 'dexter-cli_32_#.#.#')
     
    ###### LINUX
    root@/usr/share# cd dexter-cli_#.#.#_64/bin
    root@/usr/share/dexter_cli_64_#.#.#/bin# chmod +x dexter.sh
    root@/usr/share/dexter_cli_64_#.#.#/bin# ./dexter.sh my_single_id my_password
    (If you use 32bit OS, folder name can be 'dexter-cli_#.#.#_32')
     
     
    ###### You can use dexter2.bat(for window), dexter2.sh(for linux) with option as below.
    ###### Windows 
    C:\dexter_cli_64_#.#.#\bin> dexter2.bat -u singleId -p password -a
    ###### LINUX 
    root@/usr/share/dexter_cli_64_#.#.#/bin# dexter2.sh -u singleId -p password -a


    • Options

      OptionRun Dexter CommandExplanation 
      -aAsynchronous AnalysisAsynchronous Analysis. It is faster than synchronous. No Result Log and File(Check on Dexter WEB)
      -eEnable only specified checkerEnable only specified checker(s), checkercode1;checkercode2:language:toolname;... eg) -e nullpointer;initializerlist:CPP:cppcheck
      -fAnalysis Configuration File in another directoryAnalysis Configuration File. eg) -f C:/dexter/dexter_cfg.json
      -jCreate Json result fileCreate Json result file - dexter-result.json.
      -pPasswordUser Password. eg) -p password
      -sStandalone. Run Dexter Analysis without DexterServerStandalone. Run Dexter Analysis without DexterServer. you don't need log in(id & password) eg) -s
      -tTarget source code file names and pathsTarget source code file names and paths. eg) -t C:/myproject/src/main.cpp;C:/myproject/src/util.cpp
      -uUser IdUser ID. eg) -u id
      -xCreate XML result fileCreate XML result file - dexter-result.xml. eg) -x
      -XCreate XML result file with TimestampCreate XML result file with timestamp - dexter-result_yyyyMMddhh:mm:ss.xml. eg) -X
  • Only an administrator has a permission to create a new Snapshot.
  • Result example:

    Example Result Log : If you have Dexter-server, you can see the nicely formatted results on web site.
    analyzed : D:/DexterTest/src/debgub-main/comoss-debugmenu.cpp
    not supported file : Log.txt
     
    *** Summary of Results
    * Total Defects: 11
    * Critical Defects : 2
    * Major Defects: 2
    * Minor Defects : 4
    * CRC Defects : 0
    * Etc Defect :3
    * Check Dexter web site in detail : http://localhost:4982/defect
    *** End Of Dexter Analysis *** (94 seconds)
    dexter_cfg.json (FILE)
    {
        "dexterHome":"C:/dexter-cli_#.#.#_64",
        "dexterServerIp":"123.123.123.123",
        "dexterServerPort":"4982",
        "projectName":"ProjectName",
        "projectFullPath":"C:/PRJ/workspace/MyProject",
        "sourceDir":["C:/PRJ/workspace/MyProject/src/test","C:/PRJ/workspace/MyProject/src/java"],
        "headerDir":[],    																			// [Caution] If there is no need a header file to analyze, you must remove this line.
        "sourceEncoding":"UTF-8",
        "libDir":["C:/PRJ/workspace/MyProject/lib1","C:/PRJ/workspace/MyProject/lib2"],
        "binDir":"C:/PRJ/workspace/MyProject/bin",
        "type":"FILE",
        "modulePath":"package1.package2",
        "fileName":["Test1.java","Test2.java"]
    }
    dexter_cfg.json (FILE)
    {
        "dexterHome":"C:/dexter-cli_#.#.#_64",
        "dexterServerIp":"123.123.123.123",
        "dexterServerPort":"4982",
        "projectName":"ProjectName",
        "projectFullPath":"C:/PRJ/workspace/MyProject",
        "sourceDir":["C:/PRJ/workspace/MyProject/src/test","C:/PRJ/workspace/MyProject/src/java"],
        "headerDir":[],    																			// [Caution] If there is no need a header file to analyze, you must remove this line.
        "sourceEncoding":"UTF-8",
        "libDir":["C:/PRJ/workspace/MyProject/lib1","C:/PRJ/workspace/MyProject/lib2"],
        "binDir":"C:/PRJ/workspace/MyProject/bin",
        "type":"FILE",
        "modulePath":"package1.package2",
        "fileName":["Test1.java","Test2.java"]
    }




Related content