[Notes] [Git][BuildStream/buildstream][jennis/less_restrictive_pathways] _yaml.py: Do not be too restrictive in our pathway checks



Title: GitLab

James Ennis pushed to branch jennis/less_restrictive_pathways at BuildStream / buildstream

Commits:

3 changed files:

Changes:

  • buildstream/_yaml.py
    ... ... @@ -475,7 +475,7 @@ def node_get_project_path(node, key, project_dir, *,
    475 475
         is_inside = project_dir_path.resolve() in full_resolved_path.parents or (
    
    476 476
             full_resolved_path == project_dir_path)
    
    477 477
     
    
    478
    -    if path.is_absolute() or not is_inside:
    
    478
    +    if not is_inside:
    
    479 479
             raise LoadError(LoadErrorReason.PROJ_PATH_INVALID,
    
    480 480
                             "{}: Specified path '{}' must not lead outside of the "
    
    481 481
                             "project directory"
    

  • tests/sources/local.py
    ... ... @@ -43,21 +43,21 @@ def test_non_regular_file_or_directory(cli, tmpdir, datafiles):
    43 43
     
    
    44 44
     
    
    45 45
     @pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
    
    46
    -def test_invalid_absolute_path(cli, tmpdir, datafiles):
    
    46
    +def test_valid_absolute_path(cli, tmpdir, datafiles):
    
    47 47
         project = os.path.join(datafiles.dirname, datafiles.basename)
    
    48 48
     
    
    49 49
         with open(os.path.join(project, "target.bst"), 'r') as f:
    
    50 50
             old_yaml = f.read()
    
    51 51
     
    
    52
    -    new_yaml = old_yaml.replace("file.txt", os.path.join(project, "file.txt"))
    
    52
    +    new_yaml = old_yaml.replace("file.txt",
    
    53
    +                                os.path.abspath(os.path.join(project, "file.txt")))
    
    53 54
         assert old_yaml != new_yaml
    
    54 55
     
    
    55 56
         with open(os.path.join(project, "target.bst"), 'w') as f:
    
    56 57
             f.write(new_yaml)
    
    57 58
     
    
    58 59
         result = cli.run(project=project, args=['show', 'target.bst'])
    
    59
    -    result.assert_main_error(ErrorDomain.LOAD,
    
    60
    -                             LoadErrorReason.PROJ_PATH_INVALID)
    
    60
    +    result.assert_success()
    
    61 61
     
    
    62 62
     
    
    63 63
     @pytest.mark.datafiles(os.path.join(DATA_DIR, 'invalid-relative-path'))
    

  • tests/sources/patch.py
    ... ... @@ -41,21 +41,20 @@ def test_non_regular_file_patch(cli, tmpdir, datafiles):
    41 41
     
    
    42 42
     
    
    43 43
     @pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
    
    44
    -def test_invalid_absolute_path(cli, tmpdir, datafiles):
    
    44
    +def test_valid_absolute_path(cli, tmpdir, datafiles):
    
    45 45
         project = os.path.join(datafiles.dirname, datafiles.basename)
    
    46 46
     
    
    47 47
         with open(os.path.join(project, "target.bst"), 'r') as f:
    
    48 48
             old_yaml = f.read()
    
    49 49
         new_yaml = old_yaml.replace("file_1.patch",
    
    50
    -                                os.path.join(project, "file_1.patch"))
    
    50
    +                                os.path.abspath(os.path.join(project, "file_1.patch")))
    
    51 51
         assert old_yaml != new_yaml
    
    52 52
     
    
    53 53
         with open(os.path.join(project, "target.bst"), 'w') as f:
    
    54 54
             f.write(new_yaml)
    
    55 55
     
    
    56 56
         result = cli.run(project=project, args=['show', 'target.bst'])
    
    57
    -    result.assert_main_error(ErrorDomain.LOAD,
    
    58
    -                             LoadErrorReason.PROJ_PATH_INVALID)
    
    57
    +    result.assert_success()
    
    59 58
     
    
    60 59
     
    
    61 60
     @pytest.mark.datafiles(os.path.join(DATA_DIR, 'invalid-relative-path'))
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]