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

Add Workflow module to Wazuh-qa repository #4990

Conversation

fcaffieri
Copy link
Member

Description

The objective of the PR is to incorporate the DTT Workflow module into the QA repository.

Related to: #4905


Testing performed

All test in: #4910

@fcaffieri fcaffieri self-assigned this Feb 20, 2024
@fcaffieri fcaffieri linked an issue Feb 20, 2024 that may be closed by this pull request
2 tasks
QU3B1M
QU3B1M previously approved these changes Feb 21, 2024
Copy link
Member

@QU3B1M QU3B1M left a comment

Choose a reason for hiding this comment

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

LGTM

pro-akim
pro-akim previously approved these changes Feb 21, 2024
Copy link
Member

@pro-akim pro-akim left a comment

Choose a reason for hiding this comment

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

Review Notes

LGTM

@fcaffieri fcaffieri dismissed stale reviews from pro-akim and QU3B1M via a9a815f February 21, 2024 15:08
Copy link
Member

@rauldpm rauldpm left a comment

Choose a reason for hiding this comment

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

GJ, some changes

deployability/modules/setup.py Outdated Show resolved Hide resolved
deployability/modules/workflow_engine/README.md Outdated Show resolved Hide resolved
@fcaffieri fcaffieri requested a review from rauldpm February 21, 2024 15:52
rauldpm
rauldpm previously approved these changes Feb 21, 2024
Copy link
Member

@rauldpm rauldpm left a comment

Choose a reason for hiding this comment

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

LGTM

script_path = os.path.dirname(__file__)
rel_path = "../version.json"
abs_file_path = os.path.join(script_path, rel_path)
f = open(abs_file_path)
Copy link
Member

Choose a reason for hiding this comment

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

Always use a with statement to open files, ensuring an appropriate context handling

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in c9e7911

from setuptools import setup, find_packages
import os

def get_files_from_directory(directory):
Copy link
Member

Choose a reason for hiding this comment

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

This may lead to including unwanted files (like temporary or binary files) in the distribution package. It's generally better to specify only the types of files we need explicitly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in c9e7911

paths = []
for (path, directories, filenames) in os.walk(directory):
for filename in filenames:
paths.append(os.path.join('..', path, filename))
Copy link
Member

Choose a reason for hiding this comment

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

We are assuming the package's structure relative to where the setup script is run, which can vary and not work as expected while packaging. We need to consider using a more predictable method to specify package data instead of ../

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in c9e7911


def get_version():
script_path = os.path.dirname(__file__)
rel_path = "../version.json"
Copy link
Member

Choose a reason for hiding this comment

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

We always need to add appropriate exception handling, if the version.json file doesn't exist or contains invalid JSON it will lead to a runtime error without proper handling.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in c9e7911


class ThreadIDFilter(logging.Filter):
"""
A filter that uppercases the name of the log record.
Copy link
Member

Choose a reason for hiding this comment

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

This seems wrong based on the function below

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in c9e7911

"""
A filter that uppercases the name of the log record.
"""
def filter(self, record: str) -> bool:
Copy link
Member

Choose a reason for hiding this comment

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

The str type hint is incorrect, it should be logging.LogRecord

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in c9e7911

bool: True if the record should be logged, False otherwise.
"""
record.thread_id = threading.get_native_id()
return record
Copy link
Member

Choose a reason for hiding this comment

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

This is not returning a bool but the record itself

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in c9e7911


def _load_config() -> None:
"""
Loads the logging configuration from 'config.yaml' file.
Copy link
Member

Choose a reason for hiding this comment

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

Add error handling around the file reading and YAML parsing process. If the config.yaml file is missing, corrupt, or contains invalid YAML, the application should handle this gracefully, possibly falling back to a default logging configuration.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in c9e7911

@@ -0,0 +1,3 @@
# Copyright (C) 2015, Wazuh Inc.
Copy link
Member

Choose a reason for hiding this comment

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

What is this empty file?

Copy link
Member Author

Choose a reason for hiding this comment

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

This file is not used for the Workflow, it is dragged in case it is required at some point, but at the moment it is not necessary and was eliminated in 39e5f11.

@davidjiglesias davidjiglesias merged commit eaad054 into 4.9.0 Mar 4, 2024
2 checks passed
@davidjiglesias davidjiglesias deleted the 4989-dtt1-iteration-3-workflow-engine-module-release-workflow-module branch March 4, 2024 07:05
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.

DTT1 - Iteration 3 - WorkFlow engine module - Release Workflow module
5 participants