Updates/bazel fixes 2 #2447
No reviewers
Labels
No labels
1week
2weeks
Failed compliance check
IP cameras
NATS
Possible security concern
Review effort 1/5
Review effort 2/5
Review effort 3/5
Review effort 4/5
Review effort 5/5
UI
aardvark
accessibility
amd64
api
arm64
auth
back-end
bgp
blog
bug
build
checkers
ci-cd
cleanup
cnpg
codex
core
dependencies
device-management
documentation
duplicate
dusk
ebpf
enhancement
eta 1d
eta 1hr
eta 3d
eta 3hr
feature
fieldsurvey
github_actions
go
good first issue
help wanted
invalid
javascript
k8s
log-collector
mapper
mtr
needs-triage
netflow
network-sweep
observability
oracle
otel
plug-in
proton
python
question
reddit
redhat
research
rperf
rperf-checker
rust
sdk
security
serviceradar-agent
serviceradar-agent-gateway
serviceradar-web
serviceradar-web-ng
siem
snmp
sysmon
topology
ubiquiti
wasm
wontfix
zen-engine
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
carverauto/serviceradar!2447
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/2447/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from GitHub pull request.
Original GitHub pull request: #1979
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/1979
Original created: 2025-11-23T09:21:29Z
Original updated: 2025-11-23T09:23:05Z
Original head: carverauto/serviceradar:updates/bazel_fixes_2
Original base: main
Original merged: 2025-11-23T09:21:40Z 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:
Describe your changes
Issue ticket number and link
Code checklist before requesting a review
PR Type
Enhancement
Description
Add cmake_share filegroup to cmake prebuilt archive
Introduce flex, bison, and gperf source dependencies via http_archive
Build flex, bison, gperf from source in age_extension_layer for glibc compatibility
Create BUILD.bazel files for pg_extension_toolchain with source_tree targets
Fix cmake path resolution to handle both relative and absolute paths
Diagram Walkthrough
File Walkthrough
MODULE.bazel
Add toolchain source dependencies to MODULE.bazelMODULE.bazel
cmake_sharefilegroup to cmake_linux_amd64_prebuilt archivegperf_src
sources
BUILD.bazel
Add bison source_tree target via copy_to_directorythird_party/pg_extension_toolchain/bison/BUILD.bazel
BUILD.bazel
Add flex source_tree target via copy_to_directorythird_party/pg_extension_toolchain/flex/BUILD.bazel
BUILD.bazel
Add gperf source_tree target via copy_to_directorythird_party/pg_extension_toolchain/gperf/BUILD.bazel
BUILD.bazel
Build toolchain dependencies from source for age extensiondocker/images/BUILD.bazel
@cmake_linux_amd64_prebuilt//:cmake_shareto cmake toolsdependency
with conditional logic
srcs
with proper environment variables
for age extension build
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/1979#issuecomment-3567667895
Original created: 2025-11-23T09:22:04Z
PR Compliance Guide 🔍
Below is a summary of compliance checks for this PR:
Untrusted build execution
Description: Building and executing third-party autotools configure/make steps at build time without
verification or sandboxing (flex, gperf, bison) risks executing untrusted build scripts on
the build host; although archives are pinned by sha256, the configure scripts and
Makefiles run arbitrary shell which can exfiltrate data or modify outputs unless executed
in a hermetic/sandboxed environment.
BUILD.bazel [1578-1651]
Referred Code
Unsafe library injection
Description: Blindly copying all shared libraries from the locally built flex tree into the install
prefix (cp -a "$${FLEX_ROOT}/lib/." "$${INSTALL_PREFIX}/usr/lib/" || true) may introduce
unintended or conflicting libraries into runtime images, enabling DLL preloading/hijacking
or ABI conflicts if downstream consumers pick up these libraries before system ones.
BUILD.bazel [1660-1662]
Referred Code
Tool path spoofing
Description: The CMake path handling treats any non-absolute path as trustworthy and later chmod +x and
executes it; if Bazel action inputs could be influenced, this could allow path
spoofing—ensure the resolved tool path comes only from the trusted repository and not from
the working directory.
BUILD.bazel [1506-1515]
Referred Code
🎫 No ticket provided
Codebase context is not defined
Follow the guide to enable codebase context checks.
Generic: Meaningful Naming and Self-Documenting Code
Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting
Status: Passed
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
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
Generic: Comprehensive Audit Trails
Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.
Status:
No audit logs: The added build steps for fetching and building toolchain components (flex, bison, gperf)
and packaging layers do not include any logging of critical actions, but as build
infrastructure code this may not require audit trails.
Referred Code
Generic: Robust Error Handling and Edge Case Management
Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation
Status:
Partial error checks: The script uses set -euo pipefail but many build and copy operations (e.g., cp -a, make,
configure) lack explicit error handling or validation of prereqs, which may be acceptable
in Bazel genrule context.
Referred Code
Generic: Security-First Input Validation and Data Handling
Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities
Status:
External sources: The script builds external sources and adjusts environment paths without explicit
verification of inputs beyond Bazel hashes, which may be sufficient under hermetic builds
but not evident from the diff.
Referred Code
Compliance status legend
🟢 - Fully Compliant🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/1979#issuecomment-3567671653
Original created: 2025-11-23T09:23:04Z
PR Code Suggestions ✨
Explore these optional code suggestions:
Use Bazel rules for external dependencies
Instead of building
flex,bison, andgperfinside agenruleshell script, use adedicated Bazel ruleset like
rules_foreign_cc. This will create proper Bazeltargets for these dependencies, improving modularity and enabling better
caching.
Examples:
docker/images/BUILD.bazel [1537-1664]
Solution Walkthrough:
Before:
After:
Suggestion importance[1-10]: 9
__
Why: The suggestion correctly identifies that building three dependencies within a single
genrulescript is a significant Bazel anti-pattern, proposing a more robust, maintainable, and idiomatic solution that improves caching and modularity.Avoid suppressing errors during copy
Remove the
|| trueerror suppression from thecpcommand. Instead, explicitlycheck if the source directory (
$${FLEX_ROOT}/lib) exists and is not empty beforecopying, and fail the build with an error message if it is not.
docker/images/BUILD.bazel [1660-1661]
Suggestion importance[1-10]: 8
__
Why: The suggestion correctly identifies that using
|| truehides potential critical errors, such as missing libraries, which could lead to a broken build artifact. The proposed change adds explicit checks and error handling, making the build process more robust and reliable.Simplify directory cleanup and creation
Simplify directory cleanup by replacing the conditional check and removal with
an unconditional
rm -rf, followed bymkdir -p. This makes the script moreconcise.
docker/images/BUILD.bazel [1578-1585]
Suggestion importance[1-10]: 4
__
Why: The suggestion correctly identifies a shell script pattern that can be simplified, improving code conciseness and readability. The
ifcheck is redundant withrm -rf.