kleya 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/kleya/artifact.rb +2 -0
- data/test/artifact_test.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3637aa608ae5b732ac331b301d73342c352e89b51cf9cca1539949bf696cb967
|
|
4
|
+
data.tar.gz: 407dffe786eded0e8d1b4936cfd2d3746df84b553b8cc67487e49aaf1482a9c1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fbe9b5a622435673de2a6491bf459811e047d777aaeb907c63ee047dcb57db38880dd2962ddfb550480d49094aa770732f47653cbd0eb4e5f7fea5c9b028d256
|
|
7
|
+
data.tar.gz: c874c21a1523e2df494c4e9d413bb7ab7c564dfe96a0422b937054e7d37d481d62b8b39a896adad0e979afaa51bb888a3008c655c35cd1fdabd732c6ca459b27
|
data/lib/kleya/artifact.rb
CHANGED
|
@@ -35,6 +35,8 @@ module Kleya
|
|
|
35
35
|
# @param path [String] the path to save the artifact
|
|
36
36
|
# @return [String] the full path where the file was saved
|
|
37
37
|
def save(path = nil)
|
|
38
|
+
raise ArgumentError, 'path cannot contain parent directory traversal' if path.to_s.split(/[\\\/]/).include?('..')
|
|
39
|
+
|
|
38
40
|
if path.nil?
|
|
39
41
|
path = filename
|
|
40
42
|
elsif File.directory?(path)
|
data/test/artifact_test.rb
CHANGED
|
@@ -36,6 +36,12 @@ class ArtifactTest < Minitest::Test
|
|
|
36
36
|
assert File.exist?('appends_extension.jpeg')
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
+
def test_artifact_save_rejects_parent_directory_traversal
|
|
40
|
+
error = assert_raises(ArgumentError) { @artifact.save('../escaped') }
|
|
41
|
+
|
|
42
|
+
assert_equal('path cannot contain parent directory traversal', error.message)
|
|
43
|
+
end
|
|
44
|
+
|
|
39
45
|
def test_artifact_base64
|
|
40
46
|
assert_equal(Base64.encode64('test'), @artifact.base64)
|
|
41
47
|
end
|