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

Update usage of GET /groups/{group_id}/files/{file_name}/- json/xml #6385

Conversation

JuanGarriuz
Copy link
Member

@JuanGarriuz JuanGarriuz commented Feb 6, 2024

Description

The following endpoints have been refactored:

GET /groups/{group_id}/files/{file_name}/json
GET /groups/{group_id}/files/{file_name}/xml

Therefore, a revision in the code to properly manage them has been necessary.

The change to the endpoints has been to remove the extension from the path and replace it with a raw variable, making it so that if the variable is set to true, it will return the response structured as an XML; if the parameter is not added, it will return the response as a JSON.

Within the front-end structure, no endpoint needs a JSON structure, so I have added the parameter raw=true as the default. This is reflected in the file plugins/main/public/controllers/management/components/management/groups/utils/groups-handler.js, in the function getFileContent.

Issues Resolved

Update usage of GET /groups/{group_id}/files/{file_name}/json and GET /groups/{group_id}/files/{file_name}/XML

Evidence

Evidence.mp4

Test

To generate a manager that works correctly, it will be necessary to use the master branch. For this, you can include this code in the dev.yml.

wazuh-manager-master:
    build:
      context: /PATH/TO/OLD_ENVIRONMENTS/images/wazuh_manager_filebeat_sources_cmake
      args:
        WAZUH_VERSION: 'master'
        FILEBEAT_VERSION: '7.10.2'
        FILEBEAT_WAZUH_TEMPLATE_URL: https://raw.githubusercontent.com/wazuh/wazuh/master/extensions/elasticsearch/7.x/wazuh-template.json
        FILEBEAT_WAZUH_MODULE_URL: https://packages.wazuh.com/4.x/filebeat/wazuh-filebeat-0.2.tar.gz
    image: wazuh-manager:master-7.10.2
    hostname: wazuh-manager-master-7102
    volumes:
      - '/PATH/TO/OLD_ENVIRONMENTS/config/filebeat/filebeat.odfe.yml:/etc/filebeat/filebeat.yml'
    ports:
      - '514:514'
      - '1514:1514'
      - '1515:1515'
      - '1516:1516'
      - '55000:55000'
    depends_on:
      - os1
    environment:
      NODE_IP: wazuh-manager-master
      NODE_NAME: manager-node
      NODE_TYPE: master
    networks:
      - os-dev

The files located in /wazuh_manager_filebeat_sources_cmake should be replaced with the following ones:

master-manager-enviroment.zip

  • Check that all the edit and view options of endpoint groups function by displaying agent.conf

Check List

  • All tests pass
    • yarn test:jest
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

@JuanGarriuz JuanGarriuz self-assigned this Feb 8, 2024
@JuanGarriuz JuanGarriuz linked an issue Feb 8, 2024 that may be closed by this pull request
2 tasks
@JuanGarriuz JuanGarriuz changed the base branch from master to 4.9.0 February 13, 2024 09:27
@JuanGarriuz JuanGarriuz marked this pull request as ready for review February 13, 2024 11:40
@JuanGarriuz JuanGarriuz requested a review from a team as a code owner February 13, 2024 11:40
Tostti
Tostti previously approved these changes Feb 21, 2024
Copy link
Member

@Tostti Tostti left a comment

Choose a reason for hiding this comment

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

Test

Video_2024-02-21_11-29-28.mp4

Test ✅
CR ✅

LGTM

Copy link
Member

@asteriscos asteriscos left a comment

Choose a reason for hiding this comment

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

CR: 🔴
We should delete commented code.
Missing changelog.

Test: 🟢

Peek 2024-02-28 18-36

# Get a file in group
- method: GET
path: /groups/{group_id}/files/{file_name}/json
# # Get a file in group
Copy link
Member

Choose a reason for hiding this comment

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

If this is not used I think we should remove it to avoid polluting the file.

asteriscos
asteriscos previously approved these changes Feb 29, 2024
Copy link
Contributor

Wazuh Core plugin code coverage (Jest) test % values
Statements 21.38% ( 176 / 823 )
Branches 19.45% ( 79 / 406 )
Functions 14.17% ( 36 / 254 )
Lines 21.57% ( 173 / 802 )

Copy link
Contributor

Wazuh Check Updates plugin code coverage (Jest) test % values
Statements 76.44% ( 172 / 225 )
Branches 58.65% ( 61 / 104 )
Functions 61.7% ( 29 / 47 )
Lines 76.44% ( 172 / 225 )

Copy link
Contributor

Main plugin code coverage (Jest) test % values
Statements 12.33% ( 4288 / 34757 )
Branches 8.08% ( 1855 / 22931 )
Functions 11.87% ( 988 / 8323 )
Lines 12.5% ( 4164 / 33290 )

Copy link
Member

@Tostti Tostti left a comment

Choose a reason for hiding this comment

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

LGTM

@Tostti Tostti merged commit 2ebaace into 4.9.0 Feb 29, 2024
4 checks passed
@Tostti Tostti deleted the feat/6381-update-usage-of-GET-/groups/{group_id}/files/{file_name} branch February 29, 2024 11:04
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 usage of refactored API endpoints
4 participants