fixing kong build #2433

Merged
mfreeman451 merged 1 commit from refs/pull/2433/head into main 2025-11-20 04:47:37 +00:00
mfreeman451 commented 2025-11-20 04:47:18 +00:00 (Migrated from github.com)
Owner

Imported from GitHub pull request.

Original GitHub pull request: #1965
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/1965
Original created: 2025-11-20T04:47:18Z
Original updated: 2025-12-08T06:54:44Z
Original head: carverauto/serviceradar:chore/fix_1_0_54_rel
Original base: main
Original merged: 2025-11-20T04:47:37Z by @mfreeman451

User description

IMPORTANT: Please sign the Developer Certificate of Origin

Thank you for your contribution to ServiceRadar. Please note, when contributing, the developer must include
a DCO sign-off statement indicating the DCO acceptance in one commit message. Here
is an example DCO Signed-off-by line in a commit message:

Signed-off-by: J. Doe <j.doe@domain.com>

Describe your changes

Code checklist before requesting a review

  • I have signed the DCO?
  • The build completes without errors?
  • All tests are passing when running make test?

PR Type

Bug fix, Enhancement


Description

  • Add C compiler detection and installation logic to Kong build script

  • Automatically resolve missing gcc/clang by checking environment and installing build-essential

  • Ensure CC environment variable is properly set before Kong compilation

  • Call new ensure_cc function in main build pipeline


Diagram Walkthrough

flowchart LR
  main["main function"] -- "calls" --> ensure_cc["ensure_cc function"]
  ensure_cc -- "checks" --> cc_env["CC environment variable"]
  ensure_cc -- "searches" --> gcc["gcc/clang availability"]
  ensure_cc -- "installs" --> build_essential["build-essential package"]
  ensure_cc -- "exports" --> cc_var["CC variable"]

File Walkthrough

Relevant files
Bug fix
build-kong-vendor.sh
Add C compiler detection and auto-installation logic         

scripts/build-kong-vendor.sh

  • Added new ensure_cc() function to detect and configure C compiler
  • Function checks CC environment variable, searches for gcc/clang, and
    auto-installs build-essential if needed
  • Supports both sudo and non-sudo installation paths for flexibility
  • Integrated ensure_cc call into main build pipeline after ensure_clone
+41/-0   

Imported from GitHub pull request. Original GitHub pull request: #1965 Original author: @mfreeman451 Original URL: https://github.com/carverauto/serviceradar/pull/1965 Original created: 2025-11-20T04:47:18Z Original updated: 2025-12-08T06:54:44Z Original head: carverauto/serviceradar:chore/fix_1_0_54_rel Original base: main Original merged: 2025-11-20T04:47:37Z by @mfreeman451 --- ### **User description** ## IMPORTANT: Please sign the Developer Certificate of Origin Thank you for your contribution to ServiceRadar. Please note, when contributing, the developer must include a [DCO sign-off statement]( https://developercertificate.org/) indicating the DCO acceptance in one commit message. Here is an example DCO Signed-off-by line in a commit message: ``` Signed-off-by: J. Doe <j.doe@domain.com> ``` ## Describe your changes ## Issue ticket number and link ## Code checklist before requesting a review - [ ] I have signed the DCO? - [ ] The build completes without errors? - [ ] All tests are passing when running make test? ___ ### **PR Type** Bug fix, Enhancement ___ ### **Description** - Add C compiler detection and installation logic to Kong build script - Automatically resolve missing gcc/clang by checking environment and installing build-essential - Ensure CC environment variable is properly set before Kong compilation - Call new ensure_cc function in main build pipeline ___ ### Diagram Walkthrough ```mermaid flowchart LR main["main function"] -- "calls" --> ensure_cc["ensure_cc function"] ensure_cc -- "checks" --> cc_env["CC environment variable"] ensure_cc -- "searches" --> gcc["gcc/clang availability"] ensure_cc -- "installs" --> build_essential["build-essential package"] ensure_cc -- "exports" --> cc_var["CC variable"] ``` <details> <summary><h3> File Walkthrough</h3></summary> <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Bug fix</strong></td><td><table> <tr> <td> <details> <summary><strong>build-kong-vendor.sh</strong><dd><code>Add C compiler detection and auto-installation logic</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> scripts/build-kong-vendor.sh <ul><li>Added new <code>ensure_cc()</code> function to detect and configure C compiler<br> <li> Function checks CC environment variable, searches for gcc/clang, and <br>auto-installs build-essential if needed<br> <li> Supports both sudo and non-sudo installation paths for flexibility<br> <li> Integrated <code>ensure_cc</code> call into main build pipeline after <code>ensure_clone</code></ul> </details> </td> <td><a href="https://github.com/carverauto/serviceradar/pull/1965/files#diff-60c9831d4f024788268c9fa56e16e212061b7b55939899f04579d8445036df24">+41/-0</a>&nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> </details> ___
qodo-code-review[bot] commented 2025-11-20 04:47:37 +00:00 (Migrated from github.com)
Author
Owner

Imported GitHub PR comment.

Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/1965#issuecomment-3555771129
Original created: 2025-11-20T04:47:37Z

PR Compliance Guide 🔍

(Compliance updated until commit github.com/carverauto/serviceradar@803b06a893)

Below is a summary of compliance checks for this PR:

Security Compliance
Insecure package install

Description: Unconditional package installation with apt-get (including sudo) based solely on PATH
checks can be abused if PATH is compromised or if running in an unintended environment;
restrict PATH, use absolute paths (/usr/bin/apt-get, /usr/bin/sudo), and validate
non-interactive, trusted environment before installing packages.
build-kong-vendor.sh [79-87]

Referred Code
if command -v apt-get >/dev/null 2>&1; then
  info "Installing gcc via apt-get (build-essential)" >&2
  if command -v sudo >/dev/null 2>&1; then
    sudo apt-get update -y >/dev/null
    sudo apt-get install -y build-essential >/dev/null
  else
    apt-get update -y >/dev/null
    apt-get install -y build-essential >/dev/null
  fi
Untrusted compiler path

Description: Trusting CC environment variable or first gcc/clang found on PATH without validation may
allow use of a malicious compiler if PATH or CC is attacker-influenced; consider
whitelisting known locations, checking file ownership/permissions, or hashing binaries.
build-kong-vendor.sh [60-76]

Referred Code
if command -v "${CC:-}" >/dev/null 2>&1; then
  info "Using C compiler from CC=${CC}" >&2
  return
fi

if command -v gcc >/dev/null 2>&1; then
  CC="$(command -v gcc)"
  export CC
  info "Using gcc at ${CC}" >&2
  return
fi

if command -v clang >/dev/null 2>&1; then
  CC="$(command -v clang)"
  export CC
  info "Using clang at ${CC}" >&2
  return
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
Missing audit logs: Newly added compiler detection/installation steps perform critical system actions (package
installation) without emitting structured audit logs tying actions to a user or including
outcome details.

Referred Code
if command -v apt-get >/dev/null 2>&1; then
  info "Installing gcc via apt-get (build-essential)" >&2
  if command -v sudo >/dev/null 2>&1; then
    sudo apt-get update -y >/dev/null
    sudo apt-get install -y build-essential >/dev/null
  else
    apt-get update -y >/dev/null
    apt-get install -y build-essential >/dev/null
  fi
  if command -v gcc >/dev/null 2>&1; then
    CC="$(command -v gcc)"
    export CC
    return
  fi
fi

echo "[kong] No C compiler found (gcc/clang). Install one or set CC before running this script." >&2
exit 1

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Limited error context: The failure path prints a generic message and exits without capturing command failures
(e.g., apt-get install failing) or logging actionable context like return codes.

Referred Code
echo "[kong] No C compiler found (gcc/clang). Install one or set CC before running this script." >&2
exit 1

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status:
Package install risk: Auto-installing build-essential via apt-get without verification or user confirmation may
introduce supply-chain risks and lacks validation of environment and package integrity.

Referred Code
if command -v apt-get >/dev/null 2>&1; then
  info "Installing gcc via apt-get (build-essential)" >&2
  if command -v sudo >/dev/null 2>&1; then
    sudo apt-get update -y >/dev/null
    sudo apt-get install -y build-essential >/dev/null
  else
    apt-get update -y >/dev/null
    apt-get install -y build-essential >/dev/null
  fi

Learn more about managing compliance generic rules or creating your own custom rules

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
- Requires Further Human Verification
🏷️ - Compliance label

Previous compliance checks

Compliance check up to commit 803b06a
Security Compliance
Unverified package install

Description: Installing packages non-interactively via apt-get without verifying sources or pinning
versions could be abused in compromised environments (e.g., poisoned mirrors or tampered
PATH/sudo), leading to supply-chain risk; consider validating environment, using trusted
repos, and minimizing privilege usage.
build-kong-vendor.sh [79-87]

Referred Code
if command -v apt-get >/dev/null 2>&1; then
  info "Installing gcc via apt-get (build-essential)" >&2
  if command -v sudo >/dev/null 2>&1; then
    sudo apt-get update -y >/dev/null
    sudo apt-get install -y build-essential >/dev/null
  else
    apt-get update -y >/dev/null
    apt-get install -y build-essential >/dev/null
  fi
PATH hijack risk

Description: Trusting CC from the environment or first gcc/clang found in PATH without validation can
allow PATH hijacking to execute a malicious compiler binary; validate that CC resolves to
an expected absolute path and resides in trusted directories.
build-kong-vendor.sh [60-76]

Referred Code
if command -v "${CC:-}" >/dev/null 2>&1; then
  info "Using C compiler from CC=${CC}" >&2
  return
fi

if command -v gcc >/dev/null 2>&1; then
  CC="$(command -v gcc)"
  export CC
  info "Using gcc at ${CC}" >&2
  return
fi

if command -v clang >/dev/null 2>&1; then
  CC="$(command -v clang)"
  export CC
  info "Using clang at ${CC}" >&2
  return
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
No auditing: The new compiler detection/installation flow performs system actions (package
installation) without emitting structured audit logs capturing user, timestamp, action,
and outcome.

Referred Code
if command -v apt-get >/dev/null 2>&1; then
  info "Installing gcc via apt-get (build-essential)" >&2
  if command -v sudo >/dev/null 2>&1; then
    sudo apt-get update -y >/dev/null
    sudo apt-get install -y build-essential >/dev/null
  else
    apt-get update -y >/dev/null
    apt-get install -y build-essential >/dev/null
  fi
  if command -v gcc >/dev/null 2>&1; then
    CC="$(command -v gcc)"
    export CC
    return
  fi
fi

echo "[kong] No C compiler found (gcc/clang). Install one or set CC before running this script." >&2
exit 1

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Limited errors: Failure to install or detect a compiler results in a generic exit without capturing
actionable context (e.g., which step failed, apt-get exit code) for debugging.

Referred Code
if command -v apt-get >/dev/null 2>&1; then
  info "Installing gcc via apt-get (build-essential)" >&2
  if command -v sudo >/dev/null 2>&1; then
    sudo apt-get update -y >/dev/null
    sudo apt-get install -y build-essential >/dev/null
  else
    apt-get update -y >/dev/null
    apt-get install -y build-essential >/dev/null
  fi
  if command -v gcc >/dev/null 2>&1; then
    CC="$(command -v gcc)"
    export CC
    return
  fi
fi

echo "[kong] No C compiler found (gcc/clang). Install one or set CC before running this script." >&2
exit 1

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status:
Unstructured logs: Newly added informational messages are plain text written to stderr and not structured,
which may hinder auditing and log parsing.

Referred Code
if command -v "${CC:-}" >/dev/null 2>&1; then
  info "Using C compiler from CC=${CC}" >&2
  return
fi

if command -v gcc >/dev/null 2>&1; then
  CC="$(command -v gcc)"
  export CC
  info "Using gcc at ${CC}" >&2
  return
fi

if command -v clang >/dev/null 2>&1; then
  CC="$(command -v clang)"
  export CC
  info "Using clang at ${CC}" >&2
  return

Learn more about managing compliance generic rules or creating your own custom rules

Imported GitHub PR comment. Original author: @qodo-code-review[bot] Original URL: https://github.com/carverauto/serviceradar/pull/1965#issuecomment-3555771129 Original created: 2025-11-20T04:47:37Z --- ## PR Compliance Guide 🔍 <!-- https://github.com/carverauto/serviceradar/commit/803b06a8934725a830273aabcef6d97e24526aab --> #### (Compliance updated until commit https://github.com/carverauto/serviceradar/commit/803b06a8934725a830273aabcef6d97e24526aab) Below is a summary of compliance checks for this PR:<br> <table><tbody><tr><td colspan='2'><strong>Security Compliance</strong></td></tr> <tr><td rowspan=2>⚪</td> <td><details><summary><strong>Insecure package install </strong></summary><br> <b>Description:</b> Unconditional package installation with apt-get (including sudo) based solely on PATH <br>checks can be abused if PATH is compromised or if running in an unintended environment; <br>restrict PATH, use absolute paths (/usr/bin/apt-get, /usr/bin/sudo), and validate <br>non-interactive, trusted environment before installing packages.<br> <strong><a href='https://github.com/carverauto/serviceradar/pull/1965/files#diff-60c9831d4f024788268c9fa56e16e212061b7b55939899f04579d8445036df24R79-R87'>build-kong-vendor.sh [79-87]</a></strong><br> <details open><summary>Referred Code</summary> ```shell if command -v apt-get >/dev/null 2>&1; then info "Installing gcc via apt-get (build-essential)" >&2 if command -v sudo >/dev/null 2>&1; then sudo apt-get update -y >/dev/null sudo apt-get install -y build-essential >/dev/null else apt-get update -y >/dev/null apt-get install -y build-essential >/dev/null fi ``` </details></details></td></tr> <tr><td><details><summary><strong>Untrusted compiler path </strong></summary><br> <b>Description:</b> Trusting CC environment variable or first gcc/clang found on PATH without validation may <br>allow use of a malicious compiler if PATH or CC is attacker-influenced; consider <br>whitelisting known locations, checking file ownership/permissions, or hashing binaries.<br> <strong><a href='https://github.com/carverauto/serviceradar/pull/1965/files#diff-60c9831d4f024788268c9fa56e16e212061b7b55939899f04579d8445036df24R60-R76'>build-kong-vendor.sh [60-76]</a></strong><br> <details open><summary>Referred Code</summary> ```shell if command -v "${CC:-}" >/dev/null 2>&1; then info "Using C compiler from CC=${CC}" >&2 return fi if command -v gcc >/dev/null 2>&1; then CC="$(command -v gcc)" export CC info "Using gcc at ${CC}" >&2 return fi if command -v clang >/dev/null 2>&1; then CC="$(command -v clang)" export CC info "Using clang at ${CC}" >&2 return ``` </details></details></td></tr> <tr><td colspan='2'><strong>Ticket Compliance</strong></td></tr> <tr><td>⚪</td><td><details><summary>🎫 <strong>No ticket provided </strong></summary> - [ ] Create ticket/issue <!-- /create_ticket --create_ticket=true --> </details></td></tr> <tr><td colspan='2'><strong>Codebase Duplication Compliance</strong></td></tr> <tr><td>⚪</td><td><details><summary><strong>Codebase context is not defined </strong></summary> Follow the <a href='https://qodo-merge-docs.qodo.ai/core-abilities/rag_context_enrichment/'>guide</a> to enable codebase context checks. </details></td></tr> <tr><td colspan='2'><strong>Custom Compliance</strong></td></tr> <tr><td rowspan=3>🟢</td><td> <details><summary><strong>Generic: Meaningful Naming and Self-Documenting Code</strong></summary><br> **Objective:** Ensure all identifiers clearly express their purpose and intent, making code <br>self-documenting<br> **Status:** Passed<br> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td> <details><summary><strong>Generic: Secure Error Handling</strong></summary><br> **Objective:** To prevent the leakage of sensitive system information through error messages while <br>providing sufficient detail for internal debugging.<br> **Status:** Passed<br> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td> <details><summary><strong>Generic: Secure Logging Practices</strong></summary><br> **Objective:** To ensure logs are useful for debugging and auditing without exposing sensitive <br>information like PII, PHI, or cardholder data.<br> **Status:** Passed<br> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td rowspan=3>⚪</td> <td><details> <summary><strong>Generic: Comprehensive Audit Trails</strong></summary><br> **Objective:** To create a detailed and reliable record of critical system actions for security analysis <br>and compliance.<br> **Status:** <br><a href='https://github.com/carverauto/serviceradar/pull/1965/files#diff-60c9831d4f024788268c9fa56e16e212061b7b55939899f04579d8445036df24R79-R96'><strong>Missing audit logs</strong></a>: Newly added compiler detection/installation steps perform critical system actions (package <br>installation) without emitting structured audit logs tying actions to a user or including <br>outcome details.<br> <details open><summary>Referred Code</summary> ```shell if command -v apt-get >/dev/null 2>&1; then info "Installing gcc via apt-get (build-essential)" >&2 if command -v sudo >/dev/null 2>&1; then sudo apt-get update -y >/dev/null sudo apt-get install -y build-essential >/dev/null else apt-get update -y >/dev/null apt-get install -y build-essential >/dev/null fi if command -v gcc >/dev/null 2>&1; then CC="$(command -v gcc)" export CC return fi fi echo "[kong] No C compiler found (gcc/clang). Install one or set CC before running this script." >&2 exit 1 ``` </details> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td><details> <summary><strong>Generic: Robust Error Handling and Edge Case Management</strong></summary><br> **Objective:** Ensure comprehensive error handling that provides meaningful context and graceful <br>degradation<br> **Status:** <br><a href='https://github.com/carverauto/serviceradar/pull/1965/files#diff-60c9831d4f024788268c9fa56e16e212061b7b55939899f04579d8445036df24R95-R96'><strong>Limited error context</strong></a>: The failure path prints a generic message and exits without capturing command failures <br>(e.g., apt-get install failing) or logging actionable context like return codes.<br> <details open><summary>Referred Code</summary> ```shell echo "[kong] No C compiler found (gcc/clang). Install one or set CC before running this script." >&2 exit 1 ``` </details> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td><details> <summary><strong>Generic: Security-First Input Validation and Data Handling</strong></summary><br> **Objective:** Ensure all data inputs are validated, sanitized, and handled securely to prevent <br>vulnerabilities<br> **Status:** <br><a href='https://github.com/carverauto/serviceradar/pull/1965/files#diff-60c9831d4f024788268c9fa56e16e212061b7b55939899f04579d8445036df24R79-R87'><strong>Package install risk</strong></a>: Auto-installing build-essential via apt-get without verification or user confirmation may <br>introduce supply-chain risks and lacks validation of environment and package integrity.<br> <details open><summary>Referred Code</summary> ```shell if command -v apt-get >/dev/null 2>&1; then info "Installing gcc via apt-get (build-essential)" >&2 if command -v sudo >/dev/null 2>&1; then sudo apt-get update -y >/dev/null sudo apt-get install -y build-essential >/dev/null else apt-get update -y >/dev/null apt-get install -y build-essential >/dev/null fi ``` </details> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td align="center" colspan="2"> <!-- placeholder --> <!-- /compliance --update_compliance=true --> </td></tr></tbody></table> <details><summary>Compliance status legend</summary> 🟢 - Fully Compliant<br> 🟡 - Partial Compliant<br> 🔴 - Not Compliant<br> ⚪ - Requires Further Human Verification<br> 🏷️ - Compliance label<br> </details> ___ #### Previous compliance checks <details> <summary>Compliance check up to commit <a href='https://github.com/carverauto/serviceradar/commit/803b06a8934725a830273aabcef6d97e24526aab'>803b06a</a></summary><br> <table><tbody><tr><td colspan='2'><strong>Security Compliance</strong></td></tr> <tr><td rowspan=2>⚪</td> <td><details><summary><strong>Unverified package install </strong></summary><br> <b>Description:</b> Installing packages non-interactively via apt-get without verifying sources or pinning <br>versions could be abused in compromised environments (e.g., poisoned mirrors or tampered <br>PATH/sudo), leading to supply-chain risk; consider validating environment, using trusted <br>repos, and minimizing privilege usage.<br> <strong><a href='https://github.com/carverauto/serviceradar/pull/1965/files#diff-60c9831d4f024788268c9fa56e16e212061b7b55939899f04579d8445036df24R79-R87'>build-kong-vendor.sh [79-87]</a></strong><br> <details open><summary>Referred Code</summary> ```shell if command -v apt-get >/dev/null 2>&1; then info "Installing gcc via apt-get (build-essential)" >&2 if command -v sudo >/dev/null 2>&1; then sudo apt-get update -y >/dev/null sudo apt-get install -y build-essential >/dev/null else apt-get update -y >/dev/null apt-get install -y build-essential >/dev/null fi ``` </details></details></td></tr> <tr><td><details><summary><strong>PATH hijack risk </strong></summary><br> <b>Description:</b> Trusting CC from the environment or first gcc/clang found in PATH without validation can <br>allow PATH hijacking to execute a malicious compiler binary; validate that CC resolves to <br>an expected absolute path and resides in trusted directories.<br> <strong><a href='https://github.com/carverauto/serviceradar/pull/1965/files#diff-60c9831d4f024788268c9fa56e16e212061b7b55939899f04579d8445036df24R60-R76'>build-kong-vendor.sh [60-76]</a></strong><br> <details open><summary>Referred Code</summary> ```shell if command -v "${CC:-}" >/dev/null 2>&1; then info "Using C compiler from CC=${CC}" >&2 return fi if command -v gcc >/dev/null 2>&1; then CC="$(command -v gcc)" export CC info "Using gcc at ${CC}" >&2 return fi if command -v clang >/dev/null 2>&1; then CC="$(command -v clang)" export CC info "Using clang at ${CC}" >&2 return ``` </details></details></td></tr> <tr><td colspan='2'><strong>Ticket Compliance</strong></td></tr> <tr><td>⚪</td><td><details><summary>🎫 <strong>No ticket provided </strong></summary> - [ ] Create ticket/issue <!-- /create_ticket --create_ticket=true --> </details></td></tr> <tr><td colspan='2'><strong>Codebase Duplication Compliance</strong></td></tr> <tr><td>⚪</td><td><details><summary><strong>Codebase context is not defined </strong></summary> Follow the <a href='https://qodo-merge-docs.qodo.ai/core-abilities/rag_context_enrichment/'>guide</a> to enable codebase context checks. </details></td></tr> <tr><td colspan='2'><strong>Custom Compliance</strong></td></tr> <tr><td rowspan=3>🟢</td><td> <details><summary><strong>Generic: Meaningful Naming and Self-Documenting Code</strong></summary><br> **Objective:** Ensure all identifiers clearly express their purpose and intent, making code <br>self-documenting<br> **Status:** Passed<br> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td> <details><summary><strong>Generic: Secure Error Handling</strong></summary><br> **Objective:** To prevent the leakage of sensitive system information through error messages while <br>providing sufficient detail for internal debugging.<br> **Status:** Passed<br> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td> <details><summary><strong>Generic: Security-First Input Validation and Data Handling</strong></summary><br> **Objective:** Ensure all data inputs are validated, sanitized, and handled securely to prevent <br>vulnerabilities<br> **Status:** Passed<br> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td rowspan=3>⚪</td> <td><details> <summary><strong>Generic: Comprehensive Audit Trails</strong></summary><br> **Objective:** To create a detailed and reliable record of critical system actions for security analysis <br>and compliance.<br> **Status:** <br><a href='https://github.com/carverauto/serviceradar/pull/1965/files#diff-60c9831d4f024788268c9fa56e16e212061b7b55939899f04579d8445036df24R79-R96'><strong>No auditing</strong></a>: The new compiler detection/installation flow performs system actions (package <br>installation) without emitting structured audit logs capturing user, timestamp, action, <br>and outcome.<br> <details open><summary>Referred Code</summary> ```shell if command -v apt-get >/dev/null 2>&1; then info "Installing gcc via apt-get (build-essential)" >&2 if command -v sudo >/dev/null 2>&1; then sudo apt-get update -y >/dev/null sudo apt-get install -y build-essential >/dev/null else apt-get update -y >/dev/null apt-get install -y build-essential >/dev/null fi if command -v gcc >/dev/null 2>&1; then CC="$(command -v gcc)" export CC return fi fi echo "[kong] No C compiler found (gcc/clang). Install one or set CC before running this script." >&2 exit 1 ``` </details> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td><details> <summary><strong>Generic: Robust Error Handling and Edge Case Management</strong></summary><br> **Objective:** Ensure comprehensive error handling that provides meaningful context and graceful <br>degradation<br> **Status:** <br><a href='https://github.com/carverauto/serviceradar/pull/1965/files#diff-60c9831d4f024788268c9fa56e16e212061b7b55939899f04579d8445036df24R79-R96'><strong>Limited errors</strong></a>: Failure to install or detect a compiler results in a generic exit without capturing <br>actionable context (e.g., which step failed, apt-get exit code) for debugging.<br> <details open><summary>Referred Code</summary> ```shell if command -v apt-get >/dev/null 2>&1; then info "Installing gcc via apt-get (build-essential)" >&2 if command -v sudo >/dev/null 2>&1; then sudo apt-get update -y >/dev/null sudo apt-get install -y build-essential >/dev/null else apt-get update -y >/dev/null apt-get install -y build-essential >/dev/null fi if command -v gcc >/dev/null 2>&1; then CC="$(command -v gcc)" export CC return fi fi echo "[kong] No C compiler found (gcc/clang). Install one or set CC before running this script." >&2 exit 1 ``` </details> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td><details> <summary><strong>Generic: Secure Logging Practices</strong></summary><br> **Objective:** To ensure logs are useful for debugging and auditing without exposing sensitive <br>information like PII, PHI, or cardholder data.<br> **Status:** <br><a href='https://github.com/carverauto/serviceradar/pull/1965/files#diff-60c9831d4f024788268c9fa56e16e212061b7b55939899f04579d8445036df24R60-R76'><strong>Unstructured logs</strong></a>: Newly added informational messages are plain text written to stderr and not structured, <br>which may hinder auditing and log parsing.<br> <details open><summary>Referred Code</summary> ```shell if command -v "${CC:-}" >/dev/null 2>&1; then info "Using C compiler from CC=${CC}" >&2 return fi if command -v gcc >/dev/null 2>&1; then CC="$(command -v gcc)" export CC info "Using gcc at ${CC}" >&2 return fi if command -v clang >/dev/null 2>&1; then CC="$(command -v clang)" export CC info "Using clang at ${CC}" >&2 return ``` </details> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td align="center" colspan="2"> <!-- placeholder --> <!-- /compliance --update_compliance=true --> </td></tr></tbody></table> </details>
qodo-code-review[bot] commented 2025-11-20 04:48:30 +00:00 (Migrated from github.com)
Author
Owner

