max icon indicating copy to clipboard operation
max copied to clipboard

[Magic CLI] Magic does not sanitize disallowed environment names

Open DWSimmons opened this issue 1 year ago • 2 comments

Not sure if this is a Pixi or Magic thing, but environment names request "only lower case letters, numbers and dashes". Oddly/interestingly, one can add them and then they can't use magic to remove them...

Steps to reproduce: create a project add an environment with invalid characters and be allowed to do it be unable to either enter shell or remove the environment because of the magic (necessary) mechanics [edit toml file manually to undo the issue]

darin@home:/media/darin/M2/magic$ magic init underscores_ --mojoproject
✔ Created /media/darin/M2/magic/underscores_/mojoproject.toml
✔ Added max >=24.5.0,<25
darin@home:/media/darin/M2/magic$ cd underscores_/
darin@home:/media/darin/M2/magic/underscores_$ magic project environment add foo_
✔ Added environment foo_
darin@home:/media/darin/M2/magic/underscores_$ magic s
  × failed to parse project manifest
    ╭─[pixi.toml:14:1]
 13 │ [environments]
 14 │ foo_ = []
    · ──┬─
    ·   ╰── Failed to parse environment name 'foo_', please use only lowercase letters, numbers and dashes
    ╰────

darin@home:/media/darin/M2/magic/underscores_$ magic project environment remove foo_
  × failed to parse project manifest
    ╭─[pixi.toml:14:1]
 13 │ [environments]
 14 │ foo_ = []
    · ──┬─
    ·   ╰── Failed to parse environment name 'foo_', please use only lowercase letters, numbers and dashes
    ╰────
darin@home:/media/darin/M2/magic/underscores_$ magic --version
magic 0.3.1 - (based on pixi 0.29.0)

Steps to fix: add sanitation check to magic project environment add or loosen requirements

DWSimmons avatar Oct 08 '24 20:10 DWSimmons