Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPA filter implementation && doc reference #856

Merged
merged 5 commits into from Nov 28, 2022

Conversation

jthann
Copy link
Collaborator

@jthann jthann commented Nov 17, 2022

OPA filter implementation && doc reference #832

@codecov-commenter
Copy link

codecov-commenter commented Nov 17, 2022

Codecov Report

Base: 77.09% // Head: 77.05% // Decreases project coverage by -0.04% ⚠️

Coverage data is based on head (bb415e6) compared to base (59cc1a2).
Patch coverage: 75.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #856      +/-   ##
==========================================
- Coverage   77.09%   77.05%   -0.05%     
==========================================
  Files         108      109       +1     
  Lines       12241    12345     +104     
==========================================
+ Hits         9437     9512      +75     
- Misses       2278     2305      +27     
- Partials      526      528       +2     
Impacted Files Coverage Δ
pkg/filters/opafilter/opafilter.go 75.00% <75.00%> (ø)
pkg/filters/validator/basicauth.go 78.80% <0.00%> (-1.85%) ⬇️
pkg/object/mqttproxy/client.go 81.61% <0.00%> (-0.90%) ⬇️
pkg/filters/proxy/pool.go 80.17% <0.00%> (+0.87%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

pkg/filters/opafilter/opafilter.go Outdated Show resolved Hide resolved
pkg/filters/opafilter/opafilter.go Outdated Show resolved Hide resolved
pkg/filters/opafilter/opafilter.go Outdated Show resolved Hide resolved
doc/reference/filters.md Outdated Show resolved Hide resolved
doc/reference/filters.md Outdated Show resolved Hide resolved
| input.request.path_parts | array | The current http request URL path parts | ["a","b","c"] |
| input.request.raw_query | string | The current http request raw query | "a=1&b=2&c=3" |
| input.request.query | map | The current http request query map | {"a":1,"b":2,"c":3} |
| input.request.headers | map | The current http request header map targeted by<br/> includedHeaders | {"Content-Type":"application/json"} |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo, <br/>

doc/reference/filters.md Outdated Show resolved Hide resolved
doc/reference/filters.md Outdated Show resolved Hide resolved
doc/reference/filters.md Outdated Show resolved Hide resolved
doc/reference/filters.md Outdated Show resolved Hide resolved
pkg/filters/opafilter/opafilter.go Outdated Show resolved Hide resolved
return o.opaError(w, err)
}

if len(results) == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think it is nessesary to check if len(results) > 1 and then report error?


var body string
if o.spec.ReadBody {
_ = r.FetchPayload(0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has already been done in the HTTPServer.

Suggested change
_ = r.FetchPayload(0)

Comment on lines 207 to 209
if a, exists := resMap["allow"]; exists {
allow = cast.ToBool(a)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we are sure resMap["allow"] is a string, propose using strconv.ParseBool to avoid introducing a new 3rd party package.

Comment on lines 221 to 225
} else {
if !allow {
w.SetStatusCode(isc)
}
}
Copy link
Collaborator

@localvar localvar Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to reduce nesting.

Suggested change
} else {
if !allow {
w.SetStatusCode(isc)
}
}
} else if !allow {
w.SetStatusCode(isc)
}

@suchen-sci suchen-sci merged commit b3ef1b8 into easegress-io:main Nov 28, 2022
@anderseknert
Copy link

Hey, this is really neat! If you'd like to submit your integration to the OPA ecosystem page, we'd be happy to see it there.

@localvar
Copy link
Collaborator

@anderseknert Thanks for the information, we have submitted a PR: open-policy-agent/opa#5421

caoshengdong pushed a commit to caoshengdong/easegress that referenced this pull request Dec 20, 2022
* OPA filter implementation && doc reference

* Doc reference changed & using type assertion for performance issue

* remove extra opa functions, only retain allow result

* remove extra r.FetchPayload(0)

* remove unused unit test cases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants