cucumber-create-meta 1.0.0 → 2.0.2

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: fc6fadee5d6df3e7e90f5f21741bd7eb9850b645efa7b120098329932dc9f165
4
- data.tar.gz: 8e9553277de8b14d988529b320489685c9a104f60a31a6adf35160ed751e9e76
3
+ metadata.gz: 4a4f36daf37f233cc900ef6e7e9b962dc8109d1054faecf1de72e532a59335ff
4
+ data.tar.gz: 0c1fe89598d1eedb5914ac7f8fea417a03c59f6a5b901ef503542fb7695ea675
5
5
  SHA512:
6
- metadata.gz: cf282b4a220dfb292340b9d216b379a46094ca932d30227382a94f3ec14fca86025504d74f8c334903ff354818ea94b82d7515966ee2550c2d185ca4377dfeb9
7
- data.tar.gz: cc3c3328c0c32dc453f2dd5d4fd4a5821aa8ec09fd7e3a4ddeca96b059dea802d6aabf29dee78270c0079acf21272707af9b516d0a5b45066a5f2fefd11c75f0
6
+ metadata.gz: 7141737ea7d22b1bc7e78f282c0e589eb4c12fc9bfc793b99f75efe69119e5392beb2660d3ce87839e553b917c5a47967777db5eb26cb3ab40740b9dd328cb91
7
+ data.tar.gz: 7aa043622a0c97318e8abe92941e41a82071e3fecae213962e7a99c437d4bd16dfb34bd4e7b7d71e98788bcbf66da11242002d5bff094682e936cc396a879a10
@@ -45,9 +45,9 @@
45
45
  }
46
46
  },
