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

feat: support chaitin-waf plugin #9838

Merged
merged 21 commits into from
Aug 1, 2023

Conversation

lingsamuel
Copy link
Member

Description

Fixes # (issue)

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

Signed-off-by: Ling Samuel (WSL) <lingsamuelgrace@gmail.com>
@lingsamuel lingsamuel marked this pull request as draft July 14, 2023 10:59
Signed-off-by: Ling Samuel (WSL) <lingsamuelgrace@gmail.com>
Signed-off-by: Ling Samuel (WSL) <lingsamuelgrace@gmail.com>
@lingsamuel lingsamuel marked this pull request as ready for review July 28, 2023 06:57
404 page not found
```

当满足匹配条件时,正常请求依然可以触达:
Copy link
Contributor

Choose a reason for hiding this comment

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

触达上游?

Copy link
Contributor

Choose a reason for hiding this comment

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

Done


local function get_conf(conf, metadata)
local t = {
mode = "block", -- block or monitor or off, default off
Copy link
Contributor

Choose a reason for hiding this comment

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

default value is ’off‘ ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Done


if conf.match then
for _, match in ipairs(conf.match) do
local exp, err = expr.new(match.vars)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we cache the result of expression compilation?

Copy link
Contributor

Choose a reason for hiding this comment

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

We will do it after this pr

Copy link
Contributor

Choose a reason for hiding this comment

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

Add TODO pls

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

config = {
type = "object",
properties = {
-- connect timeout, in milliseconds, integer, default 1s (1000ms)
Copy link
Contributor

Choose a reason for hiding this comment

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

Annotation looks unnecessary

Copy link
Member

Choose a reason for hiding this comment

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

let's move it to the properties item desc?

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

type = "object",
properties = {
host = {
type = "string",
Copy link
Contributor

Choose a reason for hiding this comment

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

It is recommended to use a stricter schema definition. https://github.com/apache/apisix/blob/master/apisix/schema_def.lua#L40

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

- 9200
- "127.0.0.1:9201"
plugins:
- chaitin-waf
Copy link
Contributor

Choose a reason for hiding this comment

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

The plugin has been enabled by default, there is no need to add it separately

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

apisix/plugins/chaitin-waf.lua Outdated Show resolved Hide resolved
config = {
type = "object",
properties = {
-- connect timeout, in milliseconds, integer, default 1s (1000ms)
Copy link
Member

Choose a reason for hiding this comment

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

let's move it to the properties item desc?

apisix/plugins/chaitin-waf.lua Show resolved Hide resolved
{"code": 403, "success":false, "message": "blocked by Chaitin SafeLine Web Application Firewall", "event_id": "51a268653f2c4189bfa3ec66afbcb26d"}
```

## Disable Plugin
Copy link
Member

@kayx23 kayx23 Aug 1, 2023

Choose a reason for hiding this comment

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

Suggested change
## Disable Plugin
## Delete Plugin

This sections of all plugin docs (en/zh) have been corrected previously. Reference to the latest here: https://apisix.apache.org/docs/apisix/next/plugins/response-rewrite/#delete-plugin

Copy link
Contributor

Choose a reason for hiding this comment

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

Done


## Disable Plugin

To disable the `chaitin-waf` plugin, remove the plugin configuration in the plugin configuration:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
To disable the `chaitin-waf` plugin, remove the plugin configuration in the plugin configuration:
To remove the `chaitin-waf` plugin, delete the the corresponding JSON configuration from the Plugin configuration:

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

{"code": 403, "success":false, "message": "blocked by Chaitin SafeLine Web Application Firewall", "event_id": "51a268653f2c4189bfa3ec66afbcb26d"}
```

## 禁用插件
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
## 禁用插件
## 删除插件

| add_header | bool | false | true | Whether to add response headers |
| add_debug_header | bool | false | false | Whether or not to add debugging headers, effective when `add_header` is `true`. |
| config | object | false | | Configuration of the Chaitin SafeLine WAF service. When the route is not configured, the parameters configured in the metadata are used. |
| config.connect_timeout | integer | false | | connect timeout, in milliseconds, integer |
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
| config.connect_timeout | integer | false | | connect timeout, in milliseconds, integer |
| config.connect_timeout | integer | false | | connect timeout, in milliseconds |

Same for below. Remove all integer from the description as the data types have already been specified in Type.

@monkeyDluffy6017 monkeyDluffy6017 merged commit 455d5bf into apache:master Aug 1, 2023
34 checks passed
rubikplanet pushed a commit to rubikplanet/apisix that referenced this pull request Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants