Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
erp5 erp5
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Labels
    • Labels
  • Merge requests 141
    • Merge requests 141
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Jobs
  • Commits
Collapse sidebar
  • nexedi
  • erp5erp5
  • Merge requests
  • !1519

Closed
Created Dec 02, 2021 by Vincent Pelletier@vpelletierOwner
  • Report abuse
Report abuse

erp5_web_service: Do not change working directory on remote.

  • Overview 6
  • Commits 1
  • Changes 1

Allowing callers to exit the path set on the connector seem wrong to me, was this intended ? So I would rather always construct absolute paths locally (which allows checking them) than let callers accidentally write out of the path configured on the connector. The intent being to have fewer surprises when we change the connector's base path.

Also, this saves one round-trip on every connection (although this is likely unnoticeable for most uses).

To illustrate the intended behaviour changes (using writeFile as it is the most complex use-case):

connector url code before after
sftp://example.com/ writeFile(path='bar', filename='baz.txt') /bar/baz.txt /bar/baz.txt
sftp://example.com/foo writeFile(path='bar', filename='baz.txt') /foo/bar/baz.txt /foo/bar/baz.txt
sftp://example.com/ writeFile(path='/bar', filename='baz.txt') /bar/baz.txt /bar/baz.txt
sftp://example.com/foo writeFile(path='/bar', filename='baz.txt') /bar/baz.txt ⚠ /foo/bar/baz.txt
sftp://example.com/ writeFile(path='../bar', filename='baz.txt') /bar/baz.txt /bar/baz.txt1
sftp://example.com/foo writeFile(path='../bar', filename='baz.txt') /bar/baz.txt ⚠ ValueError
sftp://example.com/ writeFile(path='bar', filename='/baz.txt') /baz.txt /bar/baz.txt2
sftp://example.com/foo writeFile(path='bar', filename='/baz.txt') /baz.txt ⚠ /foo/bar/baz.txt2
sftp://example.com/ writeFile(path='bar', filename='../baz.txt') /baz.txt /baz.txt2
sftp://example.com/foo writeFile(path='bar', filename='../baz.txt') /foo/baz.txt /foo/baz.txt2
sftp://example.com/ writeFile(path='bar', filename='../../baz.txt') /baz.txt /baz.txt2
sftp://example.com/foo writeFile(path='bar', filename='../../baz.txt') /baz.txt ⚠ ValueError

@kazuhiko @jerome @georgios.dagkakis @aurel

  1. I would prefer to raise ValueError here, but the detection code would be quite complex just for this case... ↩

  2. The desirable behaviour in these cases is unclear to me... Is caller responsible of providing non-conflicting arguments ? ↩

Edited Dec 02, 2021 by Vincent Pelletier
Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: sftp_relpath
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7