ruby_smb 3.1.0 → 3.1.3
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/examples/file_server.rb +6 -61
- data/examples/virtual_file_server.rb +91 -0
- data/lib/ruby_smb/client/negotiation.rb +7 -7
- data/lib/ruby_smb/client.rb +2 -2
- data/lib/ruby_smb/fscc/file_information/file_access_information.rb +15 -0
- data/lib/ruby_smb/fscc/file_information/file_alignment_information.rb +45 -0
- data/lib/ruby_smb/fscc/file_information/file_all_information.rb +23 -0
- data/lib/ruby_smb/fscc/file_information/file_basic_information.rb +20 -0
- data/lib/ruby_smb/fscc/file_information/file_both_directory_information.rb +3 -3
- data/lib/ruby_smb/fscc/file_information/file_directory_information.rb +3 -3
- data/lib/ruby_smb/fscc/file_information/file_ea_information.rb +1 -0
- data/lib/ruby_smb/fscc/file_information/file_full_directory_information.rb +3 -3
- data/lib/ruby_smb/fscc/file_information/file_id_both_directory_information.rb +3 -3
- data/lib/ruby_smb/fscc/file_information/file_id_full_directory_information.rb +3 -3
- data/lib/ruby_smb/fscc/file_information/file_internal_information.rb +15 -0
- data/lib/ruby_smb/fscc/file_information/file_mode_information.rb +29 -0
- data/lib/ruby_smb/fscc/file_information/file_name_information.rb +16 -0
- data/lib/ruby_smb/fscc/file_information/file_names_information.rb +1 -1
- data/lib/ruby_smb/fscc/file_information/file_normalized_name_information.rb +16 -0
- data/lib/ruby_smb/fscc/file_information/file_position_information.rb +15 -0
- data/lib/ruby_smb/fscc/file_information/file_rename_information.rb +1 -1
- data/lib/ruby_smb/fscc/file_information/file_standard_information.rb +20 -0
- data/lib/ruby_smb/fscc/file_information/file_stream_information.rb +3 -0
- data/lib/ruby_smb/fscc/file_information.rb +41 -8
- data/lib/ruby_smb/fscc/file_system_information/file_fs_attribute_information.rb +1 -0
- data/lib/ruby_smb/fscc/file_system_information/file_fs_volume_information.rb +1 -0
- data/lib/ruby_smb/fscc/file_system_information.rb +4 -0
- data/lib/ruby_smb/gss/provider/ntlm.rb +20 -3
- data/lib/ruby_smb/gss/provider.rb +10 -1
- data/lib/ruby_smb/ntlm/client.rb +74 -0
- data/lib/ruby_smb/ntlm.rb +1 -0
- data/lib/ruby_smb/server/cli.rb +121 -0
- data/lib/ruby_smb/server/server_client/session_setup.rb +4 -2
- data/lib/ruby_smb/server/server_client.rb +9 -1
- data/lib/ruby_smb/server/session.rb +5 -1
- data/lib/ruby_smb/server/share/provider/disk/processor/close.rb +9 -5
- data/lib/ruby_smb/server/share/provider/disk/processor/create.rb +2 -2
- data/lib/ruby_smb/server/share/provider/disk/processor/query.rb +2 -2
- data/lib/ruby_smb/server/share/provider/disk/processor/read.rb +15 -14
- data/lib/ruby_smb/server/share/provider/disk/processor.rb +76 -12
- data/lib/ruby_smb/server/share/provider/disk.rb +8 -2
- data/lib/ruby_smb/server/share/provider/virtual_disk/virtual_file.rb +85 -0
- data/lib/ruby_smb/server/share/provider/virtual_disk/virtual_pathname.rb +196 -0
- data/lib/ruby_smb/server/share/provider/virtual_disk/virtual_stat.rb +175 -0
- data/lib/ruby_smb/server/share/provider/virtual_disk.rb +116 -0
- data/lib/ruby_smb/server/share/provider.rb +1 -0
- data/lib/ruby_smb/server.rb +14 -3
- data/lib/ruby_smb/smb2/tree.rb +1 -0
- data/lib/ruby_smb/version.rb +1 -1
- data/spec/lib/ruby_smb/client_spec.rb +11 -2
- data/spec/lib/ruby_smb/fscc/file_information/file_access_information_spec.rb +21 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_alignment_information_spec.rb +21 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_all_information_spec.rb +61 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_basic_information_spec.rb +41 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_both_directory_information_spec.rb +59 -10
- data/spec/lib/ruby_smb/fscc/file_information/file_directory_information_spec.rb +30 -12
- data/spec/lib/ruby_smb/fscc/file_information/file_ea_information_spec.rb +21 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_full_directory_information_spec.rb +30 -12
- data/spec/lib/ruby_smb/fscc/file_information/file_id_both_directory_information_spec.rb +63 -10
- data/spec/lib/ruby_smb/fscc/file_information/file_id_full_directory_information_spec.rb +30 -12
- data/spec/lib/ruby_smb/fscc/file_information/file_internal_information_spec.rb +21 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_mode_information_spec.rb +21 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_name_information_spec.rb +44 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_names_information_spec.rb +30 -12
- data/spec/lib/ruby_smb/fscc/file_information/file_network_open_information_spec.rb +51 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb +44 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_position_information_spec.rb +21 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_rename_information_spec.rb +1 -1
- data/spec/lib/ruby_smb/fscc/file_information/file_standard_information_spec.rb +41 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_stream_information_spec.rb +51 -0
- data/spec/lib/ruby_smb/fscc/file_information_spec.rb +14 -0
- data/spec/lib/ruby_smb/fscc/file_system_information/file_fs_attribute_information_spec.rb +46 -0
- data/spec/lib/ruby_smb/fscc/file_system_information/file_fs_volume_information_spec.rb +51 -0
- data/spec/lib/ruby_smb/fscc/file_system_information_spec.rb +14 -0
- data/spec/lib/ruby_smb/ntlm/client/session_spec.rb +114 -0
- data/spec/lib/ruby_smb/ntlm/client_spec.rb +36 -0
- data/spec/lib/ruby_smb/server/server_client_spec.rb +15 -0
- data/spec/lib/ruby_smb/server/share/provider/virtual_disk/virtual_pathname_spec.rb +581 -0
- data/spec/lib/ruby_smb/server/share/provider/virtual_disk/virtual_stat_spec.rb +207 -0
- data/spec/lib/ruby_smb/server/share/provider/virtual_disk_spec.rb +122 -0
- data.tar.gz.sig +2 -2
- metadata +63 -2
- metadata.gz.sig +0 -0
@@ -28,6 +28,14 @@ RSpec.describe RubySMB::Fscc::FileInformation::FileIdBothDirectoryInformation do
|
|
28
28
|
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
29
29
|
end
|
30
30
|
|
31
|
+
it 'tracks the next offset in a Uint32 field' do
|
32
|
+
expect(struct.next_offset).to be_a BinData::Uint32le
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'tracks the file index in a Uint32 field' do
|
36
|
+
expect(struct.file_index).to be_a BinData::Uint32le
|
37
|
+
end
|
38
|
+
|
31
39
|
it 'tracks the creation time in a Filetime field' do
|
32
40
|
expect(struct.create_time).to be_a RubySMB::Field::FileTime
|
33
41
|
end
|
@@ -44,6 +52,14 @@ RSpec.describe RubySMB::Fscc::FileInformation::FileIdBothDirectoryInformation do
|
|
44
52
|
expect(struct.last_change).to be_a RubySMB::Field::FileTime
|
45
53
|
end
|
46
54
|
|
55
|
+
it 'tracks the file size in a Int64 field' do
|
56
|
+
expect(struct.end_of_file).to be_a BinData::Int64le
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'tracks the allocation size in a Int64 field' do
|
60
|
+
expect(struct.allocation_size).to be_a BinData::Int64le
|
61
|
+
end
|
62
|
+
|
47
63
|
it 'contains the file attributes of the file' do
|
48
64
|
expect(struct.file_attributes).to be_a RubySMB::Fscc::FileAttributes
|
49
65
|
end
|
@@ -53,20 +69,57 @@ RSpec.describe RubySMB::Fscc::FileInformation::FileIdBothDirectoryInformation do
|
|
53
69
|
expect(struct.file_name_length).to eq struct.file_name.do_num_bytes
|
54
70
|
end
|
55
71
|
|
56
|
-
it '
|
57
|
-
|
58
|
-
|
59
|
-
|
72
|
+
it 'tracks the extended attributes size in a Uint32 field' do
|
73
|
+
expect(struct.ea_size).to be_a BinData::Uint32le
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'tracks the short name length in a Uint8 field' do
|
77
|
+
expect(struct.short_name_length).to be_a BinData::Uint8
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'tracks the short name in a String16 field' do
|
81
|
+
expect(struct.short_name).to be_a RubySMB::Field::String16
|
60
82
|
end
|
61
83
|
|
62
|
-
|
63
|
-
|
84
|
+
it 'tracks the file id in a Uint64 field' do
|
85
|
+
expect(struct.file_id).to be_a BinData::Uint64le
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'tracks the file name in a String16 field' do
|
89
|
+
expect(struct.file_name).to be_a RubySMB::Field::String16
|
90
|
+
end
|
91
|
+
|
92
|
+
describe '#short_name' do
|
93
|
+
it 'automatically encodes the short name in UTF-16LE' do
|
94
|
+
name = 'Hello_world.'
|
95
|
+
struct.short_name = name
|
96
|
+
expect(struct.short_name.force_encoding('utf-16le')).to eq name.encode('utf-16le')
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'is always exactly 24 bytes in length' do
|
100
|
+
struct.short_name = ''
|
101
|
+
expect(struct.short_name.num_bytes).to eq 24
|
102
|
+
struct.short_name = 'Hello_world.'
|
103
|
+
expect(struct.short_name.num_bytes).to eq 24
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe '#file_name' do
|
108
|
+
it 'automatically encodes the file name in UTF-16LE' do
|
64
109
|
name = 'Hello_world.txt'
|
65
110
|
struct.file_name = name
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
111
|
+
expect(struct.file_name.force_encoding('utf-16le')).to eq name.encode('utf-16le')
|
112
|
+
end
|
113
|
+
|
114
|
+
describe 'reading in from a blob' do
|
115
|
+
it 'uses the file_name_length to know when to stop reading' do
|
116
|
+
name = 'Hello_world.txt'
|
117
|
+
struct.file_name = name
|
118
|
+
blob = struct.to_binary_s
|
119
|
+
blob << 'AAAA'
|
120
|
+
new_from_blob = described_class.read(blob)
|
121
|
+
expect(new_from_blob.file_name.force_encoding('utf-16le')).to eq name.encode('utf-16le')
|
122
|
+
end
|
70
123
|
end
|
71
124
|
end
|
72
125
|
end
|
@@ -26,6 +26,14 @@ RSpec.describe RubySMB::Fscc::FileInformation::FileIdFullDirectoryInformation do
|
|
26
26
|
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
27
27
|
end
|
28
28
|
|
29
|
+
it 'tracks the next offset in a Uint32 field' do
|
30
|
+
expect(struct.next_offset).to be_a BinData::Uint32le
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'tracks the file index in a Uint32 field' do
|
34
|
+
expect(struct.file_index).to be_a BinData::Uint32le
|
35
|
+
end
|
36
|
+
|
29
37
|
it 'tracks the creation time in a Filetime field' do
|
30
38
|
expect(struct.create_time).to be_a RubySMB::Field::FileTime
|
31
39
|
end
|
@@ -42,6 +50,14 @@ RSpec.describe RubySMB::Fscc::FileInformation::FileIdFullDirectoryInformation do
|
|
42
50
|
expect(struct.last_change).to be_a RubySMB::Field::FileTime
|
43
51
|
end
|
44
52
|
|
53
|
+
it 'tracks the file size in a Int64 field' do
|
54
|
+
expect(struct.end_of_file).to be_a BinData::Int64le
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'tracks the allocation size in a Int64 field' do
|
58
|
+
expect(struct.allocation_size).to be_a BinData::Int64le
|
59
|
+
end
|
60
|
+
|
45
61
|
it 'contains the file attributes of the file' do
|
46
62
|
expect(struct.file_attributes).to be_a RubySMB::Fscc::FileAttributes
|
47
63
|
end
|
@@ -51,20 +67,22 @@ RSpec.describe RubySMB::Fscc::FileInformation::FileIdFullDirectoryInformation do
|
|
51
67
|
expect(struct.file_name_length).to eq struct.file_name.do_num_bytes
|
52
68
|
end
|
53
69
|
|
54
|
-
|
55
|
-
name
|
56
|
-
struct.file_name = name
|
57
|
-
expect(struct.file_name.force_encoding('utf-16le')).to eq name.encode('utf-16le')
|
58
|
-
end
|
59
|
-
|
60
|
-
describe 'reading in from a blob' do
|
61
|
-
it 'uses the file_name_length to know when to stop reading' do
|
70
|
+
describe '#file_name' do
|
71
|
+
it 'automatically encodes the file name in UTF-16LE' do
|
62
72
|
name = 'Hello_world.txt'
|
63
73
|
struct.file_name = name
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
74
|
+
expect(struct.file_name.force_encoding('utf-16le')).to eq name.encode('utf-16le')
|
75
|
+
end
|
76
|
+
|
77
|
+
describe 'reading in from a blob' do
|
78
|
+
it 'uses the file_name_length to know when to stop reading' do
|
79
|
+
name = 'Hello_world.txt'
|
80
|
+
struct.file_name = name
|
81
|
+
blob = struct.to_binary_s
|
82
|
+
blob << 'AAAA'
|
83
|
+
new_from_blob = described_class.read(blob)
|
84
|
+
expect(new_from_blob.file_name.force_encoding('utf-16le')).to eq name.encode('utf-16le')
|
85
|
+
end
|
68
86
|
end
|
69
87
|
end
|
70
88
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::Fscc::FileInformation::FileInternalInformation do
|
4
|
+
it 'references the correct class level' do
|
5
|
+
expect(described_class).to be_const_defined(:CLASS_LEVEL)
|
6
|
+
expect(described_class::CLASS_LEVEL).to be RubySMB::Fscc::FileInformation::FILE_INTERNAL_INFORMATION
|
7
|
+
end
|
8
|
+
|
9
|
+
subject(:struct) { described_class.new }
|
10
|
+
|
11
|
+
it { should respond_to :file_id }
|
12
|
+
|
13
|
+
it 'is little endian' do
|
14
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'tracks the file ID in a Uint64 field' do
|
18
|
+
expect(struct.file_id).to be_a BinData::Uint64le
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::Fscc::FileInformation::FileModeInformation do
|
4
|
+
it 'references the correct class level' do
|
5
|
+
expect(described_class).to be_const_defined(:CLASS_LEVEL)
|
6
|
+
expect(described_class::CLASS_LEVEL).to be RubySMB::Fscc::FileInformation::FILE_MODE_INFORMATION
|
7
|
+
end
|
8
|
+
|
9
|
+
subject(:struct) { described_class.new }
|
10
|
+
|
11
|
+
it { should respond_to :flags }
|
12
|
+
|
13
|
+
it 'is little endian' do
|
14
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'tracks the flags in a struct field' do
|
18
|
+
expect(struct.flags).to be_a BinData::Struct
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::Fscc::FileInformation::FileNameInformation do
|
4
|
+
it 'references the correct class level' do
|
5
|
+
expect(described_class).to be_const_defined(:CLASS_LEVEL)
|
6
|
+
expect(described_class::CLASS_LEVEL).to be RubySMB::Fscc::FileInformation::FILE_NAME_INFORMATION
|
7
|
+
end
|
8
|
+
|
9
|
+
subject(:struct) { described_class.new }
|
10
|
+
|
11
|
+
it { should respond_to :file_name_length }
|
12
|
+
it { should respond_to :file_name }
|
13
|
+
|
14
|
+
it 'is little endian' do
|
15
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'tracks the file name length in a Uint32 field' do
|
19
|
+
expect(struct.file_name_length).to be_a BinData::Uint32le
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'tracks the file name in a String16 field' do
|
23
|
+
expect(struct.file_name).to be_a RubySMB::Field::String16
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#file_name' do
|
27
|
+
it 'automatically encodes the file name in UTF-16LE' do
|
28
|
+
name = 'Hello_world.txt'
|
29
|
+
struct.file_name = name
|
30
|
+
expect(struct.file_name.force_encoding('utf-16le')).to eq name.encode('utf-16le')
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'reading in from a blob' do
|
34
|
+
it 'uses the file_name_length to know when to stop reading' do
|
35
|
+
name = 'Hello_world.txt'
|
36
|
+
struct.file_name = name
|
37
|
+
blob = struct.to_binary_s
|
38
|
+
blob << 'AAAA'
|
39
|
+
new_from_blob = described_class.read(blob)
|
40
|
+
expect(new_from_blob.file_name.force_encoding('utf-16le')).to eq name.encode('utf-16le')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -17,25 +17,43 @@ RSpec.describe RubySMB::Fscc::FileInformation::FileNamesInformation do
|
|
17
17
|
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
18
18
|
end
|
19
19
|
|
20
|
+
it 'tracks the next offset in a Uint32 field' do
|
21
|
+
expect(struct.next_offset).to be_a BinData::Uint32le
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'tracks the file index in a Uint32 field' do
|
25
|
+
expect(struct.file_index).to be_a BinData::Uint32le
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'tracks the file name length in a Uint32 field' do
|
29
|
+
expect(struct.file_name_length).to be_a BinData::Uint32le
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'tracks the file name in a String16 field' do
|
33
|
+
expect(struct.file_name).to be_a RubySMB::Field::String16
|
34
|
+
end
|
35
|
+
|
20
36
|
it 'tracks the length of the file_name field' do
|
21
37
|
struct.file_name = 'Hello.txt'
|
22
38
|
expect(struct.file_name_length).to eq struct.file_name.do_num_bytes
|
23
39
|
end
|
24
40
|
|
25
|
-
|
26
|
-
name
|
27
|
-
struct.file_name = name
|
28
|
-
expect(struct.file_name.force_encoding('utf-16le')).to eq name.encode('utf-16le')
|
29
|
-
end
|
30
|
-
|
31
|
-
describe 'reading in from a blob' do
|
32
|
-
it 'uses the file_name_length to know when to stop reading' do
|
41
|
+
describe '#file_name' do
|
42
|
+
it 'automatically encodes the file name in UTF-16LE' do
|
33
43
|
name = 'Hello_world.txt'
|
34
44
|
struct.file_name = name
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
45
|
+
expect(struct.file_name.force_encoding('utf-16le')).to eq name.encode('utf-16le')
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'reading in from a blob' do
|
49
|
+
it 'uses the file_name_length to know when to stop reading' do
|
50
|
+
name = 'Hello_world.txt'
|
51
|
+
struct.file_name = name
|
52
|
+
blob = struct.to_binary_s
|
53
|
+
blob << 'AAAA'
|
54
|
+
new_from_blob = described_class.read(blob)
|
55
|
+
expect(new_from_blob.file_name.force_encoding('utf-16le')).to eq name.encode('utf-16le')
|
56
|
+
end
|
39
57
|
end
|
40
58
|
end
|
41
59
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::Fscc::FileInformation::FileNetworkOpenInformation do
|
4
|
+
it 'references the correct class level' do
|
5
|
+
expect(described_class).to be_const_defined(:CLASS_LEVEL)
|
6
|
+
expect(described_class::CLASS_LEVEL).to be RubySMB::Fscc::FileInformation::FILE_NETWORK_OPEN_INFORMATION
|
7
|
+
end
|
8
|
+
|
9
|
+
subject(:struct) { described_class.new }
|
10
|
+
|
11
|
+
it { should respond_to :create_time }
|
12
|
+
it { should respond_to :last_access }
|
13
|
+
it { should respond_to :last_write }
|
14
|
+
it { should respond_to :last_change }
|
15
|
+
it { should respond_to :allocation_size }
|
16
|
+
it { should respond_to :end_of_file }
|
17
|
+
it { should respond_to :file_attributes }
|
18
|
+
|
19
|
+
it 'is little endian' do
|
20
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'tracks the create time in a FileTime field' do
|
24
|
+
expect(struct.create_time).to be_a RubySMB::Field::FileTime
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'tracks the last access time in a FileTime field' do
|
28
|
+
expect(struct.last_access).to be_a RubySMB::Field::FileTime
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'tracks the last write time in a FileTime field' do
|
32
|
+
expect(struct.last_write).to be_a RubySMB::Field::FileTime
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'tracks the last modified time in a FileTime field' do
|
36
|
+
expect(struct.last_change).to be_a RubySMB::Field::FileTime
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'tracks the file size in a Int64 field' do
|
40
|
+
expect(struct.end_of_file).to be_a BinData::Int64le
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'tracks the allocation size in a Int64 field' do
|
44
|
+
expect(struct.allocation_size).to be_a BinData::Int64le
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'tracks the file attributes in a FileAttributes field' do
|
48
|
+
expect(struct.file_attributes).to be_a RubySMB::Fscc::FileAttributes
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::Fscc::FileInformation::FileNormalizedNameInformation do
|
4
|
+
it 'references the correct class level' do
|
5
|
+
expect(described_class).to be_const_defined(:CLASS_LEVEL)
|
6
|
+
expect(described_class::CLASS_LEVEL).to be RubySMB::Fscc::FileInformation::FILE_NORMALIZED_NAME_INFORMATION
|
7
|
+
end
|
8
|
+
|
9
|
+
subject(:struct) { described_class.new }
|
10
|
+
|
11
|
+
it { should respond_to :file_name_length }
|
12
|
+
it { should respond_to :file_name }
|
13
|
+
|
14
|
+
it 'is little endian' do
|
15
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'tracks the file name length in a Uint32 field' do
|
19
|
+
expect(struct.file_name_length).to be_a BinData::Uint32le
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'tracks the file name in a String16 field' do
|
23
|
+
expect(struct.file_name).to be_a RubySMB::Field::String16
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#file_name' do
|
27
|
+
it 'automatically encodes the file name in UTF-16LE' do
|
28
|
+
name = 'Hello_world.txt'
|
29
|
+
struct.file_name = name
|
30
|
+
expect(struct.file_name.force_encoding('utf-16le')).to eq name.encode('utf-16le')
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'reading in from a blob' do
|
34
|
+
it 'uses the file_name_length to know when to stop reading' do
|
35
|
+
name = 'Hello_world.txt'
|
36
|
+
struct.file_name = name
|
37
|
+
blob = struct.to_binary_s
|
38
|
+
blob << 'AAAA'
|
39
|
+
new_from_blob = described_class.read(blob)
|
40
|
+
expect(new_from_blob.file_name.force_encoding('utf-16le')).to eq name.encode('utf-16le')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::Fscc::FileInformation::FilePositionInformation do
|
4
|
+
it 'references the correct class level' do
|
5
|
+
expect(described_class).to be_const_defined(:CLASS_LEVEL)
|
6
|
+
expect(described_class::CLASS_LEVEL).to be RubySMB::Fscc::FileInformation::FILE_POSITION_INFORMATION
|
7
|
+
end
|
8
|
+
|
9
|
+
subject(:struct) { described_class.new }
|
10
|
+
|
11
|
+
it { should respond_to :current_byte_offset }
|
12
|
+
|
13
|
+
it 'is little endian' do
|
14
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'tracks the current byte offset in a Int64 field' do
|
18
|
+
expect(struct.current_byte_offset).to be_a BinData::Int64le
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
RSpec.describe RubySMB::Fscc::FileInformation::FileRenameInformation do
|
4
4
|
it 'references the correct class level' do
|
5
5
|
expect(described_class).to be_const_defined(:CLASS_LEVEL)
|
6
|
-
expect(described_class::CLASS_LEVEL).to be RubySMB::Fscc::FileInformation::
|
6
|
+
expect(described_class::CLASS_LEVEL).to be RubySMB::Fscc::FileInformation::FILE_RENAME_INFORMATION
|
7
7
|
end
|
8
8
|
|
9
9
|
subject(:struct) { described_class.new }
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::Fscc::FileInformation::FileStandardInformation do
|
4
|
+
it 'references the correct class level' do
|
5
|
+
expect(described_class).to be_const_defined(:CLASS_LEVEL)
|
6
|
+
expect(described_class::CLASS_LEVEL).to be RubySMB::Fscc::FileInformation::FILE_STANDARD_INFORMATION
|
7
|
+
end
|
8
|
+
|
9
|
+
subject(:struct) { described_class.new }
|
10
|
+
|
11
|
+
it { should respond_to :allocation_size }
|
12
|
+
it { should respond_to :end_of_file }
|
13
|
+
it { should respond_to :number_of_links }
|
14
|
+
it { should respond_to :delete_pending }
|
15
|
+
it { should respond_to :directory }
|
16
|
+
|
17
|
+
it 'is little endian' do
|
18
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'tracks the allocation size in a Int64 field' do
|
22
|
+
expect(struct.allocation_size).to be_a BinData::Int64le
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'tracks the file size in a Int64 field' do
|
26
|
+
expect(struct.end_of_file).to be_a BinData::Int64le
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'tracks the number of links in a Uint32 field' do
|
30
|
+
expect(struct.number_of_links).to be_a BinData::Uint32le
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'tracks if a delete is pending in a Int8 field' do
|
34
|
+
expect(struct.delete_pending).to be_a BinData::Int8
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'tracks if it is a directory in a Int8 field' do
|
38
|
+
expect(struct.directory).to be_a BinData::Int8
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::Fscc::FileInformation::FileStreamInformation do
|
4
|
+
it 'references the correct class level' do
|
5
|
+
expect(described_class).to be_const_defined(:CLASS_LEVEL)
|
6
|
+
expect(described_class::CLASS_LEVEL).to be RubySMB::Fscc::FileInformation::FILE_STREAM_INFORMATION
|
7
|
+
end
|
8
|
+
|
9
|
+
subject(:struct) { described_class.new }
|
10
|
+
|
11
|
+
it { should respond_to :next_entry_offset }
|
12
|
+
it { should respond_to :stream_name_length }
|
13
|
+
it { should respond_to :stream_size }
|
14
|
+
it { should respond_to :stream_allocation_size }
|
15
|
+
it { should respond_to :stream_name }
|
16
|
+
|
17
|
+
it 'is little endian' do
|
18
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'tracks the next entry offset in a Uint32 field' do
|
22
|
+
expect(struct.next_entry_offset).to be_a BinData::Uint32le
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'tracks the stream name length in a Uint32 field' do
|
26
|
+
expect(struct.stream_name_length).to be_a BinData::Uint32le
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'tracks the stream size in a Int64 field' do
|
30
|
+
expect(struct.stream_size).to be_a BinData::Int64le
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'tracks the stream allocation size in a Int64 field' do
|
34
|
+
expect(struct.stream_allocation_size).to be_a BinData::Int64le
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'tracks the stream name in a String16 field' do
|
38
|
+
expect(struct.stream_name).to be_a RubySMB::Field::String16
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'tracks the length of the stream_name field' do
|
42
|
+
struct.stream_name = 'Hello.txt'
|
43
|
+
expect(struct.stream_name_length).to eq struct.stream_name.do_num_bytes
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'automatically encodes the stream name in UTF-16LE' do
|
47
|
+
name = 'Hello_world.txt'
|
48
|
+
struct.stream_name = name
|
49
|
+
expect(struct.stream_name.force_encoding('utf-16le')).to eq name.encode('utf-16le')
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::Fscc::FileInformation do
|
4
|
+
|
5
|
+
describe '#name' do
|
6
|
+
it 'maps constant names to their value' do
|
7
|
+
expect(described_class.name(RubySMB::Fscc::FileInformation::FILE_DIRECTORY_INFORMATION)).to eq :FILE_DIRECTORY_INFORMATION
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'returns nil for values that do not exist' do
|
11
|
+
expect(described_class.name(-1)).to be_nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::Fscc::FileSystemInformation::FileFsAttributeInformation do
|
4
|
+
it 'references the correct class level' do
|
5
|
+
expect(described_class).to be_const_defined(:CLASS_LEVEL)
|
6
|
+
expect(described_class::CLASS_LEVEL).to be RubySMB::Fscc::FileSystemInformation::FILE_FS_ATTRIBUTE_INFORMATION
|
7
|
+
end
|
8
|
+
|
9
|
+
subject(:struct) { described_class.new }
|
10
|
+
|
11
|
+
it { should respond_to :file_system_attributes }
|
12
|
+
it { should respond_to :maximum_component_name_length }
|
13
|
+
it { should respond_to :file_system_name_length }
|
14
|
+
it { should respond_to :file_system_name }
|
15
|
+
|
16
|
+
it 'is little endian' do
|
17
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'tracks the file system attributes in a struct field' do
|
21
|
+
expect(struct.file_system_attributes).to be_a BinData::Struct
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'tracks the maximum component name length in a Int32 field' do
|
25
|
+
expect(struct.maximum_component_name_length).to be_a BinData::Int32le
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'tracks the file system name length in a Uint32 field' do
|
29
|
+
expect(struct.file_system_name_length).to be_a BinData::Uint32le
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'tracks the file system name in a String16 field' do
|
33
|
+
expect(struct.file_system_name).to be_a RubySMB::Field::String16
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'tracks the length of the file_system_name field' do
|
37
|
+
struct.file_system_name = 'NTFS'
|
38
|
+
expect(struct.file_system_name_length).to eq struct.file_system_name.do_num_bytes
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'automatically encodes the file system name in UTF-16LE' do
|
42
|
+
name = 'NTFS'
|
43
|
+
struct.file_system_name = name
|
44
|
+
expect(struct.file_system_name.force_encoding('utf-16le')).to eq name.encode('utf-16le')
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::Fscc::FileSystemInformation::FileFsVolumeInformation do
|
4
|
+
it 'references the correct class level' do
|
5
|
+
expect(described_class).to be_const_defined(:CLASS_LEVEL)
|
6
|
+
expect(described_class::CLASS_LEVEL).to be RubySMB::Fscc::FileSystemInformation::FILE_FS_VOLUME_INFORMATION
|
7
|
+
end
|
8
|
+
|
9
|
+
subject(:struct) { described_class.new }
|
10
|
+
|
11
|
+
it { should respond_to :volume_creation_time }
|
12
|
+
it { should respond_to :volume_serial_number }
|
13
|
+
it { should respond_to :volume_label_length }
|
14
|
+
it { should respond_to :supports_objects }
|
15
|
+
it { should respond_to :volume_label }
|
16
|
+
|
17
|
+
it 'is little endian' do
|
18
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'tracks the volume creation time in a FileTime field' do
|
22
|
+
expect(struct.volume_creation_time).to be_a RubySMB::Field::FileTime
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'tracks the volume serial number in a Uint32 field' do
|
26
|
+
expect(struct.volume_serial_number).to be_a BinData::Uint32le
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'tracks the volume label length in a Uint32 field' do
|
30
|
+
expect(struct.volume_label_length).to be_a BinData::Uint32le
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'tracks if it supports objects in a Uint8 field' do
|
34
|
+
expect(struct.supports_objects).to be_a BinData::Uint8
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'tracks the volume label in a String16 field' do
|
38
|
+
expect(struct.volume_label).to be_a RubySMB::Field::String16
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'tracks the length of the volume_label field' do
|
42
|
+
struct.volume_label = 'NTFS'
|
43
|
+
expect(struct.volume_label_length).to eq struct.volume_label.do_num_bytes
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'automatically encodes the file system name in UTF-16LE' do
|
47
|
+
name = 'NTFS'
|
48
|
+
struct.volume_label = name
|
49
|
+
expect(struct.volume_label.force_encoding('utf-16le')).to eq name.encode('utf-16le')
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RubySMB::Fscc::FileSystemInformation do
|
4
|
+
|
5
|
+
describe '#name' do
|
6
|
+
it 'maps constant names to their value' do
|
7
|
+
expect(described_class.name(RubySMB::Fscc::FileSystemInformation::FILE_FS_VOLUME_INFORMATION)).to eq :FILE_FS_VOLUME_INFORMATION
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'returns nil for values that do not exist' do
|
11
|
+
expect(described_class.name(-1)).to be_nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|