thales-pse 0.1.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9822d9ede725eb7e93e61f5da6edd57880e9085263fac58f4e0d28ac72949747
4
- data.tar.gz: c3c6041f5dbde1e17a4709092be0a425f752f11535fb2db9074cb39d2a19abbb
3
+ metadata.gz: cb679e7365c1decbdd2d5f67b3730ac74227b0eae1721807fd576043e91a1188
4
+ data.tar.gz: 8d0a0f1a0da459a696989c85a2682afbd4ba9617811497d32023390a7e26e22b
5
5
  SHA512:
6
- metadata.gz: 8bfc6a8cd47b76425c40c9d00959997583d07c5a62394a7e6f928ff367d89905c5dbcc189c0aebbc780a1e33753501c980b2bd74dc09f5403732e327e78d3f3b
7
- data.tar.gz: 51661eade08e5edfd65a7d61a2e3d4e32978e5c07aebb0552067ef92623e091b44f9e8e1d7b39eda3ea916f9d45315ef99819ae2ff8b7fca49e55d2aa644b0e7
6
+ metadata.gz: b12c2861bacc7bb18714ae1d2422577747ed30008bb09c2bf1395fdf4c5dc57808727b57b08e13e157cec3a4b00297e0788524879e4b6451054fa020524fe3f3
7
+ data.tar.gz: 968de2560c771ac44ee12951c41fa484bab289c797cb1fad89b093fa0875e727a9a73c4aa7badc3abf73674a03a6801f7a52c43e655b611c94ad8a375948e819
@@ -0,0 +1,8 @@
1
+ ---
2
+ thales-pse:
3
+ - :version: 0.2.0
4
+ :timestamp: 1634916519.8704317
5
+ - :version: 0.2.1
6
+ :timestamp: 1640072484.0339034
7
+ - :version: 0.2.2
8
+ :timestamp: 1640072784.0902636
@@ -0,0 +1,6 @@
1
+ ---
2
+ thales-pse:
3
+ - :version: 0.1.0
4
+ :created_at: 2021-10-21 13:10:44.299627127 +08:00
5
+ - :version: 0.1.1
6
+ :created_at: 2021-10-21 13:12:03.741967043 +08:00
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- thales-pse (0.1.0)
4
+ thales-pse (0.2.2)
5
5
  tlogger
6
6
  toolrack
7
7
 
@@ -9,18 +9,23 @@ GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  base58 (0.2.3)
12
- devops_helper (0.5.0)
12
+ devops_assist (0.1.0)
13
13
  git_cli
14
+ git_cli_prompt
14
15
  gvcs
15
16
  tlogger
16
17
  toolrack
17
- tty-prompt (= 0.22.0)
18
+ tty-prompt
18
19
  diff-lcs (1.4.4)
19
- git_cli (0.8.0)
20
- gvcs (>= 0.1.0)
20
+ git_cli (0.9.0)
21
+ gvcs
21
22
  ptools (~> 1.4.0)
22
- tlogger (>= 0.21)
23
- toolrack (>= 0.4.0)
23
+ tlogger
24
+ toolrack
25
+ git_cli_prompt (0.2.0)
26
+ tlogger
27
+ toolrack
28
+ tty-prompt
24
29
  gvcs (0.1.0)
25
30
  pastel (0.8.0)
26
31
  tty-color (~> 0.5)
@@ -40,12 +45,12 @@ GEM
40
45
  rspec-support (~> 3.10.0)
41
46
  rspec-support (3.10.2)
42
47
  tlogger (0.26.1)
43
- toolrack (0.15.0)
48
+ toolrack (0.16.0)
44
49
  base58
45
50
  tlogger
46
51
  tty-color (0.6.0)
47
52
  tty-cursor (0.7.1)
48
- tty-prompt (0.22.0)
53
+ tty-prompt (0.23.1)
49
54
  pastel (~> 0.8)
50
55
  tty-reader (~> 0.8)
51
56
  tty-reader (0.9.0)
@@ -58,13 +63,14 @@ GEM
58
63
  PLATFORMS
59
64
  java
60
65
  universal-java-1.8
66
+ universal-java-11
61
67
  x86_64-linux
62
68
 
63
69
  DEPENDENCIES
64
- devops_helper
70
+ devops_assist
65
71
  rake (~> 13.0)
66
72
  rspec (~> 3.0)
67
73
  thales-pse!
68
74
 
69
75
  BUNDLED WITH
70
- 2.2.28
76
+ 2.2.29
data/Rakefile CHANGED
@@ -3,7 +3,8 @@
3
3
  require "bundler/gem_tasks"
4
4
  require "rspec/core/rake_task"
5
5
 
6
- require 'devops_helper'
6
+ #require 'devops_helper'
7
+ require 'devops_assist'
7
8
 
8
9
  RSpec::Core::RakeTask.new(:spec)
9
10
 