Imported GitHub PR comment.

Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/1965#issuecomment-3555772824
Original created: 2025-11-20T04:48:30Z

PR Code Suggestions

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
High-level
Avoid automatic system package installation

The build script should not automatically install system packages like
build-essential. Instead, it should verify dependencies and fail with a clear
error message if they are missing, leaving installation to the user or a
provisioning system.

Examples:

scripts/build-kong-vendor.sh [79-93]
  if command -v apt-get >/dev/null 2>&1; then
    info "Installing gcc via apt-get (build-essential)" >&2
    if command -v sudo >/dev/null 2>&1; then
      sudo apt-get update -y >/dev/null
      sudo apt-get install -y build-essential >/dev/null
    else
      apt-get update -y >/dev/null
      apt-get install -y build-essential >/dev/null
    fi
    if command -v gcc >/dev/null 2>&1; then

 ... (clipped 5 lines)

Solution Walkthrough:

Before:

function ensure_cc() {
  if compiler is configured or found; then
    return
  fi

  # Attempt to automatically install compiler
  if apt-get is found; then
    info "Installing gcc via apt-get..."
    if sudo is available; then
      sudo apt-get install -y build-essential
    else
      apt-get install -y build-essential
    fi
    # Re-check for compiler
    ...
    return
  fi

  echo "No C compiler found"
  exit 1
}

