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

jsonschema.exceptions.ValidationError: 'PORTS' is a required property #3993

Open
underdarknl opened this issue Dec 30, 2024 · 1 comment · May be fixed by #3995
Open

jsonschema.exceptions.ValidationError: 'PORTS' is a required property #3993

underdarknl opened this issue Dec 30, 2024 · 1 comment · May be fixed by #3995
Assignees
Labels
boefjes Issues related to boefjes bug Something isn't working 😸 Review/QA feedback Review/QA feedback provided

Comments

@underdarknl
Copy link
Contributor

Describe the bug
When enabling a boefje without setting all its required settings (which is allowed due to the possible existence of env-vars), the boefje runner throws a jsonschema validationerror. this error however does not produce an error raw file accessible via the tasklist's job.

To Reproduce
Steps to reproduce the behavior:

  1. Go to katalogus
  2. Enable nmap-ports, do not fill out the number of ports
  3. Scan an IP
  4. See error, notice there's no raw files do the dowloaded.

Expected behavior
At least we should store the error/stacktrace and allow the user to see they need to conform the boefje's settings to the schema by adding settings or env-vars.

Screenshots

SettingsNotConformingToSchema: ('nmap-ports', "'PORTS' is a required property")
Traceback (most recent call last):
  File "/app/boefjes/boefjes/job_handler.py", line 85, in get_environment_settings
    validate(instance=new_env, schema=schema)
  File "/usr/local/lib/python3.11/site-packages/jsonschema/validators.py", line 1332, in validate
    raise error
jsonschema.exceptions.ValidationError: 'PORTS' is a required property

Failed validating 'required' in schema:
    {'title': 'Arguments',
     'type': 'object',
     'properties': {'PORTS': {'title': 'PORTS',
                              'maxLength': 2048,
                              'type': 'string',
                              'pattern': '^((6553[0-5]|655[0-2]\\d|65[0-4]\\d{2}|6[0-4]\\d{3}|[1-5]\\d{4}|\\d{1,4})|(6553[0-5]|655[0-2]\\d|65[0-4]\\d{2}|6[0-4]\\d{3}|[1-5]\\d{4}|\\d{1,4})-(6553[0-5]|655[0-2]\\d|65[0-4]\\d{2}|6[0-4]\\d{3}|[1-5]\\d{4}|\\d{1,4}))$|^((6553[0-5]|655[0-2]\\d|65[0-4]\\d{2}|6[0-4]\\d{3}|[1-5]\\d{4}|\\d{1,4})|(6553[0-5]|655[0-2]\\d|65[0-4]\\d{2}|6[0-4]\\d{3}|[1-5]\\d{4}|\\d{1,4})-(6553[0-5]|655[0-2]\\d|65[0-4]\\d{2}|6[0-4]\\d{3}|[1-5]\\d{4}|\\d{1,4}))(,((6553[0-5]|655[0-2]\\d|65[0-4]\\d{2}|6[0-4]\\d{3}|[1-5]\\d{4}|\\d{1,4})|(6553[0-5]|655[0-2]\\d|65[0-4]\\d{2}|6[0-4]\\d{3}|[1-5]\\d{4}|\\d{1,4})-(6553[0-5]|655[0-2]\\d|65[0-4]\\d{2}|6[0-4]\\d{3}|[1-5]\\d{4}|\\d{1,4})))+$',
                              'description': 'Specify the ports that need '
                                             'to be scanned (nmap format). '
                                             'Single ports are comma '
                                             'separated, port ranges can '
                                             'be specified using the dash '
                                             'symbol. For example: '
                                             '22,111,137,80-100 will scan '
                                             'ports 22, 111, 137 and the '
                                             'port range 80 up to 100.'}},
     'required': ['PORTS']}

On instance:
    {}

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/boefjes/boefjes/app.py", line 251, in _start_working
    handler.handle(p_item.data)
  File "/app/boefjes/boefjes/job_handler.py", line 135, in handle
    boefje_meta.environment = get_environment_settings(boefje_meta, plugin.boefje_schema)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/boefjes/boefjes/job_handler.py", line 87, in get_environment_settings
    raise SettingsNotConformingToSchema(boefje_meta.boefje.id, e.message) from e
boefjes.storage.interfaces.SettingsNotConformingToSchema: ('nmap-ports', "'PORTS' is a required property")

OpenKAT version
Main

@underdarknl underdarknl added boefjes Issues related to boefjes bug Something isn't working labels Dec 30, 2024
@github-project-automation github-project-automation bot moved this to Incoming features / Need assessment in KAT Dec 31, 2024
@madelondohmen madelondohmen moved this from Incoming features / Need assessment to Review in KAT Dec 31, 2024
@madelondohmen madelondohmen assigned ammar92 and unassigned Donnype Dec 31, 2024
@ammar92 ammar92 moved this from Review to QA review / functional testing in KAT Jan 3, 2025
@stephanie0x00 stephanie0x00 added the 😸 Review/QA feedback Review/QA feedback provided label Jan 6, 2025
@underdarknl underdarknl moved this from QA review / functional testing to In Progress in KAT Jan 6, 2025
@ammar92 ammar92 moved this from In Progress to Ready for merge in KAT Jan 8, 2025
@Rieven Rieven assigned underdarknl and unassigned ammar92 Jan 14, 2025
@underdarknl
Copy link
Contributor Author

@dekkers 's feedback boiled down to the broad catch all on both the boefje execution and the collection of resources. He feels catching all is too broad, and conflates possible errors in KAT (connectivity, config, others) with possible errors in the boefje.
Since we dont have another return channel for the errors in KAT, separate from the errors that might occur in the boefje, I feel our best bet currently is to use this boefje error channel to communicate in the broadest sense when something breaks when trying to run a boefje, regardless of where the error occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
boefjes Issues related to boefjes bug Something isn't working 😸 Review/QA feedback Review/QA feedback provided
Projects
Status: Ready for merge
Development

Successfully merging a pull request may close this issue.

4 participants