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

Better JSON schema support for plugin settings in Rocky #939

Merged
merged 31 commits into from
Jun 1, 2023

Conversation

Donnype
Copy link
Contributor

@Donnype Donnype commented May 9, 2023

Changes

Simplify the settings setup to support JSON schema validation from the plugins. This means no add/edit/delete per key, only an upsert (idempotent PUT/create_or_update) and a delete. Since we validate settings as a whole against the schema it makes more sense to treat it as one entity as well.

Issue link

Fixes #464.
Fixes #108.

Proof

Some jsonschema errors in the form:

image

image


Code Checklist

  • All the commits in this PR are properly PGP-signed and verified;
  • This PR only contains functionality relevant to the issue; tickets have been created for newly discovered issues.
  • I have written unit tests for the changes or fixes I made.
  • For any non-trivial functionality, I have added integration and/or end-to-end tests.
  • I have performed a self-review of my code and refactored it to the best of my abilities.

Communication

  • I have informed others of any required .env changes files if required and changed the .env-dist accordingly.
  • I have made corresponding changes to the documentation, if necessary.

Checklist for code reviewers:

Copy-paste the checklist from the docs/source/templates folder into your comment.


Checklist for QA:

Copy-paste the checklist from the docs/source/templates folder into your comment.

@Donnype Donnype requested a review from a team as a code owner May 9, 2023 10:10
@Donnype Donnype changed the title Feature/full json support for settings Feature/better json support for settings May 9, 2023
@underdarknl
Copy link
Contributor

Nice! functionally this looks like a great step in the right direction.

@github-actions
Copy link
Contributor

github-actions bot commented May 10, 2023

File Coverage
All files 65%
bits/definitions.py 65%
bits/runner.py 56%
bits/https_availability/https_availability.py 93%
bits/oois_in_headers/oois_in_headers.py 57%
bits/spf_discovery/internetnl_spf_parser.py 55%
bits/spf_discovery/spf_discovery.py 72%
octopoes/api/api.py 58%
octopoes/api/models.py 75%
octopoes/api/router.py 46%
octopoes/core/app.py 80%
octopoes/core/service.py 44%
octopoes/events/events.py 96%
octopoes/events/manager.py 65%
octopoes/models/__init__.py 86%
octopoes/models/datetime.py 66%
octopoes/models/exception.py 83%
octopoes/models/origin.py 70%
octopoes/models/path.py 99%
octopoes/models/types.py 95%
octopoes/models/ooi/certificate.py 96%
octopoes/models/ooi/config.py 89%
octopoes/models/ooi/email_security.py 95%
octopoes/models/ooi/findings.py 94%
octopoes/models/ooi/network.py 97%
octopoes/models/ooi/service.py 91%
octopoes/models/ooi/software.py 71%
octopoes/models/ooi/web.py 81%
octopoes/models/ooi/dns/records.py 95%
octopoes/models/ooi/dns/zone.py 77%
octopoes/repositories/ooi_repository.py 39%
octopoes/repositories/origin_parameter_repository.py 53%
octopoes/repositories/origin_repository.py 52%
octopoes/repositories/scan_profile_repository.py 45%
octopoes/xtdb/client.py 49%
octopoes/xtdb/query_builder.py 69%
octopoes/xtdb/related_field_generator.py 71%
tests/conftest.py 88%
tests/integration/test_xtdb_client.py 34%

Minimum allowed coverage is 75%

Generated by 🐒 cobertura-action against 9190bea

ammar92
ammar92 previously approved these changes May 17, 2023
Copy link
Contributor

@ammar92 ammar92 left a comment

Choose a reason for hiding this comment

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

Looks good I don't have much to say except other than that single linter suppression

rocky/katalogus/forms/plugin_settings.py Outdated Show resolved Hide resolved
@Darwinkel
Copy link
Contributor

Checklist for QA:

  • I have checked out this branch, and successfully ran a fresh make reset.
  • I confirmed that there are no unintended functional regressions in this branch:
    • I have managed to pass the onboarding flow
    • Objects and Findings are created properly
    • Tasks are created and completed properly
  • I confirmed that the PR's advertised feature or hotfix works as intended.

What works:

  • Integer validation works on the nmap boefje
    image
    image

What doesn't work:

  • When a string is entered in the integer field, a success message is given but the field becomes Unset
    image
    image

@Donnype
Copy link
Contributor Author

Donnype commented May 17, 2023

@Darwinkel Firefox seems to send empty strings when you pass text in a number field. (Chromium does not allow text, although you can bypass that.) So I guess this is expected behavior? Also because one of the (optional) fields is actually being set?

@Darwinkel
Copy link
Contributor

@Darwinkel Firefox seems to send empty strings when you pass text in a number field. (Chromium does not allow text, although you can bypass that.) So I guess this is expected behavior? Also because one of the (optional) fields is actually being set?

Fair point. Would it be much work to add a new error message for when text is somehow passed to a number field (or a similar situation)?

@Donnype
Copy link
Contributor Author

Donnype commented May 24, 2023

@Darwinkel When actual text is passed to a number field you do see a message of the kind "Enter a whole number" (also see the test cases).

@praseodym praseodym changed the title Feature/better json support for settings Better JSON schema support for plugin settings May 25, 2023
@Donnype Donnype changed the title Better JSON schema support for plugin settings Better JSON schema support for plugin settings in Rocky May 30, 2023
@dekkers dekkers merged commit 25ee2cd into main Jun 1, 2023
@dekkers dekkers deleted the feature/full-json-support-for-settings branch June 1, 2023 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update settings support in Katalogus/Rocky to json Boefje settings integer handling
5 participants