After:

function ensure_cc() {
  if compiler is configured or found; then
    return
  fi

  # Fail with a clear error message instead of installing
  echo "[kong] No C compiler found (gcc/clang)."
  echo "Please install build-essential or set CC before running this script."
  exit 1
}

Suggestion importance[1-10]: 9

__

Why: This suggestion correctly identifies a major design flaw, as build scripts should not have side effects like installing system packages, which harms portability and violates the principle of separation of concerns.

High
Possible issue
Improve package installation error handling

Refactor the build-essential installation logic to improve error handling by
removing command duplication, checking for sudo or root privileges, and
validating the exit status of apt-get to provide clearer error messages on
failure.

scripts/build-kong-vendor.sh [81-87]

+local SUDO_CMD=""
 if command -v sudo >/dev/null 2>&1; then
-  sudo apt-get update -y >/dev/null
-  sudo apt-get install -y build-essential >/dev/null
-else
-  apt-get update -y >/dev/null
-  apt-get install -y build-essential >/dev/null
+  SUDO_CMD="sudo"
+elif [[ "$(id -u)" -ne 0 ]]; then
+  echo "[kong] 'sudo' not found and not running as root. Cannot install build-essential." >&2
+  # The script will then proceed to the final error message.
+  return 1
 fi
 
+if ! ${SUDO_CMD} apt-get update -y || ! ${SUDO_CMD} apt-get install -y build-essential; then
+  echo "[kong] Failed to install build-essential. Please install it manually and re-run the script." >&2
+  exit 1
+fi
+
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies that redirecting apt-get output to /dev/null hides installation errors and proposes a robust solution that checks for sudo or root privileges and validates the command's exit status, significantly improving error handling and user feedback.

Medium
  • More
Imported GitHub PR comment. Original author: @qodo-code-review[bot] Original URL: https://github.com/carverauto/serviceradar/pull/1965#issuecomment-3555772824 Original created: 2025-11-20T04:48:30Z --- ## PR Code Suggestions ✨ <!-- 803b06a --> Explore these optional code suggestions: <table><thead><tr><td><strong>Category</strong></td><td align=left><strong>Suggestion&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </strong></td><td align=center><strong>Impact</strong></td></tr><tbody><tr><td rowspan=1>High-level</td> <td> <details><summary>Avoid automatic system package installation</summary> ___ **The build script should not automatically install system packages like <br><code>build-essential</code>. Instead, it should verify dependencies and fail with a clear <br>error message if they are missing, leaving installation to the user or a <br>provisioning system.** ### Examples: <details> <summary> <a href="https://github.com/carverauto/serviceradar/pull/1965/files#diff-60c9831d4f024788268c9fa56e16e212061b7b55939899f04579d8445036df24R79-R93">scripts/build-kong-vendor.sh [79-93]</a> </summary> ```bash if command -v apt-get >/dev/null 2>&1; then info "Installing gcc via apt-get (build-essential)" >&2 if command -v sudo >/dev/null 2>&1; then sudo apt-get update -y >/dev/null sudo apt-get install -y build-essential >/dev/null else apt-get update -y >/dev/null apt-get install -y build-essential >/dev/null fi if command -v gcc >/dev/null 2>&1; then ... (clipped 5 lines) ``` </details> ### Solution Walkthrough: #### Before: ```bash function ensure_cc() { if compiler is configured or found; then return fi # Attempt to automatically install compiler if apt-get is found; then info "Installing gcc via apt-get..." if sudo is available; then sudo apt-get install -y build-essential else apt-get install -y build-essential fi # Re-check for compiler ... return fi echo "No C compiler found" exit 1 } ``` #### After: ```bash function ensure_cc() { if compiler is configured or found; then return fi # Fail with a clear error message instead of installing echo "[kong] No C compiler found (gcc/clang)." echo "Please install build-essential or set CC before running this script." exit 1 } ``` <details><summary>Suggestion importance[1-10]: 9</summary> __ Why: This suggestion correctly identifies a major design flaw, as build scripts should not have side effects like installing system packages, which harms portability and violates the principle of separation of concerns. </details></details></td><td align=center>High </td></tr><tr><td rowspan=1>Possible issue</td> <td> <details><summary>Improve package installation error handling</summary> ___ **Refactor the <code>build-essential</code> installation logic to improve error handling by <br>removing command duplication, checking for <code>sudo</code> or root privileges, and <br>validating the exit status of <code>apt-get</code> to provide clearer error messages on <br>failure.** [scripts/build-kong-vendor.sh [81-87]](https://github.com/carverauto/serviceradar/pull/1965/files#diff-60c9831d4f024788268c9fa56e16e212061b7b55939899f04579d8445036df24R81-R87) ```diff +local SUDO_CMD="" if command -v sudo >/dev/null 2>&1; then - sudo apt-get update -y >/dev/null - sudo apt-get install -y build-essential >/dev/null -else - apt-get update -y >/dev/null - apt-get install -y build-essential >/dev/null + SUDO_CMD="sudo" +elif [[ "$(id -u)" -ne 0 ]]; then + echo "[kong] 'sudo' not found and not running as root. Cannot install build-essential." >&2 + # The script will then proceed to the final error message. + return 1 fi +if ! ${SUDO_CMD} apt-get update -y || ! ${SUDO_CMD} apt-get install -y build-essential; then + echo "[kong] Failed to install build-essential. Please install it manually and re-run the script." >&2 + exit 1 +fi + ``` - [ ] **Apply / Chat** <!-- /improve --apply_suggestion=1 --> <details><summary>Suggestion importance[1-10]: 8</summary> __ Why: The suggestion correctly identifies that redirecting `apt-get` output to `/dev/null` hides installation errors and proposes a robust solution that checks for `sudo` or root privileges and validates the command's exit status, significantly improving error handling and user feedback. </details></details></td><td align=center>Medium </td></tr> <tr><td align="center" colspan="2"> - [ ] More <!-- /improve --more_suggestions=true --> </td><td></td></tr></tbody></table>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
carverauto/serviceradar!2433
No description provided.