cifrado 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (361) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.gitignore +18 -0
  3. data/CHANGELOG.md +44 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +247 -0
  7. data/RELEASE.md +10 -0
  8. data/Rakefile +21 -0
  9. data/TODO.md +6 -0
  10. data/bin/cifrado +7 -0
  11. data/cifrado.gemspec +31 -0
  12. data/gem-public_cert.pem +20 -0
  13. data/lib/cifrado.rb +48 -0
  14. data/lib/cifrado/cli.rb +140 -0
  15. data/lib/cifrado/cli/cinema.rb +81 -0
  16. data/lib/cifrado/cli/delete.rb +36 -0
  17. data/lib/cifrado/cli/download.rb +54 -0
  18. data/lib/cifrado/cli/jukebox.rb +94 -0
  19. data/lib/cifrado/cli/list.rb +64 -0
  20. data/lib/cifrado/cli/post.rb +10 -0
  21. data/lib/cifrado/cli/progressbar.rb +86 -0
  22. data/lib/cifrado/cli/saio.rb +11 -0
  23. data/lib/cifrado/cli/saio/base.rb +20 -0
  24. data/lib/cifrado/cli/saio/bootstrap.rb +118 -0
  25. data/lib/cifrado/cli/saio/destroy.rb +16 -0
  26. data/lib/cifrado/cli/saio/scripts/saio.sh.erb +445 -0
  27. data/lib/cifrado/cli/set_acl.rb +10 -0
  28. data/lib/cifrado/cli/setup.rb +64 -0
  29. data/lib/cifrado/cli/stat.rb +41 -0
  30. data/lib/cifrado/cli/upload.rb +269 -0
  31. data/lib/cifrado/config.rb +18 -0
  32. data/lib/cifrado/core_ext/ruby18_base64.rb +15 -0
  33. data/lib/cifrado/crypto_services.rb +218 -0
  34. data/lib/cifrado/file_splitter.rb +67 -0
  35. data/lib/cifrado/rate_limit.rb +23 -0
  36. data/lib/cifrado/streaming_downloader.rb +49 -0
  37. data/lib/cifrado/streaming_uploader.rb +57 -0
  38. data/lib/cifrado/swift_client.rb +313 -0
  39. data/lib/cifrado/utils.rb +59 -0
  40. data/lib/cifrado/version.rb +3 -0
  41. data/tests/cli/list_tests.rb +28 -0
  42. data/tests/cli/upload_multi_tests.rb +94 -0
  43. data/tests/cli/upload_tests.rb +167 -0
  44. data/tests/cli_tests.rb +2 -0
  45. data/tests/crypto_services_tests.rb +145 -0
  46. data/tests/file_splitter_tests.rb +61 -0
  47. data/tests/helper.rb +117 -0
  48. data/tests/swift_client/create_directory.rb +14 -0
  49. data/tests/swift_client/download_tests.rb +208 -0
  50. data/tests/swift_client/file_available.rb +25 -0
  51. data/tests/swift_client/head_tests.rb +34 -0
  52. data/tests/swift_client/match_tests.rb +29 -0
  53. data/tests/swift_client/upload_tests.rb +70 -0
  54. data/tests/swift_client_tests.rb +29 -0
  55. data/tests/utils_tests.rb +33 -0
  56. data/vendor/fog/.document +3 -0
  57. data/vendor/fog/.gitignore +23 -0
  58. data/vendor/fog/.irbrc +82 -0
  59. data/vendor/fog/.travis.yml +21 -0
  60. data/vendor/fog/README.cifrado +3 -0
  61. data/vendor/fog/README.md +156 -0
  62. data/vendor/fog/RELEASE.md +39 -0
  63. data/vendor/fog/changelog.txt +4156 -0
  64. data/vendor/fog/fog.gemspec +70 -0
  65. data/vendor/fog/lib/fog.rb +17 -0
  66. data/vendor/fog/lib/fog/cdn.rb +30 -0
  67. data/vendor/fog/lib/fog/compute.rb +127 -0
  68. data/vendor/fog/lib/fog/compute/models/server.rb +73 -0
  69. data/vendor/fog/lib/fog/core.rb +38 -0
  70. data/vendor/fog/lib/fog/core/attributes.rb +221 -0
  71. data/vendor/fog/lib/fog/core/collection.rb +145 -0
  72. data/vendor/fog/lib/fog/core/connection.rb +36 -0
  73. data/vendor/fog/lib/fog/core/credentials.rb +65 -0
  74. data/vendor/fog/lib/fog/core/current_machine.rb +34 -0
  75. data/vendor/fog/lib/fog/core/deprecated_connection_accessors.rb +41 -0
  76. data/vendor/fog/lib/fog/core/deprecation.rb +23 -0
  77. data/vendor/fog/lib/fog/core/errors.rb +108 -0
  78. data/vendor/fog/lib/fog/core/hmac.rb +48 -0
  79. data/vendor/fog/lib/fog/core/json.rb +34 -0
  80. data/vendor/fog/lib/fog/core/logger.rb +45 -0
  81. data/vendor/fog/lib/fog/core/mock.rb +92 -0
  82. data/vendor/fog/lib/fog/core/model.rb +79 -0
  83. data/vendor/fog/lib/fog/core/parser.rb +116 -0
  84. data/vendor/fog/lib/fog/core/provider.rb +35 -0
  85. data/vendor/fog/lib/fog/core/scp.rb +96 -0
  86. data/vendor/fog/lib/fog/core/service.rb +223 -0
  87. data/vendor/fog/lib/fog/core/ssh.rb +137 -0
  88. data/vendor/fog/lib/fog/core/time.rb +32 -0
  89. data/vendor/fog/lib/fog/core/timeout.rb +11 -0
  90. data/vendor/fog/lib/fog/core/wait_for.rb +15 -0
  91. data/vendor/fog/lib/fog/digitalocean.rb +9 -0
  92. data/vendor/fog/lib/fog/digitalocean/compute.rb +100 -0
  93. data/vendor/fog/lib/fog/digitalocean/examples/getting_started.md +106 -0
  94. data/vendor/fog/lib/fog/digitalocean/models/compute/flavor.rb +14 -0
  95. data/vendor/fog/lib/fog/digitalocean/models/compute/flavors.rb +25 -0
  96. data/vendor/fog/lib/fog/digitalocean/models/compute/image.rb +15 -0
  97. data/vendor/fog/lib/fog/digitalocean/models/compute/images.rb +25 -0
  98. data/vendor/fog/lib/fog/digitalocean/models/compute/region.rb +14 -0
  99. data/vendor/fog/lib/fog/digitalocean/models/compute/regions.rb +25 -0
  100. data/vendor/fog/lib/fog/digitalocean/models/compute/server.rb +150 -0
  101. data/vendor/fog/lib/fog/digitalocean/models/compute/servers.rb +27 -0
  102. data/vendor/fog/lib/fog/digitalocean/requests/compute/create_server.rb +49 -0
  103. data/vendor/fog/lib/fog/digitalocean/requests/compute/create_ssh_key.rb +26 -0
  104. data/vendor/fog/lib/fog/digitalocean/requests/compute/destroy_server.rb +28 -0
  105. data/vendor/fog/lib/fog/digitalocean/requests/compute/get_server_details.rb +25 -0
  106. data/vendor/fog/lib/fog/digitalocean/requests/compute/list_flavors.rb +25 -0
  107. data/vendor/fog/lib/fog/digitalocean/requests/compute/list_images.rb +25 -0
  108. data/vendor/fog/lib/fog/digitalocean/requests/compute/list_regions.rb +25 -0
  109. data/vendor/fog/lib/fog/digitalocean/requests/compute/list_servers.rb +25 -0
  110. data/vendor/fog/lib/fog/digitalocean/requests/compute/list_ssh_keys.rb +25 -0
  111. data/vendor/fog/lib/fog/digitalocean/requests/compute/power_cycle_server.rb +25 -0
  112. data/vendor/fog/lib/fog/digitalocean/requests/compute/power_off_server.rb +25 -0
  113. data/vendor/fog/lib/fog/digitalocean/requests/compute/power_on_server.rb +25 -0
  114. data/vendor/fog/lib/fog/digitalocean/requests/compute/reboot_server.rb +25 -0
  115. data/vendor/fog/lib/fog/digitalocean/requests/compute/shutdown_server.rb +25 -0
  116. data/vendor/fog/lib/fog/dns.rb +59 -0
  117. data/vendor/fog/lib/fog/identity.rb +27 -0
  118. data/vendor/fog/lib/fog/image.rb +24 -0
  119. data/vendor/fog/lib/fog/local.rb +11 -0
  120. data/vendor/fog/lib/fog/local/models/storage/directories.rb +33 -0
  121. data/vendor/fog/lib/fog/local/models/storage/directory.rb +57 -0
  122. data/vendor/fog/lib/fog/local/models/storage/file.rb +131 -0
  123. data/vendor/fog/lib/fog/local/models/storage/files.rb +87 -0
  124. data/vendor/fog/lib/fog/local/storage.rb +103 -0
  125. data/vendor/fog/lib/fog/network.rb +26 -0
  126. data/vendor/fog/lib/fog/openstack.rb +214 -0
  127. data/vendor/fog/lib/fog/openstack/README.identity.md +69 -0
  128. data/vendor/fog/lib/fog/openstack/compute.rb +423 -0
  129. data/vendor/fog/lib/fog/openstack/identity.rb +299 -0
  130. data/vendor/fog/lib/fog/openstack/image.rb +217 -0
  131. data/vendor/fog/lib/fog/openstack/models/compute/address.rb +71 -0
  132. data/vendor/fog/lib/fog/openstack/models/compute/addresses.rb +33 -0
  133. data/vendor/fog/lib/fog/openstack/models/compute/flavor.rb +45 -0
  134. data/vendor/fog/lib/fog/openstack/models/compute/flavors.rb +28 -0
  135. data/vendor/fog/lib/fog/openstack/models/compute/host.rb +29 -0
  136. data/vendor/fog/lib/fog/openstack/models/compute/hosts.rb +32 -0
  137. data/vendor/fog/lib/fog/openstack/models/compute/image.rb +58 -0
  138. data/vendor/fog/lib/fog/openstack/models/compute/images.rb +33 -0
  139. data/vendor/fog/lib/fog/openstack/models/compute/key_pair.rb +60 -0
  140. data/vendor/fog/lib/fog/openstack/models/compute/key_pairs.rb +31 -0
  141. data/vendor/fog/lib/fog/openstack/models/compute/metadata.rb +68 -0
  142. data/vendor/fog/lib/fog/openstack/models/compute/metadatum.rb +29 -0
  143. data/vendor/fog/lib/fog/openstack/models/compute/network.rb +13 -0
  144. data/vendor/fog/lib/fog/openstack/models/compute/networks.rb +29 -0
  145. data/vendor/fog/lib/fog/openstack/models/compute/security_group.rb +44 -0
  146. data/vendor/fog/lib/fog/openstack/models/compute/security_groups.rb +27 -0
  147. data/vendor/fog/lib/fog/openstack/models/compute/server.rb +278 -0
  148. data/vendor/fog/lib/fog/openstack/models/compute/servers.rb +44 -0
  149. data/vendor/fog/lib/fog/openstack/models/compute/snapshot.rb +44 -0
  150. data/vendor/fog/lib/fog/openstack/models/compute/snapshots.rb +26 -0
  151. data/vendor/fog/lib/fog/openstack/models/compute/tenant.rb +24 -0
  152. data/vendor/fog/lib/fog/openstack/models/compute/tenants.rb +24 -0
  153. data/vendor/fog/lib/fog/openstack/models/compute/volume.rb +59 -0
  154. data/vendor/fog/lib/fog/openstack/models/compute/volumes.rb +26 -0
  155. data/vendor/fog/lib/fog/openstack/models/identity/ec2_credential.rb +44 -0
  156. data/vendor/fog/lib/fog/openstack/models/identity/ec2_credentials.rb +53 -0
  157. data/vendor/fog/lib/fog/openstack/models/identity/role.rb +50 -0
  158. data/vendor/fog/lib/fog/openstack/models/identity/roles.rb +21 -0
  159. data/vendor/fog/lib/fog/openstack/models/identity/tenant.rb +62 -0
  160. data/vendor/fog/lib/fog/openstack/models/identity/tenants.rb +29 -0
  161. data/vendor/fog/lib/fog/openstack/models/identity/user.rb +70 -0
  162. data/vendor/fog/lib/fog/openstack/models/identity/users.rb +32 -0
  163. data/vendor/fog/lib/fog/openstack/models/image/image.rb +91 -0
  164. data/vendor/fog/lib/fog/openstack/models/image/images.rb +60 -0
  165. data/vendor/fog/lib/fog/openstack/models/meta_parent.rb +33 -0
  166. data/vendor/fog/lib/fog/openstack/models/network/floating_ip.rb +52 -0
  167. data/vendor/fog/lib/fog/openstack/models/network/floating_ips.rb +34 -0
  168. data/vendor/fog/lib/fog/openstack/models/network/network.rb +47 -0
  169. data/vendor/fog/lib/fog/openstack/models/network/networks.rb +34 -0
  170. data/vendor/fog/lib/fog/openstack/models/network/port.rb +53 -0
  171. data/vendor/fog/lib/fog/openstack/models/network/ports.rb +34 -0
  172. data/vendor/fog/lib/fog/openstack/models/network/subnet.rb +56 -0
  173. data/vendor/fog/lib/fog/openstack/models/network/subnets.rb +34 -0
  174. data/vendor/fog/lib/fog/openstack/models/storage/directories.rb +39 -0
  175. data/vendor/fog/lib/fog/openstack/models/storage/directory.rb +50 -0
  176. data/vendor/fog/lib/fog/openstack/models/storage/file.rb +152 -0
  177. data/vendor/fog/lib/fog/openstack/models/storage/files.rb +94 -0
  178. data/vendor/fog/lib/fog/openstack/models/volume/volume.rb +47 -0
  179. data/vendor/fog/lib/fog/openstack/models/volume/volumes.rb +27 -0
  180. data/vendor/fog/lib/fog/openstack/network.rb +247 -0
  181. data/vendor/fog/lib/fog/openstack/requests/compute/add_fixed_ip.rb +29 -0
  182. data/vendor/fog/lib/fog/openstack/requests/compute/allocate_address.rb +42 -0
  183. data/vendor/fog/lib/fog/openstack/requests/compute/associate_address.rb +27 -0
  184. data/vendor/fog/lib/fog/openstack/requests/compute/attach_volume.rb +38 -0
  185. data/vendor/fog/lib/fog/openstack/requests/compute/boot_from_snapshot.rb +41 -0
  186. data/vendor/fog/lib/fog/openstack/requests/compute/change_server_password.rb +24 -0
  187. data/vendor/fog/lib/fog/openstack/requests/compute/confirm_resize_server.rb +24 -0
  188. data/vendor/fog/lib/fog/openstack/requests/compute/create_flavor.rb +85 -0
  189. data/vendor/fog/lib/fog/openstack/requests/compute/create_image.rb +49 -0
  190. data/vendor/fog/lib/fog/openstack/requests/compute/create_key_pair.rb +49 -0
  191. data/vendor/fog/lib/fog/openstack/requests/compute/create_security_group.rb +52 -0
  192. data/vendor/fog/lib/fog/openstack/requests/compute/create_security_group_rule.rb +59 -0
  193. data/vendor/fog/lib/fog/openstack/requests/compute/create_server.rb +131 -0
  194. data/vendor/fog/lib/fog/openstack/requests/compute/create_volume.rb +54 -0
  195. data/vendor/fog/lib/fog/openstack/requests/compute/create_volume_snapshot.rb +47 -0
  196. data/vendor/fog/lib/fog/openstack/requests/compute/delete_flavor.rb +28 -0
  197. data/vendor/fog/lib/fog/openstack/requests/compute/delete_image.rb +40 -0
  198. data/vendor/fog/lib/fog/openstack/requests/compute/delete_key_pair.rb +31 -0
  199. data/vendor/fog/lib/fog/openstack/requests/compute/delete_metadata.rb +28 -0
  200. data/vendor/fog/lib/fog/openstack/requests/compute/delete_security_group.rb +33 -0
  201. data/vendor/fog/lib/fog/openstack/requests/compute/delete_security_group_rule.rb +31 -0
  202. data/vendor/fog/lib/fog/openstack/requests/compute/delete_server.rb +38 -0
  203. data/vendor/fog/lib/fog/openstack/requests/compute/delete_snapshot.rb +26 -0
  204. data/vendor/fog/lib/fog/openstack/requests/compute/delete_volume.rb +26 -0
  205. data/vendor/fog/lib/fog/openstack/requests/compute/detach_volume.rb +26 -0
  206. data/vendor/fog/lib/fog/openstack/requests/compute/disassociate_address.rb +27 -0
  207. data/vendor/fog/lib/fog/openstack/requests/compute/get_address.rb +41 -0
  208. data/vendor/fog/lib/fog/openstack/requests/compute/get_console_output.rb +28 -0
  209. data/vendor/fog/lib/fog/openstack/requests/compute/get_flavor_details.rb +43 -0
  210. data/vendor/fog/lib/fog/openstack/requests/compute/get_host_details.rb +74 -0
  211. data/vendor/fog/lib/fog/openstack/requests/compute/get_image_details.rb +33 -0
  212. data/vendor/fog/lib/fog/openstack/requests/compute/get_limits.rb +93 -0
  213. data/vendor/fog/lib/fog/openstack/requests/compute/get_metadata.rb +29 -0
  214. data/vendor/fog/lib/fog/openstack/requests/compute/get_quota.rb +31 -0
  215. data/vendor/fog/lib/fog/openstack/requests/compute/get_quota_defaults.rb +31 -0
  216. data/vendor/fog/lib/fog/openstack/requests/compute/get_security_group.rb +49 -0
  217. data/vendor/fog/lib/fog/openstack/requests/compute/get_server_details.rb +32 -0
  218. data/vendor/fog/lib/fog/openstack/requests/compute/get_server_volumes.rb +23 -0
  219. data/vendor/fog/lib/fog/openstack/requests/compute/get_snapshot_details.rb +39 -0
  220. data/vendor/fog/lib/fog/openstack/requests/compute/get_usage.rb +53 -0
  221. data/vendor/fog/lib/fog/openstack/requests/compute/get_vnc_console.rb +40 -0
  222. data/vendor/fog/lib/fog/openstack/requests/compute/get_volume_details.rb +42 -0
  223. data/vendor/fog/lib/fog/openstack/requests/compute/list_address_pools.rb +23 -0
  224. data/vendor/fog/lib/fog/openstack/requests/compute/list_addresses.rb +32 -0
  225. data/vendor/fog/lib/fog/openstack/requests/compute/list_all_addresses.rb +64 -0
  226. data/vendor/fog/lib/fog/openstack/requests/compute/list_flavors.rb +38 -0
  227. data/vendor/fog/lib/fog/openstack/requests/compute/list_flavors_detail.rb +38 -0
  228. data/vendor/fog/lib/fog/openstack/requests/compute/list_hosts.rb +32 -0
  229. data/vendor/fog/lib/fog/openstack/requests/compute/list_images.rb +33 -0
  230. data/vendor/fog/lib/fog/openstack/requests/compute/list_images_detail.rb +39 -0
  231. data/vendor/fog/lib/fog/openstack/requests/compute/list_key_pairs.rb +39 -0
  232. data/vendor/fog/lib/fog/openstack/requests/compute/list_metadata.rb +28 -0
  233. data/vendor/fog/lib/fog/openstack/requests/compute/list_private_addresses.rb +32 -0
  234. data/vendor/fog/lib/fog/openstack/requests/compute/list_public_addresses.rb +32 -0
  235. data/vendor/fog/lib/fog/openstack/requests/compute/list_security_groups.rb +50 -0
  236. data/vendor/fog/lib/fog/openstack/requests/compute/list_servers.rb +37 -0
  237. data/vendor/fog/lib/fog/openstack/requests/compute/list_servers_detail.rb +44 -0
  238. data/vendor/fog/lib/fog/openstack/requests/compute/list_snapshots.rb +32 -0
  239. data/vendor/fog/lib/fog/openstack/requests/compute/list_tenants.rb +45 -0
  240. data/vendor/fog/lib/fog/openstack/requests/compute/list_usages.rb +43 -0
  241. data/vendor/fog/lib/fog/openstack/requests/compute/list_volumes.rb +51 -0
  242. data/vendor/fog/lib/fog/openstack/requests/compute/live_migrate_server.rb +31 -0
  243. data/vendor/fog/lib/fog/openstack/requests/compute/migrate_server.rb +24 -0
  244. data/vendor/fog/lib/fog/openstack/requests/compute/pause_server.rb +24 -0
  245. data/vendor/fog/lib/fog/openstack/requests/compute/reboot_server.rb +24 -0
  246. data/vendor/fog/lib/fog/openstack/requests/compute/rebuild_server.rb +31 -0
  247. data/vendor/fog/lib/fog/openstack/requests/compute/release_address.rb +34 -0
  248. data/vendor/fog/lib/fog/openstack/requests/compute/remove_fixed_ip.rb +29 -0
  249. data/vendor/fog/lib/fog/openstack/requests/compute/rescue_server.rb +24 -0
  250. data/vendor/fog/lib/fog/openstack/requests/compute/reset_server_state.rb +24 -0
  251. data/vendor/fog/lib/fog/openstack/requests/compute/resize_server.rb +24 -0
  252. data/vendor/fog/lib/fog/openstack/requests/compute/resume_server.rb +24 -0
  253. data/vendor/fog/lib/fog/openstack/requests/compute/revert_resize_server.rb +30 -0
  254. data/vendor/fog/lib/fog/openstack/requests/compute/server_action.rb +18 -0
  255. data/vendor/fog/lib/fog/openstack/requests/compute/server_actions.rb +27 -0
  256. data/vendor/fog/lib/fog/openstack/requests/compute/server_diagnostics.rb +25 -0
  257. data/vendor/fog/lib/fog/openstack/requests/compute/set_metadata.rb +45 -0
  258. data/vendor/fog/lib/fog/openstack/requests/compute/set_tenant.rb +21 -0
  259. data/vendor/fog/lib/fog/openstack/requests/compute/suspend_server.rb +24 -0
  260. data/vendor/fog/lib/fog/openstack/requests/compute/unpause_server.rb +24 -0
  261. data/vendor/fog/lib/fog/openstack/requests/compute/update_metadata.rb +46 -0
  262. data/vendor/fog/lib/fog/openstack/requests/compute/update_quota.rb +32 -0
  263. data/vendor/fog/lib/fog/openstack/requests/compute/update_server.rb +35 -0
  264. data/vendor/fog/lib/fog/openstack/requests/identity/add_user_to_tenant.rb +34 -0
  265. data/vendor/fog/lib/fog/openstack/requests/identity/check_token.rb +23 -0
  266. data/vendor/fog/lib/fog/openstack/requests/identity/create_ec2_credential.rb +58 -0
  267. data/vendor/fog/lib/fog/openstack/requests/identity/create_role.rb +37 -0
  268. data/vendor/fog/lib/fog/openstack/requests/identity/create_tenant.rb +32 -0
  269. data/vendor/fog/lib/fog/openstack/requests/identity/create_user.rb +47 -0
  270. data/vendor/fog/lib/fog/openstack/requests/identity/create_user_role.rb +26 -0
  271. data/vendor/fog/lib/fog/openstack/requests/identity/delete_ec2_credential.rb +44 -0
  272. data/vendor/fog/lib/fog/openstack/requests/identity/delete_role.rb +32 -0
  273. data/vendor/fog/lib/fog/openstack/requests/identity/delete_tenant.rb +31 -0
  274. data/vendor/fog/lib/fog/openstack/requests/identity/delete_user.rb +32 -0
  275. data/vendor/fog/lib/fog/openstack/requests/identity/delete_user_role.rb +26 -0
  276. data/vendor/fog/lib/fog/openstack/requests/identity/get_ec2_credential.rb +49 -0
  277. data/vendor/fog/lib/fog/openstack/requests/identity/get_role.rb +28 -0
  278. data/vendor/fog/lib/fog/openstack/requests/identity/get_tenant.rb +31 -0
  279. data/vendor/fog/lib/fog/openstack/requests/identity/get_tenants_by_id.rb +23 -0
  280. data/vendor/fog/lib/fog/openstack/requests/identity/get_tenants_by_name.rb +23 -0
  281. data/vendor/fog/lib/fog/openstack/requests/identity/get_user_by_id.rb +34 -0
  282. data/vendor/fog/lib/fog/openstack/requests/identity/get_user_by_name.rb +31 -0
  283. data/vendor/fog/lib/fog/openstack/requests/identity/list_ec2_credentials.rb +44 -0
  284. data/vendor/fog/lib/fog/openstack/requests/identity/list_endpoints_for_token.rb +23 -0
  285. data/vendor/fog/lib/fog/openstack/requests/identity/list_roles.rb +36 -0
  286. data/vendor/fog/lib/fog/openstack/requests/identity/list_roles_for_user_on_tenant.rb +30 -0
  287. data/vendor/fog/lib/fog/openstack/requests/identity/list_tenants.rb +45 -0
  288. data/vendor/fog/lib/fog/openstack/requests/identity/list_user_global_roles.rb +22 -0
  289. data/vendor/fog/lib/fog/openstack/requests/identity/list_users.rb +34 -0
  290. data/vendor/fog/lib/fog/openstack/requests/identity/remove_user_from_tenant.rb +20 -0
  291. data/vendor/fog/lib/fog/openstack/requests/identity/set_tenant.rb +21 -0
  292. data/vendor/fog/lib/fog/openstack/requests/identity/update_tenant.rb +28 -0
  293. data/vendor/fog/lib/fog/openstack/requests/identity/update_user.rb +36 -0
  294. data/vendor/fog/lib/fog/openstack/requests/identity/validate_token.rb +23 -0
  295. data/vendor/fog/lib/fog/openstack/requests/image/add_member_to_image.rb +23 -0
  296. data/vendor/fog/lib/fog/openstack/requests/image/create_image.rb +79 -0
  297. data/vendor/fog/lib/fog/openstack/requests/image/delete_image.rb +25 -0
  298. data/vendor/fog/lib/fog/openstack/requests/image/get_image.rb +45 -0
  299. data/vendor/fog/lib/fog/openstack/requests/image/get_image_by_id.rb +32 -0
  300. data/vendor/fog/lib/fog/openstack/requests/image/get_image_members.rb +29 -0
  301. data/vendor/fog/lib/fog/openstack/requests/image/get_shared_images.rb +29 -0
  302. data/vendor/fog/lib/fog/openstack/requests/image/list_public_images.rb +32 -0
  303. data/vendor/fog/lib/fog/openstack/requests/image/list_public_images_detailed.rb +31 -0
  304. data/vendor/fog/lib/fog/openstack/requests/image/remove_member_from_image.rb +23 -0
  305. data/vendor/fog/lib/fog/openstack/requests/image/set_tenant.rb +21 -0
  306. data/vendor/fog/lib/fog/openstack/requests/image/update_image.rb +70 -0
  307. data/vendor/fog/lib/fog/openstack/requests/image/update_image_members.rb +37 -0
  308. data/vendor/fog/lib/fog/openstack/requests/network/associate_floating_ip.rb +49 -0
  309. data/vendor/fog/lib/fog/openstack/requests/network/create_floating_ip.rb +50 -0
  310. data/vendor/fog/lib/fog/openstack/requests/network/create_network.rb +44 -0
  311. data/vendor/fog/lib/fog/openstack/requests/network/create_port.rb +52 -0
  312. data/vendor/fog/lib/fog/openstack/requests/network/create_subnet.rb +56 -0
  313. data/vendor/fog/lib/fog/openstack/requests/network/delete_floating_ip.rb +30 -0
  314. data/vendor/fog/lib/fog/openstack/requests/network/delete_network.rb +30 -0
  315. data/vendor/fog/lib/fog/openstack/requests/network/delete_port.rb +30 -0
  316. data/vendor/fog/lib/fog/openstack/requests/network/delete_subnet.rb +30 -0
  317. data/vendor/fog/lib/fog/openstack/requests/network/disassociate_floating_ip.rb +49 -0
  318. data/vendor/fog/lib/fog/openstack/requests/network/get_floating_ip.rb +42 -0
  319. data/vendor/fog/lib/fog/openstack/requests/network/get_network.rb +42 -0
  320. data/vendor/fog/lib/fog/openstack/requests/network/get_port.rb +48 -0
  321. data/vendor/fog/lib/fog/openstack/requests/network/get_subnet.rb +49 -0
  322. data/vendor/fog/lib/fog/openstack/requests/network/list_floating_ips.rb +27 -0
  323. data/vendor/fog/lib/fog/openstack/requests/network/list_networks.rb +27 -0
  324. data/vendor/fog/lib/fog/openstack/requests/network/list_ports.rb +27 -0
  325. data/vendor/fog/lib/fog/openstack/requests/network/list_subnets.rb +27 -0
  326. data/vendor/fog/lib/fog/openstack/requests/network/set_tenant.rb +21 -0
  327. data/vendor/fog/lib/fog/openstack/requests/network/update_network.rb +41 -0
  328. data/vendor/fog/lib/fog/openstack/requests/network/update_port.rb +44 -0
  329. data/vendor/fog/lib/fog/openstack/requests/network/update_subnet.rb +44 -0
  330. data/vendor/fog/lib/fog/openstack/requests/storage/copy_object.rb +27 -0
  331. data/vendor/fog/lib/fog/openstack/requests/storage/delete_container.rb +22 -0
  332. data/vendor/fog/lib/fog/openstack/requests/storage/delete_object.rb +23 -0
  333. data/vendor/fog/lib/fog/openstack/requests/storage/get_container.rb +44 -0
  334. data/vendor/fog/lib/fog/openstack/requests/storage/get_containers.rb +33 -0
  335. data/vendor/fog/lib/fog/openstack/requests/storage/get_object.rb +29 -0
  336. data/vendor/fog/lib/fog/openstack/requests/storage/get_object_https_url.rb +51 -0
  337. data/vendor/fog/lib/fog/openstack/requests/storage/head_container.rb +28 -0
  338. data/vendor/fog/lib/fog/openstack/requests/storage/head_containers.rb +25 -0
  339. data/vendor/fog/lib/fog/openstack/requests/storage/head_object.rb +23 -0
  340. data/vendor/fog/lib/fog/openstack/requests/storage/post_set_meta_temp_url_key.rb +37 -0
  341. data/vendor/fog/lib/fog/openstack/requests/storage/put_container.rb +22 -0
  342. data/vendor/fog/lib/fog/openstack/requests/storage/put_object.rb +30 -0
  343. data/vendor/fog/lib/fog/openstack/requests/storage/put_object_manifest.rb +25 -0
  344. data/vendor/fog/lib/fog/openstack/requests/volume/create_volume.rb +54 -0
  345. data/vendor/fog/lib/fog/openstack/requests/volume/create_volume_snapshot.rb +47 -0
  346. data/vendor/fog/lib/fog/openstack/requests/volume/delete_snapshot.rb +26 -0
  347. data/vendor/fog/lib/fog/openstack/requests/volume/delete_volume.rb +26 -0
  348. data/vendor/fog/lib/fog/openstack/requests/volume/get_snapshot_details.rb +39 -0
  349. data/vendor/fog/lib/fog/openstack/requests/volume/get_volume_details.rb +42 -0
  350. data/vendor/fog/lib/fog/openstack/requests/volume/list_snapshots.rb +32 -0
  351. data/vendor/fog/lib/fog/openstack/requests/volume/list_volumes.rb +55 -0
  352. data/vendor/fog/lib/fog/openstack/requests/volume/set_tenant.rb +21 -0
  353. data/vendor/fog/lib/fog/openstack/storage.rb +162 -0
  354. data/vendor/fog/lib/fog/openstack/volume.rb +219 -0
  355. data/vendor/fog/lib/fog/providers.rb +2 -0
  356. data/vendor/fog/lib/fog/schema/data_validator.rb +154 -0
  357. data/vendor/fog/lib/fog/storage.rb +97 -0
  358. data/vendor/fog/lib/fog/version.rb +3 -0
  359. data/vendor/fog/lib/fog/volume.rb +25 -0
  360. metadata +576 -0
  361. metadata.gz.sig +0 -0
