#8324 Bug API spec for object "dnsserver" defines method "add", but there is no command "dnsserver_add"
Opened by schlitzered. Modified

Request for enhancement

fix api spec

Issue

either the spec for object dnsserver[''methods"] is wrong because it contains the methods "add",

or the documentation for the command "dnsserver_add" is missing.

Steps to Reproduce

  1. request "'json_metadata', [], {"command": "all", "object": "all"}" from the demo ipa server.
  2. inspect result for object dnsserver attribute methods, there "add" is listed
  3. you will notice that there is no command dnsserver_add

Actual behavior

api spec is wrong

Expected behavior

correct api spec

Version/Release/Distribution

found in https://ipa.demo1.freeipa.org/ipa/ui/

Additional info:


Please use the issue template to report bugs and fill in as much information as possible.

adjusted comment, to use the default template

I have the feeling that this simply shouldn't be in the json_metadata value since these are internal-only functions.

i actually find this information useful, since it helps me to automatically discover the api. so i would have to use something else get the same information if is removed.

For the record, the request {method: "json_metadata", params: [[], {object: "all", version: "2.235"}]} returns the del and add for object path result.objects.dnsserver.methods although the dnsserver_add and dnsserver_del methods are internal, server local methods.

Reproducer query (without token)

curl 'https://ipa.demo1.freeipa.org/ipa/session/json' \
  -H 'Connection: keep-alive' \
  -H 'Accept: application/json, text/javascript, */*; q=0.01' \
  -H 'X-Requested-With: XMLHttpRequest' \
  -H 'User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36' \
  -H 'Content-Type: application/json' \
  -H 'Origin: https://ipa.demo1.freeipa.org' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Referer: https://ipa.demo1.freeipa.org/ipa/ui/' \
  -H 'Accept-Language: en-US,en;q=0.9,de;q=0.8' \
  -H 'Cookie: ipa_session=MagBearerToken=...' \
  --data-binary '{"method":"json_metadata","params":[[],{"object":"all","version":"2.235"}]}' \
  --compressed

i actually find this information useful, since it helps me to automatically discover the api. so i would have to use something else get the same information if is removed.

It isn't supposed to be in the public API. In fact it is probably not callable remotely anyway.

@schlitzered Could you please try out the patch from https://github.com/freeipa/freeipa/pull/4699 and report back?

My experimental patch isn't working for Rob. I don't have free resources to look into the matter now. It's not urgent either. Please feel free to come up with a patch.

diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index ec14ad1027..0f1c673a41 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -1298,7 +1298,10 @@ def __json__(self):
         )
         if self.primary_key:
             json_dict['primary_key'] = self.primary_key.name
-        json_dict['methods'] = list(self.methods)
+        json_dict['methods'] = [
+            name for name, method in self.methods.__todict__().items()
+            if not isinstance(method, Local)
+        ]
         return json_dict

Metadata Update from @cheimes:
- Custom field on_review adjusted to https://github.com/freeipa/freeipa/pull/4699
- Issue priority set to: minor
- Issue set to the milestone: Future Releases

Metadata Update from @pcech:
- Issue tagged with: community

Metadata