train-k8s-container-mitre 2.2.1 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7401f8f5a6cd3dbab1c4ccf3badcabde98032ddfe39f791eb62aa3fb6d14f17f
4
- data.tar.gz: b477518b7f03d3f419c0437ce9750af9f4e2496cf2995b0baed4bb41923034db
3
+ metadata.gz: 7b95ee2c59e32274bfbf09aa1762cb927521b5c45faebf3fe476569aa81e2fa0
4
+ data.tar.gz: 1cdf1d2feff07b4e500d846f5a33e7da436b35fa25fe35d260ef690e001eba4e
5
5
  SHA512:
6
- metadata.gz: 69b0c02f9d1d724d6760e341f9f42caec31ccf3a4f96477ae9f09b121067b3c02edbc50cd1b0524296524d770ec87c9022f806b880ca30735c2349e972f108b7
7
- data.tar.gz: 236996377e83721b771cf5c6d5103509b261c4361231dd313131340a0f52090d8020abf5437373b75aad23852d79db97cdd80c3d74960dcc52b859442035cf6e
6
+ metadata.gz: 37834018266f1c81c6410e10486331eafeb0d4d7199bfe023a7759d99793b85d9e54dbc50448897e29a80c7ac79d20099c2985a5255fdc03ebde9eb83aedcb6c
7
+ data.tar.gz: f44e54c68706db397464fb2189f23da0f12dbcef0c0436281afa5d0c53ffd73ed295d9fb71bd87acc76fc92f92104eaeca458bf54f2a7f3cac12fc4dec68fabd
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "2.2.1"
2
+ ".": "2.2.2"
3
3
  }
data/CHANGELOG.md CHANGED
@@ -5,6 +5,26 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.2.2](https://github.com/mitre/train-k8s-container/compare/v2.2.1...v2.2.2) (2026-05-28)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * parse URI host as K8s namespace ([99e7bda](https://github.com/mitre/train-k8s-container/commit/99e7bda8e0eb36f77053febddae5d4929a5af72b))
14
+ * parse URI host as K8s namespace ([6a8fb88](https://github.com/mitre/train-k8s-container/commit/6a8fb8821a25ae115136137e166abfc3f9258e2d))
15
+
16
+
17
+ ### Code Refactoring
18
+
19
+ * **connection:** collapse URI parser branches into case statement ([58206ed](https://github.com/mitre/train-k8s-container/commit/58206ed20e1b11df195ebd0e798f4f69926dc7b3))
20
+ * **connection:** use non-deprecated Train.unpack_target_from_uri ([925c17d](https://github.com/mitre/train-k8s-container/commit/925c17d8ef09391c6badfb1e62d19490904dc50d))
21
+
22
+
23
+ ### Tests
24
+
25
+ * **connection:** cover #unique_identifier delegation ([893e28b](https://github.com/mitre/train-k8s-container/commit/893e28bcdbf95b883272fd02e1556dcd7d03fa32))
26
+ * **connection:** pin URI parser behavior with characterization tests ([c2c0c34](https://github.com/mitre/train-k8s-container/commit/c2c0c3490c58e25f2cee54d8156c78d74a64d47e))
27
+
8
28
  ## [2.2.1](https://github.com/mitre/train-k8s-container/compare/v2.2.0...v2.2.1) (2026-01-17)
9
29
 
10
30
 
@@ -6,6 +6,7 @@ require 'train/file/remote/linux'
6
6
  require 'train/file/remote/windows'
7
7
  require_relative 'platform'
8
8
  require_relative 'kubernetes_name_validator'
9
+ require_relative 'kubectl_exec_client'
9
10
 
10
11
  module TrainPlugins
11
12
  module K8sContainer
@@ -18,26 +19,35 @@ module TrainPlugins
18
19
  # @example k8s-container://default/shell-demo/nginx
19
20
 
20
21
  def initialize(options)
22
+ # Defensive: unpack URI when a caller passes :target directly (e.g. programmatic use).
23
+ # InSpec normally pre-unpacks via Train.target_config, so :host/:path are already set
24
+ # and this block is a no-op. Uses unpack_target_from_uri because Train.target_config is
25
+ # flagged for deprecation upstream (see train-core/lib/train.rb). Merge direction
26
+ # matches target_config's original behavior: explicit options win over unpacked creds.
27
+ if options[:target] && options[:host].to_s.empty?
28
+ options = Train.unpack_target_from_uri(options[:target]).merge(options)
29
+ end
21
30
  super
22
31
 
23
- # Parse URI path format (InSpec converts k8s-container://target to path="//target"):
24
- # - k8s-container://pod/container → path="//pod/container" (default namespace)
25
- # - k8s-container://namespace/pod/container → path="//namespace/pod/container"
32
+ # Parse URI components:
33
+ # - k8s-container://namespace/pod/container → host="namespace", path="/pod/container"
34
+ # - k8s-container:///namespace/pod/container → path="/namespace/pod/container"
35
+ # - k8s-container:///pod/container → path="/pod/container" (default namespace)
26
36
  path_parts = options[:path]&.split('/')&.reject(&:empty?)
37
+ host = options[:host].to_s.empty? ? nil : options[:host]
27
38
 
28
- if path_parts&.length == 2
29
- # Format: //pod/container (default namespace)
30
- @namespace = options[:namespace] || TrainPlugins::K8sContainer::KubectlExecClient::DEFAULT_NAMESPACE
31
- @pod = options[:pod] || path_parts.first
32
- @container_name = options[:container_name] || path_parts[1]
33
- elsif path_parts&.length == 3
34
- # Format: //namespace/pod/container
35
- @namespace = options[:namespace] || path_parts.first
39
+ case path_parts&.length
40
+ when 3
41
+ @namespace = options[:namespace] || host || path_parts.first
36
42
  @pod = options[:pod] || path_parts[1]
37
43
  @container_name = options[:container_name] || path_parts[2]
44
+ when 2
45
+ @namespace = options[:namespace] || host || TrainPlugins::K8sContainer::KubectlExecClient::DEFAULT_NAMESPACE
46
+ @pod = options[:pod] || path_parts.first
47
+ @container_name = options[:container_name] || path_parts[1]
38
48
  else
39
49
  # No valid path - must use explicit options
40
- @namespace = options[:namespace] || TrainPlugins::K8sContainer::KubectlExecClient::DEFAULT_NAMESPACE
50
+ @namespace = options[:namespace] || host || TrainPlugins::K8sContainer::KubectlExecClient::DEFAULT_NAMESPACE
41
51
  @pod = options[:pod]
42
52
  @container_name = options[:container_name]
43
53
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module TrainPlugins
4
4
  module K8sContainer
5
- VERSION = '2.2.1'
5
+ VERSION = '2.2.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: train-k8s-container-mitre
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - MITRE SAF Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-17 00:00:00.000000000 Z
11
+ date: 2026-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64