47
47
  "GitHub Actions": {
48
- "url": "${_GITHUB_BASEURL | https://github.com/}${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}",
48
+ "url": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}",
49
49
  "git": {
50
- "remote": "${_GITHUB_BASEURL | https://github.com/}${GITHUB_REPOSITORY}.git",
50
+ "remote": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git",
51
51
  "revision": "${GITHUB_SHA}",
52
52
  "branch": "${refbranch GITHUB_REF}",
53
53
  "tag": "${reftag GITHUB_REF}"
@@ -1,29 +1,31 @@
1
+ require 'uri'
1
2
  require 'cucumber/messages'
2
3
  require 'sys/uname'
3
4
  require 'json'
4
5
 
5
6
  module Cucumber
6
7
  module CreateMeta
7
- CI_DICT = JSON.parse(IO.read(File.join(File.dirname(__FILE__),"ciDict.json")))
8
+ CI_DICT = JSON.parse(IO.read(File.join(File.dirname(__FILE__), "ciDict.json")))
8
9
 
9
- def create_meta(tool_name, tool_version)
10
+ def create_meta(tool_name, tool_version, env = ENV)
10
11
  Cucumber::Messages::Meta.new(
11
- protocol_version: Cucumber::Messages::VERSION,
12
- implementation: Cucumber::Messages::Meta::Product.new(
13
- name: tool_name,
14
- version: tool_version
15
- ),
16
- runtime: Cucumber::Messages::Meta::Product.new(
17
- name: RUBY_ENGINE,
18
- version: RUBY_VERSION
19
- ),
20
- os: Cucumber::Messages::Meta::Product.new(
21
- name: RbConfig::CONFIG['target_os'],
22
- version: Sys::Uname.uname.version
23
- ),
24
- cpu: Cucumber::Messages::Meta::Product.new(
25
- name: RbConfig::CONFIG['target_cpu']
26
- )
12
+ protocol_version: Cucumber::Messages::VERSION,
13
+ implementation: Cucumber::Messages::Meta::Product.new(
14
+ name: tool_name,
15
+ version: tool_version
16
+ ),
17
+ runtime: Cucumber::Messages::Meta::Product.new(
18
+ name: RUBY_ENGINE,
19
+ version: RUBY_VERSION
20
+ ),
21
+ os: Cucumber::Messages::Meta::Product.new(
22
+ name: RbConfig::CONFIG['target_os'],
23
+ version: Sys::Uname.uname.version
24
+ ),
25
+ cpu: Cucumber::Messages::Meta::Product.new(
26
+ name: RbConfig::CONFIG['target_cpu']
27
+ ),
28
+ ci: detect_ci(env)
27
29
  )
28
30
  end
29
31
 
@@ -40,14 +42,14 @@ module Cucumber
40
42
  return nil if url.nil?
41
43
 
42
44
  Cucumber::Messages::Meta::CI.new(
43
- url: url,
44
- name: ci_name,
45
- git: Cucumber::Messages::Meta::CI::Git.new(
46
- remote: evaluate(ci_system['git']['remote'], env),
47
- revision: evaluate(ci_system['git']['revision'], env),
48
- branch: evaluate(ci_system['git']['branch'], env),
49
- tag: evaluate(ci_system['git']['tag'], env),
50
- )
45
+ url: url,
46
+ name: ci_name,
47
+ git: Cucumber::Messages::Meta::CI::Git.new(
48
+ remote: remove_userinfo_from_url(evaluate(ci_system['git']['remote'], env)),
49
+ revision: evaluate(ci_system['git']['revision'], env),
50
+ branch: evaluate(ci_system['git']['branch'], env),
51
+ tag: evaluate(ci_system['git']['tag'], env),
52
+ )
51
53
  )
52
54
  end
53
55
 
@@ -79,6 +81,17 @@ module Cucumber
79
81
  m[1]
80
82
  end
81
83
 
82
- module_function :create_meta, :detect_ci, :create_ci, :group1, :evaluate
84
+ def remove_userinfo_from_url(value)
85
+ return nil if value.nil?
86
+ begin
87
+ uri = URI(value)
88
+ uri.userinfo = ''
89
+ uri.to_s
90
+ rescue
91
+ value
92
+ end
93
+ end
94
+
95
+ module_function :create_meta, :detect_ci, :create_ci, :group1, :evaluate, :remove_userinfo_from_url
83
96
  end
84
97
  end
@@ -0,0 +1,29 @@
1
+ require 'cucumber/create_meta'
2
+
3
+ describe 'remove_user_info_from_url' do
4
+ it 'returns nil for nil' do
5
+ expect(Cucumber::CreateMeta.remove_userinfo_from_url(nil)).to be_nil
6
+ end
7
+
8
+ it 'returns empty string for empty string' do
9
+ expect(Cucumber::CreateMeta.remove_userinfo_from_url('')).to eq('')
10
+ end
11
+
12
+ it 'leaves the data intact when no sensitive information is detected' do
13
+ expect(Cucumber::CreateMeta.remove_userinfo_from_url('pretty safe')).to eq('pretty safe')
14
+ end
15
+
16
+ context 'with URLs' do
17
+ it 'leaves intact when no password is found' do
18
+ expect(Cucumber::CreateMeta.remove_userinfo_from_url('https://example.com/git/repo.git')).to eq('https://example.com/git/repo.git')
19
+ end
20
+
21
+ it 'removes credentials when found' do
22
+ expect(Cucumber::CreateMeta.remove_userinfo_from_url('http://login@example.com/git/repo.git')).to eq('http://example.com/git/repo.git')
23
+ end
24
+
25
+ it 'removes credentials and passwords when found' do
26
+ expect(Cucumber::CreateMeta.remove_userinfo_from_url('ssh://login:password@example.com/git/repo.git')).to eq('ssh://example.com/git/repo.git')
27
+ end
28
+ end
29
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-create-meta
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Prêtre
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-29 00:00:00.000000000 Z
11
+ date: 2020-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber-messages
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '12.2'
19
+ version: '13.0'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 12.2.0
22
+ version: 13.0.1
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: '12.2'
29
+ version: '13.0'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 12.2.0
32
+ version: 13.0.1
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: sys-uname
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -101,6 +101,7 @@ files:
101
101
  - lib/cucumber/create_meta.rb
102
102
  - spec/capture_warnings.rb
103
103
  - spec/cucumber/create_meta_spec.rb
104
+ - spec/cucumber/remove_userinfo_from_url_spec.rb
104
105
  homepage: https://github.com/cucumber/create-meta-ruby
105
106
  licenses:
106
107
  - MIT
@@ -129,7 +130,8 @@ requirements: []
129
130
  rubygems_version: 3.1.2
130
131
  signing_key:
131
132
  specification_version: 4
132
- summary: cucumber-create-meta-1.0.0
133
+ summary: cucumber-create-meta-2.0.2
133
134
  test_files:
134
135
  - spec/cucumber/create_meta_spec.rb
136
+ - spec/cucumber/remove_userinfo_from_url_spec.rb
135
137
  - spec/capture_warnings.rb