Skip to content

Commit bf24ed0

Browse files
committed
fix
1 parent 65b7fe6 commit bf24ed0

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

.github/scripts/list-plugins-to-build-and-test.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22

33
import json
4+
import os
45
import subprocess
56
import argparse
67
from pathlib import Path
@@ -47,7 +48,12 @@ def add_package_info(packaging_file, build=True, test=True):
4748
test_dependencies = []
4849
rpm_file = packaging_dir / 'rpm.json'
4950
if rpm_file.exists():
50-
with open(rpm_file) as rf:
51+
packaging_base = os.path.realpath("packaging")
52+
rpm_file_real = os.path.realpath(rpm_file)
53+
if os.path.commonpath([packaging_base, rpm_file_real]) != packaging_base:
54+
raise Exception("Invalid file path")
55+
fd = os.open(rpm_file_real, os.O_RDONLY | os.O_NOFOLLOW)
56+
with os.fdopen(fd) as rf:
5157
rpm_data = json.load(rf)
5258
test_dependencies = [dependency for dependency in rpm_data.get('dependencies', []) if dependency.lower().startswith('centreon-plugin-')]
5359
if packaging['pkg_name'] not in list_plugins:

0 commit comments

Comments
 (0)