Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #11625: sanitize invalidly named FS paths #2909

Merged
merged 6 commits into from Aug 26, 2014

Conversation

mtbc
Copy link
Member

@mtbc mtbc commented Aug 4, 2014

Fixes http://trac.openmicroscopy.org.uk/ome/ticket/11625 by partially reverting mtbc@34748dd. Now Python clients should be able to set FilesetEntry.clientPath to a /-separated but otherwise-hairy path (e.g., "/".join(dir.splitall())) and have the server fix the path at import time so as to sanitize it according to http://www.openmicroscopy.org/site/support/omero5.1-staging/sysadmins/fs-upload-configuration.html#legal-file-names. (ImportLibrary.createImport has ImportContainer.fillData do path sanitization but clients may import by other means.) The FilePathNamingValidator class, though now unused, may yet have further use and is very lovely, so remains in the codebase.
--no-rebase

basePath = basePath.transform(sanitizer);
int index = paths.size();
while (--index >= 0) {
paths.set(index, paths.get(index).transform(sanitizer));
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered if there was some nice Guava way to transform the elements of a collection (map (map f) ...) but I don't easily see one.

@joshmoore
Copy link
Member

Relaunched on 247. In general, patch seems like quite the easy fix. We likely have zero integration tests running on Windows so manual testing will be necessary.

@snoopycrimecop
Copy link
Member

Conflicting PR. Removed from build OME-5.1-merge-push#371. See the console output for more details.

@snoopycrimecop
Copy link
Member

Conflicting PR. Removed from build OME-5.1-merge-push#372. See the console output for more details.

@mtbc
Copy link
Member Author

mtbc commented Aug 6, 2014

If it helps any with testing the sanitization: One could hack ImportLibrary.createImport to construct a ClientFilePathTransformer with a Function<String, String> argument that simply returns the string it was given, that should disable the client-side sanitization so one can see how the server copes with a nasty path.

@bpindelski
Copy link

In the ImportLibrary.createImport() method I did

final ClientFilePathTransformer sanitizer = new ClientFilePathTransformer(new Function<String, String>() {
            public String apply(String string) {
                return string;
            }
        });

Then I used Insight and tried importing a file named //**``\\test11_R3D.dv. The import succeeds and the file path in the client is shown without changes, but in ManagedRepository the files is stored as xx;;xx``!!test11_R3D.dv. I presume this is expected behaviour. The same transformation happens with no changes to createImport().

Are there any other test cases I should try out? If not, then I'd presume this is good to merge.

@mtbc
Copy link
Member Author

mtbc commented Aug 6, 2014

Looks good, thank you.

@snoopycrimecop
Copy link
Member

Conflicting PR. Removed from build OME-5.1-merge-push#375. See the console output for more details.

@snoopycrimecop
Copy link
Member

Conflicting PR. Removed from build OME-5.1-merge-push#376. See the console output for more details.

@mtbc
Copy link
Member Author

mtbc commented Aug 7, 2014

Please kick travis for me.

@mtbc
Copy link
Member Author

mtbc commented Aug 7, 2014

Need to re-test this PR after merging in develop?

@joshmoore
Copy link
Member

Patch still looks quite simple and straight-forward, so no worries here. One question though: @bpindelski, did your testing occur on Windows?

@bpindelski
Copy link

@joshmoore No, the test was done on OS X.

@joshmoore
Copy link
Member

If I can be so rude, I really think this there needs to be some cross testing, though if @pwalczysko prefers to do that via a different build, we an merge and list this elsewhere. We simply don't have anything that does:

V server/client >  | *nix  | Windows
--------------------------------------
      *nix         |       |
--------------------------------------
   Windows         |       |  

/cc @sbesson

@bpindelski
Copy link

@joshmoore I can test this PR again tomorrow, as currently I don't have a Windows VM handy. Unless Petr beats me to it.

@mtbc
Copy link
Member Author

mtbc commented Aug 7, 2014

Which client/server combinations suffice? (Perhaps just Windows client to Unix server?) Also, should the cross-testing include @bpindelski's hack from #2909 (comment) in the client?

@pwalczysko
Copy link
Member

Well, I am not sure what is this about, but in a hope this would help I took a Windows Insight and imported some images into trout. It went fine.

@snoopycrimecop
Copy link
Member

Conflicting PR. Removed from build OME-5.1-merge-push#377. See the console output for more details.

@snoopycrimecop
Copy link
Member

Conflicting PR. Removed from build OME-5.1-merge-push#378. See the console output for more details.

@snoopycrimecop
Copy link
Member

Conflicting PR. Removed from build OME-5.1-merge-push#381. See the console output for more details.

@mtbc
Copy link
Member Author

mtbc commented Aug 8, 2014

@joshmoore is mostly worred about how /, \ get converted cross-platform. I would expect forbidden ones to be converted to !: for instance, importing a\b from a Unix client to a Windows server should result in a!b.

@mtbc
Copy link
Member Author

mtbc commented Aug 8, 2014

@bpindelski kindly determined that this PR's conflict is with #2884.

@bpindelski
Copy link

V server/client >  | *nix  | Windows
------------------------------------
      *nix         |   ✓   |   ✓
------------------------------------
   Windows         |   ✓   |   ✓

Notes:

  • Windows server/OS X client - tested using Windows\foo/bar\bizz/buzz.fake. In Windows OMERO.insight the displayed filename is Windows\foo:bar\bizz:buzz.fake and in ManagedRepository - Windows!foo;bar!bizz;buzz.fake
  • OS X server/Windows client - impossible to import anything with \ or / in the file name (Windows prohibits such file's existence; Insight prohibits adding such files to the import list).
  • Windows server/Windows client - again, NTFS doesn't allow for any funny characters in the file name, so not much testing possible.
  • OS X server/OS X client - tested using Windows\foo/bar\bizz/buzz.fake. In OS X OMERO.insight the displayed filename is Windows\foo:bar\bizz:buzz.fake and in ManagedRepository - Windows!foo;bar!bizz;buzz.fake

@joshmoore
Copy link
Member

💯 for the testing, @bpindelski!

…-sanitize-file-paths

Conflicts:
	components/blitz/src/ome/services/blitz/repo/ManagedRepositoryI.java
@bpindelski
Copy link

The last commit doesn't change anything on the code-path of file name sanitisation, so this is good to merge.

jburel added a commit that referenced this pull request Aug 26, 2014
fix #11625: sanitize invalidly named FS paths
@jburel jburel merged commit 8af67ea into ome:develop Aug 26, 2014
@mtbc mtbc deleted the trac-11625-sanitize-file-paths branch August 26, 2014 08:48
@sbesson sbesson added this to the 5.1.0-m1 milestone Oct 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants