@infrascan/cli 0.2.2 → 0.2.4
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.
- package/dist/index.mjs +20 -7
- package/package.json +4 -3
package/dist/index.mjs
CHANGED
|
@@ -79,6 +79,10 @@ import {
|
|
|
79
79
|
fromIni,
|
|
80
80
|
fromTemporaryCredentials
|
|
81
81
|
} from "@aws-sdk/credential-providers";
|
|
82
|
+
import {
|
|
83
|
+
loadSharedConfigFiles,
|
|
84
|
+
DEFAULT_PROFILE
|
|
85
|
+
} from "@smithy/shared-ini-file-loader";
|
|
82
86
|
function getConfig(path) {
|
|
83
87
|
const resolvedConfigPath = resolve2(path);
|
|
84
88
|
return JSON.parse(readFileSync2(resolvedConfigPath, "utf8"));
|
|
@@ -90,18 +94,20 @@ function writeScanMetadata(outputDirectory, metadata) {
|
|
|
90
94
|
"utf8"
|
|
91
95
|
);
|
|
92
96
|
}
|
|
93
|
-
function
|
|
97
|
+
function resolveCredentialProvider(profile, roleToAssume) {
|
|
94
98
|
if (profile) {
|
|
95
|
-
return fromIni({
|
|
96
|
-
profile
|
|
99
|
+
return (region) => fromIni({
|
|
100
|
+
profile,
|
|
101
|
+
clientConfig: { region }
|
|
97
102
|
});
|
|
98
103
|
}
|
|
99
104
|
if (roleToAssume) {
|
|
100
|
-
return fromTemporaryCredentials({
|
|
105
|
+
return (region) => fromTemporaryCredentials({
|
|
101
106
|
params: {
|
|
102
107
|
RoleArn: roleToAssume,
|
|
103
108
|
RoleSessionName: "infrascan-cli-scan"
|
|
104
|
-
}
|
|
109
|
+
},
|
|
110
|
+
clientConfig: { region }
|
|
105
111
|
});
|
|
106
112
|
}
|
|
107
113
|
throw new Error(
|
|
@@ -139,13 +145,20 @@ var ScanCmd = class extends CommandLineAction2 {
|
|
|
139
145
|
createTargetDirectory: true
|
|
140
146
|
});
|
|
141
147
|
const metadata = [];
|
|
148
|
+
const awsConfig = await loadSharedConfigFiles().catch((err) => {
|
|
149
|
+
console.warn(
|
|
150
|
+
`Failed to load AWS config file, falling back to @infrascan/sdk defaults. (${err.message})`
|
|
151
|
+
);
|
|
152
|
+
return void 0;
|
|
153
|
+
});
|
|
142
154
|
for (const accountConfig of scanConfig) {
|
|
143
155
|
const { profile, roleToAssume, regions } = accountConfig;
|
|
144
|
-
const credentials =
|
|
156
|
+
const credentials = resolveCredentialProvider(profile, roleToAssume);
|
|
157
|
+
const defaultRegion = awsConfig?.configFile?.[profile ?? DEFAULT_PROFILE]?.region;
|
|
145
158
|
const accountMetadata = await this.infrascanClient.performScan(
|
|
146
159
|
credentials,
|
|
147
160
|
connector,
|
|
148
|
-
{ regions }
|
|
161
|
+
{ regions, defaultRegion }
|
|
149
162
|
);
|
|
150
163
|
metadata.push(accountMetadata);
|
|
151
164
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infrascan/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Thin command line wrapper around the infrascan sdk",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
6
|
"scripts": {
|
|
@@ -37,10 +37,11 @@
|
|
|
37
37
|
"license": "MPL-2.0",
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@aws-sdk/credential-providers": "3.428.0",
|
|
40
|
-
"@infrascan/aws": "^0.
|
|
40
|
+
"@infrascan/aws": "^0.3.0",
|
|
41
41
|
"@infrascan/fs-connector": "^0.2.2",
|
|
42
|
-
"@infrascan/sdk": "^0.
|
|
42
|
+
"@infrascan/sdk": "^0.3.0",
|
|
43
43
|
"@rushstack/ts-command-line": "^4.15.2",
|
|
44
|
+
"@smithy/shared-ini-file-loader": "^2.2.2",
|
|
44
45
|
"minimatch": "^6.1.6"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|