train-pwsh 0.1.5 → 1.0.7
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 +4 -4
- data/LICENSE.md +1 -1
- data/README.md +25 -0
- data/Rakefile +9 -0
- data/lib/train-pwsh/connection.rb +37 -0
- data/lib/train-pwsh/version.rb +1 -1
- data/train-pwsh.gemspec +7 -9
- metadata +10 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da66dd3bfae044e714689303864eed1b206c158282c49b0023a2847edcc9466d
|
4
|
+
data.tar.gz: de4f87e4206d4d54bd1fd0ca908ffb5bdaed81573c92046d71d9c64ea832b85e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c78670c60457b39db97f0f83011c353841be259b8c2b0fdc1ab4967f878ab2aecfb5ba4707f101e180615fde9407bebfa137cdecd46be4523d72e64b135890f
|
7
|
+
data.tar.gz: d9cb83c1ef7f82c51d3f26b583b2496e8f57c9ede8c28006efedd4848cfc3a491a9868c5044c2ca1b652034ac4fe618ec14f3c887d73258bd8b4f56215a49faf
|
data/LICENSE.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Licensed under the
|
1
|
+
Licensed under the Apache-2.0 license, except as noted below.
|
2
2
|
|
3
3
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
4
4
|
|
data/README.md
CHANGED
@@ -12,6 +12,31 @@ A train-pwsh connection has eight fields that are needed for authentication, whi
|
|
12
12
|
|
13
13
|
These fields need to be defined in the config file stored at this directory: `~/.inspec/config.json`. Particularly, under the `credentials` key of the json file, create a `pwsh` key with the value being another dictionary. This dictionary should have a key named `pwsh-options` with the value being another dictionary. This dictionary should contain the names of the eight fields above as well as their values. Please refer to this [link](https://origin.inspec.io/docs/reference/config/) for more detailed instructions.
|
14
14
|
|
15
|
+
As mentioned in the link above documentation, to run train-pwsh, a `config.json` file is needed at the following directory: `~/.inspec/config.json`. An example json file is shown below; the values will need to be populated with your actual data.
|
16
|
+
|
17
|
+
```json
|
18
|
+
{
|
19
|
+
"version": "1.1",
|
20
|
+
"cli_options": {
|
21
|
+
"color": "true"
|
22
|
+
},
|
23
|
+
"credentials": {
|
24
|
+
"pwsh": {
|
25
|
+
"pwsh-options": {
|
26
|
+
"client_id": "INSERT CLIENT ID",
|
27
|
+
"tenant_id": "INSERT TENANT ID",
|
28
|
+
"client_secret": "INSERT CLIENT SECRET",
|
29
|
+
"certificate_path": "INSERT CERTIFICATE PATH",
|
30
|
+
"certificate_password": "INSERT CERTIFICATE PASSWORD",
|
31
|
+
"organization": "INSERT ORGANIZATION",
|
32
|
+
"sharepoint_admin_url": "INSERT SHAREPOINT ADMIN URL",
|
33
|
+
"pwsh_path": "INSERT POWERSHELL PATH"
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
```
|
39
|
+
|
15
40
|
On top of this, environment variables may need to be defined for some of these eight fields if they are to be used elsewhere in the profile as inputs. The README for the profile will specify which ones need to be stored as environment variables.
|
16
41
|
|
17
42
|
To set an environment variable on Mac, go to the `zschrc` file located at `~/.zschrc` and enter in the following syntax: `export VARIABLE_NAME='insert_value'`
|
data/Rakefile
CHANGED
@@ -1,4 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
|
+
require 'github_changelog_generator/task'
|
5
|
+
|
4
6
|
task default: %i[]
|
7
|
+
|
8
|
+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
9
|
+
config.user = 'skandwal'
|
10
|
+
config.project = 'train-pwsh'
|
11
|
+
config.since_tag = '1.0.7'
|
12
|
+
config.future_release = '2.0.0'
|
13
|
+
end
|
@@ -55,6 +55,7 @@ module TrainPlugins
|
|
55
55
|
#@pwsh_session_teams_pnp = @options.delete(:teams_pnp_session)
|
56
56
|
@pwsh_session_graph_exchange = ::Pwsh::Manager.instance("#{@pwsh_path}", ['-NoLogo'])
|
57
57
|
@pwsh_session_teams_pnp = ::Pwsh::Manager.instance("#{@pwsh_path}", [])
|
58
|
+
@pwsh_session_azure = ::Pwsh::Manager.instance("#{@pwsh_path}", ['-NoProfile'])
|
58
59
|
@client_id = @options.delete(:client_id)
|
59
60
|
@tenant_id = @options.delete(:tenant_id)
|
60
61
|
@client_secret = @options.delete(:client_secret)
|
@@ -65,10 +66,13 @@ module TrainPlugins
|
|
65
66
|
|
66
67
|
exit_status_graph_exchange = install_connect_graph_exchange()
|
67
68
|
exit_status_teams_pnp = install_connect_teams_pnp()
|
69
|
+
exit_status_azure = install_azure()
|
68
70
|
if exit_status_graph_exchange != 0
|
69
71
|
return exit_status_graph_exchange
|
70
72
|
elsif exit_status_teams_pnp != 0
|
71
73
|
return exit_status_teams_pnp
|
74
|
+
elsif exit_status_azure != 0
|
75
|
+
return exit_status_azure
|
72
76
|
end
|
73
77
|
|
74
78
|
end
|
@@ -82,6 +86,8 @@ module TrainPlugins
|
|
82
86
|
return run_script_in_graph_exchange(script)
|
83
87
|
elsif session_type_hash.key?(:teams_pnp_session)
|
84
88
|
return run_script_in_teams_pnp(script)
|
89
|
+
elsif session_type_hash.key?(:azure_session)
|
90
|
+
return run_script_in_azure(script)
|
85
91
|
else
|
86
92
|
return CommandResult.new("","",0)
|
87
93
|
end
|
@@ -146,6 +152,24 @@ module TrainPlugins
|
|
146
152
|
return pwsh_teams_pnp_install_connect_result[:exitcode]
|
147
153
|
end
|
148
154
|
|
155
|
+
def install_azure()
|
156
|
+
pwsh_azure_install_connect = %{
|
157
|
+
#Collect designated inputs required for Graph, Exchange, and PnP connections
|
158
|
+
$client_id = '#{@client_id}'
|
159
|
+
$tenantid = '#{@tenant_id}'
|
160
|
+
$certificate_password = '#{@certificate_password}'
|
161
|
+
$certificate_path = '#{@certificate_path}'
|
162
|
+
$sharepoint_admin_url = '#{@sharepoint_admin_url}'
|
163
|
+
|
164
|
+
#Connect to Teams module
|
165
|
+
If ($null -eq (Get-Module -ListAvailable -Name "Az")) {Install-Module Az -Force -AllowClobber}
|
166
|
+
If ($null -eq (Get-Module -Name "Az")) {Import-Module Az}
|
167
|
+
Connect-AzAccount
|
168
|
+
}
|
169
|
+
pwsh_azure_install_connect_result = @pwsh_session_azure.execute(pwsh_azure_install_connect)
|
170
|
+
return pwsh_azure_install_connect_result[:exitcode]
|
171
|
+
end
|
172
|
+
|
149
173
|
def run_script_in_graph_exchange(script)
|
150
174
|
result = @pwsh_session_graph_exchange.execute(script)
|
151
175
|
if result[:stdout].nil?
|
@@ -171,6 +195,19 @@ module TrainPlugins
|
|
171
195
|
end
|
172
196
|
return CommandResult.new(result[:stdout],result[:stderr],result[:exitcode])
|
173
197
|
end
|
198
|
+
|
199
|
+
def run_script_in_azure(script)
|
200
|
+
result = @pwsh_session_azure.execute(script)
|
201
|
+
if result[:stdout].nil?
|
202
|
+
result[:stdout] = ""
|
203
|
+
end
|
204
|
+
if !result[:stdout].empty? && result[:stdout].match?(/is not recognized|session is not established/i)
|
205
|
+
result[:stderr] = result[:stdout]
|
206
|
+
result[:stdout] = ""
|
207
|
+
result[:exitcode] = -1
|
208
|
+
end
|
209
|
+
return CommandResult.new(result[:stdout],result[:stderr],result[:exitcode])
|
210
|
+
end
|
174
211
|
end
|
175
212
|
end
|
176
213
|
end
|
data/lib/train-pwsh/version.rb
CHANGED
data/train-pwsh.gemspec
CHANGED
@@ -8,17 +8,15 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["Sujay Kandwal"]
|
9
9
|
spec.email = ["skandwal@mitre.org"]
|
10
10
|
spec.files = Dir['lib/**/*.rb'] + Dir['bin/*']+ ["README.md", "LICENSE.md", "NOTICE.md", "CHANGELOG.md", "CODE_OF_CONDUCT.md"]
|
11
|
-
spec.summary = "Enabling continuous Powershell connection over Inspec"
|
12
|
-
|
13
|
-
|
14
|
-
spec.license = "
|
11
|
+
spec.summary = "Enabling continuous Powershell connection over Inspec."
|
12
|
+
spec.description = "Enabling continuous Powershell connection over Inspec."
|
13
|
+
spec.homepage = "https://rubygems.org/gems/train-pwsh"
|
14
|
+
spec.license = "Apache-2.0"
|
15
15
|
spec.required_ruby_version = ">= 2.6.0"
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
#spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
21
|
-
#spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/mitre/train-pwsh/"
|
19
|
+
spec.metadata["changelog_uri"] = spec.metadata['source_code_uri'] + "blob/main/CHANGELOG.md"
|
22
20
|
|
23
21
|
# Specify which files should be added to the gem when it is released.
|
24
22
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: train-pwsh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sujay Kandwal
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: train
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description:
|
41
|
+
description: Enabling continuous Powershell connection over Inspec.
|
42
42
|
email:
|
43
43
|
- skandwal@mitre.org
|
44
44
|
executables: []
|
@@ -59,10 +59,13 @@ files:
|
|
59
59
|
- lib/train-pwsh/version.rb
|
60
60
|
- sig/train/pwsh.rbs
|
61
61
|
- train-pwsh.gemspec
|
62
|
-
homepage:
|
62
|
+
homepage: https://rubygems.org/gems/train-pwsh
|
63
63
|
licenses:
|
64
|
-
-
|
65
|
-
metadata:
|
64
|
+
- Apache-2.0
|
65
|
+
metadata:
|
66
|
+
homepage_uri: https://rubygems.org/gems/train-pwsh
|
67
|
+
source_code_uri: https://github.com/mitre/train-pwsh/
|
68
|
+
changelog_uri: https://github.com/mitre/train-pwsh/blob/main/CHANGELOG.md
|
66
69
|
post_install_message:
|
67
70
|
rdoc_options: []
|
68
71
|
require_paths:
|
@@ -81,5 +84,5 @@ requirements: []
|
|
81
84
|
rubygems_version: 3.3.27
|
82
85
|
signing_key:
|
83
86
|
specification_version: 4
|
84
|
-
summary: Enabling continuous Powershell connection over Inspec
|
87
|
+
summary: Enabling continuous Powershell connection over Inspec.
|
85
88
|
test_files: []
|