data/docker/Dockerfile ADDED
@@ -0,0 +1,15 @@
1
+
2
+ FROM rvm-dev
3
+
4
+ WORKDIR /opt
5
+ COPY PTKcpsdk-5.9.0-RC5.x86_64.rpm .
6
+
7
+ #RUN apt-get update && apt-get install -y alien && alien -i *.rpm
8
+ RUN apt-get install -y alien && cd /opt && alien --scripts -i *.rpm
9
+ RUN ln -s /opt/safenet/protecttoolkit5/cpsdk/lib/linux-x86_64/libctsw.so /usr/lib/libcryptoki.so
10
+ RUN ln -s /opt/safenet/protecttoolkit5/cpsdk/lib/linux-x86_64/libethsm.so /usr/lib/libethsm.so
11
+
12
+ ENV PATH="/opt/safenet/protecttoolkit5/cpsdk/bin:/opt/safenet/protecttoolkit5/cpsdk/bin/linux-x86_64:$PATH"
13
+
14
+ ENTRYPOINT [ "/bin/bash", "--login" ]
15
+
data/docker/build.sh ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ docker build -t thales-pse-test .
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ docker run -it --rm -v $PWD/..:/opt/thales-pse thales-pse-test
@@ -28,29 +28,47 @@ module Thales
28
28
 
29
29
  PTY.spawn(exePath, *params) do |read, write, pid|
30
30
 
31
+ cont = ""
32
+ timeoutAfter = 1
31
33
  begin
32
34
 
35
+ logger.tdebug :cmd, "expect list : #{expect_list}"
33
36
  if not is_empty?(expect_list)
34
37
  expect_list.each do |ex|
38
+ timeoutAfter = ex[:timeout_after] || 5
39
+ logger.tdebug :cmd, "expect list element : #{ex}"
35
40
  to = ex[:timeout] || 1
41
+ logger.tdebug :cmd, "Expecting : #{ex[:matcher]}"
36
42
  cont = read.expect(/#{ex[:matcher]}/, to)
37
- output.puts cont
38
- write.puts block.call(ex[:block_key], cont)
43
+ output.puts cont.first if not_empty?(cont)
44
+ v = block.call(ex[:block_key],cont)
45
+ #logger.tdebug :cmd, "Calling block_key '#{ex[:block_key]}' got #{v}"
46
+ if not_empty?(v)
47
+ write.puts v
48
+ else
49
+ write.puts ""
50
+ end
51
+ #write.puts block.call(ex[:block_key], cont)
39
52
  end
40
53
  end
41
54
 
42
- Timeout.timeout(1) do
55
+ Timeout.timeout(timeoutAfter) do
43
56
  read.each do |l|
44
57
  output.puts l if not_empty?(l)
45
58
  end
46
59
  end
47
60
 
61
+ output.puts "[Done2] #{cmd}"
62
+
48
63
  rescue Timeout::Error => e
49
64
  read.close
50
65
  write.close
51
66
  Process.kill('TERM',pid)
52
67
  output.puts "Process #{cmd} ('#{pid}') killed due to timeout"
53
- rescue Errno::EIO
68
+ rescue Errno::EIO => e
69
+ #output.puts e.message
70
+ #output.puts e.backtrace.join("\n")
71
+ #output.puts "Read : #{cont}"
54
72
  output.puts "[Done] #{cmd}"
55
73
  end
56
74
  end
@@ -23,9 +23,9 @@ module Thales
23
23
  raise TokenError, "Slot is not available!" if is_empty?(@slot)
24
24
 
25
25
  expect = [
26
- { matcher: "new token label:", block_key: :token_label, timeout: 1 },
27
- { matcher: "enter Security Officer\'s pin:", block_key: :token_so_pin, timeout: 1 },
28
- { matcher: "confirm Security Officer\'s pin:", block_key: :token_so_pin_confirm, timeout: 1 }
26
+ { matcher: "new token label:", block_key: :token_label, timeout: 5 },
27
+ { matcher: "enter Security Officer\'s pin:", block_key: :token_so_pin, timeout: 5 },
28
+ { matcher: "confirm Security Officer\'s pin:", block_key: :token_so_pin_confirm, timeout: 5 }
29
29
  ]
30
30
 
31
31
  #slot = block.call(:slot) || 0
@@ -57,9 +57,9 @@ module Thales
57
57
 
58
58
  expect = [
59
59
  # this key is handled locally not passed to external
60
- { matcher: "Security Officer PIN.+:|current user PIN.+:", block_key: :auth_pin, timeout: 3 },
61
- { matcher: "enter the new user PIN.+:", block_key: :token_user_pin, timeout: 1 },
62
- { matcher: "confirm the new user PIN.+:", block_key: :token_user_pin_confirm, timeout: 1 }
60
+ { matcher: "Security Officer PIN.+:|current user PIN.+:", block_key: :auth_pin, timeout: 5 },
61
+ { matcher: "enter the new user PIN.+:", block_key: :token_user_pin, timeout: 5 },
62
+ { matcher: "confirm the new user PIN.+:", block_key: :token_user_pin_confirm, timeout: 5 }
63
63
  ]
64
64
 
65
65
  #slot = block.call(:slot) || 0
@@ -98,7 +98,7 @@ module Thales
98
98
  raise TokenError, "Slot is not available!" if is_empty?(@slot)
99
99
 
100
100
  expect = [
101
- { matcher: "Enter user PIN.+:", block_key: :token_user_pin, timeout: 1 }
101
+ { matcher: "Enter user PIN.+:", block_key: :token_user_pin, timeout: 1, timeout_after: 60*5 }
102
102
  ]
103
103
 
104
104
  type = args.first
@@ -163,7 +163,7 @@ module Thales
163
163
  cli_exec("ctkmu") do |ops, val|
164
164
  case ops
165
165
  when :params
166
- ["c","-t#{type}","-s#{slot}","-n#{keylabel}","-a#{atRes.join}"]
166
+ ["c","-t#{type}","-s#{slot}","-n#{keylabel}","-a#{atRes.join}","-z#{keysize}"]
167
167
  when :expect_list
168
168
  expect
169
169
  else
@@ -183,7 +183,7 @@ module Thales
183
183
  raise TokenError, "Slot is not available!" if is_empty?(@slot)
184
184
 
185
185
  expect = [
186
- { matcher: "Enter user PIN.+:", block_key: :token_user_pin, timeout: 1 },
186
+ { matcher: "Enter user PIN.+:", block_key: :token_user_pin, timeout: 60 }
187
187
  ]
188
188
 
189
189
  keylabel = block.call(:keylabel)
@@ -208,19 +208,19 @@ module Thales
208
208
 
209
209
  cn = block.call(:common_name)
210
210
  raise Error, "Common name is mandatory" if is_empty?(cn)
211
- expect << { matcher: "Common Name:", block_key: :cn, timeout: 1 }
211
+ expect << { matcher: "Common Name:", block_key: :cn, timeout: 5 }
212
212
  org = block.call(:org)
213
- expect << { matcher: "Organization:", block_key: :org, timeout: 1 }
213
+ expect << { matcher: "Organization:", block_key: :org, timeout: 5 }
214
214
  ou = block.call(:ou)
215
- expect << { matcher: "Organizational Unit:", block_key: :ou, timeout: 1 }
215
+ expect << { matcher: "Organizational Unit:", block_key: :ou, timeout: 5 }
216
216
  loc = block.call(:locality)
217
- expect << { matcher: "Locality:", block_key: :loc, timeout: 1 }
217
+ expect << { matcher: "Locality:", block_key: :loc, timeout: 5 }
218
218
  st = block.call(:state)
219
- expect << { matcher: "State:", block_key: :st, timeout: 1 }
219
+ expect << { matcher: "State:", block_key: :st, timeout: 5 }
220
220
  ctry = block.call(:country)
221
- expect << { matcher: "Country:", block_key: :ctry, timeout: 1 }
221
+ expect << { matcher: "Country:", block_key: :ctry, timeout: 5 }
222
222
  sn = block.call(:serial_no) || SecureRandom.uuid.gsub("-","")
223
- expect << { matcher: "certificate\'s serial number.+:", block_key: :sn, timeout: 1 }
223
+ expect << { matcher: "certificate\'s serial number.+:", block_key: :sn, timeout: 5 }
224
224
 
225
225
  params = ["c","-l#{keylabel}", "-s#{slot}"]
226
226
  if not_empty?(validFrom)
@@ -240,6 +240,7 @@ module Thales
240
240
  when :params
241
241
  params
242
242
  when :expect_list
243
+ #[expect[0]]
243
244
  expect
244
245
  when :cn
245
246
  cn
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Thales
4
4
  module Pse
5
- VERSION = "0.1.1"
5
+ VERSION = "0.3.0"
6
6
  end
7
7
  end
data/thales-pse.gemspec CHANGED
@@ -33,7 +33,8 @@ Gem::Specification.new do |spec|
33
33
  spec.add_dependency 'tlogger'
34
34
  spec.add_dependency 'toolrack'
35
35
 
36
- spec.add_development_dependency "devops_helper"
36
+ #spec.add_development_dependency "devops_helper"
37
+ spec.add_development_dependency "devops_assist"
37
38
 
38
39
  # Uncomment to register a new dependency of your gem
39
40
  # spec.add_dependency "example-gem", "~> 1.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thales-pse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-21 00:00:00.000000000 Z
11
+ date: 2021-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tlogger
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: devops_helper
42
+ name: devops_assist
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -59,13 +59,18 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - ".release_history.yml"
62
63
  - ".rspec"
64
+ - ".version_history.yml"
63
65
  - Gemfile
64
66
  - Gemfile.lock
65
67
  - README.md
66
68
  - Rakefile
67
69
  - bin/console
68
70
  - bin/setup
71
+ - docker/Dockerfile
72
+ - docker/build.sh
73
+ - docker/container.sh
69
74
  - lib/thales/pse.rb
70
75
  - lib/thales/pse/cli.rb
71
76
  - lib/thales/pse/config.rb