Skip to content

Commit 1772671

Browse files
Merge pull request #1 from CodeSecure-SE/feature/codesonar_intro
Add CodeSonar
2 parents 32eb0f8 + 30d126d commit 1772671

File tree

6 files changed

+132
-0
lines changed

6 files changed

+132
-0
lines changed

.devcontainer/devcontainer.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
3+
{
4+
"name": "NASA-cFS - CodeSonar ",
5+
"image": "ghcr.io/codesecure-se/cfs-cso-builder:8.1p0",
6+
"mounts" : [
7+
"source=${localEnv:HOME}/.csurf,target=/home/user/.csurf,type=bind",
8+
"source=${localEnv:HOME}/.ssh,target=/home/user/.ssh,type=bind",
9+
],
10+
"customizations": {
11+
"vscode": {
12+
"extensions": [
13+
"CodeSecure.vscode-codesonar",
14+
"MS-SarifVSCode.sarif-viewer",
15+
"ms-vscode.cpptools",
16+
"ms-vscode.cpptools-extension-pack",
17+
"GitHub.vscode-pull-request-github",
18+
"GitHub.remotehub"
19+
]
20+
}
21+
}
22+
// Features to add to the dev container. More info: https://containers.dev/features.
23+
// "features": {},
24+
25+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
26+
// "forwardPorts": [],
27+
28+
// Use 'postCreateCommand' to run commands after the container is created.
29+
// "postCreateCommand": "uname -a",
30+
31+
// Configure tool-specific properties.
32+
// "customizations": {},
33+
34+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
35+
// "remoteUser": "root"
36+
}
37+

.github/workflows/codesonar.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: CodeSonar
2+
on:
3+
push: # Only run onces the Pull request is created
4+
branches:
5+
- 'release/**' # Feature Branches
6+
pull_request:
7+
branches:
8+
- 'release/**'
9+
10+
jobs:
11+
CodeSonar_Analyze:
12+
permissions: write-all
13+
runs-on: codesecure-runner-set
14+
container:
15+
image: ghcr.io/codesecure-se/cfs-cso-builder:8.1p0
16+
credentials:
17+
username: ${{ github.actor }}
18+
password: ${{ secrets.github_token }}
19+
env:
20+
TOKEN: "${{ secrets.GITHUB_TOKEN }}"
21+
ROOT_TREE: "OSS-Projects/NASA-cFS-GitHub"
22+
PROJECT_NAME: "cFS"
23+
CSONAR_HUB_URL: "https://partnerdemo.codesonar.com"
24+
CSONAR_HUB_USER: "${{ secrets.CSONAR_HUB_USER }}"
25+
CSONAR_HUB_PASSWORD: "${{ secrets.CSONAR_HUB_PASS }}"
26+
REPO_URL: "https://github.com/CodeSecure-SE/cFS" # the github.repositoryUrl is not an http-link.
27+
28+
steps:
29+
- name: Set parallelism
30+
run: echo "PARALLEL=`nproc`" >> $GITHUB_ENV
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
- name: Safe directory
34+
run: git config --global --add safe.directory `pwd`
35+
- name : init submodules
36+
run: git submodule init; git submodule update
37+
- name: create makefiles
38+
run: cp cfe/cmake/Makefile.sample Makefile; cp -r cfe/cmake/sample_defs sample_defs
39+
- name: Checkout CodeSonar CI-Script
40+
uses: actions/checkout@v4
41+
with:
42+
repository: CodeSecure-SE/codesonar_ci
43+
path: cso-scripts
44+
- name: Build and Analyze
45+
run: python3 cso-scripts/build_and_analyze.py codesonar.conf make -j $PARALLEL
46+
- name: Upload SARIF to GitHub #Use this if you do not have GitHub Enterprise
47+
if: ${{ github.event.pull_request }}
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: SARIF file
51+
path: warnings.sarif
52+
- name: Push Summary Report
53+
if: ${{ github.event.pull_request }}
54+
uses: thollander/actions-comment-pull-request@v2
55+
with:
56+
filePath: warnings.md
57+
- name: Upload SARIF results
58+
uses: github/codeql-action/upload-sarif@v3
59+
with:
60+
sarif_file: warnings.sarif
61+
category: "CodeSecure CodeSonar"

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ Makefile
22
build
33
/sample_defs
44
.DS_Store
5+
cFS.prj_files/*
6+
cFS*.conf
7+
cFS.prj
8+
*.sarif
9+
apps/*

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"codesonar.project": "/OSS-Projects/NASA-cFS-GitHub/developers/mhermeling"
3+
}

.vscode/tasks.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"version": "2.0.0",
3+
"inputs": [
4+
{
5+
"id": "codesonarAnalysisName",
6+
"type": "promptString",
7+
"description": "CodeSonar analysis name",
8+
"default": "Analysis-1234"
9+
}
10+
],
11+
"tasks": [
12+
{
13+
"type": "shell",
14+
"label": "C/C++: CodeSonar analyze",
15+
"command": [
16+
"${config:codesonar.installDir}/codesonar/bin/codesonar analyze -foreground cFS -hubuser ${config:codesonar.hubUser} -auth certificate -name ${input:codesonarAnalysisName} -conf-file codesonar.conf -project OSS-Projects/NASA-cFS-GitHub/developers/${config:codesonar.hubUser} ${config:codesonar.hubAddress} make -j $(nproc)"
17+
],
18+
"group": "build",
19+
"detail": "builder: make",
20+
"presentation": {
21+
"showReuseMessage": false,
22+
"panel": "new"
23+
}
24+
}
25+
]
26+
}

codesonar.conf

Whitespace-only changes.

0 commit comments

Comments
 (0)