Skip to content

Commit

Permalink
adding adjustments for logging level
Browse files Browse the repository at this point in the history
Signed-off-by: Damien Burks <damien@damienjburks.com>

removing space from testcase

Signed-off-by: Damien Burks <damien@damienjburks.com>

website: make local dev and PR preview not build everything (open-policy-agent#4474)

With this change, the work done for local development, and the per-PR netlify preview changes:

It will no longer include the website stuff for versions other than edge, the current working tree.

We thus save us the time, and the flakiness, involved with

- checking if github has release binaries for all the versions
- checking out their sources
- fetching the release binaries to pre-hydrate old versions' live-blocks.

The previously-used, documented make target should still be intact.

Fixes open-policy-agent#4379 to some extent, I hope.

* docs/website: remove "latest" binary from opa versions cache

Having a stale binary here -- one called "latest" but not actually
being "latest" -- causes issues like this: when building the website
content for the (real) latest version, the script would take the
old (previous-latest) binary, and fail because that binary didn't
know the latest future keywords.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

website: fix download link redirect (open-policy-agent#4482)

Fixes the bug introduced in open-policy-agent#4474 causing the setup-opa action to fail
to retrieve the "latest" opa binary.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

build(deps): bump github.com/yashtewari/glob-intersection to v0.1.0 (open-policy-agent#4481)

https://github.com/yashtewari/glob-intersection/releases/tag/v0.1.0

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

docs/website: fix /docs redirect (open-policy-agent#4483)

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

website: fix template to produce proper redirects (open-policy-agent#4484)

Also redirect /docs -> /docs/edge in preview

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

docs/envoy: include new configurable gRPC msg sizes (open-policy-agent#4459)

Docs for open-policy-agent/opa-envoy-plugin#323

Signed-off-by: Elliot Maincourt <e.maincourt@gmail.com>

website/live-blocks: update caniuse/browserlist

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

website/live-blocks: don't call the github api to determine release asset urls

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

website: don't run generate twice (open-policy-agent#4488)

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

ast: Fix print call rewriting in else rules

The compiler was accidentally checking/rewriting print calls in the
body of else rules before the implicit args of the else rule were
processed. As a result, the compiler was generating false-positive
errors for refs to undeclared args. The root of the problem was the
usage of WalkBodies on the top-level rule (which implicitly walks the
bodies of else rules under the top-level rule). With this change, the
compiler will call WalkBodies on the head and body of each rule rather
than the entire rule itself (which includes the else chain).

Fixes open-policy-agent#4489

Signed-off-by: Torin Sandall <torinsandall@gmail.com>

Update maintainer status, add Will Beason (open-policy-agent#4465)

Signed-off-by: Max Smythe <smythe@google.com>

Co-authored-by: Will Beason <willbeason@google.com>

Make maintainers list alphabetical (open-policy-agent#4491)

Signed-off-by: Max Smythe <smythe@google.com>

plugins/logs: Fix broken retry logic

We were incorrectly resetting the retry counter after
every error condition instead of using the incremented
value. As a result, retry delay would always be 0s.
This meant that if OPA encountered an error while
uploading decision logs it would immediately retry
instead of doing an exponential backoff.

Fixes: open-policy-agent#4486

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>

logging: mask authorization header value in debug logs (open-policy-agent#4496)

Fixes open-policy-agent#4495

Signed-off-by: Anders Eknert <anders@eknert.com>

Fixes open-policy-agent#4376 (open-policy-agent#4494)

Do note though that this does not change how multiple
with statements are grouped. Although I agree with that,
it's IMHO a separate feature request, while the spacing
issue is a bug.

Signed-off-by: Anders Eknert <anders@eknert.com>

runtime: improve log output for binary response (open-policy-agent#4498)

This change omits the response body when using compression on metrics endpoint and when pprof is enabled.

Signed-off-by: Christian Altamirano <christian.altamirano.ayala@gmail.com>

build: bump golang: 1.17 -> 1.18

No change to go.mod's `go` stanza, so no changes in code compatibility.

However, it's used for building our docker images and release
binaries, and for fuzz testing in our nightly workflow.

Some test-related changes with the dns lookup built-in function's
error handling; and the hardcoded signature. Running

    go test ./topdown -run TestTopdownJWTEncodeSignECWithSeedReturnsSameSignature -count 10000

makes me believe that for whatever reason the signature changed,
it's at least stable.

topdown/http_test: Test-only change to accomodate this change in Go (https://go.dev/doc/go1.18):

    Certificate.Verify now uses platform APIs to verify certificate
    validity on macOS and iOS when it is called with a nil
    VerifyOpts.Roots or when using the root pool returned from
    SystemCertPool.

We're keeping the old message for go <= 1.17; in a silly-simple way.

Also:

* ci: build and test two old golang version on macos|linux

  We'll drop golang 1.15, keep one unsupported version (1.16).

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

ci: remove go-fuzz, use native go 1.18 fuzzer

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

build(dev-deps): update live-scripts deps: mocha, nanoid (open-policy-agent#4500)

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

build(deps): bump nanoid in /docs/website/scripts/live-blocks (open-policy-agent#4501)

update bob_token and alice_token in markdown (open-policy-agent#4504)

Signed-off-by: yongen.pan <yongen.pan@daocloud.io>

topdown/eval: copy without modifying expr, update test/e2e/concurrency (open-policy-agent#4503)

What we previously did turned into a race condition with multiple
concurrent calls to /v1/compile.

With a change introduced with 0.38.0 (the `every` keyword), the
`nil` Terms of an `ast.Expr` node was surfaced: previously, it would
go unnoticed, but could potentially have yielded bad results.

The effect of this change is proven using a new e2e test that would
fail on the code we had previous.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

uploading latest changes

Signed-off-by: Damien Burks <damien@damienjburks.com>

fixing test cases

Signed-off-by: Damien Burks <damien@damienjburks.com>

sdk: avoid using different state (open-policy-agent#4505)

I noticed that when operating on opa.state, locking is usually done to avoid
a race, whereas here opa.state is used directly. By comparing the previous
changes, I found that open-policy-agent#4240 changed the previous behaviour.

This change adjusts that: we ensure that we work on the state as read via
the mutex-protected `s := *opa.state`.

Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>

build(deps): update opentelemetry-go: 1.5.0 -> 1.6.1 (metrics 0.28.0) (open-policy-agent#4467)

https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.6.0
https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.6.1
https://github.com/open-telemetry/opentelemetry-go-contrib/releases/tag/v1.6.0

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

build(deps): open opentelemetry-go 1.6.0 -> 1.6.1 (open-policy-agent#4512)

This is a left-over from the previous bump, 0856120.

https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.6.1

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

sdk/opa_test: increase max delta (0.5s) (open-policy-agent#4513)

When running on GHA, we've found this test to often fail on macos-latest:
It would not functionally be wrong, but it also wasn't able to finish in
the alloted time. Now, the maximum delta has been increased a lot (10ms to
500ms). It's much, but it's still good enough to ensure that the context
passed to Stop() is the one that matters for shutdown.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

docs: Add clarifications for docs describing bundle signing and delta features

This commit adds some clarification to the bundle doc regarding
the format of bundle signatures and manifest behavior for delta
bundles.

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>

runtime: change processed file event log level to info (open-policy-agent#4514)

"Processed file watch event." will now be logged at level "info" (was "warn").

Signed-off-by: Anders Eknert <anders@eknert.com>

runtime/logging: only suppress payloads for handlers that compress responses (open-policy-agent#4502)

* runtime/logging: only suppress payloads for handlers that compress responses

To get compressed responses, two things need to be true:

1. The client must accept compressed responses
2. The handler must reply with a compressed response

For general API requests, (1) holds most of the time. (2) is only true
for the metrics endpoint at them moment, since the 3rd party library we
use for serving the prometheus endpoint will do compression.

* runtime/logging: remove dead code

The http.Hijack stuff was related to a watch feature removed in
open-policy-agent@186ef99

dropInputParam was only used by its tests.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

storage: code cosmetics

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

storage: allow implementations to override MakeDir

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

runtime+storage: integrate disk storage

With this change, the disk backend (badger) becomes available for
use with the OPA runtime properly:

It can be configured using the `storage.disk` key in OPA's config
(see included documentation).

When enabled,
- any data or policies stored with OPA will persist over restarts
- per-query metrics related to disk usage are reported
- Prometheus metrics per storage operation are exported

The main intention behind this feature is to optimize memory usage:
OPA can now operate on more data than fits into the allotted memory
resources. It is NOT meant to be used as a primary source of truth:
there are no backup/restore or desaster recovery procedures -- you
MUST secure the means to restore the data stored with OPA's disk
storage by yourself.

See also open-policy-agent#4014. Future improvements around bundle loading are
planned.

Some notes on details:

storage/disk: impose same locking regime used with inmem

With this setup, we'll ensure:

- there is only one open write txn at a time
- there are any number of open read txns at a time
- writes are blocked when reads are inflight
- during a commit (and triggers being run), no read txns can be created

This is to ensure the same atomic policy update semantics when using
'disk" as we have with "inmem". We're basically opting out of badger's
currency control and transactionality guarantees. This is because we
cannot piggy back on that to ensure the atomic update we want.

There might be other ways -- using subscribers, and blocking in some
other place -- but this one seems preferrable since it mirrors inmem.

Part of the problem is ErrTxnTooLarge, and committing and renewing
txns when it occurs: that, which is the prescribed solution to txns
growing too big, also means that reads can see half of the "logical"
transaction having been committed, while the rest is still getting
processed.

Another approach would have been using `WriteBatch`, but that won't
let us read from the batch, only apply Set and Delete operations.
We currently need to read (via an iterator) to figure out if we
need to delete keys to replace something in the store.  There is
no DropPrefix operation on the badger txn, or the WriteBatch API.

storage/disk: remove commit-and-renew-txn code for txn-too-big errors

This would break transactional guarantees we care about: while there
can be only one write transaction at a time, read transactions may
happen while a write txn is underway -- with this commit-and-reset
logic, those would read partial data.

Now, the error will be returned to the caller. The maximum txn size
depends on the size of memtables, and could be tweaked manually.
In general, the caller should try to push multiple smaller increments
of the data.

storage/disk: implement noop MakeDir

The MakeDir operation as implemented in the backend-agnostic storage
code has become an issue with the disk store: to write /foo/bar/baz,
we'd have to read /foo (among other subdirs), and that can be _much_
work for the disk backend. With inmem, it's cheap, so this wasn't
problematic before.

Some of the storage/disk/txn.go logic had to be adjusted to properly
do the MakeDir steps implicitly.

The index argument addition to patch() in storage/disk/txn.go was
necessary to keep the error messages conforming to the previous
code path: previously, conflicts (arrays indexed as objects) would
be surfaced in the MakeDir step, now it's entangled with the patch
calculation.

storage/disk: check ctx.Err() in List/Get operations

This won't abort reading a single key, but it will abort iterations.

storage/disk: support patterns in partitions

There is a potential clash here: "*", the path wildcard, is
a valid path section. However, it only affects the case when
a user would want to have a partition at

    /foo/*/bar

and would really mean "*", and not the wildcard.

Storing data at /foo/*/bar with a literal "*" won't be treated
differently than storing something at /fo/xyz/bar.

storage/disk: keep per-txn-type histograms of stats

This is done by reading off the metrics on commit, and shovelling
their numbers into the prometheus collector.

NOTE: if you were to share a metrics object among multiple transactions,
the results would be skewed, as it's not reset. However, our server
handlers don't do that.

storage/disk: opt out of badger's conflict detection

With only one write transaction in flight at any time, the situation
that badger guards against cannot happen:

A transaction has written to a key after the current, to-be-committed
transaction has last read that key from the store.

Since it can't happen, we can ignore the bookkeeping involved. This
improves the time it takes to overwrite existing keys.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

docs/management-bundles: remove quotations with info boxes (open-policy-agent#4517)

Small follow-up to open-policy-agent#4515, using info boxes instead of generic markup.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

website: fix community site (open-policy-agent#4522)

* remove hugo templating

This page doesn't go through hugo at all, so these things would
end up on the website.

A quick fix is reverting the bits that added the templating. The
downside is that local dev and PR previews will link to
/docs/latest/ecosystem, which doesn't exist there.

* link Documentation and Download to /docs

For /docs/ (not /docs/latest) we have a redirect in local dev and
PR preview mode:

    /docs -> /docs/edge

so this will be a little less broken: only ecosystem is a 404 link
on the preview.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

integrations: Add Emissary-Ingress (open-policy-agent#4523)

This PR adds the Emissary ingress to the Ecosystem page.
The blog section contains link to an article which guides on Emissary ingress and OPA integrations.

Signed-off-by: Tayyab J <tayyab.jamadar@styra.com>

storage/disk: wildcard partition validation, docs caveat (open-policy-agent#4519)

A bunch of smaller follow-up tasks to open-policy-agent#4381.

* storage/disk_test: check invalid patches with wildcard partition, too
* docs/disk: add caveat re: bundles loaded into memory
* storage/disk: auto-manage /system partitions

If these are found in the user-provided partitions, we'll error out.

* storage/disk: pretty-print partitions with "*" instead of %2A
* storage/disk: respect wildcard-replacement in partition validation

It is now allowed to replace a partition like

    /foo/bar

by

    /foo/*

also if multiple wildcards are used.

Caveats:

You cannot add a wildcard partition like /*/*, since it would overlap
the managed "/system/*" partition.

When attempting to go back from /foo/* to /foo/bar, an error is
raised _unconditionally_ -- we could check the existing data, but
currently don't.

* storage/disk: check prefix when adding wildcard partitions

The previously done check would have falsely returned that there is no problem
when adding a wildcard partition: lookup of "/foo/*" with '*' not interpreted
as a wildcard, but as a string, would yield a not-found, even if there was any
data under /foo/.

Now, we'll check the prefix-until-wildcard. It's more cautious than
theoretically necessary, but safe.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

website/style: fix code block bottom margin (open-policy-agent#4526)

The text following regular code blocks was too close. Now, the bottom
margin is the same was used with live-blocks, 1.5rem (24px).

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

docs: Add CloudFormation Hook tutorial (open-policy-agent#4525)

Obviously missing is deployment of OPA to AWS. This will come in the next iteration.

Signed-off-by: Anders Eknert <anders@eknert.com>

Prepare v0.39.0 release (open-policy-agent#4524)

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

Prepare v0.40.0 development (open-policy-agent#4527)

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

website: fix styra support link

Signed-off-by: Torin Sandall <torinsandall@gmail.com>

adopters: Add Wealthsimple (open-policy-agent#4530)

Signed-off-by: hannahyeates <hannahgrey06@gmail.com>

ci: fix rego check (open-policy-agent#4532)

* build/policies: format using 0.39.0
* workflow/pull-request: use edge opa for rego PR checks

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

website: remove right margin on sidebar (open-policy-agent#4529)

* remove right margin on sidebar
* replace the removed margin with padding

Signed-off-by: orweis <orweis@gmail.com>

website: Remove unused variables to avoid error in strict mode(open-policy-agent#4534)

To Fix:
```
2 errors occurred:
policy.rego:13: rego_compile_error: assigned var header unused
policy.rego:13: rego_compile_error: assigned var signature unused
```

Signed-off-by: panpan0000 <panpan0000@msn.com>

website: show yellow banner for old version (open-policy-agent#4533)

Hopefully this is gets more attention than the yellow "older" button
in the version picker.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>

fixing disk diagnostic test case
  • Loading branch information
damienjburks committed Apr 1, 2022
1 parent 3def349 commit e9ce256
Show file tree
Hide file tree
Showing 2,157 changed files with 12,209 additions and 15,556 deletions.
40 changes: 2 additions & 38 deletions .github/workflows/nightly.yaml
Expand Up @@ -41,14 +41,8 @@ jobs:
with:
go-version: ${{ steps.go_version.outputs.go_version }}

- name: Install gotip
run: |
go install golang.org/dl/gotip@latest
gotip download
gotip version
- name: gotip test -fuzz
run: gotip test ./ast -fuzz FuzzParseStatementsAndCompileModules -fuzztime 1h -v -run '^$'
- name: go test -fuzz
run: go test ./ast -fuzz FuzzParseStatementsAndCompileModules -fuzztime 1h -v -run '^$'

- name: Dump crashers
if: ${{ failure() }}
Expand All @@ -63,36 +57,6 @@ jobs:
status: ${{ job.status }}
fields: repo,workflow

fuzzer:
name: Go Fuzzer
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Run go-fuzz
run: make ci-go-check-fuzz

- name: Dump crashers
if: ${{ failure() }}
run: find build/fuzzer/workdir/crashers -name '*.quoted' -print -exec cat {} \;

- name: Upload Workdir
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: workdir
path: ./build/fuzzer/workdir

- name: Slack Notification
uses: 8398a7/action-slack@v3
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFICATION_WEBHOOK }}
if: ${{ failure() && env.SLACK_WEBHOOK_URL }}
with:
status: ${{ job.status }}
fields: repo,workflow

go-proxy-check:
name: Go mod check
runs-on: ubuntu-latest
Expand Down
31 changes: 19 additions & 12 deletions .github/workflows/pull-request.yaml
Expand Up @@ -130,7 +130,7 @@ jobs:
uses: actions/checkout@v3

- name: Run fuzz check (3m)
run: make ci-go-check-fuzz FUZZ_TIME=180
run: make ci-go-fuzz FUZZ_TIME=180s
timeout-minutes: 30

go-lint:
Expand Down Expand Up @@ -280,20 +280,25 @@ jobs:
working-directory: npm-opa-wasm

go-version-build:
name: Go compat builds
runs-on: ubuntu-latest
name: Go compat build/test
needs: generate
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- version: "1.16"
- version: "1.15"
os: [ubuntu-18.04, macos-latest]
version: ["1.17", "1.16"]
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Build
run: make ci-go-ci-build-linux GOVERSION=${{ matrix.version }}
timeout-minutes: 30
- uses: actions/checkout@v3
- name: Download generated artifacts
uses: actions/download-artifact@v2
with:
name: generated
- uses: actions/setup-go@v2
with:
go-version: ${{ matrix.version }}
- run: make build
- run: make go-test

# Run PR metadata against Rego policies
rego-check-pr:
Expand All @@ -305,6 +310,8 @@ jobs:

- name: Download OPA
uses: open-policy-agent/setup-opa@v1
with:
version: edge

- name: Test policies
run: opa test build/policy
Expand Down
2 changes: 1 addition & 1 deletion .go-version
@@ -1 +1 @@
1.17
1.18
2 changes: 2 additions & 0 deletions ADOPTERS.md
Expand Up @@ -237,6 +237,8 @@ pre-production (in alphabetical order):
automated code review, defining access levels or blocking execution of
unwanted code.

* [Wealthsimple](https://www.wealthsimple.com/) is using OPA to power all authorization checks their microservice ecosystem by leveraging their existing authorization library make the transition to OPA as simple as possible for development teams.

Other adopters that have gone into production or various stages of
testing include:

Expand Down
77 changes: 77 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,83 @@ project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

## 0.39.0

This release contains a number of fixes and enhancements.

### Disk Storage

The on-disk storage backend has been fully integrated with the OPA server, and
can now be enabled via configuration:

```yaml
storage:
disk:
directory: /var/opa # put data here
auto_create: true # create directory if it doesn't exist
partitions: # partitioning is important for data storage,
- /users/* # please see the documentation
```

It is intended to enable the use of OPA in scenarios where the data needed for
policy evaluation exceeds the available memory.

The on-disk contents will persist among restarts, but should not be used as a
single source of truth: there are no backup mechanisms, and certain data partitioning
changes will require a start-over. These are things that may get improved in the
future.

For all the details, please refer to the [configuration](https://www.openpolicyagent.org/docs/v0.39.0/configuration/#disk-storage)
and [detailled Disk Storage section](https://www.openpolicyagent.org/docs/v0.39.0/misc-disk/)
of the documentations.

### Tooling, SDK, and Runtime

- Server: Add warning when `input` attribute is missing in `POST /v1/data` API ([#4386](https://github.com/open-policy-agent/opa/issues/4386)) authored by @aflmp
- SDK: Support partial evaluation ([#4240](https://github.com/open-policy-agent/opa/pull/4240)), authored by @kroekle; with a fix to avoid using different state (authored by @Iceber)
- Runtime: Suppress payloads in debug logs for handlers that compress responses (`/metrics` and `/debug/pprof`) (authored by @christian1607)
- `opa test`: Add file path to failing tests to make debugging failing tests easier ([#4457](https://github.com/open-policy-agent/opa/issues/4457)), authored by @liamg
- `opa fmt`: avoid whitespace mixed with tabs on `with` statements ([#4376](https://github.com/open-policy-agent/opa/issues/4376)) reported by @tiwood
- Coverage reporting: Remove duplicates from coverage report ([#4393](https://github.com/open-policy-agent/opa/issues/4393)) reported by @gianna7wu
- Plugins: Fix broken retry logic in decision logs plugin ([#4486](https://github.com/open-policy-agent/opa/issues/4486)) reported by @iamatwork
- Plugins: Update regular polling fallback mechanism for downloader
- Plugins: Support for adding custom parameters and headers for OAuth2 Client Credentials Token request (authored by @srlk)
- Plugins: Log message on unexpected bundle content type ([#4278](https://github.com/open-policy-agent/opa/issues/4278))
- Plugins: Mask Authorization header value in debug logs ([#4495](https://github.com/open-policy-agent/opa/issues/4495))
- Docker images: Use GID 1000 in `-rootless` images ([#4380](https://github.com/open-policy-agent/opa/issues/4380)); also warn when using UID/GID 0.
- Runtime: change processed file event log level to info

### Rego and Topdown

- Type checker: Skip pattern JSON Schema attribute compilation ([#4426](https://github.com/open-policy-agent/opa/issues/4426)): These are not supported, but could have caused the parsing of a JSON Schema document to fail.
- Topdown: Copy without modifying expr, fixing a bug that could occur when running multiple partial evaluation requests concurrently.
- Compiler strict mode: Raise error on unused imports ([#4354](https://github.com/open-policy-agent/opa/issues/4354)) authored by @damienjburks
- AST: Fix print call rewriting in else rules ([#4489](https://github.com/open-policy-agent/opa/issues/4489))
- Compiler: Improve error message on missing `with` target ([#4431](https://github.com/open-policy-agent/opa/issues/4431)) reported by @gabrielfern
- Parser: hint about 'every' future keyword import

### Documentation and Website

- AWS CloudFormation Hook: New tutorial
- Community: Stretch background so it covers on larger screens ([#4402](https://github.com/open-policy-agent/opa/issues/4402)) authored by @msorens
- Build: Make local dev and PR preview not build everything ([#4379](https://github.com/open-policy-agent/opa/issues/4379))
- Philosophy: Grammar fixes (authored by @ajonesiii)
- README: Add note about Hugo version mismatch errors (authored by @ogazitt)
- Integrations: Add GraphQL-Graphene (authored by @dolevf), Emissary-Ingress (authored by @tayyabjamadar), rekor-sidekick,
- Integrations CI: ensure referenced software is listed, and logo file names match; allow SVG logos
- Envoy: Update policy primer with new control headers
- Envoy: Update bob_token and alice_token in tutorial (authored by @rokkiter)
- Envoy: Include new configurable gRPC msg sizes (authored by @emaincourt)
- Annotations: add missing title to index (authored by @itaysk)

### Miscellaneous

- Various dependency bumps, notably:
- OpenTelemetry-go: 1.4.1 -> 1.6.1
- Wasmtime-go: 0.34.0 -> 0.35.0
- Binaries and Docker images are now built using Go 1.18; CI runs build/test for Ubuntu and macos with Go 1.16 and 1.17.
- CI: remove go-fuzz, use native go 1.18 fuzzer

## 0.38.1

This is a bug fix release that addresses one issue when using `opa test` with the
Expand Down
15 changes: 8 additions & 7 deletions MAINTAINERS.md
Expand Up @@ -4,15 +4,16 @@ The following table lists OPA project maintainers and areas of expertise in alph

| Name | GitHub | Email | Organization | Repositories/Area of Expertise | Added/Renewed On |
| --- | --- | --- | --- | --- | --- |
| Ash Narkar | @ashutosh-narkar | anarkar4387@gmail.com | Styra | opa, opa-envoy-plugin | 2021-03-29 |
| Craig Tabita | @ctab | ctab@google.com | Google | gatekeeper, gatekeeper-library, cert-controller | 2021-03-29 |
| Max Smythe | @maxsmythe | smythe@google.com | Google | frameworks/constraints, gatekeeper, gatekeeper-library, cert-controller | 2021-03-29 |
| Ash Narkar | @ashutosh-narkar | anarkar4387@gmail.com | Styra | opa, opa-envoy-plugin | 2022-03-24 |
| Max Smythe | @maxsmythe | smythe@google.com | Google | frameworks/constraints, gatekeeper, gatekeeper-library, cert-controller | 2022-03-24 |
| Oren Shomron | @shomron | shomron@gmail.com | VMware | frameworks/constraints, gatekeeper, gatekeeper-library, cert-controller | 2020-11-13 |
| Rita Zhang | @ritazh | rita.z.zhang@gmail.com | Microsoft | frameworks/constraints, gatekeeper, gatekeeper-library, cert-controller | 2021-03-29 |
| Sertaç Özercan | @sozercan | sozercan@gmail.com | Microsoft | gatekeeper, gatekeeper-library, cert-controller | 2021-03-29 |
| Tim Hinrichs | @timothyhinrichs | timothy.l.hinrichs@gmail.com | Styra | all repositories | 2021-03-29 |
| Torin Sandall | @tsandall | torinsandall@gmail.com | Styra | all repositories | 2021-03-29 |
| Rita Zhang | @ritazh | rita.z.zhang@gmail.com | Microsoft | frameworks/constraints, gatekeeper, gatekeeper-library, cert-controller | 2022-03-24 |
| Sertaç Özercan | @sozercan | sozercan@gmail.com | Microsoft | gatekeeper, gatekeeper-library, cert-controller | 2022-03-24 |
| Tim Hinrichs | @timothyhinrichs | timothy.l.hinrichs@gmail.com | Styra | all repositories | 2022-03-24 |
| Torin Sandall | @tsandall | torinsandall@gmail.com | Styra | all repositories | 2022-03-24 |
| Will Beason | @willbeason | willbeason@google.com | Google | gatekeeper, gatekeeper-library, cert-controller | 2022-03-24 |

## Emeritus

* [Craig Tabita](https://github.com/ctab)
* [Patrick East](https://github.com/patrick-east)
13 changes: 7 additions & 6 deletions Makefile
Expand Up @@ -57,7 +57,7 @@ BIN := opa_$(GOOS)_$(GOARCH)
# Optional external configuration useful for forks of OPA
DOCKER_IMAGE ?= openpolicyagent/opa
S3_RELEASE_BUCKET ?= opa-releases
FUZZ_TIME ?= 3600 # 1hr
FUZZ_TIME ?= 1h
TELEMETRY_URL ?= #Default empty

BUILD_COMMIT := $(shell ./build/get-build-commit.sh)
Expand Down Expand Up @@ -166,7 +166,8 @@ clean: wasm-lib-clean

.PHONY: fuzz
fuzz:
$(MAKE) -C ./build/fuzzer all
go test ./ast -fuzz FuzzParseStatementsAndCompileModules -fuzztime ${FUZZ_TIME} -v -run '^$$'


######################################################
#
Expand Down Expand Up @@ -447,14 +448,14 @@ release-ci: push-image push-manifest-list-latest
endif

.PHONY: netlify-prod
netlify-prod: clean docs-clean build docs-generate docs-production-build
netlify-prod: clean docs-clean build docs-production-build

.PHONY: netlify-preview
netlify-preview: clean docs-clean build docs-live-blocks-install-deps docs-live-blocks-test docs-generate docs-preview-build
netlify-preview: clean docs-clean build docs-live-blocks-install-deps docs-live-blocks-test docs-dev-generate docs-preview-build

# Kept for compatibility. Use `make fuzz` instead.
.PHONY: check-fuzz
check-fuzz:
./build/check-fuzz.sh $(FUZZ_TIME)
check-fuzz: fuzz

# GOPRIVATE=* causes go to fetch all dependencies from their corresponding VCS
# source, not through the golang-provided proxy services. We're cleaning out
Expand Down
6 changes: 4 additions & 2 deletions ast/compile.go
Expand Up @@ -1496,12 +1496,14 @@ func (c *Compiler) rewritePrintCalls() {
WalkRules(mod, func(r *Rule) bool {
safe := r.Head.Args.Vars()
safe.Update(ReservedVars)
WalkBodies(r, func(b Body) bool {
vis := func(b Body) bool {
for _, err := range rewritePrintCalls(c.localvargen, c.GetArity, safe, b) {
c.err(err)
}
return false
})
}
WalkBodies(r.Head, vis)
WalkBodies(r.Body, vis)
return false
})
}
Expand Down
43 changes: 41 additions & 2 deletions ast/compile_test.go
Expand Up @@ -4113,6 +4113,45 @@ func TestCompilerRewritePrintCalls(t *testing.T) {
}
}

func TestRewritePrintCallsWithElseImplicitArgs(t *testing.T) {

module := `package test
f(x, y) {
x = y
}
else = false {
print(x, y)
}`

c := NewCompiler().WithEnablePrintStatements(true)
opts := ParserOptions{AllFutureKeywords: true, unreleasedKeywords: true}
c.Compile(map[string]*Module{
"test.rego": MustParseModuleWithOpts(module, opts),
})

if c.Failed() {
t.Fatal(c.Errors)
}

exp := MustParseModuleWithOpts(`package test
f(__local0__, __local1__) = true { __local0__ = __local1__ }
else = false { __local6__ = {__local4__ | __local4__ = __local2__}; __local7__ = {__local5__ | __local5__ = __local3__}; internal.print([__local6__, __local7__]) }
`, opts)

// NOTE(tsandall): we have to patch the implicit args on the else rule
// because of how the parser copies the arg names across from the first
// rule.
exp.Rules[0].Else.Head.Args[0] = VarTerm("__local2__")
exp.Rules[0].Else.Head.Args[1] = VarTerm("__local3__")

if !exp.Equal(c.Modules["test.rego"]) {
t.Fatalf("Expected:\n\n%v\n\nGot:\n\n%v", exp, c.Modules["test.rego"])
}
}

func TestCompilerMockFunction(t *testing.T) {
c := NewCompiler()
c.Modules["test"] = MustParseModule(`
Expand Down Expand Up @@ -4299,7 +4338,7 @@ func TestCompilerCheckUnusedAssignedVar(t *testing.T) {
{
note: "rule with nested closure",
module: `package test
p {
p {
x := 1
a := 1
{ y | y := [ z | z:=[1,2,3][a]; z > 1 ][_] }
Expand All @@ -4312,7 +4351,7 @@ func TestCompilerCheckUnusedAssignedVar(t *testing.T) {
{
note: "rule with nested closure and unused inner var",
module: `package test
p {
p {
x := 1
{ y | y := [ z | z:=[1,2,3][x]; z > 1; a := 2 ][_] }
}
Expand Down
21 changes: 14 additions & 7 deletions ast/policy.go
Expand Up @@ -1053,10 +1053,22 @@ func (expr *Expr) sortOrder() int {
return -1
}

// CopyWithoutTerms returns a deep copy of expr without its Terms
func (expr *Expr) CopyWithoutTerms() *Expr {
cpy := *expr

cpy.With = make([]*With, len(expr.With))
for i := range expr.With {
cpy.With[i] = expr.With[i].Copy()
}

return &cpy
}

// Copy returns a deep copy of expr.
func (expr *Expr) Copy() *Expr {

cpy := *expr
cpy := expr.CopyWithoutTerms()

switch ts := expr.Terms.(type) {
case *SomeDecl:
Expand All @@ -1073,12 +1085,7 @@ func (expr *Expr) Copy() *Expr {
cpy.Terms = ts.Copy()
}

cpy.With = make([]*With, len(expr.With))
for i := range expr.With {
cpy.With[i] = expr.With[i].Copy()
}

return &cpy
return cpy
}

// Hash returns the hash code of the Expr.
Expand Down

0 comments on commit e9ce256

Please sign in to comment.