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 |
There are two main use cases for direct file import.
There are two main use cases for direct file import.
In this section (and throughout this manual), $CSONAR indicates the CodeSonar installation directory.
The following diagram provides an overview of a CodeSonar build process that brings files into the CodeSonar project.
As described in Command Line Build/Analysis: Command, the general form of the usual CodeSonar build/analysis command is
To import one or more files, command must incorporate one or more invocations of codesonar add_source_files.py.
To import files or directory contents to a project, CodeSonar observes the execution of a command that incorporates one or more invocations of
where
| [file_or_dir ...] |
is a space-separated list of source file or directory paths.
Note:
If no file or directory paths are specified and the set of additional files specified with -include and -exclude is empty, the codesonar add_source_files.py subcommand has no effect. The importer will ignore files with certain extensions, including those that indicate images (.jpg, .gif,...), archives (.tar, .gz,...) and library/object files (.o, .lib, .dll,...). |
|---|---|
| [-include file_pat] [-exclude file_pat] |
Specify an additional set of source files to be
imported.
file_pat is a a recursive glob pattern representing a source file path. It matches all files whose file path matches file_pat. When a single codesonar add_source_files.py invocation contains a combination of -include and -exclude options, the set of additional files is determined by applying the corresponding inclusions and exclusions in the order in which they appear on the command line. Note:
|
| [-language lang] |
Specifies that the imported files should be recorded as having
language lang.
If -language is not specified, CodeSonar will attempt to determine the language for each file based on its file extension. If it cannot determine a language, the file language will be recorded as "text". The available lang values are:
|
| [-max-bytes num] |
Specifies a maximum size of num bytes for imported
files: files larger than this maximum size will be ignored by
the importer. If -max-bytes is not specified, the importer will ignore files larger than 500KB.
|
Suppose we want to import a ReadMe file into the CodeSonar project.
This is your CodeSonar-facing build.
| Build Tool | Example regular build command | Example CodeSonar-facing build | |
|---|---|---|---|
| make | make all |
make csonar_scan Where the Makefile has been extended to include a csonar_scan target that depends on all and has a recipe that includes invocations of codesonar add_source_files.py. Then the CodeSonar build/analysis command will be:
codesonar analyze myProject make csonar_scan
|
|
| Windows batch file | cmd /c myProj.bat |
cmd /c myProj.bat
CSonarScan Where myProj.bat has been extended to invoke codesonar add_source_files.py after the normal build steps have been performed, but only if argument CSonarScan is passed. Then the CodeSonar build/analysis command will be:
codesonar analyze myProject cmd /c myProj.bat CSonarScan
|
|
| (and so forth) For more examples demonstrating how to construct a CodeSonar build/analysis command for various build tools, see Command Line Build/Analysis: Language-Specific Examples and the Basic Tutorial. |
|||
Suppose part of your software project involves a rare programming language: so rare it does not have an analysis ecosystem.
If you use make to manage your
regular software build, your Makefile might look something like the
following.
(If you use another tool to manage your regular build then the
mechanism for expressing the steps and dependencies will be
different, but analogous.)
.PHONY: all clean # RareCompSrc.rare: a rarelang source file # rarecompile: the compiler for rarelang RareCompExe: RareCompSrc.rare rarecompile RareCompSrc.rare -o RareCompExe all: RareCompExe othercomponent1 [... other project components] clean: rm -f RareCompExe [... recipes for remaining project components]
If you built a CodeSonar project based on observing the execution of this Makefile in its original state, the CodeSonar project would not contain any information about the rarelang component.
To import RareCompSrc.rare into your CodeSonar project, do the following.
.PHONY: all clean csonar_scan RareCompExe: RareCompSrc.rare rarecompile RareCompSrc.rare -o RareCompExe all: RareCompExe othercomponent1 [... other project components] clean: rm -f RareCompExe csonar_scan: RareCompSrc.rare codesonar add_source_files.py RareCompSrc.rare [... recipes for remaining project components]
To report problems with this documentation, please visit https://support.codesecure.com/.