glsec

Rules / GL074

GL074 Tautological (always-true) rules:if condition

Severity: warn
OWASP: CICD-SEC-1 – Insufficient Flow Control Mechanisms

What glsec checks

glsec flags rules:if conditions that are provably always true. Such a condition makes the gate it guards a no-op: a job meant to run only under specific circumstances silently runs everywhere — including contexts the author intended to exclude, such as fork merge requests or scheduled pipelines. When the gated job is privileged (a deploy, a release, a job that holds secrets), the ineffective gate is a security problem, not just a logic bug.

Detected, conservatively (only expressions true regardless of any variable value):

Pattern Example
A standalone true OR operand $CI_COMMIT_BRANCH || true, true || $X
A constant comparison of two literals "true" == "true", "a" != "b"
The same variable compared == and != to the same literal across an OR $CI_PIPELINE_SOURCE != "schedule" || $CI_PIPELINE_SOURCE == "schedule"

This complements GL043 (unanchored regex in rules:if) and GL039 (|| true silencing a script command). GL074 targets the gate condition itself being a tautology.

Trigger examples

deploy:
  rules:
    - if: '$CI_COMMIT_BRANCH || true'                                            # standalone true
    - if: '"true" == "true"'                                                     # constant comparison
    - if: '$CI_PIPELINE_SOURCE != "schedule" || $CI_PIPELINE_SOURCE == "schedule"'  # A || !A
  script:
    - ./deploy.sh

Safe alternative

Write a condition that actually restricts when the job runs:

deploy:
  rules:
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
  script:
    - ./deploy.sh

What is not flagged

To keep false positives low, GL074 only reports conditions it can prove are always true. It deliberately does not flag:

References

Documentation for glsec 1.23.0. Source of this page · Rule implementation