@rotty3000/config-node 0.4.2 → 0.5.1
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/config-lxc/index.d.ts +11 -11
- package/dist/config-lxc/index.js +53 -36
- package/dist/config-lxc/index.js.map +1 -1
- package/dist/config-node/index.js +68 -28
- package/dist/config-node/index.js.map +1 -1
- package/dist/config-node/providers/1000-application-packaged.js +12 -10
- package/dist/config-node/providers/1000-application-packaged.js.map +1 -1
- package/dist/config-node/providers/10000-cli.js +1 -1
- package/dist/config-node/providers/10000-cli.js.map +1 -1
- package/dist/config-node/providers/11000-config-node-devtools.js +1 -1
- package/dist/config-node/providers/11000-config-node-devtools.js.map +1 -1
- package/dist/config-node/providers/2000-application.js +1 -1
- package/dist/config-node/providers/2000-application.js.map +1 -1
- package/dist/config-node/providers/3000-application-config.js +1 -1
- package/dist/config-node/providers/3000-application-config.js.map +1 -1
- package/dist/config-node/providers/4000-application-profile.js +5 -1
- package/dist/config-node/providers/4000-application-profile.js.map +1 -1
- package/dist/config-node/providers/5000-application-profile-config.js +5 -1
- package/dist/config-node/providers/5000-application-profile-config.js.map +1 -1
- package/dist/config-node/providers/6000-config-trees.js +5 -4
- package/dist/config-node/providers/6000-config-trees.js.map +1 -1
- package/dist/config-node/providers/8000-env-application-json.js +1 -1
- package/dist/config-node/providers/8000-env-application-json.js.map +1 -1
- package/dist/config-node/providers/9000-cli-application-json.js +1 -1
- package/dist/config-node/providers/9000-cli-application-json.js.map +1 -1
- package/dist/config-node/util/index.d.ts +29 -2
- package/dist/config-node/util/index.js +84 -7
- package/dist/config-node/util/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,19 +4,19 @@ export declare enum OAuthApplicationProfile {
|
|
|
4
4
|
}
|
|
5
5
|
export interface LXCOAuthApplication {
|
|
6
6
|
readonly applicationType: OAuthApplicationProfile;
|
|
7
|
-
readonly audience: () => string;
|
|
8
|
-
readonly authorizationUri: () => string;
|
|
9
|
-
readonly clientId: () => string;
|
|
10
|
-
readonly clientSecret: () => string;
|
|
11
|
-
readonly introspectionUri: () => string;
|
|
12
|
-
readonly jwksUri: () => string;
|
|
13
|
-
readonly scopes: () => string[];
|
|
14
|
-
readonly tokenUri: () => string;
|
|
7
|
+
readonly audience: () => string | undefined;
|
|
8
|
+
readonly authorizationUri: () => string | undefined;
|
|
9
|
+
readonly clientId: () => string | undefined;
|
|
10
|
+
readonly clientSecret: () => string | undefined;
|
|
11
|
+
readonly introspectionUri: () => string | undefined;
|
|
12
|
+
readonly jwksUri: () => string | undefined;
|
|
13
|
+
readonly scopes: () => string[] | undefined;
|
|
14
|
+
readonly tokenUri: () => string | undefined;
|
|
15
15
|
}
|
|
16
16
|
export interface LXCConfig {
|
|
17
17
|
readonly dxpDomains: () => string[];
|
|
18
|
-
readonly dxpMainDomain: () => string;
|
|
19
|
-
readonly dxpProtocol: () => string;
|
|
20
|
-
readonly oauthApplication: (erc: string) => LXCOAuthApplication;
|
|
18
|
+
readonly dxpMainDomain: () => string | undefined;
|
|
19
|
+
readonly dxpProtocol: () => string | undefined;
|
|
20
|
+
readonly oauthApplication: (erc: string) => LXCOAuthApplication | undefined;
|
|
21
21
|
}
|
|
22
22
|
export declare const lxcConfig: LXCConfig;
|
package/dist/config-lxc/index.js
CHANGED
|
@@ -7,51 +7,68 @@ var OAuthApplicationProfile;
|
|
|
7
7
|
OAuthApplicationProfile[OAuthApplicationProfile["HEADLESS_SERVER"] = 0] = "HEADLESS_SERVER";
|
|
8
8
|
OAuthApplicationProfile[OAuthApplicationProfile["USER_AGENT"] = 1] = "USER_AGENT";
|
|
9
9
|
})(OAuthApplicationProfile || (exports.OAuthApplicationProfile = OAuthApplicationProfile = {}));
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Values reach this API in three shapes depending on where they came from: a comma delimited env var arrives
|
|
12
|
+
* already split into a string[] by `unquote`, a multi-line value (the volume mounted ConfigMap/Secret form)
|
|
13
|
+
* arrives as a single string, and an unset key arrives as undefined. Normalize all three to a list of trimmed,
|
|
14
|
+
* non-empty entries so callers never have to care which shape they got.
|
|
15
|
+
*/
|
|
16
|
+
function toList(value) {
|
|
17
|
+
let values;
|
|
18
|
+
if (Array.isArray(value)) {
|
|
19
|
+
values = value;
|
|
20
|
+
}
|
|
21
|
+
else if (value) {
|
|
22
|
+
values = `${value}`.split(/[,\r\n]+/);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
values = [];
|
|
26
|
+
}
|
|
27
|
+
return values.map((entry) => entry.trim()).filter((entry) => entry.length > 0);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The single valued lxc settings (protocol, audience, URIs, …) arrive through the same sources as the list
|
|
31
|
+
* valued ones, so a comma delimited value must not leak an array into a scalar accessor.
|
|
32
|
+
*/
|
|
33
|
+
function first(value) {
|
|
34
|
+
return toList(value)[0];
|
|
35
|
+
}
|
|
11
36
|
exports.lxcConfig = {
|
|
12
|
-
dxpDomains: () => (0, config_node_1.lookupConfig)('com.liferay.lxc.dxp.domains')
|
|
37
|
+
dxpDomains: () => toList((0, config_node_1.lookupConfig)('com.liferay.lxc.dxp.domains')),
|
|
13
38
|
dxpMainDomain: () => {
|
|
14
|
-
let value = (0, config_node_1.lookupConfig)('com.liferay.lxc.dxp.main.domain');
|
|
39
|
+
let value = first((0, config_node_1.lookupConfig)('com.liferay.lxc.dxp.main.domain'));
|
|
15
40
|
if (!value) {
|
|
16
|
-
value = (0, config_node_1.lookupConfig)('com.liferay.lxc.dxp.mainDomain');
|
|
41
|
+
value = first((0, config_node_1.lookupConfig)('com.liferay.lxc.dxp.mainDomain'));
|
|
17
42
|
}
|
|
18
43
|
return value;
|
|
19
44
|
},
|
|
20
|
-
dxpProtocol: () => (0, config_node_1.lookupConfig)('com.liferay.lxc.dxp.server.protocol'),
|
|
45
|
+
dxpProtocol: () => first((0, config_node_1.lookupConfig)('com.liferay.lxc.dxp.server.protocol')),
|
|
21
46
|
oauthApplication: (erc) => {
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
return
|
|
47
|
+
const ercs = toList((0, config_node_1.lookupConfig)('liferay.oauth.application.external.reference.codes'));
|
|
48
|
+
if (!ercs.includes(erc)) {
|
|
49
|
+
return undefined;
|
|
25
50
|
}
|
|
26
|
-
let
|
|
27
|
-
if (
|
|
28
|
-
|
|
51
|
+
let applicationType = OAuthApplicationProfile.USER_AGENT;
|
|
52
|
+
if ((0, config_node_1.lookupConfig)(`${erc}.oauth2.headless.server.client.id`)) {
|
|
53
|
+
applicationType = OAuthApplicationProfile.HEADLESS_SERVER;
|
|
29
54
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
scopes: () => (applicationType === OAuthApplicationProfile.HEADLESS_SERVER ?
|
|
48
|
-
(0, config_node_1.lookupConfig)(`${erc}.oauth2.headless.server.scopes`) :
|
|
49
|
-
(0, config_node_1.lookupConfig)(`${erc}.oauth2.user.agent.scopes`)),
|
|
50
|
-
tokenUri: () => (0, config_node_1.lookupConfig)(`${erc}.oauth2.token.uri`),
|
|
51
|
-
};
|
|
52
|
-
oauthApplications.set(erc, oauthApplication);
|
|
53
|
-
}
|
|
54
|
-
return oauthApplication;
|
|
55
|
+
const family = applicationType === OAuthApplicationProfile.HEADLESS_SERVER ? 'headless.server' : 'user.agent';
|
|
56
|
+
// deliberately not memoized: the values live in the provider caches that clearCache() owns, and a module
|
|
57
|
+
// level map would keep serving the old application type after a flush
|
|
58
|
+
return {
|
|
59
|
+
applicationType,
|
|
60
|
+
audience: () => first((0, config_node_1.lookupConfig)(`${erc}.oauth2.${family}.audience`)),
|
|
61
|
+
authorizationUri: () => first((0, config_node_1.lookupConfig)(`${erc}.oauth2.authorization.uri`)),
|
|
62
|
+
clientId: () => first((0, config_node_1.lookupConfig)(`${erc}.oauth2.${family}.client.id`)),
|
|
63
|
+
clientSecret: () => first((0, config_node_1.lookupConfig)(`${erc}.oauth2.${family}.client.secret`)),
|
|
64
|
+
introspectionUri: () => first((0, config_node_1.lookupConfig)(`${erc}.oauth2.introspection.uri`)),
|
|
65
|
+
jwksUri: () => first((0, config_node_1.lookupConfig)(`${erc}.oauth2.jwks.uri`)),
|
|
66
|
+
scopes: () => {
|
|
67
|
+
const scopes = toList((0, config_node_1.lookupConfig)(`${erc}.oauth2.${family}.scopes`));
|
|
68
|
+
return scopes.length > 0 ? scopes : undefined;
|
|
69
|
+
},
|
|
70
|
+
tokenUri: () => first((0, config_node_1.lookupConfig)(`${erc}.oauth2.token.uri`)),
|
|
71
|
+
};
|
|
55
72
|
},
|
|
56
73
|
};
|
|
57
74
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config-lxc/index.ts"],"names":[],"mappings":";;;AAAA,gDAA4C;AAE5C,IAAY,uBAGX;AAHD,WAAY,uBAAuB;IACjC,2FAAe,CAAA;IACf,iFAAU,CAAA;AACZ,CAAC,EAHW,uBAAuB,uCAAvB,uBAAuB,QAGlC;AAqBD,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config-lxc/index.ts"],"names":[],"mappings":";;;AAAA,gDAA4C;AAE5C,IAAY,uBAGX;AAHD,WAAY,uBAAuB;IACjC,2FAAe,CAAA;IACf,iFAAU,CAAA;AACZ,CAAC,EAHW,uBAAuB,uCAAvB,uBAAuB,QAGlC;AAqBD;;;;;GAKG;AACH,SAAS,MAAM,CAAC,KAAoC;IAClD,IAAI,MAAgB,CAAC;IAErB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,GAAG,KAAK,CAAC;IACjB,C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0BAAY,EAAC,GAAG,GAAG,mBAAmB,CAAC,CAAC;SAC/D,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -29,6 +29,11 @@ const configProviderHolders = [];
|
|
|
29
29
|
const commonCache = new Map();
|
|
30
30
|
const stack = [];
|
|
31
31
|
const regex = /\$\{[^\$]+?\}/;
|
|
32
|
+
/**
|
|
33
|
+
* A value that keeps reproducing its own placeholder (or a pair of values that reference each other) would
|
|
34
|
+
* otherwise spin forever; stop after this many substitutions and leave the remainder literal.
|
|
35
|
+
*/
|
|
36
|
+
const MAX_INTERPOLATION_STEPS = 100;
|
|
32
37
|
/**
|
|
33
38
|
* Register one or more configuration providers.
|
|
34
39
|
*
|
|
@@ -54,7 +59,16 @@ exports.clearCache = clearCache;
|
|
|
54
59
|
* @param value - the configuration value to store
|
|
55
60
|
*/
|
|
56
61
|
function defaultConfig(key, value) {
|
|
62
|
+
// a boolean or a number is a legitimate configuration value; providers answer with a falsy value when they
|
|
63
|
+
// have nothing, so hand the core a string the way a JSON file would
|
|
64
|
+
if (typeof value === 'boolean' || typeof value === 'number') {
|
|
65
|
+
value = String(value);
|
|
66
|
+
}
|
|
57
67
|
commonCache.set(key, value);
|
|
68
|
+
// a lookup made before this call (including the one this library performs when it is imported) may have
|
|
69
|
+
// cached the absence of a value for the key; drop that entry so the default is not shadowed by a stale miss
|
|
70
|
+
const programmaticHolder = configProviderHolders.find(holder => holder.provider === _0000_programmatic_1.programmatic);
|
|
71
|
+
programmaticHolder === null || programmaticHolder === void 0 ? void 0 : programmaticHolder.cache.delete(key);
|
|
58
72
|
}
|
|
59
73
|
exports.defaultConfig = defaultConfig;
|
|
60
74
|
/**
|
|
@@ -73,27 +87,7 @@ function lookupConfig(key) {
|
|
|
73
87
|
try {
|
|
74
88
|
let valueFromCache = false;
|
|
75
89
|
if (!holder.cache.has(key)) {
|
|
76
|
-
value = holder.provider.get(key, holder.cache, commonCache);
|
|
77
|
-
if (value) {
|
|
78
|
-
if (Array.isArray(value)) {
|
|
79
|
-
if (value.length > 0 && typeof value[0] === 'string') {
|
|
80
|
-
value = value;
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
value = [];
|
|
84
|
-
}
|
|
85
|
-
value = value.map(v => _interpolatePlaceholders(v));
|
|
86
|
-
}
|
|
87
|
-
else if (typeof value !== 'string') {
|
|
88
|
-
value = JSON.stringify(value);
|
|
89
|
-
value = _interpolatePlaceholders(value);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
value = _interpolatePlaceholders(value);
|
|
93
|
-
}
|
|
94
|
-
holder.cache.set(key, value);
|
|
95
|
-
}
|
|
96
|
-
// map undefined value so we don't process it over and over again
|
|
90
|
+
value = _normalizeValue(holder.provider.get(key, holder.cache, commonCache));
|
|
97
91
|
holder.cache.set(key, value);
|
|
98
92
|
}
|
|
99
93
|
else {
|
|
@@ -101,7 +95,7 @@ function lookupConfig(key) {
|
|
|
101
95
|
valueFromCache = true;
|
|
102
96
|
}
|
|
103
97
|
if (value) {
|
|
104
|
-
util_1.verbose && console.debug('[config-node]', `Provider [${holder.provider.key}] returned${valueFromCache ? ' (from cache)' : ''}: `, key, '=', value);
|
|
98
|
+
util_1.verbose && console.debug('[config-node]', `Provider [${holder.provider.key}] returned${valueFromCache ? ' (from cache)' : ''}: `, key, '=', (0, util_1.redactValue)(key, value));
|
|
105
99
|
return value;
|
|
106
100
|
}
|
|
107
101
|
}
|
|
@@ -112,6 +106,40 @@ function lookupConfig(key) {
|
|
|
112
106
|
util_1.verbose && console.debug('[config-node]', `No Providers returned a value for:`, key);
|
|
113
107
|
}
|
|
114
108
|
exports.lookupConfig = lookupConfig;
|
|
109
|
+
/**
|
|
110
|
+
* Normalize whatever a provider returned into the `string | string[]` shape this API promises, interpolating
|
|
111
|
+
* any `${key}` placeholders on the way through.
|
|
112
|
+
*/
|
|
113
|
+
function _normalizeValue(value) {
|
|
114
|
+
// a provider answers with a falsy value (undefined, or the `key === 'x' && 'value'` idiom) when it has
|
|
115
|
+
// nothing to contribute
|
|
116
|
+
if (!value) {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
if (Array.isArray(value)) {
|
|
120
|
+
// an empty list is not an answer, let the lower precedence providers have a turn
|
|
121
|
+
if (value.length === 0) {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
if (typeof value[0] === 'string') {
|
|
125
|
+
return value.map(v => _interpolatePlaceholders(v));
|
|
126
|
+
}
|
|
127
|
+
// a list of objects or numbers is data the caller asked for; returning [] here would lose it
|
|
128
|
+
return _interpolatePlaceholders(_stringify(value));
|
|
129
|
+
}
|
|
130
|
+
if (typeof value === 'string') {
|
|
131
|
+
return _interpolatePlaceholders(value);
|
|
132
|
+
}
|
|
133
|
+
return _interpolatePlaceholders(_stringify(value));
|
|
134
|
+
}
|
|
135
|
+
function _stringify(value) {
|
|
136
|
+
try {
|
|
137
|
+
return JSON.stringify(value);
|
|
138
|
+
}
|
|
139
|
+
catch (e) {
|
|
140
|
+
util_1.verbose && console.error('[config-node]', 'Could not serialize the value:', e.message);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
115
143
|
function _compareProviders(a, b) {
|
|
116
144
|
if (a.priority < b.priority) {
|
|
117
145
|
return 1;
|
|
@@ -122,18 +150,30 @@ function _compareProviders(a, b) {
|
|
|
122
150
|
return 0;
|
|
123
151
|
}
|
|
124
152
|
function _interpolatePlaceholders(v) {
|
|
153
|
+
if (typeof v !== 'string') {
|
|
154
|
+
return v;
|
|
155
|
+
}
|
|
125
156
|
let match = regex.exec(v);
|
|
157
|
+
let steps = 0;
|
|
126
158
|
while (match) {
|
|
127
|
-
|
|
159
|
+
if (++steps > MAX_INTERPOLATION_STEPS) {
|
|
160
|
+
util_1.verbose && console.warn('[config-node]', 'Stopped interpolating after', MAX_INTERPOLATION_STEPS, 'steps:', v);
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
128
163
|
const key = match[0].slice(2, -1);
|
|
129
164
|
const lookedUpValue = lookupConfig(key);
|
|
130
|
-
if (lookedUpValue) {
|
|
131
|
-
|
|
132
|
-
match = regex.exec(v);
|
|
165
|
+
if (!lookedUpValue) {
|
|
166
|
+
break;
|
|
133
167
|
}
|
|
134
|
-
|
|
135
|
-
|
|
168
|
+
// a function replacement keeps `$&`, `$'` and `` $` `` in the resolved value literal instead of letting
|
|
169
|
+
// String.replace interpret them as replacement patterns
|
|
170
|
+
const next = v.replace(match[0], () => lookedUpValue);
|
|
171
|
+
// the value reproduced the placeholder exactly: making progress is impossible, leave it as written
|
|
172
|
+
if (next === v) {
|
|
173
|
+
break;
|
|
136
174
|
}
|
|
175
|
+
v = next;
|
|
176
|
+
match = regex.exec(v);
|
|
137
177
|
}
|
|
138
178
|
return v;
|
|
139
179
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config-node/index.ts"],"names":[],"mappings":";;;AACA,wFAA0E;AAC1E,sDAA0C;AAC1C,sFAAyE;AACzE,sFAAyE;AACzE,oFAAuE;AACvE,sEAA0D;AAC1D,kGAAqF;AACrF,oFAAwE;AACxE,kFAAsE;AACtE,oEAAyD;AACzD,sFAA0E;AAC1E,sEAA2D;AAC3D,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config-node/index.ts"],"names":[],"mappings":";;;AACA,wFAA0E;AAC1E,sDAA0C;AAC1C,sFAAyE;AACzE,sFAAyE;AACzE,oFAAuE;AACvE,sEAA0D;AAC1D,kGAAqF;AACrF,oFAAwE;AACxE,kFAAsE;AACtE,oEAAyD;AACzD,sFAA0E;AAC1E,sEAA2D;AAC3D,iCAAyE;AA8NxC,gGA9NzB,sBAAe,OA8NyB;AAA+C,2FA9NzD,iBAAU,OA8NyD;AA5NzG,MAAM,oBAAoB;IAKxB,YAAY,QAAwB;QAClC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ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AI,IAAI,KAAK,CAAC,EAAE,CAAC;YACf,MAAM;QACR,CAAC;QAED,CAAC,GAAG,IAAI,CAAC;QACT,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC;IAED,OAAO,CAAC,CAAC;AACX,CAAC;AAED,WAAW,CACT,gDAAkB,EAClB,gBAAG,EACH,+CAAkB,EAClB,+CAAkB,EAClB,6CAAiB,EACjB,gCAAW,EACX,2DAAwB,EACxB,8CAAkB,EAClB,4CAAiB,EACjB,+BAAW,EACX,gDAAmB,EACnB,iCAAY,CACb,CAAC;AAEF,IAAA,iBAAU,EAAC,YAAY,CAAC,4BAA4B,CAAC,KAAK,MAAM,CAAC,CAAC"}
|
|
@@ -10,22 +10,24 @@ const util_1 = require("../util");
|
|
|
10
10
|
exports.applicationPackaged = {
|
|
11
11
|
key: 'application.json',
|
|
12
12
|
description: 'From application property json files packaged with the app',
|
|
13
|
-
priority:
|
|
13
|
+
priority: 500,
|
|
14
14
|
get: (key, providerCache, commonCache) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
var _a, _b;
|
|
16
|
+
let mainPath;
|
|
17
|
+
if (commonCache.has('require.main.path')) {
|
|
18
|
+
mainPath = commonCache.get('require.main.path');
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
mainPath = (_a = (0, util_1.getProjectRoot)()) !== null && _a !== void 0 ? _a : (_b = require.main) === null || _b === void 0 ? void 0 : _b.path;
|
|
22
|
+
// remember the miss as well: walking up to the filesystem root on every cold key is expensive
|
|
23
|
+
commonCache.set('require.main.path', mainPath);
|
|
24
|
+
}
|
|
23
25
|
if (mainPath) {
|
|
24
26
|
const configPath = node_path_1.default.join(mainPath, 'application.json');
|
|
25
27
|
if (node_fs_1.default.existsSync(configPath)) {
|
|
26
28
|
const json = (0, util_1.computeIfAbsent)(providerCache, configPath, () => (0, util_1.readJSONFile)(configPath));
|
|
27
29
|
if (json) {
|
|
28
|
-
return (0, util_1.unquote)(json
|
|
30
|
+
return (0, util_1.unquote)((0, util_1.readKey)(json, key));
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1000-application-packaged.js","sourceRoot":"","sources":["../../../src/config-node/providers/1000-application-packaged.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAE7B,
|
|
1
|
+
{"version":3,"file":"1000-application-packaged.js","sourceRoot":"","sources":["../../../src/config-node/providers/1000-application-packaged.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAE7B,kCAAwF;AAE3E,QAAA,mBAAmB,GAAmB;IACjD,GAAG,EAAE,kBAAkB;IACvB,WAAW,EAAE,4DAA4D;IACzE,QAAQ,EAAE,GAAG;IACb,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE;;QACvC,IAAI,QAAQ,CAAC;QAEb,IAAI,WAAW,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE,CAAC;YACzC,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QAClD,CAAC;aACI,CAAC;YACJ,QAAQ,GAAG,MAAA,IAAA,qBAAc,GAAE,mCAAI,MAAA,OAAO,CAAC,IAAI,0CAAE,IAAI,CAAC;YAClD,8FAA8F;YAC9F,WAAW,CAAC,GAAG,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC;QACjD,CAAC;QACD,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;YAC3D,IAAI,iBAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC9B,MAAM,IAAI,GAAG,IAAA,sBAAe,EAAC,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,IAAA,mBAAY,EAAC,UAAU,CAAC,CAAC,CAAC;gBACxF,IAAI,IAAI,EAAE,CAAC;oBACT,OAAO,IAAA,cAAO,EAAC,IAAA,cAAO,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;gBACrC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -5,7 +5,7 @@ const util_1 = require("../util");
|
|
|
5
5
|
exports.cli = {
|
|
6
6
|
key: 'command-line-arguments',
|
|
7
7
|
description: 'From command line arguments (--key=value)',
|
|
8
|
-
priority:
|
|
8
|
+
priority: 10000,
|
|
9
9
|
get: (key, providerCache) => (0, util_1.computeIfAbsent)(providerCache, `process.args.${key}`, () => {
|
|
10
10
|
const prefix = `--${key}=`;
|
|
11
11
|
for (var arg of process.argv) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"10000-cli.js","sourceRoot":"","sources":["../../../src/config-node/providers/10000-cli.ts"],"names":[],"mappings":";;;AACA,kCAAiD;AAEpC,QAAA,GAAG,GAAmB;IACjC,GAAG,EAAE,wBAAwB;IAC7B,WAAW,EAAE,2CAA2C;IACxD,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"10000-cli.js","sourceRoot":"","sources":["../../../src/config-node/providers/10000-cli.ts"],"names":[],"mappings":";;;AACA,kCAAiD;AAEpC,QAAA,GAAG,GAAmB;IACjC,GAAG,EAAE,wBAAwB;IAC7B,WAAW,EAAE,2CAA2C;IACxD,QAAQ,EAAE,KAAK;IACf,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE,CAAC,IAAA,sBAAe,EAAC,aAAa,EAAE,gBAAgB,GAAG,EAAE,EAAE,GAAG,EAAE;QACtF,MAAM,MAAM,GAAG,KAAK,GAAG,GAAG,CAAA;QAC1B,KAAK,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YAC7B,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC3B,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAC3C,OAAO,IAAA,cAAO,EAAC,KAAK,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;CACH,CAAC"}
|
|
@@ -18,7 +18,7 @@ exports.configNodeDevtools = {
|
|
|
18
18
|
if (fs_1.default.existsSync(filePath)) {
|
|
19
19
|
const json = (0, util_1.computeIfAbsent)(providerCache, filePath, () => (0, util_1.readJSONFile)(filePath));
|
|
20
20
|
if (json) {
|
|
21
|
-
return (0, util_1.unquote)(json
|
|
21
|
+
return (0, util_1.unquote)((0, util_1.readKey)(json, key));
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"11000-config-node-devtools.js","sourceRoot":"","sources":["../../../src/config-node/providers/11000-config-node-devtools.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,4CAAoB;AACpB,0DAA6B;AAE7B,
|
|
1
|
+
{"version":3,"file":"11000-config-node-devtools.js","sourceRoot":"","sources":["../../../src/config-node/providers/11000-config-node-devtools.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,4CAAoB;AACpB,0DAA6B;AAE7B,kCAAwE;AAE3D,QAAA,kBAAkB,GAAmB;IAChD,GAAG,EAAE,8BAA8B;IACnC,WAAW,EAAE,mCAAmC;IAChD,QAAQ,EAAE,KAAK;IACf,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE,CAAC,IAAA,sBAAe,EAAC,aAAa,EAAE,GAAG,EAAE,GAAG,EAAE;QACjF,MAAM,OAAO,GAAG,IAAA,sBAAe,EAAC,WAAW,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,YAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5E,MAAM,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,OAAO,EAAE,4BAA4B,CAAC,CAAC;QAClE,IAAI,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,GAAG,IAAA,sBAAe,EAAC,aAAa,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAA,mBAAY,EAAC,QAAQ,CAAC,CAAC,CAAC;YACpF,IAAI,IAAI,EAAE,CAAC;gBACT,OAAO,IAAA,cAAO,EAAC,IAAA,cAAO,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;IACH,CAAC,CAAC;CACH,CAAC"}
|
|
@@ -17,7 +17,7 @@ exports.application = {
|
|
|
17
17
|
if (node_fs_1.default.existsSync(configPath)) {
|
|
18
18
|
const json = (0, util_1.computeIfAbsent)(providerCache, configPath, () => (0, util_1.readJSONFile)(configPath));
|
|
19
19
|
if (json) {
|
|
20
|
-
return (0, util_1.unquote)(json
|
|
20
|
+
return (0, util_1.unquote)((0, util_1.readKey)(json, key));
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"2000-application.js","sourceRoot":"","sources":["../../../src/config-node/providers/2000-application.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAE7B,
|
|
1
|
+
{"version":3,"file":"2000-application.js","sourceRoot":"","sources":["../../../src/config-node/providers/2000-application.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAE7B,kCAAwE;AAE3D,QAAA,WAAW,GAAmB;IACzC,GAAG,EAAE,yBAAyB;IAC9B,WAAW,EAAE,gDAAgD;IAC7D,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE;QACvC,MAAM,GAAG,GAAG,IAAA,sBAAe,EAAC,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACrE,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;QACtD,IAAI,iBAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,GAAG,IAAA,sBAAe,EAAC,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,IAAA,mBAAY,EAAC,UAAU,CAAC,CAAC,CAAC;YACxF,IAAI,IAAI,EAAE,CAAC;gBACT,OAAO,IAAA,cAAO,EAAC,IAAA,cAAO,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -17,7 +17,7 @@ exports.applicationConfig = {
|
|
|
17
17
|
if (node_fs_1.default.existsSync(configPath)) {
|
|
18
18
|
const json = (0, util_1.computeIfAbsent)(providerCache, configPath, () => (0, util_1.readJSONFile)(configPath));
|
|
19
19
|
if (json) {
|
|
20
|
-
return (0, util_1.unquote)(json
|
|
20
|
+
return (0, util_1.unquote)((0, util_1.readKey)(json, key));
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"3000-application-config.js","sourceRoot":"","sources":["../../../src/config-node/providers/3000-application-config.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAE7B,
|
|
1
|
+
{"version":3,"file":"3000-application-config.js","sourceRoot":"","sources":["../../../src/config-node/providers/3000-application-config.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAE7B,kCAAwE;AAE3D,QAAA,iBAAiB,GAAmB;IAC/C,GAAG,EAAE,gCAAgC;IACrC,WAAW,EAAE,uDAAuD;IACpE,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE;QACvC,MAAM,GAAG,GAAG,IAAA,sBAAe,EAAC,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACrE,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CAAC;QAChE,IAAI,iBAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,GAAG,IAAA,sBAAe,EAAC,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,IAAA,mBAAY,EAAC,UAAU,CAAC,CAAC,CAAC;YACxF,IAAI,IAAI,EAAE,CAAC;gBACT,OAAO,IAAA,cAAO,EAAC,IAAA,cAAO,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -20,11 +20,15 @@ exports.applicationProfile = {
|
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
profile = Array.isArray(profile) ? profile[profile.length - 1] : profile;
|
|
23
|
+
// the profile name is pasted into a file name, so it must not be able to walk out of the directory
|
|
24
|
+
if (!(0, util_1.isSafePathSegment)(profile)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
23
27
|
const cwd = (0, util_1.computeIfAbsent)(commonCache, 'cwd', () => process.cwd());
|
|
24
28
|
const configPath = node_path_1.default.join(cwd, `application-${profile}.json`);
|
|
25
29
|
const json = (0, util_1.computeIfAbsent)(providerCache, configPath, () => (0, util_1.readJSONFile)(configPath));
|
|
26
30
|
if (json) {
|
|
27
|
-
return (0, util_1.unquote)(json
|
|
31
|
+
return (0, util_1.unquote)((0, util_1.readKey)(json, key));
|
|
28
32
|
}
|
|
29
33
|
},
|
|
30
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"4000-application-profile.js","sourceRoot":"","sources":["../../../src/config-node/providers/4000-application-profile.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,mDAA+C;AAE/C,
|
|
1
|
+
{"version":3,"file":"4000-application-profile.js","sourceRoot":"","sources":["../../../src/config-node/providers/4000-application-profile.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,mDAA+C;AAE/C,kCAA0G;AAE7F,QAAA,kBAAkB,GAAmB;IAChD,GAAG,EAAE,mCAAmC;IACxC,WAAW,EAAE,wDAAwD;IACrE,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE;QACvC,IAAI,oBAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAChC,OAAO;QACT,CAAC;QACD,IAAI,OAAO,GAAG,IAAA,0BAAY,EAAC,6BAA6B,CAAC,CAAC;QAC1D,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO;QACT,CAAC;QACD,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACzE,mGAAmG;QACnG,IAAI,CAAC,IAAA,wBAAiB,EAAC,OAAiB,CAAC,EAAE,CAAC;YAC1C,OAAO;QACT,CAAC;QACD,MAAM,GAAG,GAAG,IAAA,sBAAe,EAAC,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACrE,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,OAAO,OAAO,CAAC,CAAC;QACjE,MAAM,IAAI,GAAG,IAAA,sBAAe,EAAC,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,IAAA,mBAAY,EAAC,UAAU,CAAC,CAAC,CAAC;QACxF,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,IAAA,cAAO,EAAC,IAAA,cAAO,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -20,11 +20,15 @@ exports.applicationProfileConfig = {
|
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
profile = Array.isArray(profile) ? profile[profile.length - 1] : profile;
|
|
23
|
+
// the profile name is pasted into a file name, so it must not be able to walk out of the directory
|
|
24
|
+
if (!(0, util_1.isSafePathSegment)(profile)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
23
27
|
const cwd = (0, util_1.computeIfAbsent)(commonCache, 'cwd', () => process.cwd());
|
|
24
28
|
const configPath = node_path_1.default.join(cwd, 'config', `application-${profile}.json`);
|
|
25
29
|
const json = (0, util_1.computeIfAbsent)(providerCache, configPath, () => (0, util_1.readJSONFile)(configPath));
|
|
26
30
|
if (json) {
|
|
27
|
-
return (0, util_1.unquote)(json
|
|
31
|
+
return (0, util_1.unquote)((0, util_1.readKey)(json, key));
|
|
28
32
|
}
|
|
29
33
|
},
|
|
30
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"5000-application-profile-config.js","sourceRoot":"","sources":["../../../src/config-node/providers/5000-application-profile-config.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,mDAA+C;AAE/C,
|
|
1
|
+
{"version":3,"file":"5000-application-profile-config.js","sourceRoot":"","sources":["../../../src/config-node/providers/5000-application-profile-config.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,mDAA+C;AAE/C,kCAA0G;AAE7F,QAAA,wBAAwB,GAAmB;IACtD,GAAG,EAAE,0CAA0C;IAC/C,WAAW,EAAE,+DAA+D;IAC5E,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE;QACvC,IAAI,oBAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAChC,OAAO;QACT,CAAC;QACD,IAAI,OAAO,GAAG,IAAA,0BAAY,EAAC,6BAA6B,CAAC,CAAC;QAC1D,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO;QACT,CAAC;QACD,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACzE,mGAAmG;QACnG,IAAI,CAAC,IAAA,wBAAiB,EAAC,OAAiB,CAAC,EAAE,CAAC;YAC1C,OAAO;QACT,CAAC;QACD,MAAM,GAAG,GAAG,IAAA,sBAAe,EAAC,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACrE,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,eAAe,OAAO,OAAO,CAAC,CAAC;QAC3E,MAAM,IAAI,GAAG,IAAA,sBAAe,EAAC,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,IAAA,mBAAY,EAAC,UAAU,CAAC,CAAC,CAAC;QACxF,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,IAAA,cAAO,EAAC,IAAA,cAAO,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.configTrees = void 0;
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
8
|
const config_node_1 = require("../../config-node");
|
|
10
9
|
const util_1 = require("../util");
|
|
11
10
|
exports.configTrees = {
|
|
@@ -23,9 +22,11 @@ exports.configTrees = {
|
|
|
23
22
|
configtrees = Array.isArray(configtrees) ? configtrees : [configtrees];
|
|
24
23
|
return (0, util_1.computeIfAbsent)(providerCache, `configtree:${key}`, () => {
|
|
25
24
|
for (var configtree of configtrees) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
// the key becomes a file name below the tree, so it is resolved and containment is checked on the
|
|
26
|
+
// real (symlink free) path: neither a `..` key nor a link can read outside the configured tree
|
|
27
|
+
const configtreeEntry = (0, util_1.resolveContainedFile)(configtree, key);
|
|
28
|
+
if (configtreeEntry) {
|
|
29
|
+
return (0, util_1.unquote)((0, util_1.trimFileValue)(node_fs_1.default.readFileSync(configtreeEntry, 'utf8')));
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"6000-config-trees.js","sourceRoot":"","sources":["../../../src/config-node/providers/6000-config-trees.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,
|
|
1
|
+
{"version":3,"file":"6000-config-trees.js","sourceRoot":"","sources":["../../../src/config-node/providers/6000-config-trees.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,mDAA+C;AAE/C,kCAAqG;AAExF,QAAA,WAAW,GAAmB;IACzC,GAAG,EAAE,cAAc;IACnB,WAAW,EAAE,yEAAyE;IACtF,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE;QAC1B,IAAI,oBAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAChC,OAAO;QACT,CAAC;QACD,IAAI,WAAW,GAAG,IAAA,0BAAY,EAAC,0BAA0B,CAAC,CAAC;QAC3D,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO;QACT,CAAC;QACD,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;QACvE,OAAO,IAAA,sBAAe,EAAC,aAAa,EAAE,cAAc,GAAG,EAAE,EAAE,GAAG,EAAE;YAC9D,KAAK,IAAI,UAAU,IAAI,WAAuB,EAAE,CAAC;gBAC/C,kGAAkG;gBAClG,+FAA+F;gBAC/F,MAAM,eAAe,GAAG,IAAA,2BAAoB,EAAC,UAAU,EAAE,GAAG,CAAC,CAAC;gBAE9D,IAAI,eAAe,EAAE,CAAC;oBACpB,OAAO,IAAA,cAAO,EAAC,IAAA,oBAAa,EAAC,iBAAE,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;gBAC1E,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -11,7 +11,7 @@ exports.envApplicationJson = {
|
|
|
11
11
|
if (value && value.length > 1) {
|
|
12
12
|
const json = (0, util_1.computeIfAbsent)(providerCache, `process.env.APPLICATION_JSON`, () => JSON.parse(value));
|
|
13
13
|
if (json) {
|
|
14
|
-
return (0, util_1.unquote)(json
|
|
14
|
+
return (0, util_1.unquote)((0, util_1.readKey)(json, key));
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"8000-env-application-json.js","sourceRoot":"","sources":["../../../src/config-node/providers/8000-env-application-json.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"8000-env-application-json.js","sourceRoot":"","sources":["../../../src/config-node/providers/8000-env-application-json.ts"],"names":[],"mappings":";;;AACA,kCAA0D;AAE7C,QAAA,kBAAkB,GAAmB;IAChD,GAAG,EAAE,8BAA8B;IACnC,WAAW,EAAE,oFAAoF;IACjG,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE,CAAC,IAAA,sBAAe,EAAC,aAAa,EAAE,GAAG,EAAE,GAAG,EAAE;QACpE,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;QAC3C,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,GAAG,IAAA,sBAAe,EAAC,aAAa,EAAE,8BAA8B,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;YACrG,IAAI,IAAI,EAAE,CAAC;gBACT,OAAO,IAAA,cAAO,EAAC,IAAA,cAAO,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;IACH,CAAC,CAAC;CACH,CAAC"}
|
|
@@ -11,7 +11,7 @@ exports.cliApplicationJson = {
|
|
|
11
11
|
for (var arg of process.argv) {
|
|
12
12
|
if (arg.startsWith(prefix)) {
|
|
13
13
|
const value = JSON.parse(arg.substring(prefix.length));
|
|
14
|
-
return (0, util_1.unquote)(value
|
|
14
|
+
return (0, util_1.unquote)((0, util_1.readKey)(value, key));
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"9000-cli-application-json.js","sourceRoot":"","sources":["../../../src/config-node/providers/9000-cli-application-json.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"9000-cli-application-json.js","sourceRoot":"","sources":["../../../src/config-node/providers/9000-cli-application-json.ts"],"names":[],"mappings":";;;AACA,kCAA0D;AAE7C,QAAA,kBAAkB,GAAmB;IAChD,GAAG,EAAE,+BAA+B;IACpC,WAAW,EAAE,wDAAwD;IACrE,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE,CAAC,IAAA,sBAAe,EAAC,aAAa,EAAE,gBAAgB,GAAG,EAAE,EAAE,GAAG,EAAE;QACtF,MAAM,MAAM,GAAG,qBAAqB,CAAA;QACpC,KAAK,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YAC7B,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;gBACvD,OAAO,IAAA,cAAO,EAAC,IAAA,cAAO,EAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;CACH,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
declare let verbose: boolean;
|
|
2
2
|
declare const protectedKeys: string[];
|
|
3
|
+
declare function findProjectRoot(currentPath?: string): string;
|
|
3
4
|
/**
|
|
4
5
|
* A utility function to get the root folder of the parent project, use this function to get the application.json file
|
|
5
6
|
* when it's packaged in the client extension files.
|
|
@@ -14,7 +15,33 @@ declare function getProjectRoot(): string;
|
|
|
14
15
|
* @returns the cached value (having been computed and added to the cache if absent when requested)
|
|
15
16
|
*/
|
|
16
17
|
declare function computeIfAbsent(cache: Map<string, any>, key: string, fn: () => any): any;
|
|
17
|
-
|
|
18
|
+
/**
|
|
19
|
+
* A lookup key is turned into a file system path by the config-tree and profile providers, so it has to be
|
|
20
|
+
* treated as a path segment rather than as free text: anything that could escape the directory it is joined
|
|
21
|
+
* to (`..`, separators, a leading dot) is rejected.
|
|
22
|
+
*/
|
|
23
|
+
declare function isSafePathSegment(value: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Resolve `name` against `root`, refusing anything that is unsafe as a path segment or that resolves (after
|
|
26
|
+
* following symlinks) to a location outside of `root`. Volume mounted ConfigMaps/Secrets are built out of
|
|
27
|
+
* symlinks into a `..data` directory inside the tree, so containment is checked on the resolved path rather
|
|
28
|
+
* than by refusing links outright.
|
|
29
|
+
*/
|
|
30
|
+
declare function resolveContainedFile(root: string, name: string): string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Strip the trailing newline that volume mounted ConfigMap/Secret files always carry.
|
|
33
|
+
*/
|
|
34
|
+
declare function trimFileValue(value: any): any;
|
|
35
|
+
/**
|
|
36
|
+
* The value of a sensitive key must never reach a log line, not even in verbose mode.
|
|
37
|
+
*/
|
|
38
|
+
declare function redactValue(key: string, value: any): any;
|
|
39
|
+
/**
|
|
40
|
+
* Read a key from a parsed JSON object without falling through to the prototype chain, so that keys like
|
|
41
|
+
* `__proto__` or `constructor` resolve to nothing instead of returning an object that no file ever declared.
|
|
42
|
+
*/
|
|
43
|
+
declare function readKey(json: Record<string, any>, key: string): any;
|
|
44
|
+
declare function readJSONFile(filePath: string): Record<string, any> | undefined;
|
|
18
45
|
/**
|
|
19
46
|
* A utility function to enable verbose output from this library, convenient for debugging.
|
|
20
47
|
*
|
|
@@ -22,4 +49,4 @@ declare function readJSONFile(path: string): string;
|
|
|
22
49
|
*/
|
|
23
50
|
declare function setVerbose(b: boolean): void;
|
|
24
51
|
declare function unquote(it: any): any;
|
|
25
|
-
export { computeIfAbsent, getProjectRoot, protectedKeys, readJSONFile, setVerbose,
|
|
52
|
+
export { computeIfAbsent, findProjectRoot, getProjectRoot, isSafePathSegment, protectedKeys, readJSONFile, readKey, redactValue, resolveContainedFile, setVerbose, trimFileValue, unquote, verbose };
|
|
@@ -3,26 +3,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.unquote = exports.
|
|
6
|
+
exports.verbose = exports.unquote = exports.trimFileValue = exports.setVerbose = exports.resolveContainedFile = exports.redactValue = exports.readKey = exports.readJSONFile = exports.protectedKeys = exports.isSafePathSegment = exports.getProjectRoot = exports.findProjectRoot = exports.computeIfAbsent = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
let verbose = false;
|
|
10
10
|
exports.verbose = verbose;
|
|
11
11
|
const protectedKeys = [
|
|
12
12
|
'config.node.config.trees',
|
|
13
|
-
'config.node.profiles.active'
|
|
13
|
+
'config.node.profiles.active',
|
|
14
|
+
'config.node.config.verbose'
|
|
14
15
|
];
|
|
15
16
|
exports.protectedKeys = protectedKeys;
|
|
17
|
+
const sensitiveKeyPattern = /(secret|password|passwd|token|credential|api[-_.]?key|private[-_.]?key)/i;
|
|
16
18
|
function findProjectRoot(currentPath = process.cwd()) {
|
|
17
19
|
const hasPackageJson = fs_1.default.existsSync(path_1.default.join(currentPath, 'package.json'));
|
|
18
20
|
if (hasPackageJson) {
|
|
19
21
|
return currentPath;
|
|
20
22
|
}
|
|
21
|
-
|
|
23
|
+
// a path is its own parent only at the filesystem root, which keeps this terminating on Windows too
|
|
24
|
+
if (path_1.default.dirname(currentPath) === currentPath) {
|
|
22
25
|
return null;
|
|
23
26
|
}
|
|
24
27
|
return findProjectRoot(path_1.default.dirname(currentPath));
|
|
25
28
|
}
|
|
29
|
+
exports.findProjectRoot = findProjectRoot;
|
|
26
30
|
/**
|
|
27
31
|
* A utility function to get the root folder of the parent project, use this function to get the application.json file
|
|
28
32
|
* when it's packaged in the client extension files.
|
|
@@ -57,14 +61,82 @@ function computeIfAbsent(cache, key, fn) {
|
|
|
57
61
|
return value;
|
|
58
62
|
}
|
|
59
63
|
exports.computeIfAbsent = computeIfAbsent;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
/**
|
|
65
|
+
* A lookup key is turned into a file system path by the config-tree and profile providers, so it has to be
|
|
66
|
+
* treated as a path segment rather than as free text: anything that could escape the directory it is joined
|
|
67
|
+
* to (`..`, separators, a leading dot) is rejected.
|
|
68
|
+
*/
|
|
69
|
+
function isSafePathSegment(value) {
|
|
70
|
+
return typeof value === 'string' &&
|
|
71
|
+
value.length > 0 &&
|
|
72
|
+
!value.includes('/') &&
|
|
73
|
+
!value.includes('\\') &&
|
|
74
|
+
!value.includes('\0') &&
|
|
75
|
+
!value.includes('..') &&
|
|
76
|
+
!value.startsWith('.');
|
|
77
|
+
}
|
|
78
|
+
exports.isSafePathSegment = isSafePathSegment;
|
|
79
|
+
/**
|
|
80
|
+
* Resolve `name` against `root`, refusing anything that is unsafe as a path segment or that resolves (after
|
|
81
|
+
* following symlinks) to a location outside of `root`. Volume mounted ConfigMaps/Secrets are built out of
|
|
82
|
+
* symlinks into a `..data` directory inside the tree, so containment is checked on the resolved path rather
|
|
83
|
+
* than by refusing links outright.
|
|
84
|
+
*/
|
|
85
|
+
function resolveContainedFile(root, name) {
|
|
86
|
+
if (!root || !isSafePathSegment(name)) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
const candidate = path_1.default.join(root, name);
|
|
90
|
+
if (!fs_1.default.existsSync(candidate)) {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
const realRoot = fs_1.default.realpathSync(root);
|
|
95
|
+
const realCandidate = fs_1.default.realpathSync(candidate);
|
|
96
|
+
if (realCandidate !== realRoot && !realCandidate.startsWith(realRoot + path_1.default.sep)) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
return realCandidate;
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
// the candidate exists but could not be resolved (a mocked fs, or a race with a deleted entry): the key
|
|
103
|
+
// itself has already been validated as a single path segment, and the read that follows will fail on its
|
|
104
|
+
// own if the path is really gone
|
|
105
|
+
return candidate;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.resolveContainedFile = resolveContainedFile;
|
|
109
|
+
/**
|
|
110
|
+
* Strip the trailing newline that volume mounted ConfigMap/Secret files always carry.
|
|
111
|
+
*/
|
|
112
|
+
function trimFileValue(value) {
|
|
113
|
+
return typeof value === 'string' ? value.replace(/[\r\n]+$/, '') : value;
|
|
114
|
+
}
|
|
115
|
+
exports.trimFileValue = trimFileValue;
|
|
116
|
+
/**
|
|
117
|
+
* The value of a sensitive key must never reach a log line, not even in verbose mode.
|
|
118
|
+
*/
|
|
119
|
+
function redactValue(key, value) {
|
|
120
|
+
return sensitiveKeyPattern.test(key) ? '[redacted]' : value;
|
|
121
|
+
}
|
|
122
|
+
exports.redactValue = redactValue;
|
|
123
|
+
/**
|
|
124
|
+
* Read a key from a parsed JSON object without falling through to the prototype chain, so that keys like
|
|
125
|
+
* `__proto__` or `constructor` resolve to nothing instead of returning an object that no file ever declared.
|
|
126
|
+
*/
|
|
127
|
+
function readKey(json, key) {
|
|
128
|
+
return json && Object.prototype.hasOwnProperty.call(json, key) ? json[key] : undefined;
|
|
129
|
+
}
|
|
130
|
+
exports.readKey = readKey;
|
|
131
|
+
function readJSONFile(filePath) {
|
|
132
|
+
if (fs_1.default.existsSync(filePath)) {
|
|
133
|
+
const contents = fs_1.default.readFileSync(filePath, 'utf8');
|
|
63
134
|
try {
|
|
64
135
|
return JSON.parse(contents);
|
|
65
136
|
}
|
|
66
137
|
catch (error) {
|
|
67
|
-
|
|
138
|
+
// never log the contents: a truncated or hand-edited config file is exactly where secrets live
|
|
139
|
+
console.error('[config-node]', 'could not parse', filePath, ':', error.message);
|
|
68
140
|
}
|
|
69
141
|
}
|
|
70
142
|
return undefined;
|
|
@@ -80,6 +152,11 @@ function setVerbose(b) {
|
|
|
80
152
|
}
|
|
81
153
|
exports.setVerbose = setVerbose;
|
|
82
154
|
function unquote(it) {
|
|
155
|
+
if (typeof it === "boolean" || typeof it === "number") {
|
|
156
|
+
// a JSON file is allowed to express false/0; providers use a falsy return for "no value", so a legitimate
|
|
157
|
+
// scalar has to travel as a string
|
|
158
|
+
return String(it);
|
|
159
|
+
}
|
|
83
160
|
if (typeof it === "string") {
|
|
84
161
|
if (it.startsWith('"') && it.endsWith('"')) {
|
|
85
162
|
return it.slice(1, -1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config-node/util/index.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AAEpB,IAAI,OAAO,GAAY,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config-node/util/index.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AAEpB,IAAI,OAAO,GAAY,KAAK,CAAC;AAoL4C,0BAAO;AAlLhF,MAAM,aAAa,GAAG;IACpB,0BAA0B;IAC1B,6BAA6B;IAC7B,4BAA4B;CAC7B,CAAC;AA6KqE,sCAAa;AA3KpF,MAAM,mBAAmB,GAAG,0EAA0E,CAAC;AAEvG,SAAS,eAAe,CAAC,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE;IAClD,MAAM,cAAc,GAAG,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;IAE7E,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,oGAAoG;IACpG,IAAI,cAAI,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,WAAW,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,eAAe,CAAC,cAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;AACpD,CAAC;AA4JkB,0CAAe;AA3JlC;;;KAGK;AACL,SAAS,cAAc;IACrB,MAAM,uBAAuB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC9C,MAAM,WAAW,GAAG,eAAe,CAAC,uBAAuB,CAAC,CAAC;IAE7D,OAAO,WAAW,CAAC;AACrB,CAAC;AAkJmC,wCAAc;AAhJlD;;;;;;;GAOG;AACH,SAAS,eAAe,CAAC,KAAuB,EAAE,GAAW,EAAE,EAAa;IAC1E,IAAI,K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