data/lib/cifrado.rb ADDED
@@ -0,0 +1,48 @@
1
+ require 'cifrado/version'
2
+ require 'cifrado/core_ext/ruby18_base64'
3
+ require 'logger'
4
+ require 'shellwords'
5
+ require 'uri'
6
+ require 'thor'
7
+ require 'fileutils'
8
+ require 'pathname'
9
+ require 'securerandom'
10
+ require 'cifrado/config'
11
+ require 'cifrado/utils'
12
+ require 'cifrado/cli/progressbar'
13
+
14
+ module Cifrado
15
+
16
+ if !defined? Log or Log.nil?
17
+ shell = Thor::Shell::Color.new
18
+ Log = Logger.new($stdout)
19
+ Log.formatter = proc do |severity, datetime, progname, msg|
20
+ if severity == 'ERROR' or severity == 'FATAL'
21
+ "#{shell.set_color(severity, :red, true)}: #{msg}\n"
22
+ elsif severity == 'WARN'
23
+ "#{shell.set_color(severity, :yellow, true)}: #{msg}\n"
24
+ elsif severity == 'INFO'
25
+ "#{msg}\n"
26
+ else
27
+ "#{severity}: #{msg}\n"
28
+ end
29
+ end
30
+ Log.level = Logger::INFO unless ENV['DEBUG']
31
+ Log.debug "Initializing logger"
32
+ end
33
+
34
+ end
35
+
36
+ vendored_fog = File.join(File.dirname(__FILE__), 'cifrado/vendor/fog/lib')
37
+ if File.directory?(vendored_fog)
38
+ fog_path = vendored_fog
39
+ else
40
+ fog_path = File.join(File.dirname(__FILE__), '/../', 'vendor/fog/lib')
41
+ end
42
+
43
+ $:.insert 0, fog_path
44
+ require 'fog/openstack'
45
+ require 'cifrado/swift_client'
46
+ require 'cifrado/file_splitter'
47
+ require 'cifrado/crypto_services'
48
+ require 'cifrado/cli'
@@ -0,0 +1,140 @@
1
+ module Cifrado
2
+ class CLI < Thor
3
+
4
+ include Cifrado
5
+ include Cifrado::Utils
6
+
7
+ attr_reader :config
8
+
9
+ check_unknown_options!
10
+
11
+ class_option :username
12
+ class_option :quiet
13
+ class_option :password
14
+ class_option :auth_url
15
+ class_option :tenant
16
+ class_option :config
17
+ class_option :region
18
+ class_option :insecure, :type => :boolean, :desc => "Insecure SSL connections"
19
+ class_option :debug, :type => :boolean
20
+
21
+ private
22
+ def secure_password
23
+ @config[:password] + @config[:secure_random]
24
+ end
25
+
26
+ def bwlimit
27
+ (options[:bwlimit] * 1024 * 1024)/8 if options[:bwlimit]
28
+ end
29
+
30
+ def client_instance
31
+
32
+ if options[:quiet] and Log.level < Logger::WARN
33
+ Log.level = Logger::WARN
34
+ end
35
+
36
+ if options[:debug]
37
+ Log.level = Logger::DEBUG
38
+ end
39
+
40
+ config = check_options
41
+ if options[:insecure]
42
+ Log.warn "SSL verification DISABLED"
43
+ end
44
+ client = Cifrado::SwiftClient.new :username => config[:username],
45
+ :api_key => config[:password],
46
+ :auth_url => config[:auth_url],
47
+ :tenant => config[:tenant],
48
+ :region => config[:region],
49
+ :password_salt => config[:secure_random],
50
+ :connection_options => {
51
+ :ssl_verify_peer => !options[:insecure]
52
+ }
53
+ @client = client
54
+ @config = config
55
+ # Validate connection
56
+ client.test_connection
57
+ client
58
+ end
59
+
60
+ def check_options
61
+ config_file = options[:config] || File.join(ENV['HOME'], '.config/cifrado/cifradorc')
62
+ config = {}
63
+
64
+ if File.exist?(config_file)
65
+ begin
66
+ Log.debug "Configuration file found: #{config_file}"
67
+ Cifrado::Log.debug "Trying to read config file #{config_file}"
68
+ config = YAML.load_file(config_file)
69
+ Cifrado::Log.debug "Config #{config_file} read"
70
+ original_config = config.dup
71
+ rescue => e
72
+ Cifrado::Log.error "Error loading config file"
73
+ raise e
74
+ end
75
+ end
76
+
77
+ config[:username] = options[:username] || config[:username]
78
+ config[:password] = options[:password] || config[:password]
79
+ config[:auth_url] = options[:auth_url] || config[:auth_url]
80
+ config[:tenant] = options[:tenant] || config[:tenant]
81
+ config[:region] = options[:region] || config[:region]
82
+ config[:secure_random] = config[:secure_random]
83
+ [:username, :password, :auth_url, :tenant].each do |opt|
84
+ if config[opt].nil?
85
+ Log.error "#{opt.to_s.capitalize} not provided."
86
+ Log.error "Use --#{opt.to_s.gsub('_', '-')} option or run 'cifrado setup' first."
87
+ raise "Missing setting"
88
+ end
89
+ end
90
+ unless config[:secure_random]
91
+ raise Exception.new("secure_random key not found in #{config_file}")
92
+ end
93
+
94
+ config
95
+ end
96
+
97
+ end
98
+ end
99
+
100
+ require 'cifrado/cli/stat'
101
+ require 'cifrado/cli/download'
102
+ require 'cifrado/cli/list'
103
+ require 'cifrado/cli/post'
104
+ require 'cifrado/cli/delete'
105
+ require 'cifrado/cli/setup'
106
+ require 'cifrado/cli/upload'
107
+ require 'cifrado/cli/set_acl'
108
+ require 'cifrado/cli/jukebox'
109
+ require 'cifrado/cli/cinema'
110
+ require 'cifrado/cli/saio'
111
+
112
+ at_exit do
113
+ include Cifrado::Utils
114
+ include Cifrado
115
+ e = $!
116
+ if e
117
+ if e.is_a? Excon::Errors::Unauthorized
118
+ Log.error "Unauthorized"
119
+ Log.error "Double check the username, password and auth_url."
120
+ elsif e.is_a? Excon::Errors::SocketError
121
+ if e.message =~ /Unable to verify certificate|hostname (was|does) not match (with )?the server/
122
+ Log.error "Unable to verify SSL certificate."
123
+ Log.error "If the server is using a self-signed certificate, try using --insecure."
124
+ Log.error "Please be aware of the security implications."
125
+ else
126
+ Log.error e.message
127
+ end
128
+ elsif e.is_a? RuntimeError
129
+ Log.error e.message
130
+ elsif e.is_a? Interrupt
131
+ Log.info
132
+ Log.info 'At your command, Sir!'
133
+ else
134
+ Log.fatal e.message
135
+ end
136
+ system 'stty echo'
137
+ prettify_backtrace e
138
+ exit! 1
139
+ end
140
+ end
@@ -0,0 +1,81 @@
1
+ module Cifrado
2
+ class CLI
3
+
4
+ desc "cinema CONTAINER VIDEO",
5
+ "Stream videos from the target container"
6
+ option :subtitles, :type => :boolean
7
+ def cinema(container, video)
8
+ client = client_instance
9
+
10
+ dir = client.service.directories.get container
11
+ unless dir
12
+ raise "Container #{container} not found."
13
+ end
14
+
15
+ to_play = dir.files.find { |v| v.key =~ /#{video}/ }
16
+ unless to_play
17
+ raise "No video matches #{video}"
18
+ end
19
+
20
+ sub_file = nil
21
+ if options[:subtitles]
22
+ begin
23
+ Log.info "Subtitles found, downloading."
24
+ sub_object = to_play.key.gsub(/\.(avi|mpeg|mov|mkv|ogv|webm)$/, '') + '.srt'
25
+ sub = client.head container, sub_object
26
+ sub_file = "/tmp/#{SecureRandom.hex}"
27
+ client.download container, sub_object, :output => sub_file
28
+ rescue => e
29
+ Log.error "Error downloading subtitles, ignoring."
30
+ end
31
+ end
32
+
33
+ $stderr.reopen('/dev/null', 'w')
34
+ pipe = IO.popen(player_command(sub_file), 'w')
35
+ begin
36
+ cb = Proc.new do |total, bytes, segment|
37
+ pipe.write segment if bytes > 0
38
+ end
39
+
40
+ Log.info "#{set_color 'Playing', :bold} #{to_play.key}"
41
+ r = client.stream container,
42
+ to_play.key,
43
+ :progress_callback => cb
44
+ Log.debug "Video finished streaming"
45
+ rescue => e
46
+ Log.debug "Closing pipe"
47
+ prettify_backtrace e
48
+ pipe.close unless pipe.closed?
49
+ Log.info set_color "\nAdios!", :bold
50
+ end
51
+ end
52
+
53
+ private
54
+ def player_command(subtitles = nil)
55
+ cvlc = '/usr/bin/cvlc'
56
+ vlc = '/usr/bin/vlc'
57
+ mplayer = '/usr/bin/mplayer'
58
+ totem = '/usr/bin/totem'
59
+
60
+ if File.exist?(cvlc)
61
+ Log.debug "Using cvlc player"
62
+ extra_args = "--sub-file #{subtitles}" if subtitles
63
+ "/usr/bin/cvlc #{extra_args} -"
64
+ elsif File.exist?(mplayer)
65
+ extra_args = "-sub #{subtitles}" if subtitles
66
+ Log.debug "Using mplayer player"
67
+ "/usr/bin/mplayer #{extra_args} -really-quiet -msglevel all=-1 -cache 256 -"
68
+ elsif File.exist?(vlc)
69
+ Log.debug "Using vlc player"
70
+ extra_args = "--sub-file #{subtitles}" if subtitles
71
+ "/usr/bin/vlc #{extra_args} -"
72
+ elsif File.exist?(totem)
73
+ Log.debug "Using totem player"
74
+ '/usr/bin/totem --enqueue fd://0'
75
+ else
76
+ raise "No player available. Install MPlayer, VLC or totem."
77
+ end
78
+ end
79
+
80
+ end
81
+ end
@@ -0,0 +1,36 @@
1
+ module Cifrado
2
+ class CLI
3
+ desc "delete CONTAINER [OBJECT]", "Delete specific container or object"
4
+ def delete(container, object = nil)
5
+ client = client_instance
6
+ if object
7
+ Log.info "Deleting file #{object}..."
8
+ deleted = false
9
+ begin
10
+ client.service.delete_object container, object
11
+ deleted = true
12
+ rescue Fog::Storage::OpenStack::NotFound
13
+ Log.debug 'Trying to find hashed object name'
14
+ file_hash = (Digest::SHA2.new << object).to_s
15
+ deleted = client.service.delete_object(container, file_hash) rescue nil
16
+ end
17
+ if deleted
18
+ Log.info "File #{object} deleted"
19
+ else
20
+ Log.error "File #{object} not found"
21
+ end
22
+ else
23
+ Log.info "Deleting container '#{container}'..."
24
+ dir = client.service.directories.get(container)
25
+ if dir
26
+ dir.files.each do |f|
27
+ Log.info "Deleting file #{f.key}..."
28
+ f.destroy
29
+ end
30
+ dir.destroy
31
+ Log.info "Container #{container} deleted"
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,54 @@
1
+ module Cifrado
2
+ class CLI
3
+ desc "download [CONTAINER] [OBJECT]", "Download container, objects"
4
+ option :decrypt, :type => :boolean
5
+ option :passphrase, :type => :string, :desc => "Passphrase used to decrypt the file"
6
+ option :output
7
+ option :progressbar, :default => :fancy
8
+ option :bwlimit, :type => :numeric
9
+ def download(container, object = nil)
10
+ client = client_instance
11
+ downloaded = []
12
+ files = []
13
+ if object
14
+ files << object
15
+ else
16
+ Log.info "Downloading files from container #{container}"
17
+ dir = client.service.directories.get(container)
18
+ files = dir.files if dir
19
+ end
20
+ pb = Progressbar.new 1, 1, :style => options[:progressbar]
21
+ files.each do |f|
22
+ obj = f.is_a?(String) ? f : f.key
23
+ if !f.is_a?(String) and f.metadata[:encrypted_name]
24
+ fname = decrypt_filename f.metadata[:encrypted_name],
25
+ @config[:password] + @config[:secure_random]
26
+ Log.info "Downloading file #{fname}"
27
+ else
28
+ Log.info "Downloading file #{obj}"
29
+ end
30
+ if client.file_available?(container, obj)
31
+ r = client.download container, obj,
32
+ :decrypt => options[:decrypt],
33
+ :passphrase => options[:passphrase],
34
+ :output => options[:output],
35
+ :progress_callback => pb.block,
36
+ :bwlimit => bwlimit
37
+ downloaded << obj
38
+ else
39
+ Log.debug 'Trying to find hashed object name'
40
+ file_hash = (Digest::SHA2.new << obj).to_s
41
+ r = client.download container, file_hash,
42
+ :decrypt => options[:decrypt],
43
+ :passphrase => options[:passphrase],
44
+ :output => options[:output],
45
+ :progress_callback => pb.block,
46
+ :bwlimit => bwlimit
47
+ downloaded << file_hash if r.status == 200
48
+ end
49
+ end
50
+ Log.warn "No files were downloaded." if downloaded.empty?
51
+ downloaded
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,94 @@
1
+ module Cifrado
2
+ class CLI
3
+
4
+ desc "jukebox CONTAINER",
5
+ "Play music randomly from the target container"
6
+ option :match, :type => :string
7
+ def jukebox(container)
8
+ client = client_instance
9
+
10
+ dir = client.service.directories.get container
11
+ unless dir
12
+ raise "Container #{container} not found."
13
+ end
14
+ songs = dir.files
15
+ last_exit = Time.now.to_f
16
+
17
+ Log.info
18
+ Log.info set_color "Cifrado Jukebox", :bold
19
+ Log.info "---------------"
20
+ Log.info
21
+ Log.info set_color("Ctrl-C once", :bold)+ " -> next song"
22
+ Log.info set_color("Ctrl-C twice", :bold)+ " -> quit"
23
+ Log.info
24
+ $stderr.reopen('/dev/null', 'w')
25
+ pipe = IO.popen(player_command, 'w')
26
+ songs.shuffle.each do |song|
27
+ if options[:match] and song.key !~ /#{options[:match]}/i
28
+ next
29
+ end
30
+ begin
31
+
32
+ cb = Proc.new do |total, bytes, segment|
33
+ pipe.write segment if bytes > 0
34
+ end
35
+
36
+ unless (song.content_type =~ /ogg|mp3/) or \
37
+ song.key =~ /(mp3|wav|ogg)$/
38
+ next
39
+ end
40
+ Log.info "#{set_color 'Playing', :bold} song"
41
+ Log.info " * #{song.key}"
42
+ r = client.stream container,
43
+ song.key,
44
+ :progress_callback => cb
45
+ Log.debug "Song finished streaming"
46
+ rescue Timeout::Error, Errno::EPIPE, Interrupt => e
47
+ Log.debug "Closing pipe"
48
+ prettify_backtrace e
49
+ pipe.close unless pipe.closed?
50
+ Log.debug "Opening new pipe"
51
+ pipe = IO.popen(player_command, 'w')
52
+ if Time.now.to_f - last_exit < 1
53
+ Log.info set_color "\nAdios!", :bold
54
+ return
55
+ else
56
+ last_exit = Time.now.to_f
57
+ Log.info 'Next song...'
58
+ end
59
+ end
60
+ end
61
+ ensure
62
+ if pipe and !pipe.closed?
63
+ Log.debug "Closing pipe, killing mplayer"
64
+ Process.kill 'SIGKILL', pipe.pid
65
+ pipe.close
66
+ end
67
+ end
68
+
69
+ private
70
+ def player_command
71
+ cvlc = '/usr/bin/cvlc'
72
+ vlc = '/usr/bin/vlc'
73
+ mplayer = '/usr/bin/mplayer'
74
+ totem = '/usr/bin/totem'
75
+
76
+ if File.exist?(cvlc)
77
+ Log.debug "Using cvlc player"
78
+ '/usr/bin/cvlc -'
79
+ elsif File.exist?(mplayer)
80
+ Log.debug "Using mplayer player"
81
+ '/usr/bin/mplayer -really-quiet -msglevel all=-1 -cache 256 -'
82
+ elsif File.exist?(vlc)
83
+ Log.debug "Using vlc player"
84
+ '/usr/bin/vlc -'
85
+ elsif File.exist?(totem)
86
+ Log.debug "Using totem player"
87
+ '/usr/bin/totem --enqueue fd://0'
88
+ else
89
+ raise "No player available. Install MPlayer, VLC or totem."
90
+ end
91
+ end
92
+
93
+ end
94
+ end