mop 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,42 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.unshift './lib'
3
+ require 'mop/version'
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "mop"
7
+ gem.version = Mop::VERSION
8
+ gem.authors = %w(☈king)
9
+ gem.email = %w(rking-mop@sharpsaw.org)
10
+ gem.summary = %q{Make OK for Public: Clean up sensitive info from a file before jisting}
11
+ gem.description = <<-EOT
12
+ A simplistic pre-filter (not (yet) a substitute for manual examination).
13
+
14
+ Usage
15
+ =====
16
+
17
+ mop < /var/log/nginx/error_log > cleaned_file
18
+ vim cleaned_file # check for anything it might've missed
19
+ jist -co cleaned_file # upload, copy its URL to clipboard, open in browser
20
+
21
+ Note
22
+ ====
23
+
24
+ This thing is really in its beginning phases. It currently:
25
+
26
+ * Deletes too much
27
+ * Leaves too much
28
+
29
+ However, all [Issues](https://github.com/rking/mop/issues) will be addressed.
30
+ Just file 'em.'
31
+ EOT
32
+ gem.homepage = 'https://github.com/rking/mop'
33
+ gem.files = `git ls-files`.split($/)
34
+ gem.executables = gem.files.grep(%r{^bin/}).map{|f| File.basename f}
35
+ gem.test_files = gem.files.grep %r{^ test|spec|features/}
36
+ gem.require_paths = ['lib']
37
+
38
+ %w(
39
+ jist
40
+ ).each do |dep| gem.add_dependency dep end
41
+ gem.add_development_dependency 'working'
42
+ end
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
@@ -0,0 +1,151 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mop (0.0.1)
5
+ jist
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ ansi (1.4.3)
11
+ awesome_print (1.1.0)
12
+ beg (0.0.3)
13
+ guard
14
+ binding_of_caller (0.6.8)
15
+ bond (0.4.3)
16
+ childprocess (0.3.6)
17
+ ffi (~> 1.0, >= 1.0.6)
18
+ coderay (1.0.8)
19
+ columnize (0.3.6)
20
+ debugger (1.2.3)
21
+ columnize (>= 0.3.1)
22
+ debugger-linecache (~> 1.1.1)
23
+ debugger-ruby_core_source (~> 1.1.5)
24
+ debugger-linecache (1.1.2)
25
+ debugger-ruby_core_source (>= 1.1.1)
26
+ debugger-ruby_core_source (1.1.6)
27
+ diff-lcs (1.1.3)
28
+ diffy (2.1.3)
29
+ ffi (1.2.0)
30
+ grit (2.5.0)
31
+ diff-lcs (~> 1.1)
32
+ mime-types (~> 1.15)
33
+ posix-spawn (~> 0.3.6)
34
+ guard (1.6.1)
35
+ listen (>= 0.6.0)
36
+ lumberjack (>= 1.0.2)
37
+ pry (>= 0.9.10)
38
+ thor (>= 0.14.6)
39
+ guard-bundler (1.0.0)
40
+ bundler (~> 1.0)
41
+ guard (~> 1.1)
42
+ guard-spork (1.4.0)
43
+ childprocess (>= 0.2.3)
44
+ guard (>= 1.1)
45
+ spork (>= 0.8.4)
46
+ guard-sporkminitest (0.0.2)
47
+ guard
48
+ guard-spork
49
+ rb-fsevent
50
+ rb-inotify
51
+ spork-minitest
52
+ interception (0.3)
53
+ jist (1.4.0)
54
+ json
55
+ json (1.7.6)
56
+ listen (0.7.0)
57
+ lumberjack (1.0.2)
58
+ method_source (0.8.1)
59
+ mime-types (1.19)
60
+ minitest (4.3.3)
61
+ nokogiri (1.5.6)
62
+ posix-spawn (0.3.6)
63
+ pry (0.9.11)
64
+ coderay (~> 1.0.5)
65
+ method_source (~> 0.8)
66
+ slop (~> 3.3.1)
67
+ pry-awesome_print (9.6.5)
68
+ awesome_print (~> 1.1.0)
69
+ pry-de (0.1.0)
70
+ guard
71
+ pry-full
72
+ pry-debugger (0.2.1)
73
+ debugger (~> 1.2.0)
74
+ pry (~> 0.9.10)
75
+ pry-developer_tools (0.1.1)
76
+ pry (>= 0.9.8.pre, < 0.11)
77
+ pry-doc (0.4.4)
78
+ pry (>= 0.9.9.6)
79
+ yard (~> 0.8.1)
80
+ pry-docmore (0.0.3)
81
+ pry
82
+ pry-doc
83
+ pry-editline (1.1.1)
84
+ pry-exception_explorer (0.2.3)
85
+ pry-stack_explorer (>= 0.4.6)
86
+ pry-full (1.2.0)
87
+ pry-awesome_print
88
+ pry-developer_tools
89
+ pry-editline
90
+ pry-git
91
+ pry-highlight
92
+ pry-plus
93
+ pry-pretty-numeric
94
+ pry-syntax-hacks
95
+ pry-theme
96
+ pry-git (0.2.3)
97
+ diffy
98
+ grit
99
+ pry (>= 0.9.8)
100
+ pry-highlight (0.0.1)
101
+ coderay
102
+ json
103
+ nokogiri
104
+ pry
105
+ pry-plus (0.2.0)
106
+ bond
107
+ jist
108
+ pry-debugger
109
+ pry-doc
110
+ pry-docmore
111
+ pry-exception_explorer
112
+ pry-rescue
113
+ pry-stack_explorer
114
+ pry-pretty-numeric (0.1.1)
115
+ pry
116
+ pry-rescue (0.14)
117
+ interception (>= 0.3)
118
+ pry
119
+ pry-stack_explorer (0.4.7)
120
+ binding_of_caller (~> 0.6.8)
121
+ pry-syntax-hacks (0.0.6)
122
+ pry (>= 0.9.8)
123
+ pry-theme (0.1.3)
124
+ json
125
+ rake (10.0.3)
126
+ rb-fsevent (0.9.3)
127
+ rb-inotify (0.8.8)
128
+ ffi (>= 0.5.0)
129
+ slop (3.3.3)
130
+ spork (0.9.2)
131
+ spork-minitest (0.0.3)
132
+ spork
133
+ thor (0.16.0)
134
+ turn (0.9.6)
135
+ ansi
136
+ working (0.0.7)
137
+ beg
138
+ guard-bundler
139
+ guard-sporkminitest
140
+ minitest
141
+ pry-de
142
+ rake
143
+ turn
144
+ yard (0.8.3)
145
+
146
+ PLATFORMS
147
+ ruby
148
+
149
+ DEPENDENCIES
150
+ mop!
151
+ working
@@ -0,0 +1,4 @@
1
+ require 'working/guard'
2
+ guard :sporkminitest do
3
+ watch 'test/cases.yml' do 'test/mop_test.rb' end
4
+ end
@@ -0,0 +1,103 @@
1
+ mop
2
+ ===
3
+
4
+ Make OK for Public. A simplistic pre-filter (not (yet) a substitute for manual
5
+ examination).
6
+
7
+ Usage
8
+ -----
9
+
10
+ mop < /var/log/nginx/error_log > cleaned_file
11
+ vim cleaned_file # check for anything it might've missed
12
+ jist -co cleaned_file # upload, copy its URL to clipboard, open in browser
13
+
14
+ Note
15
+ ----
16
+
17
+ This thing is really in its beginning phases. It currently:
18
+
19
+ * Deletes too much
20
+ * Leaves too much
21
+
22
+ However, all [Issues](https://github.com/rking/mop/issues) will be addressed.
23
+ Just file 'em.'
24
+
25
+ Currently Works With
26
+ --------------------
27
+
28
+ - Passwords
29
+ - `"password: secr3t"` ⇒ `"password: hiddenpass"`
30
+ - `"password: secr3t"` ⇒ `"password: hiddenpass"`
31
+ - `"password:\n\tsecr3t"` ⇒ `"password:\n\thiddenpass"`
32
+ - `"password: 'secr3t'"` ⇒ `"password: hiddenpass"`
33
+ - `"password:secr3t"` ⇒ `"password:hiddenpass"`
34
+ - `"passwd:secr3t"` ⇒ `"passwd:hiddenpass"`
35
+ - `"passwd: secr3t"` ⇒ `"passwd: hiddenpass"`
36
+ - `"password=secr3t"` ⇒ `"password=hiddenpass"`
37
+ - `"passwd=secr3t"` ⇒ `"passwd=hiddenpass"`
38
+ - `"password=\"secr3t\""` ⇒ `"password=hiddenpass"`
39
+ - `"buzbuz password: secr3t bizbiz"` ⇒ `"buzbuz password: hiddenpass bizbiz"`
40
+ - `"buzbuz password: secr3t bizbiz another password: secr4t bazbaz"` ⇒ `"buzbuz password: hiddenpass bizbiz another password: hiddenpass bazbaz"`
41
+ - `"USER: user55 PASS: secr3t"` ⇒ `"USER: hiddenuser PASS: hiddenpass"`
42
+ - `"U/N: user55 P/W: secr3t"` ⇒ `"U/N: hiddenuser P/W: hiddenpass"`
43
+ - `"U: user55 P: secr3t"` ⇒ `"U: hiddenuser P: hiddenpass"`
44
+ - `"U=user55 P=secr3t"` ⇒ `"U=hiddenuser P=hiddenpass"`
45
+ - `"u=user55 p=secr3t"` ⇒ `"u=hiddenuser p=hiddenpass"`
46
+ - `"u: user55 p: secr3t"` ⇒ `"u: hiddenuser p: hiddenpass"`
47
+ - `"L=user55 P=secr3t"` ⇒ `"L=hiddenuser P=hiddenpass"`
48
+ - Users
49
+ - `"user: user55"` ⇒ `"user: hiddenuser"`
50
+ - `"User=user55"` ⇒ `"User=hiddenuser"`
51
+ - `"/Users/user55"` ⇒ `"hiddenuser"`
52
+ - `"/home/user55"` ⇒ `"hiddenuser"`
53
+ - IPv4 Addresses
54
+ - `"1.2.3.4"` ⇒ `"XX.YY.ZZ.AA"`
55
+ - `"asdf 1.2.3.4 asdf"` ⇒ `"asdf XX.YY.ZZ.AA asdf"`
56
+ - `"1.2.3.4:22"` ⇒ `"XX.YY.ZZ.AA:22"`
57
+ - `"123.45.67.89"` ⇒ `"XX.YY.ZZ.AA"`
58
+ - `"0.0.0.0"` _(unchanged)_
59
+ - `"127.0.0.1"` _(unchanged)_
60
+ - IPv6 Addresses (probably many patterns TODO on this one)
61
+ - `"21:43:6f:1a:f6:f6"` ⇒ `"aa:bb:cc:dd:ee:ff"`
62
+ - Capistrano's `deploy.rb`
63
+ - `"host_name: 'shouldhide'"` ⇒ `"host_name: caphidden"`
64
+ - `"host_name: \"shouldhide\""` ⇒ `"host_name: caphidden"`
65
+ - `":host_name => 'shouldhide'"` ⇒ `":host_name => caphidden"`
66
+ - `":host_name, 'shouldhide'"` ⇒ `":host_name, caphidden"`
67
+ - `":port => 'shouldhide'"` ⇒ `":port => caphidden"`
68
+ - `"deploy_to, 'shouldhide'"` ⇒ `"deploy_to, caphidden"`
69
+ - `"server 'shouldhide', …"` ⇒ `"server capserver …"`
70
+ - `"set :application, \"shouldhide\""` ⇒ `"set :application, caphidden"`
71
+ - `"set :user, \"shouldhide\""` ⇒ `"set :user, hiddenuser"`
72
+ - `"server without comma"` _(unchanged)_
73
+ - `"portage"` _(unchanged)_
74
+ - /etc/passwd having "fakeuser" and "fakeuser2"
75
+ - `"foo bar fakeuser baz"` ⇒ `"foo bar hiddenuser baz"`
76
+ - `"~/fakeuser"` ⇒ `"~/hiddenuser"`
77
+ - `"/home/fakeuser/.foo"` ⇒ `"hiddenuser"`
78
+ - `"fakeuser2"` ⇒ `"hiddenuser"`
79
+ - `"cron"` _(unchanged)_
80
+ - `"root"` _(unchanged)_
81
+ - hostname being 'gargantatron'
82
+ - `"gargantatron"` ⇒ `"hiddenhost"`
83
+ - Git repos
84
+ - `"git@github.com/username/reponame.git"` ⇒ `"git@github.com/hiddenrepo"`
85
+ - `"git@github.com/username/reponame"` ⇒ `"git@github.com/hiddenrepo"`
86
+ - `"git@github.com:username/reponame"` ⇒ `"git@github.com:hiddenrepo"`
87
+ - `"https://github.com/username/reponame"` ⇒ `"https://github.com/hiddenrepo"`
88
+ - `"http://github.com/username/reponame"` ⇒ `"http://github.com/hiddenrepo"`
89
+ - `"git://github.com/username/reponame"` ⇒ `"git://github.com/hiddenrepo"`
90
+ - `"http://someotherhost.net/reponame.git"` ⇒ `"http://hiddenrepo"`
91
+ - SSH
92
+ - `"ssh://user55@secrethost/path/to/reponame.git/"` ⇒ `"ssh://hiddensshurl"`
93
+
94
+
95
+ TODO
96
+ ----
97
+
98
+ - Add -j for ConradIrwin's `jist` gem
99
+ - Make distinct (similar to an uglifier's symbol replacement)
100
+ - first.host.name ⇒ hiddenhostname1
101
+ - second.host.name ⇒ hiddenhostname2
102
+ - Learn more about IPv6 Addresses
103
+ - Dorky ISP-given hostnames that show IP addresses
@@ -0,0 +1,38 @@
1
+ mop
2
+ ===
3
+
4
+ Make OK for Public. A simplistic pre-filter (not (yet) a substitute for manual
5
+ examination).
6
+
7
+ Usage
8
+ -----
9
+
10
+ mop < /var/log/nginx/error_log > cleaned_file
11
+ vim cleaned_file # check for anything it might've missed
12
+ jist -co cleaned_file # upload, copy its URL to clipboard, open in browser
13
+
14
+ Note
15
+ ----
16
+
17
+ This thing is really in its beginning phases. It currently:
18
+
19
+ * Deletes too much
20
+ * Leaves too much
21
+
22
+ However, all [Issues](https://github.com/rking/mop/issues) will be addressed.
23
+ Just file 'em.'
24
+
25
+ Currently Works With
26
+ --------------------
27
+
28
+ <%= actual_results %>
29
+
30
+ TODO
31
+ ----
32
+
33
+ - Add -j for ConradIrwin's `jist` gem
34
+ - Make distinct (similar to an uglifier's symbol replacement)
35
+ - first.host.name ⇒ hiddenhostname1
36
+ - second.host.name ⇒ hiddenhostname2
37
+ - Learn more about IPv6 Addresses
38
+ - Dorky ISP-given hostnames that show IP addresses
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ task :dev do
4
+ sh 'urxvt -e bundle exec guard &'
5
+ sh './edit'
6
+ end
@@ -0,0 +1,3 @@
1
+ #!/bin/zsh -e
2
+ cmd=${@:-sudo cat /var/log/messages}
3
+ vimdiff =(eval $cmd) =(eval $cmd | bin/mop)
data/bin/mop ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'mop'
3
+ puts Mop.wipe $stdin.read
data/edit ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/sh -xe
2
+ tmux splitw 'vim spec/cases.yml'
3
+ vim lib/mop.rb
@@ -0,0 +1,63 @@
1
+ class Mop
2
+ IPv4_ADDRESSES = %r/((\d+\.){3}\d+)/
3
+ HEXDIGIT = %r/[a-z0-9]/i # XXX a-f
4
+ IPv6_ADDRESSES = %r/((#{HEXDIGIT}+:){5}#{HEXDIGIT}+)/
5
+ EQUATE = %r/\s*(?:=>|[:=]|,)\s*/
6
+ USER_EQUALS = %r/(user#{EQUATE})\S+/i
7
+ HOME_DIRS = %r((/(?:Users|home)/)\S+) # not worried about spaces in usernames.
8
+ USER_PATTERN = %r/(?:#{USER_EQUALS}|#{HOME_DIRS})/
9
+ PASSWORD_EQUALS = %r/(passw?(or)?d?#{EQUATE})\S+/i
10
+ UN = %r[\b(?:[ul]\/?n?)\b]i
11
+ PW = %r[\b(?:p\/?w?)\b]i
12
+ USERNAME_AND_PASSWORD = %r/(#{UN}#{EQUATE})\S+(\s*#{PW}#{EQUATE})\S+/
13
+ GITHUB_URL = %r[((?:git@|(?:https?|git)://)github.com[:/])[^/]+/.+(\.git)?]i
14
+ GIT_URL = %r[(ssh|git|https?|ftp|rsync)://\S+(\.git)]
15
+ SSH_URL = %r[(ssh://)\S+]i
16
+ CAPISTRANO_KEYWORDS = %r/((?:host_name|port|deploy_to|application)(?:#{EQUATE}))\S+/
17
+ CAPISTRANO_SERVER = %r/(\bserver\s+)\S+,/
18
+
19
+ def self.wipe input
20
+ cleanups = username_cleanups + [
21
+ hostname_cleanup,
22
+ [ IPv4_ADDRESSES, -> { check_address $1 } ],
23
+ [ IPv6_ADDRESSES, -> { 'aa:bb:cc:dd:ee:ff' } ],
24
+ [ USER_PATTERN, -> { "#$1hiddenuser" } ],
25
+ [ PASSWORD_EQUALS, -> { "#$1hiddenpass" } ],
26
+ [ USERNAME_AND_PASSWORD, -> { "#$1hiddenuser#$2hiddenpass" } ],
27
+ [ GITHUB_URL, -> { "#$1hiddenrepo#$2" } ],
28
+ [ GIT_URL, -> { "#$1://hiddenrepo" } ],
29
+ [ SSH_URL, -> { "#$1hiddensshurl" } ],
30
+ [ CAPISTRANO_KEYWORDS, -> { "#$1caphidden" } ],
31
+ [ CAPISTRANO_SERVER, -> { "#$1capserver" } ],
32
+ ]
33
+ cleanups.inject input do |result, xform|
34
+ result.gsub xform[0] do xform[1].call end
35
+ end
36
+ end
37
+
38
+ def self.username_cleanups
39
+ users = read_etc_passwd.split(/\n/).map do |e|
40
+ username, archaic, uid, *junk = e.split ':'
41
+ uid.to_i >= 1000 and username
42
+ end.compact
43
+ users.map do |e|
44
+ [ %r/\b#{e}\b/, -> { 'hiddenuser' } ]
45
+ end
46
+ end
47
+ def self.read_etc_passwd; File.read '/etc/passwd' end
48
+
49
+ def self.hostname_cleanup
50
+ [ %r/\b#{find_hostname}\b/, -> { 'hiddenhost' } ]
51
+ end
52
+ def self.find_hostname; `hostname`.chomp || 'weird, no hostname' end
53
+
54
+ PASSTHRU_ADDRESSES = %w(127.0.0.1 0.0.0.0)
55
+ def self.check_address addr
56
+ if PASSTHRU_ADDRESSES.include? addr
57
+ addr
58
+ else
59
+ 'XX.YY.ZZ.AA'
60
+ end
61
+ end
62
+ end
63
+
@@ -0,0 +1,3 @@
1
+ class Mop
2
+ VERSION = '0.0.2'
3
+ end
Binary file
@@ -0,0 +1,97 @@
1
+ fake passwd file: |
2
+ root:x:0:0:root:/root:/bin/zsh
3
+ cron:x:16:16:added by portage for cronbase:/var/spool/cron:/sbin/nologin
4
+ fakeuser:x:1000:1000::/home/fakeuser:/bin/zsh
5
+ fakeuser2:x:1001:1001::/home/fakeuser2:/bin/zsh
6
+ fake hostname: gargantatron
7
+ Passwords:
8
+ - filter: [ secr3t, secr4t ]
9
+ from:
10
+ - 'password: secr3t'
11
+ - 'password: secr3t'
12
+ - "password:\n\tsecr3t"
13
+ - "password: 'secr3t'"
14
+ - 'password:secr3t'
15
+ - 'passwd:secr3t'
16
+ - 'passwd: secr3t'
17
+ - password=secr3t
18
+ - passwd=secr3t
19
+ - password="secr3t"
20
+ - 'buzbuz password: secr3t bizbiz'
21
+ - 'buzbuz password: secr3t bizbiz another password: secr4t bazbaz'
22
+ - 'USER: user55 PASS: secr3t'
23
+ - 'U/N: user55 P/W: secr3t'
24
+ - 'U: user55 P: secr3t'
25
+ - U=user55 P=secr3t
26
+ - u=user55 p=secr3t
27
+ - 'u: user55 p: secr3t'
28
+ - L=user55 P=secr3t
29
+ Users:
30
+ - filter: user55
31
+ from:
32
+ - 'user: user55'
33
+ - 'User=user55'
34
+ - '/Users/user55'
35
+ - '/home/user55'
36
+ IPv4 Addresses:
37
+ - filter: 1.2.3.4
38
+ from:
39
+ - 1.2.3.4
40
+ - asdf 1.2.3.4 asdf
41
+ - 1.2.3.4:22
42
+ - filter: 123.45.67.89
43
+ from:
44
+ - 123.45.67.89
45
+ - passthru:
46
+ - 0.0.0.0
47
+ - 127.0.0.1
48
+ IPv6 Addresses (probably many patterns TODO on this one):
49
+ - filter: 21:43:6f:1a:f6:f6
50
+ from:
51
+ - 21:43:6f:1a:f6:f6
52
+ "Capistrano's `deploy.rb`":
53
+ - filter: shouldhide
54
+ from:
55
+ - "host_name: 'shouldhide'"
56
+ - 'host_name: "shouldhide"'
57
+ - ":host_name => 'shouldhide'"
58
+ - ":host_name, 'shouldhide'"
59
+ - ":port => 'shouldhide'"
60
+ - deploy_to, 'shouldhide'
61
+ - server 'shouldhide', …
62
+ - 'set :application, "shouldhide"'
63
+ - 'set :user, "shouldhide"'
64
+ - passthru:
65
+ - server without comma
66
+ - portage
67
+ /etc/passwd having "fakeuser" and "fakeuser2":
68
+ - filter: fakeuser
69
+ from:
70
+ - foo bar fakeuser baz
71
+ - ~/fakeuser
72
+ - /home/fakeuser/.foo
73
+ - filter: fakeuser2
74
+ from:
75
+ - fakeuser2
76
+ - passthru:
77
+ - cron
78
+ - root
79
+ hostname being 'gargantatron':
80
+ - filter: gargantatron
81
+ from:
82
+ - gargantatron
83
+ Git repos:
84
+ - filter: [ username, reponame, someotherhost ]
85
+ from:
86
+ - git@github.com/username/reponame.git
87
+ - git@github.com/username/reponame
88
+ - git@github.com:username/reponame
89
+ - https://github.com/username/reponame
90
+ - http://github.com/username/reponame
91
+ - git://github.com/username/reponame
92
+ - http://someotherhost.net/reponame.git
93
+ SSH:
94
+ - filter: [ user55, secrethost, path, to, reponame ]
95
+ from:
96
+ - ssh://user55@secrethost/path/to/reponame.git/
97
+ # TODO [user@]host.xz:path/to/repo.git/
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+ require './test/test_helper'
3
+ require 'stringio'
4
+ require 'erb'
5
+
6
+ class MopTest < MiniTest::Unit::TestCase
7
+ def setup
8
+ @cases = YAML.load_file('test/cases.yml')
9
+ $passwd_contents = @cases.delete 'fake passwd file'
10
+ def Mop.read_etc_passwd; $passwd_contents end
11
+ $hostname = @cases.delete 'fake hostname'
12
+ def Mop.find_hostname; $hostname end
13
+ end
14
+
15
+ def write_readme actual_results
16
+ template = ERB.new File.read('README.md.erb')
17
+ File.write 'README.md', template.result(binding)
18
+ end
19
+
20
+ def test_in_a_big_loop
21
+ doc = StringIO.new
22
+ @cases.each do |name, intentions|
23
+ doc.puts '- ' + name
24
+ intentions.each do |intention|
25
+ if intention.has_key? 'passthru'
26
+ intention['passthru'].each do |already_clean|
27
+ assert_equal Mop.wipe(already_clean), already_clean
28
+ doc.puts " - `#{already_clean.inspect}` _(unchanged)_"
29
+ end
30
+ elsif intention.has_key? 'filter' and intention.has_key? 'from'
31
+ illicit = [intention['filter']].flatten
32
+ intention['from'].each do |dirty|
33
+ dirty.freeze # make sure original is unchanged
34
+ clean = Mop.wipe dirty
35
+ illicit.each do |e|
36
+ refute clean.include?(e),
37
+ "#{name} — should wipe #{illicit} from #{dirty}"
38
+ end
39
+ doc.puts " - `#{dirty.inspect}` ⇒ `#{clean.inspect}`"
40
+ end
41
+ else
42
+ fail "Unknown test case structure: #{intention.to_yaml}"
43
+ end
44
+ end
45
+ end
46
+ write_readme doc.string
47
+ end
48
+
49
+ def test_differentiated_symbols_like_an_uglifier
50
+ # TODO
51
+ end
52
+ end
@@ -0,0 +1,5 @@
1
+ require 'working/test_helper'
2
+ Spork.each_run do
3
+ require 'mop'
4
+ end
5
+ # Spork.prefork doesn't like it when this line is missing
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mop
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - ☈king
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: jist
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: working
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: ! "A simplistic pre-filter (not (yet) a substitute for manual examination).\n\nUsage\n=====\n\n
47
+ \ mop < /var/log/nginx/error_log > cleaned_file\n vim cleaned_file # check
48
+ for anything it might've missed\n jist -co cleaned_file # upload, copy its URL
49
+ to clipboard, open in browser\n\nNote\n====\n\nThis thing is really in its beginning
50
+ phases. It currently:\n\n* Deletes too much\n* Leaves too much\n\nHowever, all [Issues](https://github.com/rking/mop/issues)
51
+ will be addressed.\nJust file 'em.'\n"
52
+ email:
53
+ - rking-mop@sharpsaw.org
54
+ executables:
55
+ - mop
56
+ extensions: []
57
+ extra_rdoc_files: []
58
+ files:
59
+ - .gemspec
60
+ - .rspec
61
+ - Gemfile
62
+ - Gemfile.lock
63
+ - Guardfile
64
+ - README.md
65
+ - README.md.erb
66
+ - Rakefile
67
+ - acceptance-test
68
+ - bin/mop
69
+ - edit
70
+ - lib/mop.rb
71
+ - lib/mop/version.rb
72
+ - pkg/mop-0.0.1.gem
73
+ - test/cases.yml
74
+ - test/mop_test.rb
75
+ - test/test_helper.rb
76
+ homepage: https://github.com/rking/mop
77
+ licenses: []
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 1.8.24
97
+ signing_key:
98
+ specification_version: 3
99
+ summary: ! 'Make OK for Public: Clean up sensitive info from a file before jisting'
100
+ test_files:
101
+ - .gemspec
102
+ - .rspec
103
+ has_rdoc: