mirror of
https://github.com/optim-enterprises-bv/nDPId.git
synced 2025-10-29 17:32:23 +00:00
Sonarcloud integration
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
This commit is contained in:
45
.github/workflows/sonarcloud.yml
vendored
Normal file
45
.github/workflows/sonarcloud.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- tmp
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
name: Sonarcloud Scan
|
||||
jobs:
|
||||
sonarcloud:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 1
|
||||
- name: Install sonar-scanner and build-wrapper
|
||||
uses: SonarSource/sonarcloud-github-c-cpp@v2
|
||||
- name: Install Prerequisites
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install autoconf automake cmake libtool pkg-config gettext libjson-c-dev flex bison libpcap-dev zlib1g-dev
|
||||
- name: Run build-wrapper
|
||||
run: |
|
||||
mkdir build
|
||||
cmake -S . -B build -DBUILD_NDPI=ON -DDENABLE_ZLIB=ON -DNDPI_WITH_GCRYPT=OFF
|
||||
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build/ --config Release
|
||||
- name: Run tests
|
||||
run: |
|
||||
./test/run_tests.sh ./libnDPI ./build/nDPId-test
|
||||
- name: Run sonar-scanner
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||
run: |
|
||||
sonar-scanner \
|
||||
--define sonar.branch.name=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} \
|
||||
--define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \
|
||||
--define sonar.organization=lnslbrty \
|
||||
--define sonar.projectKey=lnslbrty_nDPId \
|
||||
--define sonar.exclusions=dependencies/uthash/tests/** \
|
||||
--define sonar.verbose=true \
|
||||
--define sonar.python.version=3.8
|
||||
@@ -1,6 +1,12 @@
|
||||
[](https://github.com/utoni/nDPId/actions/workflows/build.yml)
|
||||
[](https://gitlab.com/utoni/nDPId/-/pipelines)
|
||||
[](https://app.circleci.com/pipelines/github/utoni/nDPId)
|
||||
[](https://sonarcloud.io/summary/new_code?id=lnslbrty_nDPId)
|
||||
[](https://sonarcloud.io/summary/new_code?id=lnslbrty_nDPId)
|
||||
[](https://sonarcloud.io/summary/new_code?id=lnslbrty_nDPId)
|
||||
[](https://sonarcloud.io/summary/new_code?id=lnslbrty_nDPId)
|
||||
[](https://sonarcloud.io/summary/new_code?id=lnslbrty_nDPId)
|
||||
[](https://sonarcloud.io/summary/new_code?id=lnslbrty_nDPId)
|
||||

|
||||
|
||||
# References
|
||||
|
||||
4
dependencies/nDPIsrvd.h
vendored
4
dependencies/nDPIsrvd.h
vendored
@@ -479,7 +479,7 @@ static inline int nDPIsrvd_set_read_timeout(struct nDPIsrvd_socket * const sock,
|
||||
{
|
||||
struct timeval tv = {.tv_sec = seconds, .tv_usec = micro_seconds};
|
||||
|
||||
if (sock->fd < 0)
|
||||
if (sock == NULL || sock->fd < 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -559,7 +559,7 @@ static inline void nDPIsrvd_cleanup_instance(struct nDPIsrvd_socket * const sock
|
||||
struct nDPIsrvd_thread_data * current_thread_data;
|
||||
struct nDPIsrvd_thread_data * ttmp;
|
||||
|
||||
if (instance != NULL)
|
||||
if (sock != NULL && instance != NULL)
|
||||
{
|
||||
#ifdef ENABLE_MEMORY_PROFILING
|
||||
nDPIsrvd_memprof_log("Cleaning up instance 0x%x.", instance->alias_source_key);
|
||||
|
||||
1
dependencies/nDPIsrvd.py
vendored
1
dependencies/nDPIsrvd.py
vendored
@@ -182,7 +182,6 @@ class FlowManager:
|
||||
if alias not in self.instances:
|
||||
self.instances[alias] = dict()
|
||||
if source not in self.instances[alias]:
|
||||
self.instances[alias][source] = dict()
|
||||
self.instances[alias][source] = Instance(alias, source)
|
||||
|
||||
self.instances[alias][source].setMostRecentFlowTimeFromJSON(json_dict)
|
||||
|
||||
@@ -55,6 +55,12 @@ static void nDPIsrvd_write_flow_info_cb(struct nDPIsrvd_socket const * sock,
|
||||
(void)instance;
|
||||
(void)user_data;
|
||||
|
||||
if (flow == NULL || thread_data == NULL)
|
||||
{
|
||||
fprintf(stderr, "%s\n", "[WriteFlowInfoCallback] BUG: Internal error.");
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"[Thread %2d][Flow %5llu][ptr: "
|
||||
#ifdef __LP64__
|
||||
|
||||
@@ -475,6 +475,11 @@ static enum nDPIsrvd_callback_return update_flow_packets_processed(struct nDPIsr
|
||||
struct nDPIsrvd_json_token const * const flow_total_packets_processed[FD_COUNT] = {
|
||||
TOKEN_GET_SZ(sock, "flow_src_packets_processed"), TOKEN_GET_SZ(sock, "flow_dst_packets_processed")};
|
||||
|
||||
if (sock == NULL)
|
||||
{
|
||||
return CALLBACK_ERROR;
|
||||
}
|
||||
|
||||
if (sock->flow_user_data_size > 0)
|
||||
{
|
||||
flow_stats->total_packets_processed = 0;
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
sonar.projectKey=lnslbrty_nDPId
|
||||
sonar.organization=lnslbrty
|
||||
|
||||
# This is the name and version displayed in the SonarCloud UI.
|
||||
#sonar.projectName=nDPId
|
||||
#sonar.projectVersion=1.0
|
||||
sonar.projectName=nDPId
|
||||
sonar.projectVersion=1.5
|
||||
|
||||
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
|
||||
#sonar.sources=.
|
||||
|
||||
# Encoding of the source code. Default is default system encoding
|
||||
#sonar.sourceEncoding=UTF-8
|
||||
sonar.sourceEncoding=UTF-8
|
||||
sonar.sources=*.c,*.h,dependencies/nDPIsrvd.h,dependencies/nDPIsrvd.py,examples/c-*/**,examples/cxx-*/**,examples/py-*/**
|
||||
|
||||
Reference in New Issue
Block a user