Merge branch 'fix/install_input_validation' into 'master'

fix(idf_tools): Validate input features

Closes IDF-11703

See merge request espressif/esp-idf!37852
This commit is contained in:
Roland Dobai
2025-03-19 21:38:52 +08:00
2 changed files with 22 additions and 9 deletions

View File

@@ -1783,14 +1783,24 @@ def process_and_check_features(idf_env_obj: IDFEnv, features_str: str) -> List[s
"""
new_features = []
remove_features = []
for new_feature_candidate in features_str.split(','):
invalid_features = []
for new_feature_candidate in [feature for feature in features_str.split(',') if feature != '']:
# Feature to be added/removed needs to be checked if valid
sanitized_feat = new_feature_candidate.lstrip('-+')
if not os.path.isfile(feature_to_requirements_path(sanitized_feat)):
invalid_features += [sanitized_feat]
continue
if new_feature_candidate.startswith('-'):
remove_features += [new_feature_candidate.lstrip('-')]
else:
new_feature_candidate = new_feature_candidate.lstrip('+')
# Feature to be added needs to be checked if is valid
if os.path.isfile(feature_to_requirements_path(new_feature_candidate)):
new_features += [new_feature_candidate]
new_features += [new_feature_candidate.lstrip('+')]
if invalid_features:
fatal(f'The following selected features are not valid: {", ".join(invalid_features)}')
raise SystemExit(1)
idf_env_obj.get_active_idf_record().update_features(tuple(new_features), tuple(remove_features))
return idf_env_obj.get_active_idf_record().features