-
Notifications
You must be signed in to change notification settings - Fork 25
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
chore: adds kong example. #144
Draft
jcchavezs
wants to merge
6
commits into
main
Choose a base branch
from
kong_example
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f24b4dd
chore: adds kong example.
jcchavezs e1c15b3
chore: implements docker-compose.
jcchavezs f0fd1be
wip
jcchavezs 549305c
wip
jcchavezs f466a07
fix: applies @hishamhm suggestions.
jcchavezs 52c552d
docs: adds basic readme.
jcchavezs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Kong example | ||
|
||
## Getting started | ||
|
||
```shell | ||
METRICS=off mage build | ||
``` | ||
|
||
In `example/kong` folder: | ||
|
||
```shell | ||
docker-compose up | ||
``` | ||
|
||
In `e2e`: | ||
|
||
```shell | ||
ENVOY_HOST=localhost:8000 HTTPBIN_HOST=localhost:8080 ./e2e-example.sh | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# a very minimal declarative config file | ||
_format_version: "1.1" | ||
_transform: true | ||
|
||
services: | ||
- name: httpbin | ||
host: "httpbin" | ||
path: "/" | ||
port: 8080 | ||
protocol: http | ||
routes: | ||
- name: httpbin | ||
methods: | ||
- GET | ||
paths: | ||
- / | ||
- /anything | ||
- /uuid | ||
plugins: | ||
- name: proxy-wasm | ||
config: | ||
filters: | ||
- name: main | ||
config: '{ | ||
"rules": [ | ||
"Include @demo-conf", | ||
"Include @crs-setup-demo-conf", | ||
"SecRuleEngine DetectionOnly", | ||
"SecDebugLogLevel 3", | ||
"Include @owasp_crs/*.conf", | ||
"SecRule REQUEST_URI \"@streq /uuid\" \"id:101,phase:1,t:lowercase,deny\"", | ||
"SecRule REQUEST_BODY \"@rx maliciouspayload\" \"id:102,phase:2,t:lowercase,deny\"", | ||
"SecRule RESPONSE_HEADERS::status \"@rx 406\" \"id:103,phase:3,t:lowercase,deny\"", | ||
"SecRule RESPONSE_BODY \"@contains responsebodycode\" \"id:104,phase:4,t:lowercase,deny\"" | ||
] | ||
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Inspired in https://github.com/Kong/docker-kong | ||
version: '3.9' | ||
|
||
volumes: | ||
kong_prefix_vol: | ||
driver_opts: | ||
type: tmpfs | ||
device: tmpfs | ||
kong_tmp_vol: | ||
driver_opts: | ||
type: tmpfs | ||
device: tmpfs | ||
|
||
networks: | ||
kong-net: | ||
external: false | ||
|
||
services: | ||
kong: | ||
image: "kong/incubator:gateway-wasmer-3.0.0.0" | ||
user: "${KONG_USER:-kong}" | ||
environment: | ||
KONG_DATABASE: "off" | ||
KONG_ADMIN_ACCESS_LOG: /dev/stdout | ||
KONG_ADMIN_ERROR_LOG: /dev/stderr | ||
KONG_PROXY_LISTEN: "${KONG_PROXY_LISTEN:-0.0.0.0:8000}" | ||
KONG_ADMIN_LISTEN: "${KONG_ADMIN_LISTEN:-0.0.0.0:8001}" | ||
KONG_PROXY_ACCESS_LOG: /dev/stdout | ||
KONG_PROXY_ERROR_LOG: /dev/stderr | ||
KONG_PREFIX: ${KONG_PREFIX:-/var/run/kong} | ||
KONG_DECLARATIVE_CONFIG: "/opt/kong/kong.yaml" | ||
KONG_WASM: "on" | ||
KONG_WASM_MODULES: "/wasm/main.wasm" | ||
networks: | ||
- kong-net | ||
ports: | ||
# The following two environment variables default to an insecure value (0.0.0.0) | ||
# according to the CIS Security test. | ||
- "${KONG_INBOUND_PROXY_LISTEN:-0.0.0.0}:8000:8000/tcp" | ||
- "${KONG_INBOUND_SSL_PROXY_LISTEN:-0.0.0.0}:8443:8443/tcp" | ||
# Making them mandatory but undefined, like so would be backwards-breaking: | ||
# - "${KONG_INBOUND_PROXY_LISTEN?Missing inbound proxy host}:8000:8000/tcp" | ||
# - "${KONG_INBOUND_SSL_PROXY_LISTEN?Missing inbound proxy ssl host}:8443:8443/tcp" | ||
# Alternative is deactivating check 5.13 in the security bench, if we consider Kong's own config to be enough security here | ||
|
||
- "127.0.0.1:8001:8001/tcp" | ||
- "127.0.0.1:8444:8444/tcp" | ||
healthcheck: | ||
test: [ "CMD", "kong", "health" ] | ||
interval: 10s | ||
timeout: 10s | ||
retries: 10 | ||
restart: on-failure:5 | ||
read_only: true | ||
volumes: | ||
- kong_prefix_vol:${KONG_PREFIX:-/var/run/kong} | ||
- kong_tmp_vol:/tmp | ||
- ./config:/opt/kong | ||
- ../../build:/wasm | ||
security_opt: | ||
- no-new-privileges | ||
depends_on: | ||
- httpbin | ||
|
||
httpbin: | ||
image: mccutchen/go-httpbin:v2.5.0 | ||
environment: | ||
- MAX_BODY_SIZE=15728640 # 15 MiB | ||
ports: | ||
- 8080:8080 | ||
networks: | ||
- kong-net |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright The OWASP Coraza contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//go:build disable_metrics | ||
|
||
package wasmplugin | ||
|
||
type wafMetrics struct{} | ||
|
||
func NewWAFMetrics() *wafMetrics { | ||
return &wafMetrics{} | ||
} | ||
|
||
func (*wafMetrics) CountTX() {} | ||
|
||
func (*wafMetrics) CountTXInterruption(_ string, _ int) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DefineCountMetric isn't supported by kong yet.