Conversation
Add the existing Rust implementation, manifests, documentation, and test fixtures verbatim so the later build integration remains separately reviewable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a dedicated crate-universe vendoring target and update script for the build-mode-none extractor. Expose its Cargo manifests to Bazel and keep the standalone Cargo workspace separate from the repository-wide workspace. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Check in the Bazel crate-universe output produced by update_cpp_bmn_deps.sh so the build-mode-none extractor can consume its pinned Cargo dependencies without regenerating them during builds. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a public Bazel target for the Rust build-mode-none extractor, expose its generated crate universe through the standalone module, and resolve test resources through Bazel's TEST_SRCDIR runfiles root. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The updated Rust toolchain introduced additional Clippy lints. This fixes the lints.
Run Cargo and Bazel checks when the build-mode-none extractor changes, integrate its Rust lint into pre-commit, and document the standalone development workflow. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Extraction failure propagation, overlay invalidation, source discovery, and dependency-installation issues can produce incomplete or misleading extraction results.
Review effort: Balanced
Findings: 2
Open (5)
Report extraction failure when commands cannot launch or succeed · New Handle deleted headers when computing overlay dependency changes · New Deduplicate package installation attempts before invoking installer · New Allow whitespace between # and include in preprocessing directives · New Recognize uppercase C and C++ source file extensions · New
What changed in this PR
Moves the C/C++ build-mode-none Rust extractor into the public CodeQL repository and integrates it with existing build, test, lint, and CI infrastructure.
Changes:
- Imports the extractor, unit tests, fixtures, and developer documentation.
- Adds Cargo and Bazel targets with a dedicated generated Rust dependency universe.
- Adds CI and repository-wide lint/dependency-update integration.
| File | Description |
|---|---|
.github/workflows/cpp-bmn.yml |
Adds Cargo and Bazel CI. |
.pre-commit-config.yaml |
Registers BMN linting. |
MODULE.bazel |
Registers BMN Rust repositories. |
lint |
Runs the BMN linter. |
cpp/extractor/bmn/.gitignore |
Ignores Cargo artifacts. |
cpp/extractor/bmn/BUILD.bazel |
Defines binary and test targets. |
cpp/extractor/bmn/Cargo.lock |
Locks Rust dependencies. |
cpp/extractor/bmn/Cargo.toml |
Defines the Rust package. |
cpp/extractor/bmn/FILE_FILTERING.md |
Documents file filtering. |
cpp/extractor/bmn/README.md |
Documents development workflows. |
cpp/extractor/bmn/lint |
Runs formatting and Clippy checks. |
cpp/extractor/bmn/src/compiler.rs |
Discovers and represents compilers. |
cpp/extractor/bmn/src/dependency_installation.rs |
Installs inferred packages. |
cpp/extractor/bmn/src/directory_tree.rs |
Models project files. |
cpp/extractor/bmn/src/environment.rs |
Reads extraction environment settings. |
cpp/extractor/bmn/src/extraction_command_runner.rs |
Executes extraction commands. |
cpp/extractor/bmn/src/file_filter.rs |
Implements source filtering. |
cpp/extractor/bmn/src/gnu_compiler_default_include_finder.rs |
Discovers compiler include paths. |
cpp/extractor/bmn/src/include_finder.rs |
Resolves include dependencies. |
cpp/extractor/bmn/src/include_scanner.rs |
Parses include directives. |
cpp/extractor/bmn/src/logger.rs |
Configures logging. |
cpp/extractor/bmn/src/main.rs |
Orchestrates extraction. |
cpp/extractor/bmn/src/overlays.rs |
Selects overlay dependencies. |
cpp/extractor/bmn/src/package_database.rs |
Queries package metadata. |
cpp/extractor/bmn/src/path_utils.rs |
Provides path utilities. |
cpp/extractor/bmn/src/project_definitions.rs |
Discovers project sources. |
cpp/extractor/bmn/src/telemetry.rs |
Emits extraction telemetry. |
cpp/extractor/bmn/src/test_utils.rs |
Provides test helpers. |
cpp/extractor/bmn/src/timing.rs |
Records operation timings. |
cpp/extractor/bmn/tests/resources/** |
Adds 24 extractor test fixtures. |
misc/bazel/3rdparty/BUILD.bazel |
Defines dependency generation. |
misc/bazel/3rdparty/cpp_bmn_deps_extension.bzl |
Exposes generated repositories. |
misc/bazel/3rdparty/cpp_bmn_deps/BUILD.bazel |
Configures crate vendoring. |
misc/bazel/3rdparty/cpp_bmn_deps/alias_rules.bzl |
Defines generated aliases. |
misc/bazel/3rdparty/cpp_bmn_deps/crates.bzl |
Registers vendored crates. |
misc/bazel/3rdparty/cpp_bmn_deps/defs.bzl |
Defines generated dependencies. |
misc/bazel/3rdparty/cpp_bmn_deps/BUILD.*.bazel |
Adds 163 generated crate targets. |
misc/bazel/3rdparty/update_cargo_deps.sh |
Includes BMN dependency updates. |
misc/bazel/3rdparty/update_cpp_bmn_deps.sh |
Regenerates BMN dependencies. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| .attributes(extraction_stats.get_telemetry_value()), | ||
| ); | ||
|
|
||
| Ok(()) |
Comment on lines
+127
to
+130
| let has_changed_header = result | ||
| .resolved_headers | ||
| .iter() | ||
| .any(|header| changed_files.contains(header)); |
Comment on lines
+183
to
+203
| let mut already_installed_packages = HashSet::new(); | ||
|
|
||
| // Try to install packages for each missing include | ||
| let (installed_packages, failed_packages) = inferred_dependencies | ||
| .filter_map(|package_name| { | ||
| (!already_installed_packages.contains(&package_name)).then(|| { | ||
| let result = package_installer.install_package(&package_name); | ||
| if let Err(ref e) = result { | ||
| info!("Package {package_name:?} was not installed due to error {e:?}."); | ||
| Err(InstallationFailure { | ||
| package_name, | ||
| installation_error: e.to_string(), | ||
| }) | ||
| } else { | ||
| debug!("Installed package {package_name:?}."); | ||
| already_installed_packages.insert(package_name.clone()); | ||
| Ok(package_name) | ||
| } | ||
| }) | ||
| }) | ||
| .partition_result(); |
Comment on lines
+7
to
+12
| static SYSTEM_INCLUDE_RE: LazyLock<Regex> = LazyLock::new(|| { | ||
| Regex::new(r#"^\s*#include\s+<([^">]+)>"#).expect("Failed to compile system include regex") | ||
| }); | ||
| static LOCAL_INCLUDE_RE: LazyLock<Regex> = LazyLock::new(|| { | ||
| Regex::new(r#"^\s*#include\s+"([^">]+)""#).expect("Failed to compile local include regex") | ||
| }); |
Comment on lines
+14
to
+22
| fn get_extension_info(ext: &str) -> Option<(Language, bool)> { | ||
| match ext { | ||
| "c" => Some((Language::C, false)), | ||
| "h" => Some((Language::C, true)), | ||
| "cpp" | "cc" | "cxx" | "c++" => Some((Language::Cpp, false)), | ||
| "hpp" | "hxx" | "hh" | "h++" | "inc" => Some((Language::Cpp, true)), | ||
| _ => None, | ||
| } | ||
| } |
Regenerate the checked-in crate universe with the new cpp_bmn vendor target instead of adapting the former semmle-code output. This includes the generated build-script packages and the root vendor repository required by bazel mod tidy. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 87b09ca6-1af2-45eb-ab29-894f5128e483
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Move the C/C++ build-mode-none Rust extractor into
cpp/extractor/bmnso it can be built, tested, and maintained in the public repository.This PR:
Validation:
A dependent
github/semmle-codePR will switch C++ packaging to this target and remove the migrated implementation.