From 6e445be108b32562e7bd560b93a40a16dbf4d8d2 Mon Sep 17 00:00:00 2001 From: Alexey <247128645+axkurcom@users.noreply.github.com> Date: Thu, 12 Feb 2026 18:58:03 +0300 Subject: [PATCH] CodeQL Tuning --- .../queries/common/ProductionOnly.qll | 20 +++++++++++++++++++ .github/workflows/queries/qlpack.yml | 4 ++++ 2 files changed, 24 insertions(+) create mode 100644 .github/workflows/queries/common/ProductionOnly.qll create mode 100644 .github/workflows/queries/qlpack.yml diff --git a/.github/workflows/queries/common/ProductionOnly.qll b/.github/workflows/queries/common/ProductionOnly.qll new file mode 100644 index 0000000..c51cb3a --- /dev/null +++ b/.github/workflows/queries/common/ProductionOnly.qll @@ -0,0 +1,20 @@ +import rust + +predicate isTestOnly(Item i) { + exists(ConditionalCompilation cc | + cc.getItem() = i and + cc.getCfg().toString() = "test" + ) +} + +predicate hasTestAttribute(Item i) { + exists(Attribute a | + a.getItem() = i and + a.getName() = "test" + ) +} + +predicate isProductionCode(Item i) { + not isTestOnly(i) and + not hasTestAttribute(i) +} diff --git a/.github/workflows/queries/qlpack.yml b/.github/workflows/queries/qlpack.yml new file mode 100644 index 0000000..c9da5ba --- /dev/null +++ b/.github/workflows/queries/qlpack.yml @@ -0,0 +1,4 @@ +name: rust-production-only +version: 0.0.1 +dependencies: + codeql/rust-all: "*"