minvws / nl-kat-coordination

Repo nl-kat-coordination for minvws
European Union Public License 1.2
123 stars 55 forks source link

Boefje variant json schema contains lot of null values #3569

Closed stephanie0x00 closed 6 days ago

stephanie0x00 commented 1 week ago

Describe the bug During the QA of #3557 it appeared that the API used by the boefje variants does something silly with/near the JSON schema.

To Reproduce Steps to reproduce the behavior:

  1. Go to Nmap TCP boefje and create a variant.
  2. Observe that the JSON schema contains a lot of 'null' values.
  3. Open the newly created boefje variant in the Katalogus.
  4. Observe that the settings page 'exploded' with variables.
  5. Running the boefje variant results in an error. The output from raw is posted below.

Expected behavior The JSON schema for the nmap options should be displayed on the katalogus page.

Screenshots JSON schema when creating a new boefje variant: image

Viewing this new boefje variant in the katalogus: image

OpenKAT version main

Contents RAW file

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/app/oci_adapter.py", line 46, in <module>
    main()
  File "/app/oci_adapter.py", line 13, in main
    boefje_input = httpx.get(input_url).json()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_models.py", line 766, in json
    return jsonlib.loads(self.content, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
underdarknl commented 6 days ago

It looks like this is a regression due to @ammar92 's migration of some fieldnames / or should be fixed by the migration. What you are seeing here is the Internal Pydantic Schema of the Boefje, not the boefjes JsonSchema as defined in our plugin itself. I think we made an error in merging https://github.com/minvws/nl-kat-coordination/pull/3557