Skip to content

Commit 68c9e5f

Browse files
Merge branch 'develop' into sync_master_into_develop
2 parents 27658e8 + 7ad12e9 commit 68c9e5f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1769
-324
lines changed

.devcontainer/Visual_Studio_Code_Setup.md

Lines changed: 106 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
# Using VS Code For Development
1+
# Development Environment Setup
2+
3+
## Using VS Code For Development
24

35
[Visual Studio Code](https://code.visualstudio.com/) is a functional free IDE which can be used to develop many projects. Through the use of Docker images it allows developers to develop in containers where build tools can be pre-configured, precluding the need to have a special host to build on with instructions to follow for tool installation. It can be used on Windows hosts using Docker Desktop or on Linux hosts with Docker installed.
46

57
## Setup
68

7-
See https://code.visualstudio.com/docs/devcontainers/containers as a reference on setting up your environment. Here is a summary of the steps below with the assumption that a Linux environment is being used.
9+
This project includes a DevContainer setup which allows for developing in a containerized environment that will spawn run-time depedencies for testing.
10+
11+
> [!NOTE]
12+
> This setup will recreate a Dev Container docker image for V2X Hub, targeting the `build` stage in the dockerfile in order to include build dependencies. This image will be called **v2xhub-devcontainer**
813
914
### Installation
1015

@@ -35,4 +40,102 @@ The configuration comes with 3 configured tasks. These can be run under from th
3540
* test: After a successful build you can use this task to run all the build unit tests
3641

3742
> [!NOTE]
38-
> Both **test** and **build** tasks have a duplicate version which includes **coverage** to build the source code and run the unit tests to get code coverage metrics.
43+
> Both **test** and **build** tasks have a duplicate version which includes **coverage** to build the source code and run the unit tests to get code coverage metrics.
44+
45+
## DevContainer VSCode Extensions
46+
47+
By default our dev container installs several VSCode extensions helpful for developing and testing V2X Hub code changes. These are documented in the `.devcontainer/devcontainer.json` under **customizations.vscode.extensions** and also listed below:
48+
- **CPP Tools**, **CPP Tools Extension Pack**, and **CMake Tools** are extensions for C++ and CMake to make editing our source code and build files easier and more intuitive
49+
- **Sonar Lint** is a code quality and linting tool that provides feedback about best practices and security issues or hotspots
50+
51+
52+
### Sonar Lint One-Time Setup
53+
54+
The first time setting up Sonar Lint, there are a couple VSCode prompts to navitigate to allow you to get Sonar Lint feedback. After deploying the DevContainer, you should see on the right hand side a new icon at the bottom representing the SonarLint VSCode extension.
55+
56+
![alt text](docs/sonar_lint_tab.png)
57+
58+
Clicking this icon should bring up a SonarQube Setup page. Under **Connected Mode** there should be a **SonarQube Cloud** menu with a single connection. Clicking this connection should provide a connection page that allows you to generate a token for a SonarQube Cloud connection. This provides some additional features such as a connection to Quality Profiles set on Sonar Cloud. Simply click **Generate Token** which should open a browser and allow you to login to Sonar Cloud with you GitHub account. Doing so will grant the VSCode extension a token to use to connect to Sonar Cloud.
59+
60+
![alt text](docs/sonar_lint_connect.png)
61+
62+
> [!NOTE]
63+
> Please ensure you save the connection after generating the token. Sometimes the **Save Connection** button is greyed out but simply resetting the organization or connection name should allow you to save the connection.
64+
65+
Lastly you will need to build the code, using **Ctrl + Shift + B** or the build task. The Sonar Lint VS Code extension requires a compilation database file which is generated during the build to function.
66+
67+
### Confirming Setup was Successful
68+
69+
After compiling once, you should be able to edit a *.cpp file an save it. This should result in code smells reported both in the code editor and in the Sonar Qube Terminal
70+
71+
![alt text](docs/sonar_lint_report.png)
72+
73+
Using **Ctrl + I** will allow you to generate AI recommended fixes for reported issues where applicable
74+
75+
76+
## Configuring DevContainer to Trust Organizational Certificate Authorities / Internal TLS
77+
78+
> [!NOTE]
79+
> Skip if not required. For developers, developing inside coporate VPN, this step is required to avoid certificate issues.
80+
81+
If your organization uses private Certificate Authorities (CA), TLS inspection, or a corporate VPN that intercepts HTTPS traffic, the DevContainer must trust your organization’s root and/or intermediate CA certificates.
82+
83+
Without these certificates installed, tools such as curl, nvm, git, or package managers may fail with TLS certificate verification errors.
84+
85+
### Steps
86+
1. Obtain Required Certificates
87+
Request from your IT/security team:
88+
89+
The organization’s Root CA certificate
90+
Any Intermediate CA certificates used for perimeter or TLS inspection
91+
You do not need the VPN server certificate or any private keys — only public CA certificates.
92+
93+
2. Save Certificates to the Repository
94+
Place the certificate files (public certs only) in:
95+
96+
.devcontainer/perimeter-certs/
97+
Requirements:
98+
99+
Files must be in PEM format
100+
Use the .crt file extension (required for automatic installation)
101+
Multiple certificates may be added if needed
102+
Example:
103+
104+
.devcontainer/perimeter-certs/
105+
├── Corp-Root-CA.crt
106+
├── Corp-Perimeter-CA.crt
107+
3. Rebuild the DevContainer
108+
In VS Code:
109+
110+
Dev Containers: Rebuild Container
111+
During container setup, the DevContainer initialization script will:
112+
113+
Detect any .crt files in .devcontainer/perimeter-certs/
114+
Install them into /usr/local/share/ca-certificates/
115+
Update the container’s system trust store
116+
No manual installation steps are required.
117+
118+
Verification (Optional)
119+
After rebuilding, verify that TLS trust works from DevContainer:
120+
121+
curl -I https://nodejs.org/dist/index.json
122+
Expected result:
123+
124+
You should see an HTTP/1.1 200 or HTTP/2 200 response
125+
No certificate verification errors
126+
If this succeeds, certificate trust is correctly configured.
127+
128+
### Troubleshooting
129+
130+
If you still see certificate errors:
131+
132+
Ensure certificate files use the .crt extension
133+
Confirm the files contain valid PEM-encoded certificates
134+
Verify you included both root and intermediate CA certificates (if required)
135+
Rebuild the container again after changes
136+
Security Note
137+
Only public CA certificates should be committed to the repository.
138+
Never commit private keys.
139+
140+
Proceed
141+
After certificate trust is configured, continue with V2XHub deployment as usual.

.devcontainer/devcontainer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// Check for .env file in configuration directory. Copy devcontainer.env if none exists
88
"initializeCommand" : ".devcontainer/check_for_env.sh",
99
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
10-
"dockerComposeFile": ["../configuration/docker-compose.yml","docker-compose-vscode.yml",],
10+
"dockerComposeFile": ["../configuration/docker-compose.yml","docker-compose-vscode.yml"],
1111

1212
// The 'service' property is the name of the service for the container that VS Code should
1313
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
@@ -23,7 +23,8 @@
2323
"extensions": [
2424
"ms-vscode.cpptools",
2525
"ms-vscode.cpptools-extension-pack",
26-
"ms-vscode.cmake-tools"
26+
"ms-vscode.cmake-tools",
27+
"SonarSource.sonarlint-vscode"
2728
]
2829
}
2930
},

.devcontainer/docker-compose-vscode.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ services:
44
context: ..
55
dockerfile: ./Dockerfile
66
target: build-environment
7+
image: v2xhub-devcontainer
78
privileged: true
89
# Building source code is memory intensive so we increase the memory limit.
910
deploy:
46.2 KB
Loading
356 KB
Loading
5.76 KB
Loading
Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
/home/V2X-Hub/container/database.sh
33
/home/V2X-Hub/container/library.sh
44
ldconfig
55
# Install development tools
66

77
apt update
8-
apt install -y valgrind gdb net-tools vim
8+
apt install -y valgrind gdb net-tools vim
9+
10+
# Install perimeter certificates if present (for VPN Access)
11+
if compgen -G ".devcontainer/perimeter-certs/*.crt" > /dev/null; then
12+
echo "Perimeter certificate(s) found. Installing..."
13+
14+
mkdir -p /usr/local/share/ca-certificates/extra && \
15+
cp .devcontainer/perimeter-certs/*.crt /usr/local/share/ca-certificates/extra/ && \
16+
update-ca-certificates
17+
else
18+
echo "No perimeter certificates found. Skipping installation."
19+
fi
20+
21+
# Install Node 22 for SonarLint
22+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash
23+
export NVM_DIR="$HOME/.nvm"
24+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
25+
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
26+
nvm install 22.22.0

.github/workflows/codeql.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL Advanced"
13+
14+
on:
15+
push:
16+
branches: [ "develop", "hotfix/*", "master", "release/*" ]
17+
pull_request:
18+
branches: [ "develop", "hotfix/*", "master", "release/*" ]
19+
schedule:
20+
- cron: '19 6 * * 3'
21+
22+
jobs:
23+
analyze:
24+
name: Analyze (${{ matrix.language }})
25+
# Runner size impacts CodeQL analysis time. To learn more, please see:
26+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
27+
# - https://gh.io/supported-runners-and-hardware-resources
28+
# - https://gh.io/using-larger-runners (GitHub.com only)
29+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
30+
runs-on: ubuntu-latest
31+
container:
32+
image: ubuntu:jammy-20230126
33+
permissions:
34+
# required for all workflows
35+
security-events: write
36+
37+
# required to fetch internal or private CodeQL packs
38+
packages: read
39+
40+
# only required for workflows in private repositories
41+
actions: read
42+
contents: read
43+
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
include:
48+
- language: actions
49+
build-mode: none
50+
- language: c-cpp
51+
build-mode: manual
52+
- language: java-kotlin
53+
build-mode: none # This mode only analyzes Java. Set this to 'autobuild' or 'manual' to analyze Kotlin too.
54+
- language: javascript-typescript
55+
build-mode: none
56+
- language: python
57+
build-mode: none
58+
59+
steps:
60+
- name: Checkout repository
61+
uses: actions/checkout@v4
62+
- name: Install Dependencies
63+
run: |
64+
apt update
65+
apt install -y curl gdb
66+
curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
67+
apt install -y nodejs
68+
69+
# Run original dependency installers
70+
scripts/install_dependencies.sh
71+
cd ext/
72+
./build.sh
73+
../container/library.sh
74+
ldconfig
75+
76+
- name: Initialize CodeQL
77+
uses: github/codeql-action/init@v4
78+
with:
79+
languages: ${{ matrix.language }}
80+
build-mode: ${{ matrix.build-mode }}
81+
82+
- name: Manual Build Steps (C/C++)
83+
if: matrix.build-mode == 'manual'
84+
run: |
85+
chmod +x src/build.sh
86+
cd src
87+
./build.sh coverage --j2735-version 2024 --skip-plugins ""
88+
89+
- name: Perform CodeQL Analysis
90+
uses: github/codeql-action/analyze@v4
91+
with:
92+
category: "/language:${{matrix.language}}"

.github/workflows/sonar-scanner.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ jobs:
2828
# Disabling shallow clone is recommended for improving relevancy of reporting
2929
fetch-depth: 0
3030
submodules: recursive
31-
- name: Install Build Wrapper
32-
uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v6
3331
- name: Run install_dependencies.sh script
3432
run: |
3533
echo "CLONED_REPO_PATH=$GITHUB_WORKSPACE" >> $GITHUB_ENV
@@ -43,9 +41,8 @@ jobs:
4341
ldconfig
4442
- name: Run Tests & Generate Gcovr Reports
4543
run: |
46-
mkdir bw-output
4744
cd src
48-
build-wrapper-linux-x86-64 --out-dir ../bw-output bash build.sh coverage --j2735-version 2024 --skip-plugins ""
45+
./build.sh coverage --j2735-version 2024 --skip-plugins ""
4946
./test.sh coverage
5047
- name: Run sonar-scanner
5148
uses: usdot-fhwa-stol/actions/sonar-scanner@main

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# build directories
22
src/tmx/build
33
src/v2i-hub/build
4+
src/build
45

56
# manually created directories
67
secrets/
78
.devcontainer/MAP
9+
.devcontainer/perimeter-certs
810

911
# Compiled source #
1012
###################
@@ -91,4 +93,3 @@ tools/port-drayage-webservice/target/
9193

9294
#Java PKS for HTTPS setup
9395
tools/port-drayage-webservice/src/main/resources/tutorial.jks
94-
.vscode/settings.json

0 commit comments

Comments
 (0)