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.0p0 Hot Tips | CONFIDENTIAL | CodeSecure Inc |
If you are wish to periodically synchronize warning annotations between different hubs, you may find it useful to automate the mirroring steps.
Suppose we want to mirror the annotations from the hub at http://sourcehub:7340 to the hub at http://desthub:7340.
There are two steps:
| Step A | Set up sessions and get bearer tokens. We will use these bearer tokens for authentication in Step B. |
|---|---|
| Step B | Set up mirroring script. Create a script to perform the mirroring operations, then arrange for the script to be run automatically. |
Before you start:
We will use bearer authentication for the hub operations in this task.
If you do not already have a suitable session and bearer token for each hub, generate them now:
The process for setting up the mirroring script differs slightly between systems because of different scripting syntax and system tools.
# /bin/sh
cd /path/to/workingdir
SRC_TOKEN=$(cat $2)
DST_TOKEN=$(cat $4)
curl -H "Authorization: Bearer ${SRC_TOKEN}" $1/annotations.csv > anno.csv || exit $?
curl -H "Authorization: Bearer ${DST_TOKEN}" $3/import_annotations/ -F 'file=@anno.csv' > response.html
curl -H "Authorization: Bearer ${DST_TOKEN}" $3/import_annotations/ -F 'file=@anno.csv' -F 'overwrite=on' > response.html
| http://sourcehub:7340 | is the location of the source hub (the hub we are copying annotations from. |
|---|---|
| http://desthub:7340 | is the location of the destination hub (the hub we are copying annotations to). |
| path/to/srcbearerfile | is the path to the file where you saved your bearer token for the source hub. |
| path/to/destbearerfile | is the path to the file where you saved your bearer token for the destination hub. |
| Hub location | Bearer token stored in file |
|---|---|
| http://red:7340 | /mytokens/redtoken |
| https://blue:7340 | /mytokens/bluetoken |
5 2 * * * /path/to/csonar_push.sh http://red:7340 /mytokens/redtoken https://blue:7340 /mytokens/bluetoken 5 2 * * * /path/to/csonar_push.sh https://blue:7340 /mytokens/bluetoken http://red:7340 /mytokens/redtoken
set workdir=path\to\workingdir cd /D %workdir% set /p SRC_TOKEN=<"%2" set /p DST_TOKEN=<"%4" curl -H "Authorization: Bearer %SRC_TOKEN%" %1/annotations.csv > anno.csv || exit $? curl -H "Authorization: Bearer %DST_TOKEN%" %3/import_annotations/ -F "file=@anno.csv" > response.html
| http://sourcehub:7340 | is the location of the source hub (the hub we are copying annotations from. |
|---|---|
| http://desthub:7340 | is the location of the destination hub (the hub we are copying annotations to). |
| path/to/srcbearerfile | is the path to the file where you saved your bearer token for the source hub. |
| path/to/destbearerfile | is the path to the file where you saved your bearer token for the destination hub. |