About Me
I am currently a third-year Electrical Engineering student from Sardar Vallabhbhai National Institute of Technology with a strong interest in systems programming, automation, and DevOps. While my coursework primarily focuses on electronics and electrical systems, I have actively explored low-level programming, operating systems, and automation tools, which naturally led me to embedded systems.
My interest in embedded systems comes from working with microcontrollers for a project in my college initially and understanding how software interacts with hardware at a deep level. I enjoy optimizing performance, ensuring reliability, and automating workflows—critical aspects of embedded development
I discovered RTEMS while exploring open-source projects from GSOC organizations and their role in critical systems like aerospace, robotics, and industrial automation is huge. The structured development process and community-driven approach of RTEMS motivated me to work with the organization.
What makes me stand out is my ability to adapt and learn quickly. I have strong experience in backend development with Go and C++, which helps me write efficient software. Additionally, my interest in optimizing workflows allows me to improve development processes.
Project-Overview
Project Abstract
The project aims to integrate CodeQL into the RTEMS workflow by configuring it for source code analysis, generating reports on security and coding issues,and allowing rule customization. Additionally, it will develop a standalone tool for local static analysis, ensuring repeatability and future integration into RTEMS CI.
Project Description
RTEMS currently lacks a robust static analysis tool integrated into its development workflow.While tools like Coverity exist, they are not fully customizable or locally executable. CodeQL offers flexibility, customizability, and the ability to run locally, making it a strong candidate for adoption.
Static analysis tools help identify potential bugs, security vulnerabilities, and coding standard violations early in the development process. CodeQL's query-based approach allows developers to define custom rules tailored to RTEMS-specific requirements. The current RTEMS workflow relies on external platforms like GitLab CI for running CodeQL, generating reports, and manually modifying the source code based on findings. This creates dependencies on third-party tools, limits local development flexibility, and requires manual effort in reviewing and fixing issues.
Integrating CodeQL locally eliminates dependencies on external CI platforms like GitLab by enabling developers to run static analysis directly on their machines before committing changes. CodeQL’s query-based approach allows the creation of custom rules tailored to RTEMS-specific requirements, such as ignoring irrelevant files, directories, or rules, ensuring only meaningful checks are enforced. Automated report generation provides clear, structured insights, reducing manual review efforts and improving efficiency. A standalone tool will be developed to streamline local CodeQL execution, complemented by an RTEMS Source Builder (RSB) recipe to automate installation and configuration. This setup ensures repeatability, minimizes noise through customizable filters and includes documentation and a tutorial to guide future contributors. The solution is designed modularly to support eventual CI integration while prioritizing local developer experience and alignment with RTEMS coding standards.
Implementation
This section documents the weekly progress of the CodeQL Static Analyzer for RTEMS project as part of GSoC 2025.
Week-1
This week marked the beginning of the GSoC implementation phase.This was all the analysis and setup I did before my GSoC application where I focused on setting up the static analysis framework and laying the foundation for the CodeQL integration with the RTEMS codebase.
Work-done
-
Installation of CodeQL
-
By referring to the documentation from CodeQL, I opted for Option 2 to install the CodeQL CLI.
Option 2 focuses on downloading the standalone CodeQL CLI binary from the official GitHub releases page. This method provides:- The CodeQL CLI executable
- Minimal setup without the default GitHub query packs
- Flexibility to manually install and configure specific query packs
- I downloaded the ZIP file
(codeql-linux64.zip)
from (GitHub CodeQL CLI binary Releases), extracted it.
-
-
Creation of Database
- After installing the CodeQL CLI, the next step was to generate a CodeQL database from the RTEMS source code.
- A CodeQL database is a structured representation of the codebase, enabling static analysis through queries.
Database Creation Command:
codeql database create rtems-codeql-db --language=c --source-root=.
- This command initializes a new CodeQL database named
rtems-codeql-db
.
-
Analyze the Database
- Once the CodeQL database was successfully generated, the next step was to analyze it using specific Coding Standard rules.
Running the Analysis:
- Use the following command to analyze the database with one or more Coding Standards:
codeql database analyze rtems-codeql-db --format=sarif-latest --output=codeql-report.sarif
- The results are saved in a SARIF file, which is a standardized format for static analysis results, and can be visualized using compatible tools.
Future Improvements from discussions
- Install
option 1
method for installing CodeQL CLI and also include C standard packs like MISRA,CERT-C. - Make plan for RSB reciepe creation.
Week-2
This week, I focused on practical integration and experimentation with CodeQL, including an upgrade from the previous version and well-classified documentation. I started using the CodeQL CLI bundle to generate databases and run queries across multiple languages, i.e., C, C++, and Python. The goal was to explore CodeQL's ability to enforce secure coding standards like MISRA C, Common C, and detect low-level vulnerabilities early in embedded systems development.
Alongside CodeQL work, I also began exploring the RTEMS Source Builder (RSB) to understand how toolchains are configured and managed for RTEMS targets.
Work completed this week
1. Installation of CodeQL CLI
bundle
-
Download the
.tar.gz
file from the codeql release-page:- Here I am using CodeQL CLI bundle, which includes both the CodeQL CLI and GitHub's default security queries.I selected
codeql-bundle-linux64.tar.gz
because I was using linux-ubuntu. - Also you can install simlarly using the below link:
wget https://github.com/github/codeql-action/releases/download/codeql-bundle-v2.21.3/codeql-bundle-linux64.tar.gz
The version I used here is
v2.21.3
. - Here I am using CodeQL CLI bundle, which includes both the CodeQL CLI and GitHub's default security queries.I selected
-
Extract the
tarball
downloaded:mkdir -p ~/codeql tar -xzvf codeql-bundle-linux64.tar.gz -C ~/codeql
-
Add
codeql
toPATH
:echo 'export PATH="$HOME/codeql/codeql:$PATH"' >> ~/.bashrc source ~/.bashrc
-
Verify if
codeql
is intalled:codeql --version # Should show the CLI version .
2. Installation of C/CPP
Query-packages
- To install codeql packages that include:
misra-c-coding-standards
cert-c-coding-standards
misra-cpp-coding-standards
cert-cpp-coding-standards
autosar-cpp-coding-standards
common-c-coding-standards
common-cpp-coding-standards
Run the following command:
codeql pack download codeql/misra-c-coding-standards codeql pack download codeql/cert-c-coding-standards codeql pack download codeql/misra-cpp-coding-standards codeql pack download codeql/cert-cpp-coding-standards codeql pack download codeql/autosar-cpp-coding-standards codeql pack download codeql/common-c-coding-standards codeql pack download codeql/common-cpp-coding-standards
- To verify the location of installation:
~$ ls .codeql/packages/codeql/
Versions of each package installed are 1. autosar-cpp-coding-standards ⇒ 2.45.0 2. cert-cpp-coding-standards ⇒ 2.45.0 3. common-cpp-coding-standards ⇒ 2.45.0 4. misra-cpp-coding-standards ⇒ 2.45.0 5. cert-c-coding-standards ⇒ 2.45.0
3. Creating Database for RTEMS
- For creating a database for mulutiple langauges and other flags I reffred to this documentation.To build the database for
RTEMS
codebase use the commandcodeql database create rtems-db \ --db-cluster \ --language python,c-cpp \ --command "./build.sh" \ --no-run-unnecessary-builds \ --source-root .
The
build.sh
script is a helper file that automates the clean and build process for the RTEMS codebase:
#!/bin/bash
./waf clean && ./waf build
This script ensures the workspace is cleaned before each build, which helps avoid inconsistencies due to leftover artifacts.
- Here I am creating a database for 3 languages i.e Python,C,CPP.
- Make sure you are under
RTEMS
codebase while creation.
4. Analyzing the Database
-
For the analysis of database I reffered this documentation.
-
We can use the below command to analyse the codebase
- For MISRA C:
codeql database analyze rtems-db/cpp \ --format=sarifv2.1.0 \ --output=misra-c-results.sarif \ codeql/misra-c-coding-standards@2.45.0 \ --ram= "can be set as your wish"\ --threads= "can be set as your wish"
- For CERT C:
codeql database analyze rtems-db/cpp \ --format=sarifv2.1.0 \ --output=cert-c-results.sarif \ codeql/cert-c-coding-standards@2.45.0\ --ram= "can be set as your wish"\ --threads= "can be set as your wish"\
- For MISRA C++:
codeql database analyze rtems-db/cpp \ --format=sarifv2.1.0 \ --output=misra-cpp-results.sarif \ codeql/misra-cpp-coding-standards@2.45.0\ --ram= "can be set as your wish"\ --threads= "can be set as your wish"\
- Generate Report for Python
codeql database analyze rtems-db/python \ --format=sarifv2.1.0 \ --output=python-security-results.sarif \ codeql/python-queries # Default security queries
- For MISRA C:
-
The output generated is in
sarif
format.
Future Improvements from discussions
- Come up with recipe for installation of CodeQL into RSB
- Explore running the queries and excluding some queries
Week-3
During the third week, I collaborated closely with Dr. RTEMS to reproduce the CodeQL setup and workflow on his system using the documentation I had prepared. This joint debugging effort helped us pinpoint specific issues in the CodeQL analysis process. While attempting to integrate CodeQL with the RTEMS Source Builder (RSB), we faced configuration and compatibility challenges, leading to a revised understanding of the mid-term deliverables based on feasibility and project priorities. Additionally, Dr. RTEMS encountered issues visualizing SARIF report outputs due to toolchain limitations, so we decided to shift to the CSV format for CodeQL query results to ensure better compatibility and easier processing going forward.
Work completed this week
1. Exclude Queries
-
To exclude a query create a directory
codeql
and add the following details asrestricted-cert.qls
file.- qlpack: codeql/cert-cpp-coding-standards version: 2.46.0 - exclude: id: - cpp/cert/interleaved-input-output-without-position
Mention id in the given format
langauge/query-rule/query-name-in-small
and run the file i.e use
codeql database analyze rtems-db/cpp \ --format=sarifv2.1.0 \ --output=misra-cpp-results.sarif \ --ram=8000 \ --threads=4 \ codeql/cpp-misra-restricted.qls # Use your custom suite here
then you will be able to get the report.
-
Generate output using CSV format.
codeql database analyze rtems-db/cpp \ --format=csv \ --output=restricted-cpp-results.csv \ --ram=8000 \ --threads=4 \ codeql/cpp-misra-restricted.qls # Use your custom suite here
-
Discussed on grouping all the queries in batches which can be used in CI later.
Future Improvements
- Since our attempt to use the RTEMS Source Builder (RSB) for CodeQL integration did not go as planned, I had a detailed discussion with my mentor Dr. RTEMS regarding alternative approaches.
- We concluded that a more practical and reproducible solution would be to write dedicated scripts for each step of the CodeQL workflow — including database creation, analysis, and result handling.
- These scripts will serve as a reusable automation toolkit that others in the RTEMS community can easily run and replicate.
- This scripting-based setup will form the basis of my midterm deliverable, effectively becoming an alpha integration package for CodeQL with RTEMS.
Week-4
During Week-4, we finalized my midterm deliverables after discussions with my mentor, focusing on building a reproducible CodeQL workflow tailored for RTEMS. The primary goal is to automate the entire setup process so that others can easily replicate the analysis steps without manual intervention. To achieve this, I started writing a series of scripts that handle tasks such as downloading, unzipping, and setting up the CodeQL CLI. We also discussed implementing directory exclusion rules to ensure irrelevant files are filtered out during database creation. As of now, the installation and unzipping stages of the automation have been completed successfully, marking steady progress toward the midterm milestone.
Work completed this week
1. Finalaze mid-term delvirable
- A standalone GitHub repository containing:
- Set up scripts and config files for running CodeQL on
RTEMS
. .qls
files for selected rule sets..qls
files focusing on excluding directories accordingly.- Sample output reports (CSV / SARIF).
- Clear
README
instructions to replicate the setup manually.
- Set up scripts and config files for running CodeQL on
- A working demo showing:
- Cloning the toolkit.
- Running CodeQL and viewing actionable issues with line-level details.
- (Optional) Draft design for CI integration in the future.
- Toolkit structure
No mixing with RTEMS source filesrtems-codeql-toolkit/ ├── bin/ # CodeQL binaries (auto-downloaded) ├── config/ # Pre-configured exclusion profiles ├── reports/ # Analysis outputs ├── scripts/ # Automation scripts │ ├── setup # Installation script │ ├── sb-check # Environment validator │ └── analyze # Main analysis driver └── README.md # User guide
- Directory Exclusion Strategy:The following documentation has been reffered for directory exclusion.
2. Scripts
- This week, I completed the scripts used for installing the CodeQL CLI bundle and unzipping it. A progress bar has also been integrated to give users clear visual feedback during the installation process.
- The script detects the user's operating system and installs the appropriate bundle accordingly..
- If an older version of the bundle is already present, it gets automatically removed, and the new version is installed by simply updating the version number in the script.
- The installed CodeQL bundle is placed inside the
bin
directory for consistent and organized access.
Future Improvements
- I will write scripts that check whether
codeql
is already available in the system'sPATH
. If not, the script will guide the user to install or link it correctly. - I will also implement scripts to create a CodeQL database and run analysis using predefined or custom query packs, ensuring the process is smooth and fully automated.
Week-5
This week, I completed writing all the scripts responsible for creating the CodeQL database and performing the analysis. I also began working on excluding queries that are known to hang or get stuck during execution. I collaborated closely with my mentor to test the functionality of these scripts and we are actively working on improving them. Additionally, my mentor provided some feedback and shared initial results, which I will incorporate to further refine and enhance the scripts.
Work completed this week
1. Scripts
-
Completed the following scripts:
create_db.py
: Handles database creation with different langauges.sb_check.py
: Checks if CodeQL is available in the systemPATH
.analyze_db.py
: Handle CodeQL analysis with CSV report generation.
-
The GitLab repository rtems-codeql-toolkit is now well-documented:
- A detailed
README.md
is available explaining how to install, configure, and use each script. - Clear instructions and examples are provided to help users understand how the toolkit works and how to get started quickly.
- A detailed
Future Improvements
Based on the feedback received from Dr. RTEMS, I need to do the following improvements to the project:
-
README.md Modifications
-
Updated the
pip install
instructions to include the--user
flag for better compatibility:pip install --user -r requirements.txt
-
-
Script Enhancements
- Added a proper shebang (
#!/usr/bin/env python3
) at the top of all Python scripts to allow them to be executed directly. - Ensured that all scripts in the
scripts/
directory can be run using./scripts/<script_name>.py
format by setting appropriate execute permissions.
- Added a proper shebang (
-
CodeQL Path and Version Check
- Improve the logic to:
- Detect if CodeQL is already available in the system
PATH
. - If present, use the existing CodeQL installation.
- Verify if the CodeQL version matches the required one before proceeding.
- Detect if CodeQL is already available in the system
- Improve the logic to:
-
CSV Output Formatting
- Enhanced the CSV formatting logic to ensure the output includes a header row.
- This improves clarity and usability of analysis results for further processing or review.