train-k8s-container-mitre 2.0.0

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.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/.expeditor/buildkite/coverage.sh +46 -0
  3. data/.expeditor/buildkite/run_linux_tests.sh +16 -0
  4. data/.expeditor/config.yml +61 -0
  5. data/.expeditor/coverage.pipeline.yml +19 -0
  6. data/.expeditor/update_version.sh +12 -0
  7. data/.expeditor/verify.pipeline.yml +44 -0
  8. data/.rspec +4 -0
  9. data/.rubocop.yml +57 -0
  10. data/CHANGELOG.md +158 -0
  11. data/CODE_OF_CONDUCT.md +13 -0
  12. data/CONTRIBUTING.md +161 -0
  13. data/DEVELOPMENT.md +315 -0
  14. data/Gemfile +23 -0
  15. data/LICENSE.md +9 -0
  16. data/NOTICE.md +9 -0
  17. data/README.md +237 -0
  18. data/Rakefile +37 -0
  19. data/SECURITY.md +100 -0
  20. data/VERSION +1 -0
  21. data/cliff.toml +80 -0
  22. data/docs/README.md +1 -0
  23. data/lib/train-k8s-container/ansi_sanitizer.rb +31 -0
  24. data/lib/train-k8s-container/connection.rb +102 -0
  25. data/lib/train-k8s-container/errors.rb +22 -0
  26. data/lib/train-k8s-container/kubectl_command_builder.rb +87 -0
  27. data/lib/train-k8s-container/kubectl_exec_client.rb +176 -0
  28. data/lib/train-k8s-container/kubernetes_name_validator.rb +44 -0
  29. data/lib/train-k8s-container/platform.rb +93 -0
  30. data/lib/train-k8s-container/pty_session.rb +156 -0
  31. data/lib/train-k8s-container/result_processor.rb +94 -0
  32. data/lib/train-k8s-container/retry_handler.rb +35 -0
  33. data/lib/train-k8s-container/session_manager.rb +95 -0
  34. data/lib/train-k8s-container/shell_detector.rb +198 -0
  35. data/lib/train-k8s-container/transport.rb +30 -0
  36. data/lib/train-k8s-container/version.rb +7 -0
  37. data/lib/train-k8s-container.rb +12 -0
  38. data/sonar-project.properties +17 -0
  39. data/train-k8s-container.gemspec +49 -0
  40. metadata +107 -0
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'train'
4
+ require 'train/plugins'
5
+
6
+ module TrainPlugins
7
+ module K8sContainer
8
+ # Train transport for connecting to Kubernetes containers via kubectl exec
9
+ class Transport < Train.plugin(1)
10
+ require_relative 'connection'
11
+
12
+ name 'k8s-container'
13
+
14
+ option :kubeconfig, default: ENV['KUBECONFIG'] || '~/.kube/config'
15
+ option :pod, default: nil
16
+ option :container_name, default: nil
17
+ option :namespace, default: nil
18
+
19
+ def connection(state = nil, &)
20
+ opts = merge_options(@options, state || {})
21
+ create_new_connection(opts, &)
22
+ end
23
+
24
+ def create_new_connection(options, &)
25
+ @connection_options = options
26
+ @connection = Connection.new(options, &)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrainPlugins
4
+ module K8sContainer
5
+ VERSION = File.read(File.expand_path('../../VERSION', __dir__)).strip
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ libdir = File.dirname(__FILE__)
4
+ $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
5
+
6
+ require_relative 'train-k8s-container/version'
7
+ require_relative 'train-k8s-container/errors'
8
+ require_relative 'train-k8s-container/platform'
9
+ require_relative 'train-k8s-container/retry_handler'
10
+ require_relative 'train-k8s-container/transport'
11
+ require_relative 'train-k8s-container/connection'
12
+ require_relative 'train-k8s-container/kubectl_exec_client'
@@ -0,0 +1,17 @@
1
+ # must be unique in a given SonarQube instance
2
+ sonar.projectKey=inspec_train-k8s-container_AYvdJXl0G2RNgd1H9hTX
3
+
4
+ sonar.projectName=Chef-Inspec-train-k8s-container
5
+
6
+ # path to test coverage report generated by simplecov
7
+ #sonar.ruby.coverage.reportPaths=coverage/coverage.json
8
+
9
+ # exclude test directories from coverage
10
+ sonar.coverage.exclusions=spec/*
11
+
12
+ sonar.exclusions=**/*.java,**/*.js,vendor/*
13
+
14
+ # skip C-language processor
15
+ sonar.c.file.suffixes=-
16
+ sonar.cpp.file.suffixes=-
17
+ sonar.objc.file.suffixes=-
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'train-k8s-container/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'train-k8s-container-mitre'
9
+ spec.version = TrainPlugins::K8sContainer::VERSION
10
+ spec.authors = ['MITRE SAF Team']
11
+ spec.email = ['saf@groups.mitre.org']
12
+
13
+ spec.summary = 'Train transport plugin for scanning Kubernetes containers with InSpec/Cinc Auditor.'
14
+ spec.description = <<~DESC
15
+ A Train transport plugin that enables Chef InSpec and Cinc Auditor to run compliance
16
+ scans against containers running in Kubernetes clusters. Uses kubectl exec to execute
17
+ commands inside containers, with proper platform detection for accurate OS resource behavior.
18
+ DESC
19
+ spec.homepage = 'https://github.com/mitre/train-k8s-container'
20
+ spec.license = 'Apache-2.0'
21
+ spec.required_ruby_version = '>= 3.1'
22
+
23
+ spec.metadata['rubygems_mfa_required'] = 'true'
24
+ spec.metadata['source_code_uri'] = 'https://github.com/mitre/train-k8s-container'
25
+ spec.metadata['changelog_uri'] = 'https://github.com/mitre/train-k8s-container/blob/main/CHANGELOG.md'
26
+ spec.metadata['bug_tracker_uri'] = 'https://github.com/mitre/train-k8s-container/issues'
27
+ spec.metadata['documentation_uri'] = 'https://github.com/mitre/train-k8s-container#readme'
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(__dir__) do
32
+ `git ls-files -z`.split("\x0").reject do |f|
33
+ (File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git])
34
+ end
35
+ end
36
+
37
+ spec.require_paths = ['lib']
38
+
39
+ # NOTE: Do not list 'train' or 'inspec' as dependencies.
40
+ # Train plugins are loaded within InSpec's environment, which already provides
41
+ # train, train-core, and all their dependencies. Declaring train as a dependency
42
+ # causes gem activation conflicts (e.g., multi_json version conflicts).
43
+ #
44
+ # For development, add train to Gemfile in the development group.
45
+
46
+ # Ruby 3.4+ will remove base64 from default gems - add it explicitly
47
+ # This fixes the deprecation warning from train-core
48
+ spec.add_dependency 'base64', '~> 0.2', '>= 0.2.0'
49
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: train-k8s-container-mitre
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
+ platform: ruby
6
+ authors:
7
+ - MITRE SAF Team
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: base64
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '0.2'
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: 0.2.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '0.2'
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 0.2.0
32
+ description: |
33
+ A Train transport plugin that enables Chef InSpec and Cinc Auditor to run compliance
34
+ scans against containers running in Kubernetes clusters. Uses kubectl exec to execute
35
+ commands inside containers, with proper platform detection for accurate OS resource behavior.
36
+ email:
37
+ - saf@groups.mitre.org
38
+ executables: []
39
+ extensions: []
40
+ extra_rdoc_files: []
41
+ files:
42
+ - ".expeditor/buildkite/coverage.sh"
43
+ - ".expeditor/buildkite/run_linux_tests.sh"
44
+ - ".expeditor/config.yml"
45
+ - ".expeditor/coverage.pipeline.yml"
46
+ - ".expeditor/update_version.sh"
47
+ - ".expeditor/verify.pipeline.yml"
48
+ - ".rspec"
49
+ - ".rubocop.yml"
50
+ - CHANGELOG.md
51
+ - CODE_OF_CONDUCT.md
52
+ - CONTRIBUTING.md
53
+ - DEVELOPMENT.md
54
+ - Gemfile
55
+ - LICENSE.md
56
+ - NOTICE.md
57
+ - README.md
58
+ - Rakefile
59
+ - SECURITY.md
60
+ - VERSION
61
+ - cliff.toml
62
+ - docs/README.md
63
+ - lib/train-k8s-container.rb
64
+ - lib/train-k8s-container/ansi_sanitizer.rb
65
+ - lib/train-k8s-container/connection.rb
66
+ - lib/train-k8s-container/errors.rb
67
+ - lib/train-k8s-container/kubectl_command_builder.rb
68
+ - lib/train-k8s-container/kubectl_exec_client.rb
69
+ - lib/train-k8s-container/kubernetes_name_validator.rb
70
+ - lib/train-k8s-container/platform.rb
71
+ - lib/train-k8s-container/pty_session.rb
72
+ - lib/train-k8s-container/result_processor.rb
73
+ - lib/train-k8s-container/retry_handler.rb
74
+ - lib/train-k8s-container/session_manager.rb
75
+ - lib/train-k8s-container/shell_detector.rb
76
+ - lib/train-k8s-container/transport.rb
77
+ - lib/train-k8s-container/version.rb
78
+ - sonar-project.properties
79
+ - train-k8s-container.gemspec
80
+ homepage: https://github.com/mitre/train-k8s-container
81
+ licenses:
82
+ - Apache-2.0
83
+ metadata:
84
+ rubygems_mfa_required: 'true'
85
+ source_code_uri: https://github.com/mitre/train-k8s-container
86
+ changelog_uri: https://github.com/mitre/train-k8s-container/blob/main/CHANGELOG.md
87
+ bug_tracker_uri: https://github.com/mitre/train-k8s-container/issues
88
+ documentation_uri: https://github.com/mitre/train-k8s-container#readme
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '3.1'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubygems_version: 3.7.2
104
+ specification_version: 4
105
+ summary: Train transport plugin for scanning Kubernetes containers with InSpec/Cinc
106
+ Auditor.
107
+ test_files: []