win32-security 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +6 -0
- data/README +19 -19
- data/Rakefile +37 -28
- data/lib/win32/security.rb +40 -39
- data/lib/win32/security/ace.rb +26 -26
- data/lib/win32/security/acl.rb +136 -136
- data/lib/win32/security/sid.rb +356 -292
- data/test/test_security.rb +13 -1
- data/test/test_sid.rb +125 -117
- data/win32-security.gemspec +20 -24
- metadata +70 -56
data/test/test_security.rb
CHANGED
@@ -9,14 +9,26 @@ gem 'test-unit'
|
|
9
9
|
|
10
10
|
require 'test/unit'
|
11
11
|
require 'win32/security'
|
12
|
+
require 'windows/system_info'
|
12
13
|
|
13
14
|
class TC_Win32_Security < Test::Unit::TestCase
|
15
|
+
extend Windows::SystemInfo
|
16
|
+
|
17
|
+
def self.startup
|
18
|
+
@@version = windows_version
|
19
|
+
end
|
20
|
+
|
14
21
|
def test_version
|
15
|
-
assert_equal('0.1.
|
22
|
+
assert_equal('0.1.3', Win32::Security::VERSION)
|
16
23
|
end
|
17
24
|
|
18
25
|
def test_elevated_security
|
26
|
+
omit_if(@@version < 6.0, 'Skipped on Windows 2000 and Windows XP')
|
19
27
|
assert_respond_to(Win32::Security, :elevated_security?)
|
20
28
|
assert_boolean(Win32::Security.elevated_security?)
|
21
29
|
end
|
30
|
+
|
31
|
+
def self.shutdown
|
32
|
+
@@version= nil
|
33
|
+
end
|
22
34
|
end
|
data/test/test_sid.rb
CHANGED
@@ -4,126 +4,134 @@
|
|
4
4
|
# Test suite for the Win32::Security::SID class. You should run these
|
5
5
|
# tests via the 'rake test' task.
|
6
6
|
########################################################################
|
7
|
-
require '
|
8
|
-
gem 'test-unit'
|
9
|
-
|
10
|
-
require 'test/unit'
|
7
|
+
require 'test-unit'
|
11
8
|
require 'win32/security'
|
12
9
|
require 'sys/admin'
|
13
10
|
include Win32
|
14
11
|
|
15
12
|
class TC_Win32_Security_Sid < Test::Unit::TestCase
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
13
|
+
def self.startup
|
14
|
+
@@host = Socket.gethostname
|
15
|
+
@@name = Sys::Admin.users[0].name
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup
|
19
|
+
@sid = Security::SID.new(@@name)
|
20
|
+
end
|
21
|
+
|
22
|
+
test "version is set to expected value" do
|
23
|
+
assert_equal('0.1.3', Security::SID::VERSION)
|
24
|
+
end
|
25
|
+
|
26
|
+
test "sid method basic functionality" do
|
27
|
+
assert_respond_to(@sid, :sid)
|
28
|
+
assert_kind_of(String, @sid.sid)
|
29
|
+
end
|
30
|
+
|
31
|
+
test "account method basic functionality" do
|
32
|
+
assert_respond_to(@sid, :account)
|
33
|
+
assert_kind_of(String, @sid.account)
|
34
|
+
end
|
35
|
+
|
36
|
+
test "account_type method basic functionality" do
|
37
|
+
assert_respond_to(@sid, :account_type)
|
38
|
+
assert_kind_of(String, @sid.account_type)
|
39
|
+
end
|
40
|
+
|
41
|
+
test "domain method basic functionality" do
|
42
|
+
assert_respond_to(@sid, :domain)
|
43
|
+
assert_kind_of(String, @sid.domain)
|
44
|
+
end
|
45
|
+
|
46
|
+
test "host method basic functionality" do
|
47
|
+
assert_respond_to(@sid, :host)
|
48
|
+
assert_kind_of(String, @sid.host)
|
49
|
+
end
|
50
|
+
|
51
|
+
test "sid_to_string works as expected" do
|
52
|
+
assert_respond_to(Security::SID, :sid_to_string)
|
53
|
+
assert_kind_of(String, Security::SID.sid_to_string(@sid.sid))
|
54
|
+
assert_not_nil(Security::SID.sid_to_string(@sid.sid) =~ /\w+\-\w+/)
|
55
|
+
end
|
56
|
+
|
57
|
+
test "string_to_sid works as expected" do
|
58
|
+
assert_respond_to(Security::SID, :string_to_sid)
|
59
|
+
assert_kind_of(String, Security::SID.string_to_sid(@sid.to_s))
|
60
|
+
end
|
61
|
+
|
62
|
+
test "to_s works as expected" do
|
63
|
+
assert_respond_to(@sid, :to_s)
|
64
|
+
assert_kind_of(String, @sid.to_s)
|
65
|
+
assert_true(@sid.to_s.include?('-'))
|
66
|
+
end
|
67
|
+
|
68
|
+
test "to_str is an alias for to_s" do
|
69
|
+
assert_respond_to(@sid, :to_str)
|
70
|
+
assert_alias_method(@sid, :to_str, :to_s)
|
71
|
+
end
|
72
|
+
|
73
|
+
test "equality works as expected" do
|
74
|
+
assert_respond_to(@sid, :==)
|
75
|
+
assert_true(@sid == @sid)
|
76
|
+
end
|
77
|
+
|
78
|
+
test "valid? method works as expected" do
|
79
|
+
assert_respond_to(@sid, :valid?)
|
80
|
+
assert_true(@sid.valid?)
|
81
|
+
end
|
82
|
+
|
83
|
+
test "length method works as expected" do
|
84
|
+
assert_respond_to(@sid, :length)
|
85
|
+
assert_true(@sid.length > 0)
|
86
|
+
end
|
87
|
+
|
88
|
+
test "create method works as expected" do
|
89
|
+
assert_respond_to(Security::SID, :create)
|
90
|
+
assert_nothing_raised{
|
91
|
+
Security::SID.create(
|
92
|
+
Security::SID::SECURITY_WORLD_SID_AUTHORITY,
|
93
|
+
Security::SID::SECURITY_WORLD_RID
|
94
|
+
)
|
95
|
+
}
|
96
|
+
end
|
97
|
+
|
98
|
+
test "constructor defaults to current account" do
|
99
|
+
assert_nothing_raised{ @sid = Security::SID.new }
|
100
|
+
assert_equal(Sys::Admin.get_login, @sid.account)
|
101
|
+
end
|
102
|
+
|
103
|
+
test "constructor accepts an account argument" do
|
104
|
+
assert_nothing_raised{ Security::SID.new(@@name) }
|
105
|
+
end
|
106
|
+
|
107
|
+
test "constructor accepts a host argument" do
|
108
|
+
assert_nothing_raised{ Security::SID.new(@@name, @@host) }
|
109
|
+
end
|
110
|
+
|
111
|
+
test "constructor accepts a maximum of two arguments" do
|
112
|
+
assert_raise(ArgumentError){ Security::SID.new(@@name, @@host, @@host) }
|
113
|
+
end
|
114
|
+
|
115
|
+
test "constructor raises an error if an invalid account is passed" do
|
116
|
+
assert_raise(Security::SID::Error){ Security::SID.new('bogus') }
|
117
|
+
end
|
118
|
+
|
119
|
+
test "well known sid constants are defined" do
|
120
|
+
assert_equal('S-1-0', Security::SID::Null)
|
121
|
+
assert_equal('S-1-0-0', Security::SID::Nobody)
|
122
|
+
assert_equal('S-1-1', Security::SID::World)
|
123
|
+
assert_equal('S-1-1-0', Security::SID::Everyone)
|
124
|
+
assert_equal('S-1-5-32-544', Security::SID::BuiltinAdministrators)
|
125
|
+
assert_equal('S-1-5-32-545', Security::SID::BuiltinUsers)
|
126
|
+
assert_equal('S-1-5-32-546', Security::SID::Guests)
|
127
|
+
end
|
128
|
+
|
129
|
+
def teardown
|
130
|
+
@sid = nil
|
131
|
+
end
|
132
|
+
|
133
|
+
def self.shutdown
|
134
|
+
@@host = nil
|
135
|
+
@@name = nil
|
136
|
+
end
|
129
137
|
end
|
data/win32-security.gemspec
CHANGED
@@ -1,31 +1,27 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
gem.files = Dir['**/*'].reject{ |f| f.include?('CVS') }
|
14
|
-
gem.license = 'Artistic 2.0'
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'win32-security'
|
5
|
+
spec.version = '0.1.3'
|
6
|
+
spec.authors = ['Daniel J. Berger', 'Park Heesob']
|
7
|
+
spec.license = 'Artistic 2.0'
|
8
|
+
spec.email = 'djberg96@gmail.com'
|
9
|
+
spec.homepage = 'http://www.rubyforge.org/projects/win32utils'
|
10
|
+
spec.summary = 'A library for dealing with aspects of Windows security.'
|
11
|
+
spec.test_files = Dir['test/*.rb']
|
12
|
+
spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
|
15
13
|
|
16
|
-
|
17
|
-
|
14
|
+
spec.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
|
15
|
+
spec.rubyforge_project = 'win32utils'
|
18
16
|
|
19
|
-
|
17
|
+
spec.add_dependency('windows-pr', '>= 1.2.2')
|
20
18
|
|
21
|
-
|
22
|
-
|
19
|
+
spec.add_development_dependency('test-unit', '>= 2.5.0')
|
20
|
+
spec.add_development_dependency('sys-admin', '>= 1.5.3')
|
23
21
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
spec.description = <<-EOF
|
23
|
+
The win32-security library provides an interface for dealing with
|
24
|
+
security related aspects of MS Windows. At the moment it provides an
|
25
|
+
interface for inspecting or creating SID's.
|
26
|
+
EOF
|
29
27
|
end
|
30
|
-
|
31
|
-
Gem::Builder.new(spec).build
|
metadata
CHANGED
@@ -1,59 +1,76 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: win32-security
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
+
authors:
|
7
8
|
- Daniel J. Berger
|
8
9
|
- Park Heesob
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
date: 2012-07-12 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
17
16
|
name: windows-pr
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.2.2
|
18
23
|
type: :runtime
|
19
|
-
|
20
|
-
version_requirements: !ruby/object:Gem::Requirement
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
- !ruby/object:Gem::Dependency
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 1.2.2
|
31
|
+
- !ruby/object:Gem::Dependency
|
27
32
|
name: test-unit
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 2.5.0
|
28
39
|
type: :development
|
29
|
-
|
30
|
-
version_requirements: !ruby/object:Gem::Requirement
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.5.0
|
47
|
+
- !ruby/object:Gem::Dependency
|
37
48
|
name: sys-admin
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.5.3
|
38
55
|
type: :development
|
39
|
-
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
description: "
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.5.3
|
63
|
+
description: ! " The win32-security library provides an interface for dealing with\n
|
64
|
+
\ security related aspects of MS Windows. At the moment it provides an\n interface
|
65
|
+
for inspecting or creating SID's.\n"
|
47
66
|
email: djberg96@gmail.com
|
48
67
|
executables: []
|
49
|
-
|
50
68
|
extensions: []
|
51
|
-
|
52
|
-
extra_rdoc_files:
|
69
|
+
extra_rdoc_files:
|
53
70
|
- README
|
54
71
|
- CHANGES
|
55
72
|
- MANIFEST
|
56
|
-
files:
|
73
|
+
files:
|
57
74
|
- CHANGES
|
58
75
|
- lib/win32/security/ace.rb
|
59
76
|
- lib/win32/security/acl.rb
|
@@ -66,35 +83,32 @@ files:
|
|
66
83
|
- test/test_security.rb
|
67
84
|
- test/test_sid.rb
|
68
85
|
- win32-security.gemspec
|
69
|
-
has_rdoc: true
|
70
86
|
homepage: http://www.rubyforge.org/projects/win32utils
|
71
|
-
licenses:
|
87
|
+
licenses:
|
72
88
|
- Artistic 2.0
|
73
89
|
post_install_message:
|
74
90
|
rdoc_options: []
|
75
|
-
|
76
|
-
require_paths:
|
91
|
+
require_paths:
|
77
92
|
- lib
|
78
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ! '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
90
105
|
requirements: []
|
91
|
-
|
92
106
|
rubyforge_project: win32utils
|
93
|
-
rubygems_version: 1.
|
107
|
+
rubygems_version: 1.8.24
|
94
108
|
signing_key:
|
95
109
|
specification_version: 3
|
96
110
|
summary: A library for dealing with aspects of Windows security.
|
97
|
-
test_files:
|
111
|
+
test_files:
|
98
112
|
- test/test_acl.rb
|
99
113
|
- test/test_security.rb
|
100
114
|
- test/test_sid.rb
|