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: "*"