Skip to content

v0.32.0

Latest
Compare
Choose a tag to compare
@github-actions github-actions released this 25 Mar 17:34
· 18 commits to main since this release
fe6de2e

This release adds 3 new linter rules to Regal, as well as many improvements and fixes.

New Rule: redundant-loop-count

A loop iterating over empty collections evaluates to nothing, and counting the collection before the loop to ensure it's not empty is therefore redundant. This rule catches cases where this check is not needed. (Read more)

package policy

allow if {
    # redundant count and > comparison
    count(input.user.roles) > 0

    some role in input.user.roles
    # .. do more with role ..
}

PR #1452.

New Rule: import-shadows-rule

This new rule catches cases where users have named rules the same as an import. Imported identifier have higher precedence than rules and this can lead to confusing behaviours. (Read more)

package policy

import data.resources

# 'resources' shadowed by import 
resources contains resource if {
    # ...
}

PR #1450.

Thanks @kroekle for suggesting this rule!

New Rule: time-now-ns-twice

This new rule will catch cases where time.now_ns() is called multiple times within a single rule. This does not work in Rego since both calls will return the same value. This rule catches this case early and directs users to read about more appropriate tools. (Read more)

package policy

timed if {
    now := time.now_ns()
    # do some work here
    # this doesn't work! result is always 0
    print("work done in:", time.now_ns() - now, "ns)
}

PR #1457.

Other Rule Updates

OPA v1.2.0

While this may not seem too exciting, OPA v1.2.0 contains some performance improvements that has quite a substantial impact on Regal. We know, because we made those improvements in OPA largely to speed up Regal's linting! v0.32.0 should be considerably faster than previous versions, which should be noticeable in large policy projects in particular.

Language Server

In the language server, we addressed two bugs relating to the fixing of the idiomatic/directory-package-mismatch rule. See #1427 & #1432.

Dependencies

Go Mod:

GitHub Actions:

See #1453, #1442, #1435, #1426, #1422 and #1423 for PRs making the above updates. golangci-lint v2 update in #1455. OPA 1.2 update in #1429.

New Users

Add yourself to docs/adopters.md to get here next time!

New Contributors

Changelog