mirror of
https://github.com/wazuh/wazuh-indexer-plugins.git
synced 2025-12-10 00:28:51 -06:00
Fix verify_integrations script to read the integrations from module_list.txt (#640)
* Fix verify_integrations script to read the integrations from module_list.txt * Add Changelog entry --------- Co-authored-by: Álex Ruiz Becerra <alejandro.ruiz.becerra@wazuh.com>
This commit is contained in:
parent
9210a1e07c
commit
c409e6465c
@ -69,6 +69,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
- Update event generators [(#505)](https://github.com/wazuh/wazuh-indexer-plugins/pull/505)
|
||||
- Update `DEVELOPER_GUIDE.md` to use JDK 21 [(#538)](https://github.com/wazuh/wazuh-indexer-plugins/pull/538)
|
||||
- Fix WCS generator modules detection issues [(#620)](https://github.com/wazuh/wazuh-indexer-plugins/pull/620)
|
||||
- Fix verify_integrations script to read the integrations from module_list.txt [(#640)](https://github.com/wazuh/wazuh-indexer-plugins/pull/640)
|
||||
|
||||
### Security
|
||||
- Reduce risk of GITHUB_TOKEN exposure [(#484)](https://github.com/wazuh/wazuh-indexer-plugins/pull/484)
|
||||
|
||||
@ -36,13 +36,23 @@ def verify_integration_structure(base_path, integration_name):
|
||||
fields_path / "template-settings.json",
|
||||
fields_path / "template-settings-legacy.json",
|
||||
fields_path / "mapping-settings.json",
|
||||
custom_path / f"{integration_name}.yml"
|
||||
]
|
||||
|
||||
# For custom files, accept any .yml file inside fields/custom
|
||||
custom_yaml_files = []
|
||||
if custom_path.exists() and custom_path.is_dir():
|
||||
for p in custom_path.iterdir():
|
||||
if p.is_file() and p.suffix.lower() == '.yml':
|
||||
custom_yaml_files.append(p)
|
||||
|
||||
missing_files = []
|
||||
for file_path in required_files:
|
||||
if not file_path.exists():
|
||||
missing_files.append(str(file_path.relative_to(integration_path)))
|
||||
|
||||
# If no custom yml files found, mark the expected custom file as missing
|
||||
if not custom_yaml_files:
|
||||
missing_files.append(str((custom_path / f"{integration_name}.yml").relative_to(integration_path)))
|
||||
|
||||
# Validate JSON files are valid
|
||||
json_errors = []
|
||||
@ -54,9 +64,10 @@ def verify_integration_structure(base_path, integration_name):
|
||||
except json.JSONDecodeError as e:
|
||||
json_errors.append(f"{json_file.name}: {e}")
|
||||
|
||||
# Validate YAML files are valid
|
||||
# Validate YAML files are valid (subset + any custom YAML files)
|
||||
yaml_errors = []
|
||||
yaml_files = [fields_path / "subset.yml", custom_path / f"{integration_name}.yml"]
|
||||
yaml_files = [fields_path / "subset.yml"]
|
||||
yaml_files.extend(custom_yaml_files)
|
||||
for yaml_file in yaml_files:
|
||||
if yaml_file.exists():
|
||||
try:
|
||||
@ -78,24 +89,45 @@ def verify_integration_structure(base_path, integration_name):
|
||||
|
||||
def main():
|
||||
"""Main verification function."""
|
||||
base_path = Path(".")
|
||||
# Use the directory where this script lives as the base path so
|
||||
# module_list.txt (which resides in the ecs/ folder) is found
|
||||
base_path = Path(__file__).parent.resolve()
|
||||
|
||||
print("🔍 Verifying WCS Integration Generator Output")
|
||||
print("=" * 50)
|
||||
|
||||
# Find all stateless integration folders
|
||||
integration_folders = [d for d in base_path.glob("stateless/*") if d.is_dir() and d.name != "stateless/template"]
|
||||
|
||||
if not integration_folders:
|
||||
print("❌ No integration folders found!")
|
||||
# Read stateless integrations from module_list.txt (keys inside [ ])
|
||||
module_list_path = base_path / "module_list.txt"
|
||||
integration_names = []
|
||||
if module_list_path.exists():
|
||||
try:
|
||||
with open(module_list_path, 'r') as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
# match lines like [stateless/foo]=templates/...
|
||||
if line.startswith('[') and ']' in line:
|
||||
key = line.split(']')[0].lstrip('[').strip()
|
||||
if key.startswith('stateless/') and key != 'stateless/template':
|
||||
# store the full key (e.g. stateless/access-management)
|
||||
integration_names.append(key)
|
||||
except Exception as e:
|
||||
print(f"❌ Error reading module_list.txt: {e}")
|
||||
else:
|
||||
print("❌ module_list.txt not found, falling back to filesystem glob")
|
||||
integration_folders = [d for d in base_path.glob("stateless/*") if d.is_dir() and d.name != "template"]
|
||||
integration_names = [f"stateless/{d.name}" for d in sorted(integration_folders)]
|
||||
|
||||
if not integration_names:
|
||||
print("❌ No stateless integrations found in module_list.txt or filesystem!")
|
||||
return
|
||||
|
||||
print(f"Found {len(integration_folders)} integration folders")
|
||||
|
||||
|
||||
print(f"Found {len(integration_names)} stateless integrations")
|
||||
|
||||
# Verify each integration
|
||||
results = []
|
||||
for folder in sorted(integration_folders):
|
||||
integration_name = folder.name.replace("stateless/", "")
|
||||
for key in sorted(integration_names):
|
||||
# key is like 'stateless/access-management' -> extract name after slash
|
||||
integration_name = key.split('/', 1)[1]
|
||||
result = verify_integration_structure(base_path, integration_name)
|
||||
results.append(result)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user