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

bug: the plugin metadata obtained from etcd has not been validated by schema #11216

Open
nic-6443 opened this issue Apr 30, 2024 · 0 comments
Open

Comments

@nic-6443
Copy link
Member

Current Behavior

Part 1

We created an etcd client to handle plugin metadata in:

apisix/apisix/plugin.lua

Lines 816 to 821 in 64b81c4

local plugin_metadatas, err = core.config.new("/plugin_metadata",
{
automatic = true,
checker = check_plugin_metadata
}
)

in check_plugin_metadata function, we need a item.id(expectation is the plugin name) to check metadata schema of specific plugin.

apisix/apisix/plugin.lua

Lines 1040 to 1042 in 64b81c4

check_plugin_metadata = function(item)
local ok, err = check_single_plugin_schema(item.id, item,
core.schema.TYPE_METADATA, true)

but plugin metadata don't have a id field in our admin api, so when apisix startup with a exist plugin metadata, the checker will be triggered in config_etcd:load_full_data
if data_valid and self.checker then
data_valid, err = self.checker(item.value)
if not data_valid then
log.error("failed to check item data of [", self.key,
"] err:", err, " ,val: ", json.delay_encode(item.value))
end
end

and then checker failed with this log:
image

Part 2

When watch a new data from etcd, config_etcd.lua only check configuration that has configure with a item_schema

if res.value and self.item_schema then
local ok, err = check_schema(self.item_schema, res.value)
if not ok then
self:upgrade_version(res.modifiedIndex)
return false, "failed to check item data of ["
.. self.key .. "] err:" .. err
end
if self.checker then
local ok, err = self.checker(res.value)
if not ok then
self:upgrade_version(res.modifiedIndex)
return false, "failed to check item data of ["
.. self.key .. "] err:" .. err
end
end
end

because plugin_metadata only set checker field without item_schema, so the new plugin metadata watch from etcd don't validate by schema too.

Expected Behavior

No response

Error Logs

No response

Steps to Reproduce

/

Environment

/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant