diff --git a/modelscope/cli/plugins.py b/modelscope/cli/plugins.py index 218bc160..7b4d500b 100644 --- a/modelscope/cli/plugins.py +++ b/modelscope/cli/plugins.py @@ -11,7 +11,7 @@ plugins_manager = PluginsManager() class PluginsCMD(CLICommand): - name = 'plugin' + name = 'plugins' @staticmethod def register(subparsers: ArgumentParser) -> None: diff --git a/modelscope/hub/api.py b/modelscope/hub/api.py index 356e7a42..ab39a015 100644 --- a/modelscope/hub/api.py +++ b/modelscope/hub/api.py @@ -90,9 +90,19 @@ class HubApi(_LegacyHubApi): # ------------------------------------------------------------------ # Legacy method shims missing from LegacyHubApi # ------------------------------------------------------------------ - def create_model(self, model_id: str, **kwargs) -> None: - """Create a model repo — delegates to ``create_repo`` (model type).""" - return self.create_repo(model_id, repo_type='model', **kwargs) + def create_model(self, model_id: str, **kwargs) -> str: + """Create a model repo — delegates to ``create_repo`` (model type). + + Returns the model repository URL for backward compatibility. + Authentication errors are converted to ``ValueError`` by the compat layer. + """ + # LegacyHubApi.create_model handles exception conversion; + # override endpoint in the returned URL with local self.endpoint. + result = super().create_model(model_id, **kwargs) + # Replace endpoint in URL with the one resolved at __init__ time + if result and self.endpoint and self.endpoint not in result: + return f'{self.endpoint}/models/{model_id}' + return result def get_model_url(self, model_id: str) -> str: """Return the model page URL ``{endpoint}/{model_id}``.""" diff --git a/modelscope/utils/automodel_utils.py b/modelscope/utils/automodel_utils.py index 7b78309c..8acec9f5 100644 --- a/modelscope/utils/automodel_utils.py +++ b/modelscope/utils/automodel_utils.py @@ -147,10 +147,12 @@ def check_model_from_owner_group(model_dir: str, if group in owner_group: return True # Also check cache path pattern: {cache_root}/{owner}--{model_name}/snapshots/{revision} - # Only check the grandparent directory to avoid path traversal attacks + # Require exactly "{owner}--{name}" format (2 segments split by --) + # to prevent spoofing via accounts like "iic--hacked" which would + # produce paths like "iic--hacked--evil" and bypass the check. grandparent = os.path.basename(os.path.dirname(parent_dir)) if '--' in grandparent: - prefix = grandparent.split('--', 1)[0] - if prefix in owner_group: + parts = grandparent.split('--') + if len(parts) == 2 and parts[0] in owner_group: return True return False diff --git a/pyproject.toml b/pyproject.toml index 96994d40..0b620f96 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,7 @@ plugins = "modelscope.cli.plugins:PluginsCMD" skills = "modelscope.cli.skills:SkillsCMD" llamafile = "modelscope.cli.llamafile:LlamafileCMD" modelcard = "modelscope.cli.modelcard:ModelCardCMD" +studio = "modelscope.cli.studio:StudioCMD" [build-system] requires = ["setuptools>=69", "wheel"]