crumbl 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3b8dd0f98053b98e04343c60659836908c22ef6
4
- data.tar.gz: fe1bf8a3c123ac1650989dcd5712bf6e0a70d669
3
+ metadata.gz: 006098adc496eebb23ab9c02422bad0b71bbd141
4
+ data.tar.gz: 919397a66ec03e852e7cefc8d61d50e58f3eeb2f
5
5
  SHA512:
6
- metadata.gz: 813d43fa0cf1b6f070b8cbe0c24a5d3d1b17029422de9e40d28e0e54e340bf2c85245fad93bace746077d11046c4a408bb9047da6074e4d1c77806cb7cc38f39
7
- data.tar.gz: 236ca9d70db70d6ee5192c723086a69620b8725c0845fbad8547e64b414124967cfdea1eff974dd8327b2d11ecb95e32c5503e1488d49a9728816244e679b9bb
6
+ metadata.gz: 0981f5e8bed17773f8fb770fedd2700ff337078fbe8670c2bbacf7f71cd0b208d3752959e9dc9310b77c52618b40409db8aa0e98c02754bb303a83ffd0aa1287
7
+ data.tar.gz: 79c61c3bbd0c3befd0dcd9263696b463bee18a430be2d33a02063edbd55533da513cb9dc3c2cd84d6f66bbec97ef3310d82364a37bfd0889f3d8def9962e34dc
data/.gitignore ADDED
@@ -0,0 +1,34 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem "rake"
7
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 dlanner
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ crumbl
2
+ ============
3
+
4
+ Command line tool for reading and manipulating encoded or encrypted Rails cookies
5
+
6
+ # Installation
7
+ `gem install crumbl`
8
+
9
+ # Usage
10
+
11
+ #### Decrypt Rails 4 encrypted cookie:
12
+
13
+ ```
14
+ $ crumbl decrypt "secret key base" RWRWZ0xHSEsrNmx1TlZFOEpmcCtNVEY4QjdKelNETWlNdVV0TnlCZU0zTnA4ejZka2ZCR2EyQStydGhOaTRySC0tOEQyMFc2SkpLejRidjV5V1ZBUXpEUT09--67e625ac91a2fecc9a3da7146a3a92b667e0ed17
15
+ {"session_type"=>"user"}
16
+ ```
17
+
18
+ #### Encrypt Rails 4 cookie:
19
+ ```
20
+ $ crumbl encrypt "secret key base" --data session_type:admin
21
+ QnprY1BXSlI3WFo1MkxlZmJ6REE3b1N2ZExFaHdqYncvYnNTcHZTL0dQbmZ3RVVwU3hxNmpiVkJtQmNOTW4zYy0tNitvbnhGQ0szbWtIOTU4czNzMnJSUT09--4f397df94a66a3449511485c76e130ac10a35f32
22
+ ```
23
+
24
+ #### Decode Rails 3 signed cookie:
25
+
26
+ ```
27
+ $ crumbl decode BAh7BkkiEXNlc3Npb25fdHlwZQY6BkVUSSIJdXNlcgY7AFQ=--ff2751f14c049e970cd817b6bbb6575b7c8a7bd8
28
+ {"session_type"=>"user"}
29
+ ```
30
+
31
+ #### Encode Rails 3 signed cookie:
32
+
33
+ ```
34
+ $ crumbl encode "signing key" --data session_type:admin
35
+ BAh7BkkiEXNlc3Npb25fdHlwZQY6BkVUSSIKYWRtaW4GOwBU--a44fc16d8c2f185e4b667c4276e790ae1d40c505
36
+ ```
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.libs << 'test'
5
+ end
6
+
7
+ desc "Run tests"
8
+ task :default => :test
data/crumbl.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "crumbl/version"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'crumbl'
8
+ s.version = Crumbl::VERSION
9
+ s.date = '2014-10-08'
10
+ s.summary = "Read and manipulate encoded or encrypted Rails cookies"
11
+ s.description = "Command line tool for reading and manipulating encoded or encrypted Rails cookies"
12
+ s.authors = ["David Lanner"]
13
+ s.email = 'dhlanner2@gmail.com'
14
+ s.files = `git ls-files -z`.split("\x0")
15
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
17
+ s.require_paths = ["lib", "bin"]
18
+ s.homepage =
19
+ 'https://github.com/dlanner/crumbl'
20
+ s.license = 'MIT'
21
+ s.add_runtime_dependency "rack"
22
+ s.add_runtime_dependency "activesupport", '~> 4.0.0'
23
+ end
data/lib/crumbl/base.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'active_support/all'
2
2
  require 'rack'
3
3
 
4
- class Crumbl
4
+ module Crumbl
5
5
 
6
6
  DEFAULT_ITERATIONS = 1000
7
7
  DEFAULT_ENCRYPTED_COOKIE_SALT = "encrypted cookie"
@@ -1,3 +1,3 @@
1
1
  module Crumbl
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,56 @@
1
+ require 'minitest/autorun'
2
+ require 'crumbl'
3
+
4
+ class CrumblTest < Minitest::Unit::TestCase
5
+ def setup
6
+ @data = {:foo => "bar"}
7
+ @key_base = "secret key base"
8
+ @custom_iterations = 1001
9
+ @custom_encrypted_cookie_salt = @custom_encrypted_signed_cookie_salt = "salty"
10
+ end
11
+
12
+ def test_decrypt_encrypted
13
+ encrypted = Crumbl.encrypt(@data, @key_base)
14
+ decrypted = Crumbl.decrypt(encrypted, @key_base)
15
+ assert_equal @data, decrypted
16
+ end
17
+
18
+ def test_custom_iterations_equal
19
+ encrypted = Crumbl.encrypt(@data, @key_base, @custom_iterations)
20
+ decrypted = Crumbl.decrypt(encrypted, @key_base, @custom_iterations)
21
+ assert_equal @data, decrypted
22
+ end
23
+
24
+ def test_custom_iterations_not_equal
25
+ encrypted = Crumbl.encrypt(@data, @key_base)
26
+ assert_raises ActiveSupport::MessageVerifier::InvalidSignature do
27
+ Crumbl.decrypt(encrypted, @key_base, @custom_iterations)
28
+ end
29
+ end
30
+
31
+ def test_custom_encrypted_cookie_salt_equal
32
+ encrypted = Crumbl.encrypt(@data, @key_base, Crumbl::DEFAULT_ITERATIONS, @custom_encrypted_cookie_salt)
33
+ decrypted = Crumbl.decrypt(encrypted, @key_base, Crumbl::DEFAULT_ITERATIONS, @custom_encrypted_cookie_salt)
34
+ assert_equal @data, decrypted
35
+ end
36
+
37
+ def test_custom_encrypted_cookie_salt_not_equal
38
+ encrypted = Crumbl.encrypt(@data, @key_base)
39
+ assert_raises ActiveSupport::MessageEncryptor::InvalidMessage do
40
+ Crumbl.decrypt(encrypted, @key_base, Crumbl::DEFAULT_ITERATIONS, @custom_encrypted_cookie_salt)
41
+ end
42
+ end
43
+
44
+ def test_custom_encrypted_signed_cookie_salt_equal
45
+ encrypted = Crumbl.encrypt(@data, @key_base, Crumbl::DEFAULT_ITERATIONS, Crumbl::DEFAULT_ENCRYPTED_COOKIE_SALT, @custom_encrypted_signed_cookie_salt)
46
+ decrypted = Crumbl.decrypt(encrypted, @key_base, Crumbl::DEFAULT_ITERATIONS, Crumbl::DEFAULT_ENCRYPTED_COOKIE_SALT, @custom_encrypted_signed_cookie_salt)
47
+ assert_equal @data, decrypted
48
+ end
49
+
50
+ def test_custom_encrypted_signed_cookie_salt_not_equal
51
+ encrypted = Crumbl.encrypt(@data, @key_base)
52
+ assert_raises ActiveSupport::MessageVerifier::InvalidSignature do
53
+ Crumbl.decrypt(encrypted, @key_base, Crumbl::DEFAULT_ITERATIONS, Crumbl::DEFAULT_ENCRYPTED_COOKIE_SALT, @custom_encrypted_signed_cookie_salt)
54
+ end
55
+ end
56
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crumbl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Lanner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-07 00:00:00.000000000 Z
11
+ date: 2014-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -46,10 +46,18 @@ executables:
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
+ - ".gitignore"
50
+ - ".travis.yml"
51
+ - Gemfile
52
+ - LICENSE
53
+ - README.md
54
+ - Rakefile
49
55
  - bin/crumbl
56
+ - crumbl.gemspec
50
57
  - lib/crumbl.rb
51
58
  - lib/crumbl/base.rb
52
59
  - lib/crumbl/version.rb
60
+ - test/test_crumbl.rb
53
61
  homepage: https://github.com/dlanner/crumbl
54
62
  licenses:
55
63
  - MIT
@@ -75,4 +83,5 @@ rubygems_version: 2.4.2
75
83
  signing_key:
76
84
  specification_version: 4
77
85
  summary: Read and manipulate encoded or encrypted Rails cookies
78
- test_files: []
86
+ test_files:
87
+ - test/test_crumbl.rb