A remote scan is an alternate way to scan with no UI intervention. This can be done using a continuous integration toolchain, or manually via the command line. The results are then published on the UI automatically.

For languages such as C or C++, a strict mode remote scan can help to increase the accuracy of the scan.

How to download embold-scanner from Embold?

Download embold-scanner from your Embold Account’s section > Releases tab > CLI. There will be one file with names similar to the following: ‘browserstack-codequality-scanner-archive.tar.gz’.

l;

Remote scan using embold-scanner

  1. Download the Embold CLI tool from control panel. Extract that Embold CLI tool and make sure it has all the executable permissions.
  2. Login to Embold server. Now create a Project in Embold. Read more about creating a new project here.
  3. Generate the Embold Access Token (EAT) for remote scan. Read more here for generating EAT.
  4. Create and link a remote repository with the language you want to scan. Download the repository configuration (repository-configuration.json) for this new remote repository added.

Commands

  1. embold-scanner – This command is applicable for Linux machines.
  2. embold-scanner.bat – This command is applicable for Windows machines.

Sub-commands

  1. analyse
  2. local-analyse
  3. gated-commit

Usage: embold-scanner analyse [-am <arg>] [-b <arg>] [-c <arg>] [-d <arg>] [-h] [-l <arg>] [-r <arg>] [-s <arg>] [-sh <arg>] [-si <arg>] [-sp <arg>] [-ssu] -t <arg> -u <arg> [-v]

Example

  1. Linux:
    embold-scanner analyse -c <./repository configuration.json> -u <Embold URL> -t <Embold TOKEN> [-b <BASE_DIR>] [-d <DATA_DIR>] [-s <snapshot name>] [-r <REPO UID>] [-sh <CORONA PACKAGE PATH>] [-l <LOG_FOLDER>]
  2. Windows :
    embold-scanner.bat analyse -c <./repository configuration.json> -u <Embold URL> -t <Embold TOKEN> [-b <BASE_DIR>] [-d <DATA_DIR>] [-s <snapshot name>] [-r <REPO UID>] [-sh <CORONA PACKAGE PATH>] [-l <LOG_FOLDER>]

Options

-t,–token <arg>Embold Token
-u,–url <arg>Embold URL
-am,–analysis-mode <arg>Analysis Mode
-b,–repository-base-dir <arg>Scan will happen for this directory
-c,–scan-config-file <arg>Scan settings YAML/JSON file path
-d,–data-dir <arg>Data directory for temporary use
-h,–helpHelp
-l,–scanner-logs <arg>Embold scanner logs directory path
-r,–repository-uid <arg>The Data will be published in this
Repository in Embold UI
-s,–snapshot-label <arg>This label identifies the snapshot which
will be published on Embold UI after
successful scan. The value can also be
an environment variable
-sh,–scanner-home <arg>Embold scanner home path
-si,–session-id <arg>Session ID
-sp,–scan-profile <arg>Scan profile xml file path
-ssu,–skip-source-uploadSkip Source Upload
-v,–verboseEnable verbose mode
Options

After a successful remote scan, the below results will be displayed to the user.

On the successful scan, results are displayed on the console.

Prerequisites

  • File path use for -sh(scanner home), -l (scanner-logs) and -d(data directory) should have read write permission.
  • The following linters/tools must be installed on the remote machine.
LanguageLinterversion
CPPcppcheck2.8
C_SHARPmicrosoft_security_codescan5.6.2
TYPESCRIPTeslintv7.32.0
tslint5.9.1
JAVASCRIPTjshint2.9.5
eslintv7.32.0
GOstaticcheckv0.2.1
gosec2.8.1
gometalinterv2.0.0
PYTHONbandit1.7.0
pylint2.11.1
dlint0.11.0
PHPphpcs3.2.3
phpmd2.6.1
RUBYbrakeman5.1.1
KOTLINdetekt1.18.1
mobsfscan0.1.0
SOLIDITYsolhint3.3.6
SWIFTswiftlint0.32.0
APEXpmd6.39.0
HTMLhtmlhint0.15.1
SQLsqlcheck1
CSSstylelint14.15.1
INFRASTRUCTUREcheckov2.0.654
YAMLkubesec2.11.5
LUAluacheck0.23.0

Prerequisites to run remotescan for Swift

  • Install xcode on your macOS
  • Run below command and the output should be similar to the below screenshot
xcode-select -p
  • If your output is not as above screenshot then run the below command
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
  • Reverify the output of following command
xcode-select -p
  • your final output should be as below screenshot
  • Now run the remotescan

Configuration for https enabled Embold

  • Import the same set of certificates used for Embold in default jre keystore on standalone Corona machine.
  • Default jre path: Java/jre1.8.0_171/lib/security.
  • Below is the command:
    “keytool -import -trustcacerts -alias gamma -file “ ”-keystore cacerts”

Additional configuration for Strict mode Embold Remote scan for C/CPP code

  1. For understanding EMbold strict mode analysis, refer link https://docs.embold.io/installation-and-backup-guide/#c-strict-mode
  2. In the above repository-configuration.json file, just add path of the compilation command json file generated by your build system under the section additionalOptions as follows
    “additionalOptions” : [“–cdb=<Folder where the compilaton command json file is generated>”]

    OR

    Add the generated compilation_commands.json file under the baseDirectory path

    embold-scanner will pick up the compilation command json file from either the path given with –cdb option or from the base directory.

Running analysis in strict mode

Set up your remote Embold instance. This is where your analysis results will be published. Follow the steps to set up remote analysis here.

  1. On your build machine, navigate to the base directory of your source folder. Generate the compilation database as explained here. You should be able to see a compile_commands.json file in your base directory.
  2. Install corona on your build machine as explained here for UbuntuWindows and RedHat Enterprise Linux/CentOS. For installer versions, refer this section.
  3. Login to Embold. Create a project. Link the repository you want to scan. Select a repository type as “remote“. Read more info creating a project and linking a repository.
  4. Select a repository and “Download repository configuration” from the drop down menu of a repository.
  5. Open and edit the repository-configuration.json file. Provide the URL of your remote machine where the Embold is running and also, set your token based authentication.
    Note: Embold has deprecated the usage of username and password. Read more info. here.
  6. In the sources section, set the value of baseDir as the base directory path of your source folder on your build machine. You can also give exclusions.
    e.g. If you want to exclude folders named “build” and “test”, simply give “.*build.*” , “.*test.*” in the exclusions section.
    For edting ANY settings involving paths, even if you are running Corona on Windows, you must use Unix style path seperator. E.g. forward slash and not backward slash. If you use normal Windows format, it will not work and result into an error message.
  7. Set the dataDir to any desired location on your build machine.
  8. If you wish to create a separate build folder for running trace-utility (intercept-build), you should use the –cdb additional option while running the scan.
    The compile_commands.json will be created inside your build directory and not in the base directory of your source folder. Since, the scanner looks for the compile_commands.json in the base directory by default, use the  –cdb option to specify the directory where your compile_commands.json is located.
  9. In “settings” section, under “additionalOptions” set the directory where compilation database resides.
    Example: --cdb
  10. Go to the bin directory inside the scanboxwrapper.
    e.g. $corona_home/scanboxwrapper/bin.
    Run below command:
    /gammascanner -c
    /home/user/gamma/corona/scanboxwrapper/examples/gammascan_typical.json
  11. If the scan is successful you should see “ANALYSIS SUCCESS”. On your build machine, the last two log messages indicate that the remote analysis was successful.
  12. On your remote Embold instance, you will be able to see published results.