JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
C and C++
Java
C#
Binaries

Quick Start (CodeSonar SaaS)

This section is designed to get you started using CodeSonar SaaS as quickly as possible. If you get stuck, see the links provided for more detailed information. For a guided introduction to CodeSonar see the tutorial.



Overview

In most cases we recommend starting with the CodeSonar tutorial. However, if you want to get started as quickly as possible (for example, because you have used CodeSonar before and just need a refresher), the steps are as follows.

  1. Install CodeSonar, if you have not already done so.
  2. Identify the CodeSonar SaaS hub and analysis launch daemon that you will be using.
  3. Ensure that you have the required credentials for your CodeSonar SaaS hub user account.
  4. Build and analyze your project.
  5. Browse the analysis results on the CodeSonar SaaS hub.

Quick Start

1. Install CodeSonar

Install CodeSonar, if you have not already done so: see section Installing or Upgrading CodeSonar.
Note that you will not need to set up a hub: a hub is provided as part of your CodeSonar SaaS deployment.

2. Identify the CodeSonar SaaS hub and analysis launch daemon that you will be using

CodeSecure will provide this information when you purchase CodeSonar SaaS.

3. Ensure that you have the required credentials

Ensure that you have the required credentials for your CodeSonar SaaS hub user account.

These credentials will depend on how your organization has chosen to manage hub authentication. In general, you will need to provide either

to authorize CodeSonar operations such as running an analysis, or browsing results on the hub.
If you have not already been provided with these credentials, obtain them from your local CodeSonar administrator before proceeding.

4. Build and Analyze

The codesonar binary resides in the $CSONAR/codesonar/bin subdirectory of the CodeSonar installation. To invoke CodeSonar without specifying the path, add $CSONAR/codesonar/bin to your PATH environment variable.

On the command line, execute the following.

codesonar analyze path/to/project-name \
-remote "/saas/*" https://hmname.codesonar.com:port \
-auth password \
command

where:

project-name is the CodeSonar project name, used to identify the project to the hub. It can be different to the name of the software project you are analyzing, although it does not have to be.
/path/to/ is the project directory that CodeSonar should use to store files it generates for the analysis.
  • You must have file system write access to this directory.
  • Many users prefer to specify a directory that is outside their source directory.
  • Windows users should specify a directory located outside the Program Files directory tree.
-remote "/saas/*" specifies that the hub should choose a suitable SaaS analysis launch daemon from the /saas launchd group.
https://hmname.codesonar.com:port is the location of your SaaS hub.
-auth password specifies that you wish to use password-based hub authentication. CodeSonar will interactively prompt you for your hub username and password before starting the analysis.
  • If you are using certificate-based hub authentication, specify the following instead:
    -auth certificate -hubcert certfile -hubkey privkeyfile
    where certfile is the path to your hub certificate and privkeyfile is the path to the corresponding private key. The private key will be used to sign responses, but will not be submitted to the hub.
  • See Hub Authentication: Authenticated codesonar Subcommands for full details of the available authentication options.
    (Note that -auth anonymous and -auth default are generally not suitable for use with CodeSonar SaaS hubs).
command varies depending on the language of the software to be analyzed. See the language-specific project build documentation for full details.
  • C and C++ : the command you usually use to build your software project.
  • Java : a cs-java-scan command.
  • C# : a cs-dotnet-scan command.

For example, to analyze a C/C++ project whose regular build command is make myproj:

codesonar analyze /myfiles/cs-myproj \
-remote "/saas/*" https://example.codesonar.com:7340 \
-auth password \
make myproj

For more details, see section Command Line Build/Analysis.

5. Browse

When CodeSonar has finished building and analyzing your project, it will print the URL at which the analysis results will be available.

  1. Use a web browser to open the URL.
    You will be prompted to sign in to the hub (unless you already have an active hub session).
  2. Provide the same credentials that you used to authorize the CodeSonar build/analysis.
    Once you have signed in, you will be navigated to the Analysis page for the analysis you just performed.

The Analysis page displays information about a single CodeSonar analysis and its results. By default it will show the Warnings tab, which contains a table with a line of information about each warning issued by the analysis.

To view a warning report, click anywhere on its entry in the summary table. A warning report page will open, containing:

For more details, see section Warning Report.

More Example Build/Analysis Commands

C analysis; certificate-based authentication; default certificate locations

Build a CodeSonar project based on the software whose normal build command is gcc -c myNativeProj.c .

codesonar analyze /myfiles/cs-mycproj \
-remote "/saas/*" https://example.codesonar.com:7340 \
-auth certificate \
gcc -c myNativeProj.c

Java analysis; certificate-based authentication; specified certificate locations

Build a CodeSonar project based on the classes contained in Example.jar and the source file Example.java, both located in the current working directory.

codesonar analyze /myfiles/cs-myjavaproj \
-remote "/saas/*" https://example.codesonar.com:7340 \
-auth certificate -hubcert ~/.csurf/codesonar/mysaascert.pem -hubkey ~/.csurf/codesonar/mysaasprivkey.pem \
cs-java-scan -include-artifacts Example.jar -include-sources Example.java

C# analysis; password-based authentication; specified username and password file

Build a CodeSonar project based on the classes contained in Example.dll, located in the current working directory, where the current working directory also contains the corresponding Example.pdb file.

codesonar analyze /myfiles/cs-mycsharpproj \
-remote "/saas/*" https://example.codesonar.com:7340 \
-auth password -hubuser alex -hubpwfile /myfiles/creds/pwfile.txt \
cs-dotnet-scan -include-artifacts Example.dll

Further Examples

Example build/analysis command lines are presented at a number of locations in this manual. In particular, each of the following pages provides several annotated examples.

All supported languages Command Line Build/Analysis: Language-Specific Examples
Java Build and Analysis for Java Projects: Example Command Lines
C# Build and Analysis for C# Projects [Windows only]: Example Command Lines

If you adapt one of these examples for CodeSonar SaaS use, ensure that you have included the following.

-remote "/saas/*" to specify a SaaS analysis launch daemon.
-auth password (or other suitable combination of -auth arg and supporting options) to specify authentication type and how you will present credentials.
 

To report problems with this documentation, please visit https://support.codesecure.com/.