[ARVADOS] created: 004243ab59e3a2fc36a708b66373297dd83e0b91
git at public.curoverse.com
git at public.curoverse.com
Tue Aug 4 18:20:04 EDT 2015
at 004243ab59e3a2fc36a708b66373297dd83e0b91 (commit)
commit 004243ab59e3a2fc36a708b66373297dd83e0b91
Author: radhika <radhika at curoverse.com>
Date: Tue Aug 4 18:19:14 2015 -0400
6277: enforce manifest validation
diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb
index cac25d1..99a09bd 100644
--- a/services/api/app/models/collection.rb
+++ b/services/api/app/models/collection.rb
@@ -9,7 +9,7 @@ class Collection < ArvadosModel
serialize :properties, Hash
before_validation :check_encoding
- before_validation :log_invalid_manifest_format
+ before_validation :check_manifest_validity
before_validation :check_signatures
before_validation :strip_signatures_and_update_replication_confirmed
validate :ensure_pdh_matches_manifest_text
@@ -193,13 +193,14 @@ class Collection < ArvadosModel
end
end
- def log_invalid_manifest_format
+ def check_manifest_validity
begin
- Keep::Manifest.validate! manifest_text if manifest_text
+ Keep::Manifest.validate! manifest_text
+ true
rescue => e
logger.warn e
+ false
end
- true
end
def signed_manifest_text
diff --git a/services/api/test/functional/arvados/v1/collections_controller_test.rb b/services/api/test/functional/arvados/v1/collections_controller_test.rb
index 1418f69..c521e59 100644
--- a/services/api/test/functional/arvados/v1/collections_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/collections_controller_test.rb
@@ -809,4 +809,23 @@ EOS
assert_not_nil json_response['uuid']
assert_equal 'value_1', json_response['properties']['property_1']
end
+
+ [
+ nil,
+ ". 0:0:foo.txt",
+ ". d41d8cd98f00b204e9800998ecf8427e foo.txt",
+ "d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt",
+ ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt",
+ ].each do |manifest_text|
+ test "create collection with invalid manifest #{manifest_text}" do
+ authorize_with :active
+ post :create, {
+ collection: {
+ manifest_text: manifest_text,
+ portable_data_hash: "d30fe8ae534397864cb96c544f4cf102+47"
+ }
+ }
+ assert_response 422
+ end
+ end
end
diff --git a/services/fuse/tests/test_mount.py b/services/fuse/tests/test_mount.py
index b930974..ff88837 100644
--- a/services/fuse/tests/test_mount.py
+++ b/services/fuse/tests/test_mount.py
@@ -32,8 +32,8 @@ class FuseMountTest(MountTestBase):
cw.write("data 1")
cw.start_new_file('thing2.txt')
cw.write("data 2")
- cw.start_new_stream('dir1')
+ cw.start_new_stream('dir1')
cw.start_new_file('thing3.txt')
cw.write("data 3")
cw.start_new_file('thing4.txt')
@@ -53,11 +53,11 @@ class FuseMountTest(MountTestBase):
cw.write("data 8")
cw.start_new_stream('edgecases')
- for f in ":/./../.../-/*/\x01\\/ ".split("/"):
+ for f in ":/.../-/*/\x01\\/ ".split("/"):
cw.start_new_file(f)
cw.write('x')
- for f in ":/../.../-/*/\x01\\/ ".split("/"):
+ for f in ":/.../-/*/\x01\\/ ".split("/"):
cw.start_new_stream('edgecases/dirs/' + f)
cw.start_new_file('x/x')
cw.write('x')
@@ -74,9 +74,9 @@ class FuseMountTest(MountTestBase):
self.assertDirContents('dir2', ['thing5.txt', 'thing6.txt', 'dir3'])
self.assertDirContents('dir2/dir3', ['thing7.txt', 'thing8.txt'])
self.assertDirContents('edgecases',
- "dirs/:/_/__/.../-/*/\x01\\/ ".split("/"))
+ "dirs/:/.../-/*/\x01\\/ ".split("/"))
self.assertDirContents('edgecases/dirs',
- ":/__/.../-/*/\x01\\/ ".split("/"))
+ ":/.../-/*/\x01\\/ ".split("/"))
files = {'thing1.txt': 'data 1',
'thing2.txt': 'data 2',
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list