fingerprint 3.0.1 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/fingerprint/checker.rb +2 -2
- data/lib/fingerprint/command/analyze.rb +1 -1
- data/lib/fingerprint/command/compare.rb +1 -1
- data/lib/fingerprint/command/duplicates.rb +8 -5
- data/lib/fingerprint/command/scan.rb +1 -1
- data/lib/fingerprint/command/verify.rb +1 -1
- data/lib/fingerprint/command.rb +1 -1
- data/lib/fingerprint/record.rb +24 -7
- data/lib/fingerprint/scanner.rb +3 -3
- data/lib/fingerprint/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +50 -64
- metadata.gz.sig +0 -0
- data/.gitignore +0 -15
- data/.rspec +0 -3
- data/.travis.yml +0 -23
- data/GUIDE.md +0 -233
- data/Gemfile +0 -4
- data/README.md +0 -168
- data/Rakefile +0 -6
- data/fingerprint.gemspec +0 -28
- data/spec/fingerprint/command/analyze_spec.rb +0 -48
- data/spec/fingerprint/command/duplicates_spec.rb +0 -53
- data/spec/fingerprint/command/source_fingerprint.rb +0 -32
- data/spec/fingerprint/command/verify_spec.rb +0 -39
- data/spec/fingerprint/corpus/README.md +0 -3
- data/spec/fingerprint/scanner_spec.rb +0 -67
- data/spec/fingerprint_spec.rb +0 -33
- data/spec/spec_helper.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8ad0fb2f50f482dc7dc06185001d5eefd60ea136069d0e0c2004eaefdba4351
|
4
|
+
data.tar.gz: a0256e102d7628d5410fa94bb9f23b8f0858155a10d4dbef108097b76129ec78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0aff09d12a3c2f5c683433aa1e6ed0f9f2a8d77be668cdd1aac6d20899821d091f1edce2be721bc5889b12cfe69bfd1248fed6e275ab6a941c7da6b416d2457
|
7
|
+
data.tar.gz: 1ac6617e297ed4395fb05fd8cb6e785f98b9f298b0b1326235b034d450c78858cdbcab7370b781150c8acc06ff6cb7df444703632321374d426a02dfaf0f14c7
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data/lib/fingerprint/checker.rb
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
-
|
21
|
+
require_relative 'record'
|
22
22
|
|
23
23
|
module Fingerprint
|
24
24
|
# Given two fingerprints (master and copy) ensures that the copy has at least everything contained
|
@@ -77,7 +77,7 @@ module Fingerprint
|
|
77
77
|
end
|
78
78
|
|
79
79
|
if @options[:progress]
|
80
|
-
$stderr.puts "# Progress: File #{processed_count} / #{total_count}; Byte #{processed_size} / #{total_size} = #{sprintf('%0.2f
|
80
|
+
$stderr.puts "# Progress: File #{processed_count} / #{total_count}; Byte #{processed_size} / #{total_size} = #{sprintf('%0.2f%%', processed_size.to_f / total_size.to_f * 100.0)}"
|
81
81
|
|
82
82
|
processed_size += (record['file.size'] || 0).to_i
|
83
83
|
end
|
@@ -44,7 +44,7 @@ module Fingerprint
|
|
44
44
|
options = @options.dup
|
45
45
|
options[:output] = @parent.output
|
46
46
|
|
47
|
-
error_count = Checker.check_files(@master, @copy, options)
|
47
|
+
error_count = Checker.check_files(@master, @copy, **options)
|
48
48
|
|
49
49
|
if @options[:fail_on_errors]
|
50
50
|
abort "Data inconsistent, #{error_count} error(s) found!" if error_count != 0
|
@@ -37,15 +37,13 @@ module Fingerprint
|
|
37
37
|
end
|
38
38
|
|
39
39
|
one :master, "The source fingerprint which represents the primarily file list."
|
40
|
-
many :copies, "Zero or more fingerprints which might contain duplicates."
|
40
|
+
many :copies, "Zero or more fingerprints which might contain duplicates.", default: []
|
41
41
|
|
42
42
|
attr :duplicates_recordset
|
43
43
|
|
44
44
|
def call
|
45
|
-
@options[:output] = @parent.output
|
46
|
-
|
47
45
|
@duplicates_recordset = RecordSet.new
|
48
|
-
results = RecordSetPrinter.new(duplicates_recordset, @
|
46
|
+
results = RecordSetPrinter.new(@duplicates_recordset, @parent.output)
|
49
47
|
|
50
48
|
master_file_path = @master
|
51
49
|
File.open(master_file_path) do |master_file|
|
@@ -54,7 +52,8 @@ module Fingerprint
|
|
54
52
|
|
55
53
|
ignore_similar = false
|
56
54
|
|
57
|
-
copy_file_paths = @copies
|
55
|
+
copy_file_paths = @copies
|
56
|
+
|
58
57
|
if copy_file_paths.size == 0
|
59
58
|
copy_file_paths = [master_file_path]
|
60
59
|
ignore_similar = true
|
@@ -66,7 +65,11 @@ module Fingerprint
|
|
66
65
|
copy_recordset.parse(copy_file)
|
67
66
|
|
68
67
|
copy_recordset.records.each do |record|
|
68
|
+
next unless record.file?
|
69
|
+
|
69
70
|
record.metadata['fingerprint'] = copy_file_path
|
71
|
+
record.metadata['full_path'] = copy_recordset.full_path(record.path)
|
72
|
+
|
70
73
|
# We need to see if the record exists in the master
|
71
74
|
|
72
75
|
if @options[:verbose]
|
@@ -70,7 +70,7 @@ module Fingerprint
|
|
70
70
|
options.merge!(master.configuration.options)
|
71
71
|
end
|
72
72
|
|
73
|
-
scanner = Scanner.new(@paths, options)
|
73
|
+
scanner = Scanner.new(@paths, **options)
|
74
74
|
|
75
75
|
# We use a sparse record set here, so we can't check for additions.
|
76
76
|
copy = SparseRecordSet.new(scanner)
|
data/lib/fingerprint/command.rb
CHANGED
data/lib/fingerprint/record.rb
CHANGED
@@ -46,6 +46,10 @@ module Fingerprint
|
|
46
46
|
attr :metadata
|
47
47
|
attr :keys
|
48
48
|
|
49
|
+
def file?
|
50
|
+
@mode == :file
|
51
|
+
end
|
52
|
+
|
49
53
|
def [](key)
|
50
54
|
@metadata[key]
|
51
55
|
end
|
@@ -95,29 +99,42 @@ module Fingerprint
|
|
95
99
|
self.new.tap{|record_set| record_set.parse(io)}
|
96
100
|
end
|
97
101
|
|
98
|
-
def initialize
|
102
|
+
def initialize(root = nil)
|
103
|
+
@root = root
|
99
104
|
@records = []
|
100
105
|
@paths = {}
|
101
106
|
@keys = {}
|
102
107
|
|
103
108
|
@configuration = nil
|
104
|
-
|
109
|
+
|
105
110
|
@callback = nil
|
106
111
|
end
|
107
|
-
|
112
|
+
|
113
|
+
attr :root
|
114
|
+
|
108
115
|
attr :records
|
109
116
|
attr :paths
|
110
117
|
attr :keys
|
111
|
-
|
118
|
+
|
112
119
|
attr :configuration
|
113
|
-
|
120
|
+
|
121
|
+
def full_path(path)
|
122
|
+
Build::Files::Path.join(@root, path)
|
123
|
+
end
|
124
|
+
|
114
125
|
def <<(record)
|
115
126
|
@records << record
|
127
|
+
|
116
128
|
if record.mode == :configuration
|
117
|
-
|
129
|
+
if @configuration
|
130
|
+
raise "Multiple configurations detected!"
|
131
|
+
end
|
132
|
+
|
118
133
|
@configuration = record
|
134
|
+
@root = @configuration.path
|
119
135
|
else
|
120
136
|
@paths[record.path] = record
|
137
|
+
|
121
138
|
record.keys.each do |key|
|
122
139
|
@keys[key] ||= {}
|
123
140
|
|
@@ -125,7 +142,7 @@ module Fingerprint
|
|
125
142
|
end
|
126
143
|
end
|
127
144
|
end
|
128
|
-
|
145
|
+
|
129
146
|
def include?(path)
|
130
147
|
@paths.include?(path)
|
131
148
|
end
|
data/lib/fingerprint/scanner.rb
CHANGED
@@ -259,7 +259,7 @@ module Fingerprint
|
|
259
259
|
|
260
260
|
if @options[:progress]
|
261
261
|
@progress = lambda do |read_size|
|
262
|
-
$stderr.puts "# Progress: File #{processed_count} / #{total_count}; Byte #{processed_size + read_size} / #{total_size} = #{sprintf('%0.3f
|
262
|
+
$stderr.puts "# Progress: File #{processed_count} / #{total_count}; Byte #{processed_size + read_size} / #{total_size} = #{sprintf('%0.3f%%', (processed_size + read_size).to_f / total_size.to_f * 100.0)} (#{read_size}, #{processed_size}, #{total_size})"
|
263
263
|
end
|
264
264
|
end
|
265
265
|
|
@@ -323,7 +323,7 @@ module Fingerprint
|
|
323
323
|
end
|
324
324
|
|
325
325
|
# A helper function to scan a set of directories.
|
326
|
-
def self.scan_paths(paths, options
|
326
|
+
def self.scan_paths(paths, **options)
|
327
327
|
if options[:output]
|
328
328
|
if options.key? :recordset
|
329
329
|
recordset = options[:recordset]
|
@@ -334,7 +334,7 @@ module Fingerprint
|
|
334
334
|
options[:recordset] = RecordSetPrinter.new(recordset, options[:output])
|
335
335
|
end
|
336
336
|
|
337
|
-
scanner = Scanner.new(paths, options)
|
337
|
+
scanner = Scanner.new(paths, **options)
|
338
338
|
|
339
339
|
scanner.scan(options[:recordset])
|
340
340
|
|
data/lib/fingerprint/version.rb
CHANGED
data.tar.gz.sig
ADDED
Binary file
|
metadata
CHANGED
@@ -1,45 +1,74 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fingerprint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
-
|
8
|
+
- Glenn Rempe
|
9
|
+
autorequire:
|
9
10
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
|
11
|
+
cert_chain:
|
12
|
+
- |
|
13
|
+
-----BEGIN CERTIFICATE-----
|
14
|
+
MIIEhDCCAuygAwIBAgIBATANBgkqhkiG9w0BAQsFADA3MTUwMwYDVQQDDCxzYW11
|
15
|
+
ZWwud2lsbGlhbXMvREM9b3Jpb250cmFuc2Zlci9EQz1jby9EQz1uejAeFw0yMTA4
|
16
|
+
MTYwNjMzNDRaFw0yMjA4MTYwNjMzNDRaMDcxNTAzBgNVBAMMLHNhbXVlbC53aWxs
|
17
|
+
aWFtcy9EQz1vcmlvbnRyYW5zZmVyL0RDPWNvL0RDPW56MIIBojANBgkqhkiG9w0B
|
18
|
+
AQEFAAOCAY8AMIIBigKCAYEAyXLSS/cw+fXJ5e7hi+U/TeChPWeYdwJojDsFY1xr
|
19
|
+
xvtqbTTL8gbLHz5LW3QD2nfwCv3qTlw0qI3Ie7a9VMJMbSvgVEGEfQirqIgJXWMj
|
20
|
+
eNMDgKsMJtC7u/43abRKx7TCURW3iWyR19NRngsJJmaR51yGGGm2Kfsr+JtKKLtL
|
21
|
+
L188Wm3f13KAx7QJU8qyuBnj1/gWem076hzdA7xi1DbrZrch9GCRz62xymJlrJHn
|
22
|
+
9iZEZ7AxrS7vokhMlzSr/XMUihx/8aFKtk+tMLClqxZSmBWIErWdicCGTULXCBNb
|
23
|
+
E/mljo4zEVKhlTWpJklMIhr55ZRrSarKFuW7en0+tpJrfsYiAmXMJNi4XAYJH7uL
|
24
|
+
rgJuJwSaa/dMz+VmUoo7VKtSfCoOI+6v5/z0sK3oT6sG6ZwyI47DBq2XqNC6tnAj
|
25
|
+
w+XmCywiTQrFzMMAvcA7rPI4F0nU1rZId51rOvvfxaONp+wgTi4P8owZLw0/j0m4
|
26
|
+
8C20DYi6EYx4AHDXiLpElWh3AgMBAAGjgZowgZcwCQYDVR0TBAIwADALBgNVHQ8E
|
27
|
+
BAMCBLAwHQYDVR0OBBYEFB6ZaeWKxQjGTI+pmz7cKRmMIywwMC4GA1UdEQQnMCWB
|
28
|
+
I3NhbXVlbC53aWxsaWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MC4GA1UdEgQnMCWB
|
29
|
+
I3NhbXVlbC53aWxsaWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEB
|
30
|
+
CwUAA4IBgQBVoM+pu3dpdUhZM1w051iw5GfiqclAr1Psypf16Tiod/ho//4oAu6T
|
31
|
+
9fj3DPX/acWV9P/FScvqo4Qgv6g4VWO5ZU7z2JmPoTXZtYMunRAmQPFL/gSUc6aK
|
32
|
+
vszMHIyhtyzRc6DnfW2AiVOjMBjaYv8xXZc9bduniRVPrLR4J7ozmGLh4o4uJp7w
|
33
|
+
x9KCFaR8Lvn/r0oJWJOqb/DMAYI83YeN2Dlt3jpwrsmsONrtC5S3gOUle5afSGos
|
34
|
+
bYt5ocnEpKSomR9ZtnCGljds/aeO1Xgpn2r9HHcjwnH346iNrnHmMlC7BtHUFPDg
|
35
|
+
Ts92S47PTOXzwPBDsrFiq3VLbRjHSwf8rpqybQBH9MfzxGGxTaETQYOd6b4e4Ag6
|
36
|
+
y92abGna0bmIEb4+Tx9rQ10Uijh1POzvr/VTH4bbIPy9FbKrRsIQ24qDbNJRtOpE
|
37
|
+
RAOsIl+HOBTb252nx1kIRN5hqQx272AJCbCjKx8egcUQKffFVVCI0nye09v5CK+a
|
38
|
+
HiLJ8VOFx6w=
|
39
|
+
-----END CERTIFICATE-----
|
40
|
+
date: 2022-06-01 00:00:00.000000000 Z
|
12
41
|
dependencies:
|
13
42
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
43
|
+
name: build-files
|
15
44
|
requirement: !ruby/object:Gem::Requirement
|
16
45
|
requirements:
|
17
46
|
- - "~>"
|
18
47
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2
|
48
|
+
version: '1.2'
|
20
49
|
type: :runtime
|
21
50
|
prerelease: false
|
22
51
|
version_requirements: !ruby/object:Gem::Requirement
|
23
52
|
requirements:
|
24
53
|
- - "~>"
|
25
54
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2
|
55
|
+
version: '1.2'
|
27
56
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
57
|
+
name: samovar
|
29
58
|
requirement: !ruby/object:Gem::Requirement
|
30
59
|
requirements:
|
31
60
|
- - "~>"
|
32
61
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
62
|
+
version: '2.0'
|
34
63
|
type: :runtime
|
35
64
|
prerelease: false
|
36
65
|
version_requirements: !ruby/object:Gem::Requirement
|
37
66
|
requirements:
|
38
67
|
- - "~>"
|
39
68
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
69
|
+
version: '2.0'
|
41
70
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
71
|
+
name: bundler
|
43
72
|
requirement: !ruby/object:Gem::Requirement
|
44
73
|
requirements:
|
45
74
|
- - ">="
|
@@ -53,7 +82,7 @@ dependencies:
|
|
53
82
|
- !ruby/object:Gem::Version
|
54
83
|
version: '0'
|
55
84
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
85
|
+
name: covered
|
57
86
|
requirement: !ruby/object:Gem::Requirement
|
58
87
|
requirements:
|
59
88
|
- - ">="
|
@@ -80,42 +109,14 @@ dependencies:
|
|
80
109
|
- - "~>"
|
81
110
|
- !ruby/object:Gem::Version
|
82
111
|
version: '3.4'
|
83
|
-
|
84
|
-
name: rake
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
description: "\t\tFingerprint is a general purpose data integrity tool that uses cryptographic
|
98
|
-
hashes to detect changes in files and directory trees. The fingerprint command scans
|
99
|
-
a directory tree and generates a fingerprint file containing the names and cryptographic
|
100
|
-
hashes of the files in the tree. This snapshot can be later used to generate a list
|
101
|
-
of files that have been created, deleted or modified. If so much as a single bit
|
102
|
-
in the file data has changed, Fingerprint will detect it.\n"
|
112
|
+
description:
|
103
113
|
email:
|
104
|
-
- samuel.williams@oriontransfer.co.nz
|
105
114
|
executables:
|
106
115
|
- fingerprint
|
107
116
|
extensions: []
|
108
117
|
extra_rdoc_files: []
|
109
118
|
files:
|
110
|
-
- ".gitignore"
|
111
|
-
- ".rspec"
|
112
|
-
- ".travis.yml"
|
113
|
-
- GUIDE.md
|
114
|
-
- Gemfile
|
115
|
-
- README.md
|
116
|
-
- Rakefile
|
117
119
|
- bin/fingerprint
|
118
|
-
- fingerprint.gemspec
|
119
120
|
- lib/fingerprint.rb
|
120
121
|
- lib/fingerprint/checker.rb
|
121
122
|
- lib/fingerprint/checksums.rb
|
@@ -129,19 +130,12 @@ files:
|
|
129
130
|
- lib/fingerprint/record.rb
|
130
131
|
- lib/fingerprint/scanner.rb
|
131
132
|
- lib/fingerprint/version.rb
|
132
|
-
|
133
|
-
- spec/fingerprint/command/duplicates_spec.rb
|
134
|
-
- spec/fingerprint/command/source_fingerprint.rb
|
135
|
-
- spec/fingerprint/command/verify_spec.rb
|
136
|
-
- spec/fingerprint/corpus/README.md
|
137
|
-
- spec/fingerprint/scanner_spec.rb
|
138
|
-
- spec/fingerprint_spec.rb
|
139
|
-
- spec/spec_helper.rb
|
140
|
-
homepage: http://www.codeotaku.com/projects/fingerprint
|
133
|
+
homepage: https://github.com/ioquatix/fingerprint
|
141
134
|
licenses:
|
142
135
|
- MIT
|
143
|
-
metadata:
|
144
|
-
|
136
|
+
metadata:
|
137
|
+
funding_uri: https://github.com/sponsors/ioquatix/
|
138
|
+
post_install_message:
|
145
139
|
rdoc_options: []
|
146
140
|
require_paths:
|
147
141
|
- lib
|
@@ -149,24 +143,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
143
|
requirements:
|
150
144
|
- - ">="
|
151
145
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
146
|
+
version: '2.5'
|
153
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
148
|
requirements:
|
155
149
|
- - ">="
|
156
150
|
- !ruby/object:Gem::Version
|
157
151
|
version: '0'
|
158
152
|
requirements: []
|
159
|
-
rubygems_version: 3.
|
160
|
-
signing_key:
|
153
|
+
rubygems_version: 3.3.7
|
154
|
+
signing_key:
|
161
155
|
specification_version: 4
|
162
156
|
summary: Fingerprint is a tool for creating checksums of entire directory structures,
|
163
157
|
and comparing them for inconsistencies.
|
164
|
-
test_files:
|
165
|
-
- spec/fingerprint/command/analyze_spec.rb
|
166
|
-
- spec/fingerprint/command/duplicates_spec.rb
|
167
|
-
- spec/fingerprint/command/source_fingerprint.rb
|
168
|
-
- spec/fingerprint/command/verify_spec.rb
|
169
|
-
- spec/fingerprint/corpus/README.md
|
170
|
-
- spec/fingerprint/scanner_spec.rb
|
171
|
-
- spec/fingerprint_spec.rb
|
172
|
-
- spec/spec_helper.rb
|
158
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
dist: xenial
|
3
|
-
cache: bundler
|
4
|
-
|
5
|
-
matrix:
|
6
|
-
include:
|
7
|
-
- rvm: 2.3
|
8
|
-
- rvm: 2.4
|
9
|
-
- rvm: 2.5
|
10
|
-
- rvm: 2.6
|
11
|
-
- rvm: 2.6
|
12
|
-
env: COVERAGE=Summary,Coveralls
|
13
|
-
- rvm: truffleruby
|
14
|
-
- rvm: jruby-head
|
15
|
-
env: JRUBY_OPTS="--debug -X+O"
|
16
|
-
- rvm: ruby-head
|
17
|
-
- rvm: 2.6
|
18
|
-
os: osx
|
19
|
-
allow_failures:
|
20
|
-
- rvm: truffleruby
|
21
|
-
- rvm: ruby-head
|
22
|
-
- rvm: jruby-head
|
23
|
-
- rvm: truffleruby
|
data/GUIDE.md
DELETED
@@ -1,233 +0,0 @@
|
|
1
|
-
# Fingerprint Guide
|
2
|
-
|
3
|
-
This guide gives an overview of the various ways in which fingerprint can be used.
|
4
|
-
|
5
|
-
## Fingerprint Digests
|
6
|
-
|
7
|
-
The following are the options for which digests can be generated:
|
8
|
-
|
9
|
-
* `MD5`
|
10
|
-
* `SHA1`
|
11
|
-
* `SHA2.256`
|
12
|
-
* `SHA2.384`
|
13
|
-
* `SHA2.512`
|
14
|
-
|
15
|
-
`SHA2.256` is the default.
|
16
|
-
|
17
|
-
The use of `MD5` and `SHA1` are no longer recommended due to the
|
18
|
-
risk of hash collisions.
|
19
|
-
|
20
|
-
## Generating fingerprints
|
21
|
-
|
22
|
-
Fingerprint is designed to index directories. The basic verb `scan` will index all paths specified in order (or the current path if none is given).
|
23
|
-
|
24
|
-
``` text
|
25
|
-
$ fingerprint scan /tmp/test
|
26
|
-
C /tmp/test
|
27
|
-
fingerprint.version 2.1.5
|
28
|
-
options.checksums SHA2.256
|
29
|
-
options.extended false
|
30
|
-
summary.time.start 2016-12-09 16:42:41 -0800
|
31
|
-
D
|
32
|
-
F file-1.txt
|
33
|
-
file.size 0
|
34
|
-
key.SHA2.256 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
35
|
-
F file-2.txt
|
36
|
-
file.size 0
|
37
|
-
key.SHA2.256 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
38
|
-
F file-3.sh
|
39
|
-
file.size 0
|
40
|
-
key.SHA2.256 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
41
|
-
S 3 files processed.
|
42
|
-
summary.directories 1
|
43
|
-
summary.excluded 0
|
44
|
-
summary.files 3
|
45
|
-
summary.size 0
|
46
|
-
summary.time.end 2016-12-09 16:42:41 -0800
|
47
|
-
```
|
48
|
-
|
49
|
-
## Verifing Fingerprints
|
50
|
-
|
51
|
-
Files can be checked against a given fingerprint. In the case of `verify`, only changes and deletions will be reported. Additions are not reported.
|
52
|
-
|
53
|
-
To generate a fingerprint for a given path:
|
54
|
-
|
55
|
-
fingerprint scan /tmp/test > /tmp/test.fingerprint
|
56
|
-
|
57
|
-
This fingerprint can then be used to verify that no files have changed:
|
58
|
-
|
59
|
-
$ fingerprint verify -n /tmp/test.fingerprint /tmp/test
|
60
|
-
S 0 error(s) detected.
|
61
|
-
error.count 0
|
62
|
-
|
63
|
-
## Comparing Fingerprints
|
64
|
-
|
65
|
-
The `verify` operation checks a given fingerprint against a current filesystem, and can work efficiently according to the files in the source fingerprint. In the case that you want to compare two fingerprints, you can find all differences, including additions. This can be useful when comparing two backups to see what files changed (e.g. a tripwire).
|
66
|
-
|
67
|
-
```
|
68
|
-
/tmp$ fingerprint scan /tmp/test > /tmp/test1.fingerprint
|
69
|
-
/tmp$ vi test/file-1.txt (change this file)
|
70
|
-
/tmp$ fingerprint scan /tmp/test > /tmp/test2.fingerprint
|
71
|
-
/tmp$ fingerprint compare /tmp/test1.fingerprint /tmp/test2.fingerprint
|
72
|
-
W file-1.txt
|
73
|
-
changes.file.size.new 4
|
74
|
-
changes.file.size.old 0
|
75
|
-
changes.key.SHA2.256.new b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c
|
76
|
-
changes.key.SHA2.256.old e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
77
|
-
error.code keys_different
|
78
|
-
error.message Key SHA2.256 does not match
|
79
|
-
S 1 error(s) detected.
|
80
|
-
error.count 1
|
81
|
-
```
|
82
|
-
|
83
|
-
Here we can see files which have been changed and added to `/tmp/test` after a modifying a file.
|
84
|
-
|
85
|
-
## Transmission and Archival Usage
|
86
|
-
|
87
|
-
Fingerprint provides two high-level operations `analyze` which is roughly equivalent to `scan` but outputs to the file `index.fingerprint` by default, and `verify` which reads by default from `index.fingerprint`.
|
88
|
-
|
89
|
-
Typical use cases would include analyzing a directory before copying it, and verifying it after the copy, or analyzing a backup and verifying it before restore.
|
90
|
-
|
91
|
-
-- Fingerprint the local data:
|
92
|
-
$ fingerprint --root /srv/http analyze
|
93
|
-
|
94
|
-
-- Copy it to the remote system:
|
95
|
-
$ rsync -a /srv/http production:/srv/http
|
96
|
-
|
97
|
-
-- Run fingerprint on the remote system to verify the data copied correctly:
|
98
|
-
$ ssh production fingerprint --root /srv/http verify
|
99
|
-
S 0 error(s) detected.
|
100
|
-
error.count 0
|
101
|
-
|
102
|
-
This is equally useful for traditional backup mediums, e.g. write-only storage, offline backups, etc.
|
103
|
-
|
104
|
-
## Data Preservation
|
105
|
-
|
106
|
-
Data preservation means that data is available in a useful form for as long as it is required (which could be indefinitely). Faulty hardware, software, user error or malicious attack are the primary concerns affecting data preservation. Fingerprint can provide insight into data integrity problems, which can then be resolved appropriately.
|
107
|
-
|
108
|
-
In almost all cases of data corruption, the sooner the corruption is detected, the less damage that occurs overall. It is in this sense that regular fingerprinting of critical files should be considered an important step in comprehensive data preservation policy.
|
109
|
-
|
110
|
-
Data preservation almost always involves data replication and verification. If data becomes corrupt, it it essential that backups are available to recover the original data. However, it is also important that backup data can be verified otherwise there is no guarantee that the recovered data is correct.
|
111
|
-
|
112
|
-
End to end testing on a regular basis is the only sane policy if your data is important.
|
113
|
-
|
114
|
-
### Non-malicious Bit-rot
|
115
|
-
|
116
|
-
Using standard analyze/verify procedure, fingerprint can detect file corruption. Make sure you record extended information using `-x`. The primary indication of file corruption is a change in checksum data but not in modified time. Standard operating system functions update the modified time when the file is changed. But, if the file changes without this, it may indicate hardware or software fault, and should be investigated further.
|
117
|
-
|
118
|
-
Once data has been analyzed, you can store it on archival media (e.g. optical or tape storage). At a later date, you can verify this to ensure the data has not become damaged over time.
|
119
|
-
|
120
|
-
### Malicious Changes
|
121
|
-
|
122
|
-
Malicious modification of files can be detected using fingerprint. This setup is typically referred to as a tripwire, because when an attacker modifies some critical system files, the system administrator will be notified. To maintain the security of such a setup, the fingerprint should be stored on a separate server:
|
123
|
-
|
124
|
-
$ mv latest.fingerprint previous.fingerprint
|
125
|
-
$ ssh data.example.com fingerprint scan /etc > latest.fingerprint
|
126
|
-
$ fingerprint compare previous.fingerprint latest.fingerprint
|
127
|
-
S 0 error(s) detected.
|
128
|
-
error.count 0
|
129
|
-
|
130
|
-
This can be scripted and run in an hourly cron job:
|
131
|
-
|
132
|
-
#!/usr/bin/env ruby
|
133
|
-
|
134
|
-
require 'fileutils'
|
135
|
-
|
136
|
-
REMOTE = "server.example.com"
|
137
|
-
DIRECTORY = "/etc"
|
138
|
-
PREVIOUS = "previous.fingerprint"
|
139
|
-
LATEST = "latest.fingerprint"
|
140
|
-
|
141
|
-
if File.exist? LATEST
|
142
|
-
FileUtils.mv LATEST, PREVIOUS
|
143
|
-
end
|
144
|
-
|
145
|
-
$stderr.puts "Generating fingerprint of #{REMOTE}:#{DIRECTORY}..."
|
146
|
-
system("ssh #{REMOTE} fingerprint #{DIRECTORY} > #{LATEST}")
|
147
|
-
|
148
|
-
if File.exist? PREVIOUS
|
149
|
-
$stderr.puts "Comparing fingerprints..."
|
150
|
-
system('fingerprint', 'compare', '-a', PREVIOUS, LATEST)
|
151
|
-
end
|
152
|
-
|
153
|
-
## Backup integrity
|
154
|
-
|
155
|
-
Data backup is typically an important part of any storage system. However, without end-to-end verification of backup data, it may not be possible to ensure that a backup system is working correctly. In the event that a failure occurs, data recovery may not be possible despite the existence of a backup, if that data has not been backed up reliably or correctly.
|
156
|
-
|
157
|
-
If you are backing up online data, the backup tool you are using may backup files at non-deterministic times. This means that if software (such as a database) is writing to a file at the time the backup occurs, the data may be transferred incorrectly. Fingerprint can help to detect this, by running fingerprint before the backup on the local storage, and then verifying the backup data after it has been copied. Ideally, you'd expect to see minimal changes to critical files.
|
158
|
-
|
159
|
-
However, the real world is often not so simple. Some software doesn't provide facilities for direct synchronization; other software provides facilities for dumping data (which may not be an option of the dataset is large). In these cases, fingerprint can give you some visibility about the potential issues you may face during a restore. You may want to consider [Synco](https://github.com/ioquatix/synco) which can coordinate more complex backup tasks.
|
160
|
-
|
161
|
-
### Ensuring Data Validity
|
162
|
-
|
163
|
-
To ensure that data has been backed up correctly, use fingerprint to analyze the data before it is backed up.
|
164
|
-
|
165
|
-
-- Perform the data analysis
|
166
|
-
$ sudo fingerprint analyze -f /etc
|
167
|
-
|
168
|
-
-- Backup the data to a remote system
|
169
|
-
$ sudo rsync --archive /etc backups.example.com:/mnt/backups/server.example.com/etc
|
170
|
-
|
171
|
-
After the data has been copied to the remote backup device, restore the data to a temporary location and use fingerprint to verify the data. The exact procedure will depend on your backup system, e.g. if you use a tape you may need to restore from the tape to local storage first.
|
172
|
-
|
173
|
-
-- On the backup server
|
174
|
-
$ cd /mnt/backups/server.example.com/etc
|
175
|
-
$ fingerprint verify
|
176
|
-
S 0 error(s) detected.
|
177
|
-
error.count 0
|
178
|
-
|
179
|
-
### Preserving Backups
|
180
|
-
|
181
|
-
If your primary concern is ensuring that backup data is consistent over time (e.g. files are not modified or damaged), fingerprint can be used directly on the backup data to check for corruption. After the data has been backed up successfully, simply analyze the data as above, but on the backup server. Once this is done, at any point in the future you can verify the correctness of the backup set.
|
182
|
-
|
183
|
-
## Cryptographic Sealing
|
184
|
-
|
185
|
-
Fingerprint can be used to ensure that a set of files has been delivered without manipulation, by creating a fingerprint and signing this with a private key. The fingerprint and associated files can later be verified using the public key.
|
186
|
-
|
187
|
-
### Generating Keys
|
188
|
-
|
189
|
-
To sign fingerprints, the first step is to create a private and public key pair. This is easily achieved using OpenSSL:
|
190
|
-
|
191
|
-
-- Create a private key, which you must keep secure.
|
192
|
-
$ openssl genrsa -out private.pem 2048
|
193
|
-
Generating RSA private key, 2048 bit long modulus
|
194
|
-
.............+++
|
195
|
-
........+++
|
196
|
-
e is 65537 (0x10001)
|
197
|
-
|
198
|
-
-- Create a public key, which can be used to verify sealed fingerprints.
|
199
|
-
$ openssl rsa -in private.pem -pubout -out public.pem
|
200
|
-
writing RSA key
|
201
|
-
|
202
|
-
### Signing Fingerprints
|
203
|
-
|
204
|
-
After you have generated a fingerprint, you can sign it easily using the private key:
|
205
|
-
|
206
|
-
-- We assume here that you are using fingerprint analyze to generate fingerprints.
|
207
|
-
$ openssl dgst -sha1 -sign private.pem -out index.signature index.fingerprint
|
208
|
-
|
209
|
-
### Verifying Fingerprint Signature
|
210
|
-
|
211
|
-
You can easily verify the security of the fingerprint data:
|
212
|
-
|
213
|
-
$ openssl dgst -sha1 -verify public.pem -signature index.signature index.fingerprint
|
214
|
-
Verified OK
|
215
|
-
-- Fingerprint data has been cryptographically verified
|
216
|
-
|
217
|
-
$ fingerprint verify
|
218
|
-
S 0 error(s) detected.
|
219
|
-
error.count 0
|
220
|
-
Data verified, 0 errors found.
|
221
|
-
-- File list has been checked and no errors.
|
222
|
-
|
223
|
-
As long as private key is kept secure, we can be sure that these files have not been tampered with.
|
224
|
-
|
225
|
-
### Notarizing
|
226
|
-
|
227
|
-
In many cases it is good to ensure that documents existed at a particular time. With modern document storage systems, it may be impossible to verify this by simply relying on databases and filesystems alone, especially because technology can be manipulated.
|
228
|
-
|
229
|
-
Fingerprint can be used to produce printed documents which can be used to verify the existence of files at a given time. With appropriate physical signatures, these could be used to verify the existence of a given set of files at a specific time and place.
|
230
|
-
|
231
|
-
Simply follow the procedure to produce a cryptographic hash of a directory, print these documents out, and get them signed.
|
232
|
-
|
233
|
-
N.B. Please consult a lawyer for the correct procedure and legal standing of such techniques. This document is not legal advice and we accept no responsibility for any use or misuse of this tool.
|
data/Gemfile
DELETED
data/README.md
DELETED
@@ -1,168 +0,0 @@
|
|
1
|
-
# Fingerprint
|
2
|
-
|
3
|
-
> Matter and energy degrade to more probable, less informative states. The larger the amounts of information processed or diffused, the more likely it is that information will degrade toward meaningless variety, like noise or information overload, or sterile uniformity — Orrin Klapp
|
4
|
-
|
5
|
-
Fingerprint is a general purpose data integrity tool that uses cryptographic hashes to detect changes in files. Fingerprint scans a directory tree and generates a small transcript file containing the names and hashes of the files. This snapshot file can then be used to generate a list of files that have been created, deleted, or modified. If so much as a single bit in a single file in the directory tree has changed, fingerprint will detect it.
|
6
|
-
|
7
|
-
Traditionally, the only way to preserve data was to take regular backups and hope that any unwanted changes that occurred would be major, obvious ones (such as loss of the disk). This approach means trusting all the software to which the data is exposed: operating systems, backup software, communications software, compression software, encryption software, and archiving software. Unfortunately, each of these systems is highly complex and can inflict all kinds of damage on data, much of the damage undetectable to humans. Fingerprint allows data to be monitored, detecting even the change of a single bit.
|
8
|
-
|
9
|
-
Fingerprint can be used for:
|
10
|
-
|
11
|
-
- Preservation: Detect corruption of important data, e.g. web server integrity, write-once storage verification.
|
12
|
-
- Security: Detect changes made by intruders, e.g. firewall integrity, network configuration, software auditing.
|
13
|
-
- Transfers: Verify file copies and transfers between different systems, e.g. file transfer integrity.
|
14
|
-
- Sealing: Cryptographically seal critical files, e.g. document verification.
|
15
|
-
- Notarizing: Prove that documents existed at a particular time.
|
16
|
-
- Backups: Verify restored backups to ensure that backups are sound, e.g. backup verification and integrity.
|
17
|
-
|
18
|
-
A companion app is available in the [Mac App Store](https://itunes.apple.com/nz/app/fingerprint/id470866821). Purchasing this app helps fund the open source software development.
|
19
|
-
|
20
|
-
[![Build Status](https://travis-ci.org/ioquatix/fingerprint.svg?branch=master)](https://travis-ci.org/ioquatix/fingerprint)
|
21
|
-
[![Code Climate](https://codeclimate.com/github/ioquatix/fingerprint.svg)](https://codeclimate.com/github/ioquatix/fingerprint)
|
22
|
-
[![Coverage Status](https://coveralls.io/repos/ioquatix/fingerprint/badge.svg)](https://coveralls.io/r/ioquatix/fingerprint)
|
23
|
-
|
24
|
-
## Motivation
|
25
|
-
|
26
|
-
As the world becomes further entrenched in digital data and storage, the accuracy and correctness of said data is going to become a bigger problem. As humans create information, we are ultimately decreasing the amount of entropy in the universe. By the second law of thermodynamics, when a closed system moves from "the least to the most probable, from differentiation to sameness, from ordered individuality to a kind of chaos," (Thomas Pynchon) the only logical conclusion is that what we consider to be important data is destined to become meaningless noise in the sands of time.
|
27
|
-
|
28
|
-
When I first suffered data-loss, it wasn't catastrophic - it was the slow deterioration of a drive which silently corrupted many files. After this event, I wanted a tool which would allow me to minimize the chance of this happening in the future. When I take a backup now, I also make a fingerprint. If I ever need to restore from backup, I can be confident the data is as it was when it was backed up.
|
29
|
-
|
30
|
-
As fingerprint provides a fast way to compare the files, I've also extended it to find duplicates within one or more fingerprints. This is useful for de-duplicating your home directory and I've also used it when marking assignments to find blatant copying.
|
31
|
-
|
32
|
-
In cases where I've been concerned about the migration of data (e.g. copying my entire home directory from one system to another), I've used fingerprint to generate a transcript on the source machine, and then run it on the destination machine, to reassure me that the data was copied correctly and completely.
|
33
|
-
|
34
|
-
## Installation
|
35
|
-
|
36
|
-
Add this line to your application's Gemfile:
|
37
|
-
|
38
|
-
gem 'fingerprint'
|
39
|
-
|
40
|
-
And then execute:
|
41
|
-
|
42
|
-
$ bundle
|
43
|
-
|
44
|
-
Or install it yourself as:
|
45
|
-
|
46
|
-
$ gem install fingerprint
|
47
|
-
|
48
|
-
## Usage
|
49
|
-
|
50
|
-
Please consult the [GUIDE](GUIDE.md) for an overview of how fingerprint command can be used.
|
51
|
-
|
52
|
-
### RSpec
|
53
|
-
|
54
|
-
The simplest usage of fingerprint is checking if two directories are equivalent:
|
55
|
-
|
56
|
-
Fingerprint.identical?(source_path, destination_path) do |record|
|
57
|
-
puts "#{record.path} is different"
|
58
|
-
end
|
59
|
-
|
60
|
-
This would catch additions, removals, and changes. You can use this in RSpec:
|
61
|
-
|
62
|
-
expect(Fingerprint).to be_identical(source_path, destination_path)
|
63
|
-
|
64
|
-
### Command Line
|
65
|
-
|
66
|
-
The `fingerprint` command has a high-level and low-level interface.
|
67
|
-
|
68
|
-
#### High-level Interface
|
69
|
-
|
70
|
-
This usage is centered around analysing a given directory using `fingerprint analyze` and then, at a later date, checking that the directory is not missing any files and that all files are the same as they were originally, using `fingerprint verify`.
|
71
|
-
|
72
|
-
```
|
73
|
-
$ fingerprint analyze
|
74
|
-
$ fingerprint verify
|
75
|
-
S 0 error(s) detected.
|
76
|
-
error.count 0
|
77
|
-
```
|
78
|
-
|
79
|
-
If we modify a file (`file-1.txt` in this example), it will be reported:
|
80
|
-
|
81
|
-
```
|
82
|
-
$ fingerprint verify
|
83
|
-
W file-1.txt
|
84
|
-
changes.file.size.new 8
|
85
|
-
changes.file.size.old 4
|
86
|
-
changes.key.SHA2.256.new 1f2ec52b774368781bed1d1fb140a92e0eb6348090619c9291f9a5a3c8e8d151
|
87
|
-
changes.key.SHA2.256.old b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c
|
88
|
-
error.code keys_different
|
89
|
-
error.message Key SHA2.256 does not match
|
90
|
-
S 1 error(s) detected.
|
91
|
-
error.count 1
|
92
|
-
```
|
93
|
-
|
94
|
-
This command does not report files which have been added.
|
95
|
-
|
96
|
-
#### Low-level interface
|
97
|
-
|
98
|
-
It is possible to generate a fingerprint using the scan command, which takes a list of paths and writes out the transcript.
|
99
|
-
|
100
|
-
% fingerprint scan spec
|
101
|
-
C /home/samuel/Documents/Programming/ioquatix/fingerprint/spec
|
102
|
-
fingerprint.version 2.0.0
|
103
|
-
options.checksums MD5, SHA2.256
|
104
|
-
options.extended false
|
105
|
-
summary.time.start 2016-06-25 11:46:12 +1200
|
106
|
-
D
|
107
|
-
D fingerprint
|
108
|
-
F fingerprint/check_paths_spec.rb
|
109
|
-
file.size 1487
|
110
|
-
key.MD5 ef77034977daa683bbaaed47c553f6f5
|
111
|
-
key.SHA2.256 970ec4663ffc257ec1d4f49f54711c38434108d580afc0c92ea7bf864e08a1e0
|
112
|
-
S 1 files processed.
|
113
|
-
summary.directories 2
|
114
|
-
summary.excluded 0
|
115
|
-
summary.files 1
|
116
|
-
summary.size 1487
|
117
|
-
summary.time.end 2016-06-25 11:46:12 +1200
|
118
|
-
|
119
|
-
#### Duplicates
|
120
|
-
|
121
|
-
Fingerprint can efficiently find duplicates in one or more fingerprints.
|
122
|
-
|
123
|
-
$ fingerprint duplicates index.fingerprint
|
124
|
-
F .git/refs/heads/master
|
125
|
-
file.size 41
|
126
|
-
fingerprint index.fingerprint
|
127
|
-
key.MD5 aaadaeee72126dedcd4044d687a74068
|
128
|
-
key.SHA2.256 6750f057b38c2ea93e3725545333b8167301b6d8daa0626b0a2a613a6a4f4f04
|
129
|
-
original.fingerprint index.fingerprint
|
130
|
-
original.path .git/refs/remotes/origin/master
|
131
|
-
|
132
|
-
## Todo
|
133
|
-
|
134
|
-
* Command line option to show files that have changed but have the same modified time (hardware corruption).
|
135
|
-
* Supporting tools for signing fingerprints easily.
|
136
|
-
* Because fingerprint is currently IO bound in terms of performance, single-threaded checksumming is fine, but for SSD and other fast storage, it might be possible to improve speed somewhat by using a map-reduce style approach.
|
137
|
-
|
138
|
-
## Contributing
|
139
|
-
|
140
|
-
1. Fork it
|
141
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
142
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
143
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
144
|
-
5. Create new Pull Request
|
145
|
-
|
146
|
-
## License
|
147
|
-
|
148
|
-
Released under the MIT license.
|
149
|
-
|
150
|
-
Copyright, 2019, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
|
151
|
-
|
152
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
153
|
-
of this software and associated documentation files (the "Software"), to deal
|
154
|
-
in the Software without restriction, including without limitation the rights
|
155
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
156
|
-
copies of the Software, and to permit persons to whom the Software is
|
157
|
-
furnished to do so, subject to the following conditions:
|
158
|
-
|
159
|
-
The above copyright notice and this permission notice shall be included in
|
160
|
-
all copies or substantial portions of the Software.
|
161
|
-
|
162
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
163
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
164
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
165
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
166
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
167
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
168
|
-
THE SOFTWARE.
|
data/Rakefile
DELETED
data/fingerprint.gemspec
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
|
2
|
-
require_relative 'lib/fingerprint/version'
|
3
|
-
|
4
|
-
Gem::Specification.new do |spec|
|
5
|
-
spec.name = "fingerprint"
|
6
|
-
spec.version = Fingerprint::VERSION
|
7
|
-
spec.authors = ["Samuel Williams"]
|
8
|
-
spec.email = ["samuel.williams@oriontransfer.co.nz"]
|
9
|
-
spec.description = <<-EOF
|
10
|
-
Fingerprint is a general purpose data integrity tool that uses cryptographic hashes to detect changes in files and directory trees. The fingerprint command scans a directory tree and generates a fingerprint file containing the names and cryptographic hashes of the files in the tree. This snapshot can be later used to generate a list of files that have been created, deleted or modified. If so much as a single bit in the file data has changed, Fingerprint will detect it.
|
11
|
-
EOF
|
12
|
-
spec.summary = "Fingerprint is a tool for creating checksums of entire directory structures, and comparing them for inconsistencies."
|
13
|
-
spec.homepage = "http://www.codeotaku.com/projects/fingerprint"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_dependency "samovar", "~> 2.0"
|
22
|
-
spec.add_dependency "build-files", "~> 1.2"
|
23
|
-
|
24
|
-
spec.add_development_dependency "covered"
|
25
|
-
spec.add_development_dependency "bundler"
|
26
|
-
spec.add_development_dependency "rspec", "~> 3.4"
|
27
|
-
spec.add_development_dependency "rake"
|
28
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rspec
|
2
|
-
|
3
|
-
# Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
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
|
13
|
-
# all 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
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'fingerprint/command'
|
24
|
-
|
25
|
-
require_relative 'source_fingerprint'
|
26
|
-
|
27
|
-
RSpec.describe Fingerprint::Command::Analyze do
|
28
|
-
include_context "source fingerprint"
|
29
|
-
|
30
|
-
it "should analyze and verify files" do
|
31
|
-
Fingerprint::Command::Top["analyze", "-f"].call
|
32
|
-
|
33
|
-
expect(File).to be_exist(Fingerprint::INDEX_FINGERPRINT)
|
34
|
-
|
35
|
-
top = Fingerprint::Command::Top["verify"].tap(&:call)
|
36
|
-
|
37
|
-
expect(top.command.error_count).to be == 0
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should analyze path but exclude specified file" do
|
41
|
-
Fingerprint::Command::Top["analyze", "-n", fingerprint_name, "-f", source_directory].call
|
42
|
-
|
43
|
-
expect(File).to be_exist(fingerprint_name)
|
44
|
-
|
45
|
-
record_set = Fingerprint::RecordSet.load_file(fingerprint_name)
|
46
|
-
expect(record_set).to_not be_include(File.basename(fingerprint_name))
|
47
|
-
end
|
48
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rspec
|
2
|
-
|
3
|
-
# Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
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
|
13
|
-
# all 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
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'fingerprint/command'
|
24
|
-
|
25
|
-
require_relative 'source_fingerprint'
|
26
|
-
|
27
|
-
RSpec.describe Fingerprint::Command::Duplicates do
|
28
|
-
include_context "source fingerprint"
|
29
|
-
|
30
|
-
it "should have no duplicates" do
|
31
|
-
Fingerprint::Command::Top["analyze", "-n", fingerprint_name, "-f", source_directory].call
|
32
|
-
|
33
|
-
expect(File).to be_exist(fingerprint_name)
|
34
|
-
|
35
|
-
record_set = Fingerprint::RecordSet.load_file(fingerprint_name)
|
36
|
-
|
37
|
-
top = Fingerprint::Command::Top["duplicates", fingerprint_name].tap(&:call)
|
38
|
-
|
39
|
-
expect(top.command.duplicates_recordset).to be_empty
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should have duplicates" do
|
43
|
-
Fingerprint::Command::Top["analyze", "-n", fingerprint_name, "-f", source_directory].call
|
44
|
-
|
45
|
-
expect(File).to be_exist(fingerprint_name)
|
46
|
-
|
47
|
-
record_set = Fingerprint::RecordSet.load_file(fingerprint_name)
|
48
|
-
|
49
|
-
top = Fingerprint::Command::Top["duplicates", fingerprint_name, fingerprint_name].tap(&:call)
|
50
|
-
|
51
|
-
expect(top.command.duplicates_recordset).to_not be_empty
|
52
|
-
end
|
53
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rspec
|
2
|
-
|
3
|
-
# Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
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
|
13
|
-
# all 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
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'fileutils'
|
24
|
-
|
25
|
-
RSpec.shared_context "source fingerprint" do
|
26
|
-
let(:source_directory) {File.expand_path("../../../lib", __dir__)}
|
27
|
-
let(:fingerprint_name) {File.join(__dir__, "test.fingerprint")}
|
28
|
-
|
29
|
-
after(:each) do
|
30
|
-
FileUtils.rm_rf(fingerprint_name)
|
31
|
-
end
|
32
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rspec
|
2
|
-
|
3
|
-
# Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
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
|
13
|
-
# all 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
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'fingerprint/command'
|
24
|
-
|
25
|
-
require_relative 'source_fingerprint'
|
26
|
-
|
27
|
-
RSpec.describe Fingerprint::Command::Verify do
|
28
|
-
include_context "source fingerprint"
|
29
|
-
|
30
|
-
it "should analyze a different path" do
|
31
|
-
Fingerprint::Command::Top["analyze", "-n", fingerprint_name, "-f", source_directory].call
|
32
|
-
|
33
|
-
expect(File).to be_exist(fingerprint_name)
|
34
|
-
|
35
|
-
top = Fingerprint::Command::Top["verify", "-n", fingerprint_name, "-f", source_directory].tap(&:call)
|
36
|
-
|
37
|
-
expect(top.command.error_count).to be == 0
|
38
|
-
end
|
39
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rspec
|
2
|
-
|
3
|
-
# Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
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
|
13
|
-
# all 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
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'fingerprint/scanner'
|
24
|
-
|
25
|
-
RSpec.shared_examples "scanner checksum" do |digests|
|
26
|
-
let(:scanner) {Fingerprint::Scanner.new([__dir__], checksums: subject)}
|
27
|
-
|
28
|
-
it "computes checksums correctly" do
|
29
|
-
digests.each do |path, required_metadata|
|
30
|
-
record = scanner.scan_path(path)
|
31
|
-
|
32
|
-
expect(record.metadata).to include(required_metadata)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
RSpec.describe "defaults" do
|
38
|
-
it "defaults to SHA2.256 only" do
|
39
|
-
expect(Fingerprint::DEFAULT_CHECKSUMS).to eq(['SHA2.256'])
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
RSpec.describe ['MD5'] do
|
44
|
-
it_behaves_like "scanner checksum",
|
45
|
-
"corpus/README.md" => {
|
46
|
-
"file.size" => 52,
|
47
|
-
"key.MD5" => "2d7157522d94e7d1621daefd5b92817f",
|
48
|
-
}
|
49
|
-
end
|
50
|
-
|
51
|
-
RSpec.describe ['SHA1'] do
|
52
|
-
it_behaves_like "scanner checksum",
|
53
|
-
"corpus/README.md" => {
|
54
|
-
"file.size" => 52,
|
55
|
-
"key.SHA1" => "a36492a961d2672efc481059860af5c1dd9a2aed"
|
56
|
-
}
|
57
|
-
end
|
58
|
-
|
59
|
-
RSpec.describe ['SHA2.256', 'SHA2.384', 'SHA2.512'] do
|
60
|
-
it_behaves_like "scanner checksum",
|
61
|
-
"corpus/README.md" => {
|
62
|
-
"file.size" => 52,
|
63
|
-
"key.SHA2.256" => "0d991d01d74c50cd5dcce8140e61e4da5a06e468d9df704195e84863269ce20f",
|
64
|
-
"key.SHA2.384" => "8d9b81d6aa761b9611dbcb76471e667854ece77a134aa53953651938e233791fe6a4b6aa2db3eb7b9531bdb49ce5a31f",
|
65
|
-
"key.SHA2.512" => "73c9d10f92ca7a0d53641efe59860a7bd358185cfe5ba51fe7b19a6894344f3109de8840d3ae73742c5a059daffcbdda865111f1925604e3f6c59d33443bde2c",
|
66
|
-
}
|
67
|
-
end
|
data/spec/fingerprint_spec.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rspec
|
2
|
-
|
3
|
-
# Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
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
|
13
|
-
# all 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
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'fingerprint'
|
24
|
-
|
25
|
-
describe Fingerprint do
|
26
|
-
it "should check the same path and not report any differences" do
|
27
|
-
expect(Fingerprint).to be_identical(__dir__, __dir__)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should check different paths and report differences" do
|
31
|
-
expect(Fingerprint).to_not be_identical(__dir__, File.expand_path("../", __dir__))
|
32
|
-
end
|
33
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
20
|
-
|
21
|
-
require 'bundler/setup'
|
22
|
-
require 'covered/rspec'
|
23
|
-
|
24
|
-
RSpec.configure do |config|
|
25
|
-
# Enable flags like --only-failures and --next-failure
|
26
|
-
config.example_status_persistence_file_path = ".rspec_status"
|
27
|
-
|
28
|
-
config.expect_with :rspec do |c|
|
29
|
-
c.syntax = :expect
|
30
|
-
end
|
31
|
-
end
|