Skip to content

fix(cpp): resolve CodeQL findings and keep scans on first-party sources - #1162

Merged
ColinLeeo merged 2 commits into
apache:developfrom
ColinLeeo:colin/codeql-cpp-cleanup
Nov 30, 2026
Merged

ColinLeeo merged 2 commits into
apache:developfrom
ColinLeeo:colin/codeql-cpp-cleanup

Conversation

@ColinLeeo

Copy link
Copy Markdown
Contributor

What this changes

CodeQL configuration

The C/C++ autobuild unpacks third-party dependencies into cpp/_codeql_build_dir and compiles them during the analysis, and the scheduled quality scan reported about 560 alerts against those sources. The paths-ignore entry named the directory without a glob (cpp/_codeql_build_dir), which does not match a subtree — the configuration was already in place when the very first scan produced the alerts it was meant to prevent.

  • Match the directory with **/_codeql_build_dir/**.
  • Ignore the gitignored cpp/third_party build extracts as well.
  • Move the configuration to .github/codeql/codeql-config.yml and apply it to the security scan too, which had no config-file and therefore analyzed the build directory as well.

C++ findings

All from the CodeQL quality suite.

File Change
cpp/src/common/tsfile_common.h ITimeseriesIndex gets a virtual destructor — it is held and destroyed through the base type via shared_ptr
cpp/src/encoding/ts2diff_decoder.h the constructor calls TS2DIFFDecoder::reset() instead of dispatching to a derived override while the base is still being constructed
cpp/src/reader/qds_with_timegenerator.h SeriesScanStream releases its column iterator from its own destructor instead of relying on the owner to call destroy()
cpp/src/utils/date_utils.h localtime_r/localtime_s with a checked result replaces localtime, which returns a shared buffer and was dereferenced unchecked
cpp/src/common/datatype/date_converter.h removes a dead int32 range check — year is bounded to 1000..9999, so the packed value cannot overflow
cpp/src/writer/tsfile_writer.cc allocates the aligned ValueChunkWriter with std::nothrow so the following null check can actually fail

Verification

  • ./mvnw -P with-cpp verify — BUILD SUCCESS
  • CTest: 1895 passed, 0 failed, 3 skipped (require external fixtures), 10 disabled by design
  • Checkstyle: 0 violations; Spotless (clang-format 17.0.6) check passed

No codec, on-disk format, SDK, or CLI behavior changes, so the skill documentation is unaffected.

Alerts that already exist in cpp/_codeql_build_dir stay open, because CodeQL cannot observe files that are excluded from analysis; they will be dismissed separately.

🤖 Generated with Claude Code

The C/C++ autobuild unpacks third-party dependencies under
cpp/_codeql_build_dir and compiles them as part of the analysis. The quality
scan reported about 560 alerts against those sources. The paths-ignore entry
named the directory without a glob, which does not match a subtree, so the
filter never took effect and the first scheduled run already produced the
alerts it was meant to prevent.

Match the directory with a ** glob, ignore the gitignored cpp/third_party
build extracts as well, and share the configuration with the security scan,
which had no config file and therefore analyzed the build directory too.
- Give ITimeseriesIndex a virtual destructor; it is held through
  shared_ptr<ITimeseriesIndex> and destroyed through the base type.
- Qualify the reset() call in the TS2DIFFDecoder constructor so it does not
  dispatch to a derived override while the base is still being constructed.
- Release SeriesScanStream's column iterator from its destructor instead of
  relying on the owner to call destroy().
- Use localtime_r/localtime_s in DaysSinceEpochToYYYYMMDD. localtime returns
  a shared buffer and its result was dereferenced unchecked.
- Drop the int32 range check in date_to_int: year is bounded to 1000..9999,
  so the packed value cannot overflow.
- Allocate the aligned ValueChunkWriter with std::nothrow so the following
  null check can actually fail instead of being dead code.
@ColinLeeo
ColinLeeo merged commit 7f13d33 into apache:develop Nov 30, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant