Skip to content

Commit

Permalink
Make sure we validate specified hash in app.yaml matches with dir's a…
Browse files Browse the repository at this point in the history
…ctual hash
  • Loading branch information
sonicaj committed May 10, 2024
1 parent e3ea8ff commit 88f7dea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions apps_validation/validation/validate_app_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from apps_validation.exceptions import ValidationErrors
from catalog_reader.app_utils import get_app_basic_details
from catalog_reader.hash_utils import get_hash_of_directory
from catalog_reader.names import get_base_library_dir_name_from_version
from catalog_reader.questions_util import CUSTOM_PORTALS_KEY

Expand Down Expand Up @@ -67,6 +68,8 @@ def validate_catalog_item_version(
)
elif not base_lib_dir.is_dir():
verrors.add(f'{schema}.lib_version', f'{base_lib_dir!r} is not a directory')
elif get_hash_of_directory(str(base_lib_dir)) != app_basic_details['lib_version_hash']:
verrors.add(f'{schema}.lib_version', 'Library version hash does not match with the actual library version')

questions_path = os.path.join(version_path, 'questions.yaml')
if os.path.exists(questions_path):
Expand Down
2 changes: 1 addition & 1 deletion catalog_reader/app_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def get_app_basic_details(app_path: str) -> dict:
with contextlib.suppress(FileNotFoundError, yaml.YAMLError, KeyError):
with open(os.path.join(app_path, 'app.yaml'), 'r') as f:
app_config = yaml.safe_load(f.read())
return {'lib_version': app_config.get('lib_version')} | {
return {k: app_config.get(k) for k in ('lib_version', 'lib_version_hash')} | {
k: app_config[k] for k in ('name', 'train', 'version')
}

Expand Down

0 comments on commit 88f7dea

Please sign in to comment.