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

Unify 4.3.0 and master's regex used in the API query parameter #13369

Closed
13 tasks done
mcarmona99 opened this issue May 5, 2022 · 1 comment · Fixed by #13386
Closed
13 tasks done

Unify 4.3.0 and master's regex used in the API query parameter #13369

mcarmona99 opened this issue May 5, 2022 · 1 comment · Fixed by #13386
Assignees

Comments

@mcarmona99
Copy link
Contributor

mcarmona99 commented May 5, 2022

This issue aims to unify the 2 regexes used by the API query parameter in the current Wazuh 4.3 and master branches.

For the 4.3 version, in this pull request, we added the possibility to have strings in brackets after the main string of the value string itself:

4.3 query regex:

(\()?([\w.]+)([=!=<>~]{1,2})((?:[\[\]\w _\-.:\\/']+(?:\([\[\]\w _\-.:\\/']*\))*)+)(\))?([,;])?

image

For master, in this pull request, we added the possibility to have lists and links in the value string (among more characters):

master query regex:

(\()?([\w.]+)([=!=<>~]{1,2})(\[[\[\]\w _\-.,:?\\/'\"=@%<>]+]|[\[\]\w _\-.:?\\/'\"=@%<>]+ )(\))?([,;])?

image

Note that we should also update the corresponding framework unit tests.

Checks

wazuh/wazuh

  • Unit tests without failures. Updated and/or expanded if there are new functions/methods/outputs:
    • Cluster (framework/wazuh/core/cluster/tests/ & framework/wazuh/core/cluster/dapi/tests/)
    • Core (framework/wazuh/core/tests/)
    • SDK (framework/wazuh/tests/)
    • RBAC (framework/wazuh/rbac/tests/)
    • API (api/api/tests/)
  • API tavern integration tests without failures. Updated and/or expanded if needed (api/test/integration/):
    • Affected tests
    • Affected RBAC (black and white) tests
  • Review integration test mapping using the script (api/test/integration/mapping/integration_test_api_endpoints.json)
  • Review of spec.yaml examples and schemas (api/api/spec/spec.yaml)
  • Review exceptions remediation when any endpoint path changes or is removed (framework/wazuh/core/exception.py)
  • Changelog (CHANGELOG.md)

wazuh/wazuh-documentation

  • Migration from 3.X for changed endpoints (source/user-manual/api/equivalence.rst)
  • Update RBAC reference with new/modified actions/resources/relationships (source/user-manual/api/rbac/reference.rst)
@mcarmona99
Copy link
Contributor Author

Issue update

The parts of the query regexes that we have to unify are the ones corresponding to the capturing group representing the value:

(\[[\[\]\w _\-.,:?\\/'\"=@%<>]+]|[\[\]\w _\-.:?\\/'\"=@%<>]+)

and

((?:[\[\]\w _\-.:\\/']+(?:\([\[\]\w _\-.:\\/']*\))*)+)

The following regex can be used for the value parsing and unifies the previous regexes. Apart from unifying, I have also add the possibility to have parentheses before the value string (for example, name=(something) String). This was not possible before as brackets were only possible after the main string.

I have also modified the master's query regex as empty lists could not be parsed: []

((?:(?:\((?:\[[\[\]\w _\-.,:?\\/'\"=@%<>]*]|[\[\]\w _\-.:?\\/'\"=@%<>]*)\))*(?:\[[\[\]\w _\-.,:?\\/'\"=@%<>]*]|[\[\]\w _\-.:?\\/'\"=@%<>]+)(?:\((?:\[[\[\]\w _\-.,:?\\/'\"=@%<>]*]|[\[\]\w _\-.:?\\/'\"=@%<>]*)\))*)+)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants