Skip to content

Exclude vendored dependency trees from CodeQL scan - #60

Open
asonje wants to merge 3 commits into
mainfrom
codeql-exclude-deps
Open

asonje wants to merge 3 commits into
mainfrom
codeql-exclude-deps

Conversation

@asonje

@asonje asonje commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Description

codeql.yml builds PostgreSQL, SVS, and pgvector from source under docs/build_guide/ before tracing this extension's own build, so the C/C++ extractor records every header transitively included during that trace -- including these vendored, untracked dependency trees.

This PR add paths-ignore for all of docs/build_guide/'s build-output subdirectories, so SVS's or pgvector's own vendored headers don't produce the same class of noise later.

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Refactor / code cleanup
  • Documentation update
  • Test addition or update
  • Build / CI change

Pre-Merge Checklist

Build

  • make completes without errors or warnings
  • make install completes successfully

Tests

  • If this PR introduces no new behavior: existing regression tests (make installcheck) and TAP tests (test/t/) pass with no failures
  • If this PR introduces new behavior: test cases covering it were added to test/sql/ and/or test/t/
  • If this PR adds a standalone unit-test module under test/modules/: it builds and passes (make -C test/modules/<module> installcheck)

Documentation

  • Relevant docs under docs/ updated if architecture or usage changed

Testing Notes

codeql.yml builds PostgreSQL, SVS, and pgvector from source under
docs/build_guide/ before tracing this extension's own build, so the
C/C++ extractor records every header transitively included during
that trace -- including these vendored, untracked dependency trees.
Of the 56 open alerts triaged, 7 (cpp/commented-out-code,
cpp/fixme-comment, cpp/irregular-enum-init) sit entirely inside
PostgreSQL core's own headers under pgsql_install/include/server/,
none of which is this project's source.

Add paths-ignore for all of docs/build_guide/'s build-output
subdirectories, not just the one that happened to trigger an alert
this run, so SVS's or pgvector's own vendored headers don't produce
the same class of noise later.

Signed-off-by: Olasoji <olasoji.denloye@intel.com>
@asonje
asonje requested a review from a team October 5, 2026 18:46
asonje added 2 commits October 5, 2026 13:55
GitHub Actions requires step 'with:' values to be scalars (they become
environment variables), so the YAML sequence form failed workflow
validation outright -- 0 jobs ran, and GitHub flagged it as a broken
workflow file on push even though this workflow's own push trigger
doesn't match non-main branches, since GitHub validates every
workflow file present in a pushed commit regardless of whether its
triggers would fire.

codeql-action parses this input by splitting on newlines, so a '|'
block scalar with one path per line is the correct form for a
list-like input passed directly on the init step (as opposed to a
separate codeql-config.yml file, which is parsed by the action's own
code and does support real YAML lists for the same key).

Signed-off-by: Olasoji <olasoji.denloye@intel.com>
paths-ignore is not a recognized input to codeql-action/init at all,
in any form -- confirmed from the actual run log's own warning:
"Unexpected input(s) 'paths-ignore', valid inputs are [... 'config-file',
'config', ...]". The previous commit's fix (converting it to a
multi-line string) only silenced the workflow-schema error that came
from using a YAML sequence directly under 'with:'; the action itself
still ignored the setting entirely and the dependency paths were never
actually excluded.

The real mechanism is 'config' (or a separate codeql-config.yml via
'config-file'): a nested YAML document that codeql-action parses with
its own schema, which does support real lists for paths-ignore. Move
the exclusion there instead.

Signed-off-by: Olasoji <olasoji.denloye@intel.com>

@matt-welch matt-welch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning this up. The directory list is accurate (matches exactly what install_postgres.sh, build_svs.sh, and build_pgvector_vanilla.sh create per docs/build_guide/config), and the config: inline YAML is valid syntax for codeql-action/init.

I got curious about how paths-ignore interacts with our build-mode: manual traced build, since that combination isn't the usual case the CodeQL docs walk through. So I built the dependency stack locally and ran CodeQL CLI 2.27.1 (matching our CI version) through the same init/trace/finalize steps, once with this PR's paths-ignore config and once without, just to see what actually ends up in the database either way.

Both runs came back identical: 485 files, same total size, no difference in the file lists. The headers under docs/build_guide/pgsql_install and docs/build_guide/svs_install (the two vendored dirs the traced build actually touches) show up in both. It looks like paths-ignore doesn't affect extraction when the build is traced like ours is, so this version of the config probably won't change what gets scanned.

Also noticed the other three directories in the list (postgres, ScalableVectorSearch, pgvector-vanilla) didn't show up in either run. The traced build only ever points at the installed output dirs, not the raw source checkouts, so those three wouldn't have mattered either way.

This fix may need to happen on the build/trace side instead of through this config option. Happy to share the local repro if it'd help.

@matt-welch

Copy link
Copy Markdown
Contributor

Quick follow-up on my comment above. I wanted to check this more directly than just comparing extracted file lists, so I ran the actual security-and-quality suite (122 queries) against both reproduction databases, the one with this PR's paths-ignore config and the one without.

Both runs produced the same 56 alerts, matching exactly in rule, file, and line. 7 of those 56 are real findings sitting in vendored PostgreSQL headers under docs/build_guide/pgsql_install, things like cpp/commented-out-code and cpp/fixme-comment. Same 7, same files, same lines, whether paths-ignore was applied or not.

Then I checked that against the real analysis GitHub already has on file for main's current HEAD commit, pulled via the API rather than reproduced locally. It shows the same 56 total results and the same 7 vendored-header alerts, in the same files and lines. So this isn't just my local test agreeing with itself, it matches what's actually in production today.

That's about as direct as this can get: not extracted-file counts, but the actual alerts a reviewer would see, reproduced twice and confirmed against the live repo's own existing scan. There is a real basis for wanting this fix (those 7 alerts in vendored code are genuinely there), but this particular change doesn't clear them. Happy to share the SARIF output if it'd help track down a fix on the build/trace side.

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.

2 participants