-
Notifications
You must be signed in to change notification settings - Fork 2
RDKB-63009 RDKB-63010: Native build for Coverity #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 1 commit
3855e63
0fc1dd4
57427b8
04c1b61
14918ef
10591c6
7010a65
a29e97c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | |||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,27 @@ | |||||||||||||||||||||||||||||||||||||||||
| name: Build XDNS Component in Native Environment | |||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||
| on: | |||||||||||||||||||||||||||||||||||||||||
| push: | |||||||||||||||||||||||||||||||||||||||||
| branches: [ main, 'sprint/**', 'release/**', develop ] | |||||||||||||||||||||||||||||||||||||||||
| pull_request: | |||||||||||||||||||||||||||||||||||||||||
| branches: [ main, 'sprint/**', 'release/**', topic/RDK*, develop ] | |||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||
| jobs: | |||||||||||||||||||||||||||||||||||||||||
| build-xdns-on-pr: | |||||||||||||||||||||||||||||||||||||||||
| name: Build XDNS component in github rdkcentral | |||||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | |||||||||||||||||||||||||||||||||||||||||
| container: | |||||||||||||||||||||||||||||||||||||||||
| image: ghcr.io/rdkcentral/docker-rdk-ci:latest | |||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||
| steps: | |||||||||||||||||||||||||||||||||||||||||
| - name: Checkout code | |||||||||||||||||||||||||||||||||||||||||
| uses: actions/checkout@v3 | |||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||
| uses: actions/checkout@v3 | |
| uses: actions/checkout@v4 |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 8 days ago
In general, the fix is to add an explicit permissions block either at the workflow root (affecting all jobs) or at the job level, granting only the minimal required scopes. Since this workflow only checks out code and runs build scripts, contents: read is sufficient in most cases.
For this specific file, the minimal, non‑disruptive change is to add a job-level permissions block to build-xdns-on-pr, just under the job name (or runs-on). This will limit the workflow’s automatically provided GITHUB_TOKEN to read-only repository contents while leaving the rest of the job unchanged. Because the job already uses a secret RDKCM_RDKE for the GITHUB_TOKEN environment variable, adding this block does not interfere with that secret; it only constrains the implicit GITHUB_TOKEN that GitHub injects. No imports or additional methods are needed, only YAML changes in .github/workflows/native-build.yml.
Concretely:
- Edit
.github/workflows/native-build.yml. - Under
build-xdns-on-pr:(around line 11), insert:permissions: contents: read
- Keep indentation aligned with other job keys (
name,runs-on, etc.).
No other functional behavior needs to change.
-
Copy modified lines R12-R13
| @@ -9,6 +9,8 @@ | ||
| jobs: | ||
| build-xdns-on-pr: | ||
| name: Build XDNS component in github rdkcentral | ||
| permissions: | ||
| contents: read | ||
| runs-on: ubuntu-latest | ||
| container: | ||
| image: ghcr.io/rdkcentral/docker-rdk-ci:latest |
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The GITHUB_TOKEN environment variable is set to use a custom secret 'secrets.RDKCM_RDKE', but it's not clear if this is actually needed for the build process. If the build scripts are cloning public repositories (as seen in run_setup_dependencies.sh where it clones from https://github.com/rdkcentral/build_tools_workflows), the default GITHUB_TOKEN provided by GitHub Actions should be sufficient. If this custom token is required, please add a comment explaining why. If it's not needed, consider removing it to reduce secret dependencies.
| GITHUB_TOKEN: ${{ secrets.RDKCM_RDKE }} | |
| GITHUB_TOKEN: ${{ github.token }} |
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This overrides the built-in GITHUB_TOKEN with a repository secret, which increases the risk of credential exposure because the subsequent scripts run code from the checked-out repository in a PR context. Prefer using the default ${{ github.token }} for GitHub API operations, and if an elevated token is required, pass it under a different env name and ensure the workflow does not run untrusted PR code with that secret available.
| GITHUB_TOKEN: ${{ secrets.RDKCM_RDKE }} | |
| GITHUB_TOKEN: ${{ github.token }} |
Copilot
AI
Feb 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On pull_request events, repository secrets are not available to forks, which can cause CI to fail unexpectedly. If a token is required, prefer the built-in ${{ github.token }} (or only use the secret on non-fork contexts); if it’s not required for public submodules, remove this override.
| GITHUB_TOKEN: ${{ secrets.RDKCM_RDKE }} | |
| GITHUB_TOKEN: ${{ github.token }} |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,102 @@ | ||||||||||||||
| { | ||||||||||||||
| "_comment": "Component Build Configuration for Coverity/Native Builds", | ||||||||||||||
| "_version": "2.0", | ||||||||||||||
| "_description": "Defines dependencies and build settings for the native component", | ||||||||||||||
|
|
||||||||||||||
| "dependencies": { | ||||||||||||||
| "_comment": "External repositories needed by this component", | ||||||||||||||
| "repos": [ | ||||||||||||||
| { | ||||||||||||||
| "name": "rbus", | ||||||||||||||
|
||||||||||||||
| "name": "rbus", | |
| "name": "rbus", | |
| "_comment": "\"branch\" may refer to a branch or a tag; here v2.7.0 is a Git tag.", |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build configuration references "cov_docker_script/run_external_build.sh" as the build script for common-library (line 41) and Utopia (line 86). However, run_external_build.sh clones the build_tools_workflows repository if it doesn't exist (lines 25-33), which could lead to race conditions or conflicts if multiple dependencies try to build in parallel. Additionally, this creates a circular dependency where component_config.json references run_external_build.sh, which in turn reads component_config.json. Consider: 1) Documenting that builds must be sequential, not parallel, or 2) Restructuring to avoid the script cloning build_tools_workflows (since run_setup_dependencies.sh should handle this).
Outdated
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build configuration for the "Utopia" dependency references "cov_docker_script/run_external_build.sh" as the build script. However, this creates a circular dependency issue: run_external_build.sh is meant to be called from the build_tools_workflows repository to build external dependencies, but here it's being referenced as a script within a dependency being built. This will likely fail as the script path would need to exist within the Utopia repository, not this repository. Consider using the correct script path from build_tools_workflows or using "common_external_build.sh" directly.
| "script": "cov_docker_script/run_external_build.sh" | |
| "script": "cov_docker_script/common_external_build.sh" |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue as with common-library dependency at lines 39-42. The build configuration references "cov_docker_script/run_external_build.sh" which may cause conflicts if run_setup_dependencies.sh has already cloned build_tools_workflows, or create race conditions if dependencies build in parallel.
| ], | |
| "build": { | |
| "type": "script", | |
| "script": "cov_docker_script/run_external_build.sh" | |
| } | |
| ] |
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a trailing comma after the closing brace of the "dependencies" object. While many JSON parsers are lenient and accept trailing commas, this is technically invalid according to the JSON specification and could cause parsing errors in strict JSON parsers. Remove the comma on this line.
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The component name in this configuration is "xdns" (line 94) but the PR title mentions "RDKB-63009 RDKB-63010" without mentioning the XDNS component name. Additionally, this appears to be in a repository that should be named consistently with the component. Please verify this is the correct component name for this repository.
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All paths throughout the configuration use "$HOME" for constructing include and library paths (e.g., lines 14, 95, 96). While this provides flexibility, it assumes HOME is properly set in the build environment. In containerized builds or CI environments, this might not always point to the expected location. Consider documenting this requirement or adding validation in the build scripts to ensure HOME is set correctly before proceeding with the build.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,137 @@ | ||||||||||||||||||||||||||||||||||||||||||
| # MoCA Agent Configure Options | ||||||||||||||||||||||||||||||||||||||||||
| # This file contains autotools configure options for the moca-agent component | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
| # MoCA Agent Configure Options | |
| # This file contains autotools configure options for the moca-agent component | |
| # XDNS Configure Options | |
| # This file contains autotools configure options for the XDNS component |
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script uses "$HOME" variable in multiple paths (lines 13-14, 135), but this assumes HOME is set in the build environment. While this is typically true, in containerized or CI environments, HOME might not be set as expected. Consider verifying that HOME is set or using a more explicit path variable that's controlled by the build system.
| -I$HOME/usr/include/rdkb/ | |
| -I${HOME:?HOME environment variable is not set}/usr/include/rdkb/ |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CPPFLAGS section uses $HOME to reference user home directory paths (e.g., lines 13-14, 135), but this may not work reliably in all build environments, particularly containerized builds. The $HOME variable expansion depends on when and how it's processed. Consider: 1) Documenting the expected $HOME value for the build environment, or 2) Using a more explicit build-time variable that's set by the build system, or 3) Verifying that the build scripts properly expand $HOME before passing these flags to the configure script.
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to line 31, the flag '-U_COSA_SIM_' explicitly undefines a macro without a prior definition in this configuration. While this might be defensive programming to ensure simulation mode is disabled, consider adding a comment explaining the intent.
| -D_COSA_HAL_ | |
| -D_COSA_HAL_ | |
| # Explicitly undefine simulation mode macro to ensure non-sim build, even if defined elsewhere |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The flag '-U_ANSC_IPV6_COMPATIBLE_' on line 31 undefines this macro, but there's no corresponding '-D' definition for it in the list. This is intentional to ensure IPv6 compatibility is disabled, but it's unusual to explicitly undefine something that was never defined. Consider adding a comment explaining why this specific macro needs to be explicitly undefined, or verify if this is actually necessary.
| -D_NO_ANSC_ZLIB_ | |
| -D_NO_ANSC_ZLIB_ | |
| # Explicitly undefine ANSC IPv6 compatibility to ensure it is disabled, | |
| # even if defined by global, toolchain, or shared build flags. |
Outdated
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiple product/platform macros that are typically mutually exclusive are defined simultaneously. This makes the native build configuration hard to reason about and can enable unintended compile-time paths. Consider splitting these into per-target option sets (or selecting a single platform/product via a variable in the build scripts) instead of enabling all of them at once.
| -D_COSA_INTEL_USG_ARM_ | |
| -D_COSA_FOR_COMCAST_ | |
| -D_COSA_BCM_ARM_ | |
| -D_XB6_PRODUCT_REQ_ | |
| -D_XB7_PRODUCT_REQ_ | |
| -D_XB8_PRODUCT_REQ_ | |
| # NOTE: | |
| # The following macros represent mutually exclusive platform/product | |
| # combinations. Only enable the ones that match the target you are | |
| # building for. By default, we build for the BCM ARM XB8 profile. | |
| # | |
| # Platform selection (choose exactly one): | |
| # -D_COSA_INTEL_USG_ARM_ # Intel USG ARM platform | |
| # -D_COSA_FOR_COMCAST_ # Generic Comcast platform profile | |
| -D_COSA_BCM_ARM_ # Broadcom ARM platform (default) | |
| # | |
| # Product selection (choose exactly one): | |
| # -D_XB6_PRODUCT_REQ_ # XB6 product requirements | |
| # -D_XB7_PRODUCT_REQ_ # XB7 product requirements | |
| -D_XB8_PRODUCT_REQ_ # XB8 product requirements (default) |
Outdated
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__USE_XOPEN is a libc-internal feature test macro (glibc uses __USE_* internally) and should not be defined by applications. Prefer using standard feature test macros (for example _XOPEN_SOURCE with an explicit value) or remove this define if it isn't required.
| -D__USE_XOPEN |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,51 @@ | ||||||
| #!/usr/bin/env bash | ||||||
| set -e | ||||||
|
||||||
|
|
||||||
| ################################################################################ | ||||||
| # External Build Wrapper Script | ||||||
| # Verifies build tools and runs common_external_build.sh | ||||||
| # Usage: ./run_external_build.sh | ||||||
| # Note: run_setup_dependencies.sh should be executed first | ||||||
| ################################################################################ | ||||||
|
|
||||||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||||||
| NATIVE_COMPONENT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" | ||||||
| BUILD_TOOLS_REPO_URL="https://github.com/rdkcentral/build_tools_workflows" | ||||||
| BUILD_TOOLS_DIR="$NATIVE_COMPONENT_DIR/build_tools_workflows" | ||||||
|
|
||||||
| # Basic logging functions | ||||||
| log() { echo "[INFO] $*"; } | ||||||
| ok() { echo "[OK] $*"; } | ||||||
| err() { echo "[ERROR] $*" >&2; } | ||||||
|
|
||||||
| echo "" | ||||||
| echo "===== External Build Pipeline =====" | ||||||
| echo "" | ||||||
|
|
||||||
| # Clone build_tools_workflows if it doesn't exist | ||||||
| if [[ ! -d "$BUILD_TOOLS_DIR" ]]; then | ||||||
| log "build_tools_workflows not found, cloning repository..." | ||||||
| cd "$NATIVE_COMPONENT_DIR" | ||||||
| git clone -b develop "$BUILD_TOOLS_REPO_URL" || { err "Clone failed"; exit 1; } | ||||||
|
||||||
| ok "Repository cloned successfully" | ||||||
| else | ||||||
| log "build_tools_workflows already exists" | ||||||
| fi | ||||||
|
||||||
|
|
||||||
| if [[ ! -f "$BUILD_TOOLS_DIR/cov_docker_script/common_external_build.sh" ]]; then | ||||||
| err "common_external_build.sh not found in build_tools_workflows. Please run run_setup_dependencies.sh first." | ||||||
|
||||||
| err "common_external_build.sh not found in build_tools_workflows. Please run run_setup_dependencies.sh first." | |
| err "common_external_build.sh not found in build_tools_workflows. The repository may be incomplete or out of date. Please delete '$BUILD_TOOLS_DIR' and rerun this script, or run run_setup_dependencies.sh to re-fetch the build_tools_workflows dependencies." |
Outdated
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a trailing space after the second argument on this line. While this won't cause functional issues, it's inconsistent with run_native_build.sh line 41 which doesn't have trailing whitespace in the equivalent command invocation.
| "$BUILD_TOOLS_DIR/cov_docker_script/common_external_build.sh" "$SCRIPT_DIR/component_config.json" "$NATIVE_COMPONENT_DIR" | |
| "$BUILD_TOOLS_DIR/cov_docker_script/common_external_build.sh" "$SCRIPT_DIR/component_config.json" "$NATIVE_COMPONENT_DIR" |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,51 @@ | ||||||||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||||||||
| set -e | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ################################################################################ | ||||||||||||||||||||||||||
| # Native Build Wrapper Script | ||||||||||||||||||||||||||
| # Verifies build tools and runs build_native.sh | ||||||||||||||||||||||||||
| # Usage: ./run_native_build.sh | ||||||||||||||||||||||||||
| # Note: run_setup_dependencies.sh should be executed first | ||||||||||||||||||||||||||
| ################################################################################ | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||||||||||||||||||||||||||
| NATIVE_COMPONENT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" | ||||||||||||||||||||||||||
| BUILD_TOOLS_DIR="$NATIVE_COMPONENT_DIR/build_tools_workflows" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Basic logging functions | ||||||||||||||||||||||||||
| log() { echo "[INFO] $*"; } | ||||||||||||||||||||||||||
| ok() { echo "[OK] $*"; } | ||||||||||||||||||||||||||
| err() { echo "[ERROR] $*" >&2; } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| echo "" | ||||||||||||||||||||||||||
| echo "===== Native Build Pipeline =====" | ||||||||||||||||||||||||||
| echo "" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Verify build_tools_workflows exists (should be cloned by run_setup_dependencies.sh) | ||||||||||||||||||||||||||
| if [[ ! -d "$BUILD_TOOLS_DIR" ]]; then | ||||||||||||||||||||||||||
| err "build_tools_workflows directory not found. Please run run_setup_dependencies.sh first." | ||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if [[ ! -f "$BUILD_TOOLS_DIR/cov_docker_script/build_native.sh" ]]; then | ||||||||||||||||||||||||||
| err "build_native.sh not found in build_tools_workflows. Please run run_setup_dependencies.sh first." | ||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| log "Build script found, proceeding with build..." | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Run build_native.sh from build_tools_workflows | ||||||||||||||||||||||||||
| echo "" | ||||||||||||||||||||||||||
| log "Running build_native.sh from build_tools_workflows..." | ||||||||||||||||||||||||||
| cd "$NATIVE_COMPONENT_DIR" | ||||||||||||||||||||||||||
| "$BUILD_TOOLS_DIR/cov_docker_script/build_native.sh" "$SCRIPT_DIR/component_config.json" "$NATIVE_COMPONENT_DIR" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| echo "" | ||||||||||||||||||||||||||
| ok "Native build completed successfully!" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Cleanup build_tools_workflows directory | ||||||||||||||||||||||||||
| log "Cleaning up build_tools_workflows directory..." | ||||||||||||||||||||||||||
| rm -rf "$BUILD_TOOLS_DIR" | ||||||||||||||||||||||||||
| ok "Cleanup completed" | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| # Cleanup build_tools_workflows directory | |
| log "Cleaning up build_tools_workflows directory..." | |
| rm -rf "$BUILD_TOOLS_DIR" | |
| ok "Cleanup completed" | |
| # Cleanup build_tools_workflows directory unless preservation is requested | |
| if [[ -n "${PRESERVE_BUILD_TOOLS:-}" ]]; then | |
| log "PRESERVE_BUILD_TOOLS is set; skipping cleanup of build_tools_workflows directory." | |
| else | |
| log "Cleaning up build_tools_workflows directory..." | |
| rm -rf "$BUILD_TOOLS_DIR" | |
| ok "Cleanup completed" | |
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow uses 'actions/checkout@v3' which is an older version. GitHub Actions has released newer versions (v4 is available as of 2023). Consider updating to '@v4' for improved performance and features. This is the same pattern used in the L1-tests.yml workflow, so updating both together would maintain consistency.