Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust: reinstate extraction of test code #18347

Merged
merged 2 commits into from
Dec 21, 2024

Conversation

redsun82
Copy link
Contributor

Users will still be able to opt out:

  • for unit tests, by providing the cargo_cfg_overrides=-test extractor option
  • for integration tests, by excluding the test files from the analysis using paths-ignore in the codescanning configuration file

We may want to revisit whether we want a single option for both. Also further work will be needed to restrict our security queries to non-test code on the QL side.

Users will still be able to opt out:
* for unit tests, by providing the `cargo_cfg_overrides=-test` extractor
  option
* for integration tests, by excluding the test files from the analysis
  using `paths-ignore` in the codescanning configuration file

We may want to revisit whether we want a single option for both. Also
further work will be needed to restrict our security queries to non-test
code on the QL side.
@redsun82 redsun82 requested review from hvitved and Copilot December 20, 2024 13:16
@github-actions github-actions bot added the Rust Pull requests that update Rust code label Dec 20, 2024
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 8 changed files in this pull request and generated 1 comment.

Files not reviewed (3)
  • rust/ql/integration-tests/file-exclusions/source_archive.default.expected: Language not supported
  • rust/ql/integration-tests/options/cfg/functions.expected: Language not supported
  • rust/ql/integration-tests/options/cfg/functions.override.expected: Language not supported
Comments suppressed due to low confidence (2)

rust/extractor/src/config.rs:151

  • Ensure that test coverage includes scenarios where non-disjoint cfg overrides are provided.
let global = CfgDiff::new(enabled_cfgs, disabled_cfgs)

rust/extractor/src/config.rs:20

  • Removing the warn log might lead to a lack of visibility for potential issues. Consider re-adding the warn log for non-disjoint cfg overrides.
use std::collections::HashSet;

Tip: Leave feedback on Copilot's review comments with the 👎 and 👍 buttons to help improve review quality. Learn more

codeql.database.create(extractor_option=f"cargo_cfg_overrides={overrides}")

@pytest.mark.ql_test(expected=".override.expected")
def test_ducplicate_cfg_overrides(codeql, rust):
Copy link
Preview

Copilot AI Dec 20, 2024

Choose a reason for hiding this comment

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

The function name 'test_ducplicate_cfg_overrides' contains a typo. It should be 'test_duplicate_cfg_overrides'.

Suggested change
def test_ducplicate_cfg_overrides(codeql, rust):
@pytest.mark.ql_test(expected=".override.expected")
def test_duplicate_cfg_overrides(codeql, rust):

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@redsun82 redsun82 requested a review from aibaars December 20, 2024 13:23
@redsun82 redsun82 merged commit c95f8d7 into main Dec 21, 2024
13 checks passed
@redsun82 redsun82 deleted the redsun82/rust-include-test-code-again branch December 21, 2024 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants