k2hr3-api 1.0.38 → 1.0.40
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/ChangeLog +12 -0
- package/README.md +31 -31
- package/app.js +6 -10
- package/bin/run.sh +21 -21
- package/bin/www +1 -1
- package/config/k2hr3-init.sh.templ +5 -5
- package/eslint.config.mjs +68 -0
- package/lib/cacerts.js +8 -7
- package/lib/dummyuserapi.js +1 -1
- package/lib/ipwatch.js +1 -1
- package/lib/k2hr3acrutil.js +12 -14
- package/lib/k2hr3apiutil.js +5 -5
- package/lib/k2hr3cryptutil.js +2 -0
- package/lib/k2hr3dkc.js +25 -28
- package/lib/k2hr3template.js +54 -52
- package/lib/k2hr3tokens.js +4 -4
- package/lib/k8soidc.js +3 -3
- package/lib/openstackapiv2.js +51 -52
- package/lib/openstackapiv3.js +86 -87
- package/lib/openstackep.js +46 -46
- package/package.json +8 -8
- package/routes/acr.js +66 -110
- package/routes/debugVerify.js +12 -14
- package/routes/extdata.js +24 -40
- package/routes/list.js +24 -36
- package/routes/policy.js +72 -120
- package/routes/resource.js +110 -165
- package/routes/role.js +177 -295
- package/routes/service.js +54 -90
- package/routes/userTokens.js +1 -1
- package/routes/userdata.js +12 -20
- package/routes/version.js +39 -23
- package/tests/auto_control_subprocess.sh +9 -9
- package/tests/auto_init_config_json.sh +3 -3
- package/tests/auto_resource.js +417 -478
- package/tests/auto_role.js +55 -71
- package/tests/auto_template.sh +4 -4
- package/tests/auto_version.js +39 -23
- package/tests/k2hdkc_test_load.sh +9 -9
- package/tests/k2hr3template_test.sh +12 -12
- package/tests/k2hr3template_test_vars.js +60 -62
- package/tests/manual_acr_delete.js +11 -12
- package/tests/manual_acr_get.js +9 -10
- package/tests/manual_acr_postput.js +12 -13
- package/tests/manual_extdata_get.js +5 -6
- package/tests/manual_list_gethead.js +12 -13
- package/tests/manual_policy_delete.js +12 -13
- package/tests/manual_policy_gethead.js +27 -27
- package/tests/manual_policy_postput.js +21 -23
- package/tests/manual_resource_delete.js +11 -15
- package/tests/manual_resource_gethead.js +11 -14
- package/tests/manual_resource_postput.js +18 -21
- package/tests/manual_role_delete.js +22 -28
- package/tests/manual_role_gethead.js +53 -53
- package/tests/manual_role_postput.js +28 -31
- package/tests/manual_service_delete.js +11 -13
- package/tests/manual_service_gethead.js +13 -15
- package/tests/manual_service_postput.js +10 -11
- package/tests/manual_test.sh +10 -10
- package/tests/manual_userdata_get.js +14 -15
- package/tests/manual_usertoken_gethead.js +12 -14
- package/tests/manual_usertoken_postput.js +23 -26
- package/tests/manual_version_get.js +12 -13
- package/tests/run_local_test_k2hdkc.sh +4 -4
- package/tests/test.sh +12 -12
package/ChangeLog
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
k2hr3-api (1.0.40) unstable; urgency=low
|
|
2
|
+
|
|
3
|
+
* Fixed the options as the npm audit issue was fixed - #131
|
|
4
|
+
|
|
5
|
+
-- Takeshi Nakatani <ggtakec@gmail.com> Thu, 20 Feb 2025 09:28:41 +0900
|
|
6
|
+
|
|
7
|
+
k2hr3-api (1.0.39) unstable; urgency=low
|
|
8
|
+
|
|
9
|
+
* Changed publish NodeJS versions to v22 and Fixed scripts, etc - #129
|
|
10
|
+
|
|
11
|
+
-- Takeshi Nakatani <ggtakec@gmail.com> Mon, 17 Feb 2025 17:12:05 +0900
|
|
12
|
+
|
|
1
13
|
k2hr3-api (1.0.38) unstable; urgency=low
|
|
2
14
|
|
|
3
15
|
* Updated nodejs_helper for forked repositories - #127
|
package/README.md
CHANGED
|
@@ -37,43 +37,43 @@ K2HR3 REST API and K2HR3 API Server is the server side JavaScript program runnin
|
|
|
37
37
|

|
|
38
38
|
|
|
39
39
|
### Documents
|
|
40
|
-
[K2HR3 Document](https://k2hr3.antpick.ax/index.html)
|
|
41
|
-
[K2HR3 Web Application Usage](https://k2hr3.antpick.ax/usage_app.html)
|
|
42
|
-
[K2HR3 Command Line Interface Usage](https://k2hr3.antpick.ax/cli.html)
|
|
43
|
-
[K2HR3 REST API Usage](https://k2hr3.antpick.ax/api.html)
|
|
44
|
-
[K2HR3 OpenStack Notification Listener Usage](https://k2hr3.antpick.ax/detail_osnl.html)
|
|
45
|
-
[K2HR3 Watcher Usage](https://k2hr3.antpick.ax/tools.html)
|
|
46
|
-
[K2HR3 Get Resource Usage](https://k2hr3.antpick.ax/tools.html)
|
|
47
|
-
[K2HR3 Utilities for Setup](https://k2hr3.antpick.ax/setup.html)
|
|
48
|
-
[K2HR3 Demonstration](https://demo.k2hr3.antpick.ax/)
|
|
49
|
-
|
|
50
|
-
[About k2hdkc](https://k2hdkc.antpick.ax/)
|
|
51
|
-
[About k2hash](https://k2hash.antpick.ax/)
|
|
52
|
-
[About chmpx](https://chmpx.antpick.ax/)
|
|
53
|
-
[About k2hash transaction plugin](https://k2htpdtor.antpick.ax/)
|
|
54
|
-
|
|
55
|
-
[About AntPickax](https://antpick.ax/)
|
|
40
|
+
- [K2HR3 Document](https://k2hr3.antpick.ax/index.html)
|
|
41
|
+
- [K2HR3 Web Application Usage](https://k2hr3.antpick.ax/usage_app.html)
|
|
42
|
+
- [K2HR3 Command Line Interface Usage](https://k2hr3.antpick.ax/cli.html)
|
|
43
|
+
- [K2HR3 REST API Usage](https://k2hr3.antpick.ax/api.html)
|
|
44
|
+
- [K2HR3 OpenStack Notification Listener Usage](https://k2hr3.antpick.ax/detail_osnl.html)
|
|
45
|
+
- [K2HR3 Watcher Usage](https://k2hr3.antpick.ax/tools.html)
|
|
46
|
+
- [K2HR3 Get Resource Usage](https://k2hr3.antpick.ax/tools.html)
|
|
47
|
+
- [K2HR3 Utilities for Setup](https://k2hr3.antpick.ax/setup.html)
|
|
48
|
+
- [K2HR3 Demonstration](https://demo.k2hr3.antpick.ax/)
|
|
49
|
+
|
|
50
|
+
- [About k2hdkc](https://k2hdkc.antpick.ax/)
|
|
51
|
+
- [About k2hash](https://k2hash.antpick.ax/)
|
|
52
|
+
- [About chmpx](https://chmpx.antpick.ax/)
|
|
53
|
+
- [About k2hash transaction plugin](https://k2htpdtor.antpick.ax/)
|
|
54
|
+
|
|
55
|
+
- [About AntPickax](https://antpick.ax/)
|
|
56
56
|
|
|
57
57
|
### Repositories
|
|
58
|
-
[K2HR3 main repository](https://github.com/yahoojapan/k2hr3)
|
|
59
|
-
[K2HR3 Web Application repository](https://github.com/yahoojapan/k2hr3_app)
|
|
60
|
-
[K2HR3 Command Line Interface repository](https://github.com/yahoojapan/k2hr3_cli)
|
|
61
|
-
[K2HR3 REST API repository](https://github.com/yahoojapan/k2hr3_api)
|
|
62
|
-
[K2HR3 OpenStack Notification Listener](https://github.com/yahoojapan/k2hr3_osnl)
|
|
63
|
-
[K2HR3
|
|
64
|
-
[K2HR3
|
|
65
|
-
[K2HR3
|
|
66
|
-
|
|
67
|
-
[k2hdkc](https://github.com/yahoojapan/k2hdkc)
|
|
68
|
-
[k2hash](https://github.com/yahoojapan/k2hash)
|
|
69
|
-
[chmpx](https://github.com/yahoojapan/chmpx)
|
|
70
|
-
[k2hash transaction plugin](https://github.com/yahoojapan/k2htp_dtor)
|
|
58
|
+
- [K2HR3 main repository](https://github.com/yahoojapan/k2hr3)
|
|
59
|
+
- [K2HR3 Web Application repository](https://github.com/yahoojapan/k2hr3_app)
|
|
60
|
+
- [K2HR3 Command Line Interface repository](https://github.com/yahoojapan/k2hr3_cli)
|
|
61
|
+
- [K2HR3 REST API repository](https://github.com/yahoojapan/k2hr3_api)
|
|
62
|
+
- [K2HR3 OpenStack Notification Listener](https://github.com/yahoojapan/k2hr3_osnl)
|
|
63
|
+
- [K2HR3 Get Resource](https://github.com/yahoojapan/k2hr3_get_resource)
|
|
64
|
+
- [K2HR3 Utilities](https://github.com/yahoojapan/k2hr3_utils)
|
|
65
|
+
- [K2HR3 Container Registration Sidecar](https://github.com/yahoojapan/k2hr3_sidecar)
|
|
66
|
+
|
|
67
|
+
- [k2hdkc](https://github.com/yahoojapan/k2hdkc)
|
|
68
|
+
- [k2hash](https://github.com/yahoojapan/k2hash)
|
|
69
|
+
- [chmpx](https://github.com/yahoojapan/chmpx)
|
|
70
|
+
- [k2hash transaction plugin](https://github.com/yahoojapan/k2htp_dtor)
|
|
71
71
|
|
|
72
72
|
### Packages
|
|
73
|
-
[k2hr3-api(npm packages)](https://www.npmjs.com/package/k2hr3-api)
|
|
73
|
+
- [k2hr3-api(npm packages)](https://www.npmjs.com/package/k2hr3-api)
|
|
74
74
|
|
|
75
75
|
### Docker images
|
|
76
|
-
[k2hr3-api(Docker Hub)](https://hub.docker.com/r/antpickax/k2hr3-api)
|
|
76
|
+
- [k2hr3-api(Docker Hub)](https://hub.docker.com/r/antpickax/k2hr3-api)
|
|
77
77
|
|
|
78
78
|
### License
|
|
79
79
|
This software is released under the MIT License, see the license file.
|
package/app.js
CHANGED
|
@@ -170,12 +170,10 @@ app.use(function(req, res, next)
|
|
|
170
170
|
//
|
|
171
171
|
// case of specified user credentials(except specified unscoped token)
|
|
172
172
|
//
|
|
173
|
-
/* eslint-disable indent, no-mixed-spaces-and-tabs */
|
|
174
173
|
var result = {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
174
|
+
result: false,
|
|
175
|
+
message: 'not allow CORS(cross-origin resource sharing) to /v1/user/tokens'
|
|
176
|
+
};
|
|
179
177
|
|
|
180
178
|
resutil.errResponse(req, res, 405, result, 'application/json; charset=utf-8');
|
|
181
179
|
return;
|
|
@@ -274,12 +272,10 @@ app.use(function(err, req, res, next) // eslint-disable-line no-unused-vars
|
|
|
274
272
|
res.locals.message = err.message;
|
|
275
273
|
res.locals.error = req.app.get('env') === 'development' ? err : {};
|
|
276
274
|
|
|
277
|
-
/* eslint-disable indent, no-mixed-spaces-and-tabs */
|
|
278
275
|
var result = {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
276
|
+
result: false,
|
|
277
|
+
message: 'Internal server error'
|
|
278
|
+
};
|
|
283
279
|
|
|
284
280
|
resutil.errResponse(req, res, (err.status || 500), result, 'application/json; charset=utf-8');
|
|
285
281
|
});
|
package/bin/run.sh
CHANGED
|
@@ -154,7 +154,7 @@ stop_old_process()
|
|
|
154
154
|
#
|
|
155
155
|
for _ONE_PID in ${ALL_CHILD_PIDS}; do
|
|
156
156
|
# shellcheck disable=SC2009
|
|
157
|
-
if
|
|
157
|
+
if ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${_ONE_PID}$" || exit 1 && exit 0 ); then
|
|
158
158
|
kill -KILL "${_ONE_PID}" >/dev/null 2>&1
|
|
159
159
|
fi
|
|
160
160
|
done
|
|
@@ -165,7 +165,7 @@ stop_old_process()
|
|
|
165
165
|
#
|
|
166
166
|
for _ONE_PID in ${ALL_CHILD_PIDS}; do
|
|
167
167
|
# shellcheck disable=SC2009
|
|
168
|
-
if
|
|
168
|
+
if ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${_ONE_PID}$" || exit 1 && exit 0 ); then
|
|
169
169
|
echo "[ERROR] Could not stop old processes."
|
|
170
170
|
return 1
|
|
171
171
|
fi
|
|
@@ -195,82 +195,82 @@ while [ $# -ne 0 ]; do
|
|
|
195
195
|
if [ -z "$1" ]; then
|
|
196
196
|
break
|
|
197
197
|
|
|
198
|
-
elif
|
|
198
|
+
elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then
|
|
199
199
|
PrintUsage "${PRGNAME}"
|
|
200
200
|
exit 0
|
|
201
201
|
|
|
202
|
-
elif
|
|
202
|
+
elif echo "$1" | grep -q -i -e "^-prod$" -e "^--production$"; then
|
|
203
203
|
if [ -n "${NODE_ENV_VALUE}" ]; then
|
|
204
204
|
echo "[ERROR] already specified --production(-prod) or --development(-dev) option"
|
|
205
205
|
exit 1
|
|
206
206
|
fi
|
|
207
207
|
NODE_ENV_VALUE="production"
|
|
208
208
|
|
|
209
|
-
elif
|
|
209
|
+
elif echo "$1" | grep -q -i -e "^-dev$" -e "^--development$"; then
|
|
210
210
|
if [ -n "${NODE_ENV_VALUE}" ]; then
|
|
211
211
|
echo "[ERROR] already specified --production(-prod) or --development(-dev) option"
|
|
212
212
|
exit 1
|
|
213
213
|
fi
|
|
214
214
|
NODE_ENV_VALUE="development"
|
|
215
215
|
|
|
216
|
-
elif
|
|
216
|
+
elif echo "$1" | grep -q -i -e "^-bg$" -e "^--background$"; then
|
|
217
217
|
#
|
|
218
218
|
# Not check multi same option...
|
|
219
219
|
#
|
|
220
220
|
BACKGROUND=1
|
|
221
221
|
|
|
222
|
-
elif
|
|
222
|
+
elif echo "$1" | grep -q -i -e "^-fg$" -e "^--foreground$"; then
|
|
223
223
|
#
|
|
224
224
|
# Not check multi same option...
|
|
225
225
|
#
|
|
226
226
|
FOREGROUND=1
|
|
227
227
|
|
|
228
|
-
elif
|
|
228
|
+
elif echo "$1" | grep -q -i -e "^-s$" -e "^--stop$"; then
|
|
229
229
|
if [ "${STOP_OLD_PROCESS}" -ne 0 ]; then
|
|
230
230
|
echo "[ERROR] already specified --stop(-s) option"
|
|
231
231
|
exit 1
|
|
232
232
|
fi
|
|
233
233
|
STOP_OLD_PROCESS=1
|
|
234
234
|
|
|
235
|
-
elif
|
|
235
|
+
elif echo "$1" | grep -q -i -e "^-d$" -e "^--debug$"; then
|
|
236
236
|
if [ -n "${INSPECTOR_OPT}" ]; then
|
|
237
237
|
echo "[ERROR] already specified --debug(-d) or --debug-nobrk(-dnobrk) option"
|
|
238
238
|
exit 1
|
|
239
239
|
fi
|
|
240
240
|
INSPECTOR_OPT="--inspect-brk=${LOCAL_HOSTNAME}:9229"
|
|
241
241
|
|
|
242
|
-
elif
|
|
242
|
+
elif echo "$1" | grep -q -i -e "^-dnobrk$" -e "^--debug-nobrk$"; then
|
|
243
243
|
if [ -n "${INSPECTOR_OPT}" ]; then
|
|
244
244
|
echo "[ERROR] already specified --debug(-d) or --debug-nobrk(-dnobrk) option"
|
|
245
245
|
exit 1
|
|
246
246
|
fi
|
|
247
247
|
INSPECTOR_OPT="--inspect=${LOCAL_HOSTNAME}:9229"
|
|
248
248
|
|
|
249
|
-
elif
|
|
249
|
+
elif echo "$1" | grep -q -i -e "^-dl$" -e "^--debuglevel$"; then
|
|
250
250
|
shift
|
|
251
251
|
if [ $# -eq 0 ]; then
|
|
252
252
|
echo "[ERROR] --debuglevel(-dl) option needs parameter(dbg/msg/warn/err/custom debug level)"
|
|
253
253
|
exit 1
|
|
254
254
|
fi
|
|
255
|
-
if
|
|
255
|
+
if echo "$1" | grep -q -i -e "^dbg$" -e "^debug$"; then
|
|
256
256
|
if [ "${DEBUG_ENV_LEVEL}" -ne 0 ]; then
|
|
257
257
|
echo "[ERROR] --debuglevel(-dl) option already is set"
|
|
258
258
|
exit 1
|
|
259
259
|
fi
|
|
260
260
|
DEBUG_ENV_LEVEL=4
|
|
261
|
-
elif
|
|
261
|
+
elif echo "$1" | grep -q -i -e "^msg$" -e "^message$" -e "^info$"; then
|
|
262
262
|
if [ "${DEBUG_ENV_LEVEL}" -ne 0 ]; then
|
|
263
263
|
echo "[ERROR] --debuglevel(-dl) option already is set"
|
|
264
264
|
exit 1
|
|
265
265
|
fi
|
|
266
266
|
DEBUG_ENV_LEVEL=3
|
|
267
|
-
elif
|
|
267
|
+
elif echo "$1" | grep -q -i -e "^wan$" -e "^warn$" -e "^warning$"; then
|
|
268
268
|
if [ "${DEBUG_ENV_LEVEL}" -ne 0 ]; then
|
|
269
269
|
echo "[ERROR] --debuglevel(-dl) option already is set"
|
|
270
270
|
exit 1
|
|
271
271
|
fi
|
|
272
272
|
DEBUG_ENV_LEVEL=2
|
|
273
|
-
elif
|
|
273
|
+
elif echo "$1" | grep -q -i -e "^err$" -e "^error$"; then
|
|
274
274
|
if [ "${DEBUG_ENV_LEVEL}" -ne 0 ]; then
|
|
275
275
|
echo "[ERROR] --debuglevel(-dl) option already is set"
|
|
276
276
|
exit 1
|
|
@@ -286,14 +286,14 @@ while [ $# -ne 0 ]; do
|
|
|
286
286
|
DEBUG_ENV_CUSTOM="${DEBUG_ENV_CUSTOM}$1"
|
|
287
287
|
fi
|
|
288
288
|
|
|
289
|
-
elif
|
|
289
|
+
elif echo "$1" | grep -q -i -e "^-w$" -e "^--watcher$" -e "^--watch$"; then
|
|
290
290
|
if [ "${WATCHER_PROC}" -ne 0 ]; then
|
|
291
291
|
echo "[ERROR] already specified --watcher(-w) option"
|
|
292
292
|
exit 1
|
|
293
293
|
fi
|
|
294
294
|
WATCHER_PROC=1
|
|
295
295
|
|
|
296
|
-
elif
|
|
296
|
+
elif echo "$1" | grep -q -i -e "^-os$" -e "^--oneshot$"; then
|
|
297
297
|
if [ "${WATCH_ONESHOT}" -ne 0 ]; then
|
|
298
298
|
echo "[ERROR] already specified --oneshot(-os) option"
|
|
299
299
|
exit 1
|
|
@@ -394,13 +394,13 @@ elif [ "${DEBUG_ENV_LEVEL}" -ge 1 ]; then
|
|
|
394
394
|
else
|
|
395
395
|
DEBUG_ENV_PARAM="LOGLEVEL_SILENT"
|
|
396
396
|
if [ -n "${DEBUG_LEVEL}" ]; then
|
|
397
|
-
if
|
|
397
|
+
if echo "${DEBUG_LEVEL}" | grep -q -i -e "^dbg$" -e "^debug$"; then
|
|
398
398
|
DEBUG_ENV_PARAM="LOGLEVEL_DBG"
|
|
399
|
-
elif
|
|
399
|
+
elif echo "${DEBUG_LEVEL}" | grep -q -i -e "^msg$" -e "^message$" -e "^info$"; then
|
|
400
400
|
DEBUG_ENV_PARAM="LOGLEVEL_MSG"
|
|
401
|
-
elif
|
|
401
|
+
elif echo "${DEBUG_LEVEL}" | grep -q -i -e "^wan$" -e "^warn$" -e "^warning$"; then
|
|
402
402
|
DEBUG_ENV_PARAM="LOGLEVEL_WAN"
|
|
403
|
-
elif
|
|
403
|
+
elif echo "${DEBUG_LEVEL}" | grep -q -i -e "^err$" -e "^error$"; then
|
|
404
404
|
DEBUG_ENV_PARAM="LOGLEVEL_ERR"
|
|
405
405
|
fi
|
|
406
406
|
fi
|
package/bin/www
CHANGED
|
@@ -119,7 +119,7 @@ if(cluster.isMaster && (undefined == apiConf.isMultiProc() || false !== apiConf.
|
|
|
119
119
|
process.setuid(user);
|
|
120
120
|
console.log('Succeeded to setuid');
|
|
121
121
|
} catch (err) {
|
|
122
|
-
console.log('Failed to setuid');
|
|
122
|
+
console.log('Failed to setuid', JSON.stringify(err));
|
|
123
123
|
process.exit(1);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
@@ -154,7 +154,7 @@ check_os()
|
|
|
154
154
|
PKGMGR_BIN="apt-get"
|
|
155
155
|
PKGMGR_UPDATE_OPT="update -y -qq"
|
|
156
156
|
PKGMGR_INSTALL_OPT="install -y"
|
|
157
|
-
PKGMGR_LIST_CMD="apt list --installed"
|
|
157
|
+
PKGMGR_LIST_CMD="apt-get list --installed"
|
|
158
158
|
|
|
159
159
|
elif echo "${ID}" | grep -q -i "debian"; then
|
|
160
160
|
IS_OS_DEBIAN=1
|
|
@@ -162,7 +162,7 @@ check_os()
|
|
|
162
162
|
PKGMGR_BIN="apt-get"
|
|
163
163
|
PKGMGR_UPDATE_OPT="update -y -qq"
|
|
164
164
|
PKGMGR_INSTALL_OPT="install -y"
|
|
165
|
-
PKGMGR_LIST_CMD="apt list --installed"
|
|
165
|
+
PKGMGR_LIST_CMD="apt-get list --installed"
|
|
166
166
|
|
|
167
167
|
elif echo "${ID}" | grep -q -i "alpine"; then
|
|
168
168
|
IS_OS_DEBIAN=0
|
|
@@ -585,17 +585,17 @@ while [ $# -ne 0 ]; do
|
|
|
585
585
|
if [ -z "$1" ]; then
|
|
586
586
|
break;
|
|
587
587
|
|
|
588
|
-
elif
|
|
588
|
+
elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then
|
|
589
589
|
func_usage "${SCRIPTNAME}"
|
|
590
590
|
exit 0
|
|
591
591
|
|
|
592
|
-
elif
|
|
592
|
+
elif echo "$1" | grep -q -i -e "^-r$" -e "^--register$"; then
|
|
593
593
|
if [ -n "${SCRIPTMODE}" ]; then
|
|
594
594
|
exit_err "Already set script mode(${SCRIPTMODE}), thus option($1) is not wrong."
|
|
595
595
|
fi
|
|
596
596
|
SCRIPTMODE="r"
|
|
597
597
|
|
|
598
|
-
elif
|
|
598
|
+
elif echo "$1" | grep -q -i -e "^-d$" -e "^--delete$"; then
|
|
599
599
|
if [ -n "${SCRIPTMODE}" ]; then
|
|
600
600
|
exit_err "Already set script mode(${SCRIPTMODE}), thus option($1) is not wrong."
|
|
601
601
|
fi
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* K2HR3 REST API
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2017 Yahoo Japan Corporation.
|
|
5
|
+
*
|
|
6
|
+
* K2HR3 is K2hdkc based Resource and Roles and policy Rules, gathers
|
|
7
|
+
* common management information for the cloud.
|
|
8
|
+
* K2HR3 can dynamically manage information as "who", "what", "operate".
|
|
9
|
+
* These are stored as roles, resources, policies in K2hdkc, and the
|
|
10
|
+
* client system can dynamically read and modify these information.
|
|
11
|
+
*
|
|
12
|
+
* For the full copyright and license information, please view
|
|
13
|
+
* the license file that was distributed with this source code.
|
|
14
|
+
*
|
|
15
|
+
* AUTHOR: Takeshi Nakatani
|
|
16
|
+
* CREATE: Fri, Feb 14 2025
|
|
17
|
+
* REVISION:
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
//
|
|
22
|
+
// [NOTE]
|
|
23
|
+
// This file is the old .eslintrc.js file converted by @eslint/migrate-config.
|
|
24
|
+
//
|
|
25
|
+
import globals from "globals";
|
|
26
|
+
import path from "node:path";
|
|
27
|
+
import { fileURLToPath } from "node:url";
|
|
28
|
+
import js from "@eslint/js";
|
|
29
|
+
import { FlatCompat } from "@eslint/eslintrc";
|
|
30
|
+
|
|
31
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
32
|
+
const __dirname = path.dirname(__filename);
|
|
33
|
+
const compat = new FlatCompat({
|
|
34
|
+
baseDirectory: __dirname,
|
|
35
|
+
recommendedConfig: js.configs.recommended,
|
|
36
|
+
allConfig: js.configs.all
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export default [...compat.extends("eslint:recommended"), {
|
|
40
|
+
languageOptions: {
|
|
41
|
+
globals: {
|
|
42
|
+
...globals.node,
|
|
43
|
+
...globals.browser,
|
|
44
|
+
...globals.commonjs,
|
|
45
|
+
},
|
|
46
|
+
ecmaVersion: 2017,
|
|
47
|
+
sourceType: "commonjs",
|
|
48
|
+
},
|
|
49
|
+
files: ["**/*.js", "**/*.ts", "**/www", "**/watcher"],
|
|
50
|
+
rules: {
|
|
51
|
+
indent: ["error", "tab", {
|
|
52
|
+
SwitchCase: 1,
|
|
53
|
+
}],
|
|
54
|
+
"no-console": 0,
|
|
55
|
+
"linebreak-style": ["error", "unix"],
|
|
56
|
+
quotes: ["error", "single"],
|
|
57
|
+
semi: ["error", "always"],
|
|
58
|
+
},
|
|
59
|
+
}];
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
* Local variables:
|
|
63
|
+
* tab-width: 4
|
|
64
|
+
* c-basic-offset: 4
|
|
65
|
+
* End:
|
|
66
|
+
* vim600: noexpandtab sw=4 ts=4 fdm=marker
|
|
67
|
+
* vim<600: noexpandtab sw=4 ts=4
|
|
68
|
+
*/
|
package/lib/cacerts.js
CHANGED
|
@@ -35,23 +35,24 @@ function loadCACert()
|
|
|
35
35
|
fs.statSync(process.env.CAPATH);
|
|
36
36
|
return fs.readFileSync(process.env.CAPATH);
|
|
37
37
|
}catch(err){
|
|
38
|
-
r3logger.elog('CAPATH environment' + process.env.CAPATH + ' file does not exist, then use default ca certs.');
|
|
38
|
+
r3logger.elog('CAPATH environment' + process.env.CAPATH + ' file does not exist, then use default ca certs.', JSON.stringify(err));
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
// load one of CA certs
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
var def_certs = [
|
|
44
|
+
'/etc/ssl/certs/ca-certificates.crt',
|
|
45
|
+
'/etc/pki/tls/certs/ca-bundle.crt',
|
|
46
|
+
'/etc/ssl/certs/ca-bundle.crt',
|
|
47
|
+
'/etc/ssl/certs/ca-bundle.trust.crt'
|
|
48
|
+
];
|
|
49
49
|
|
|
50
50
|
for(var cnt = 0; cnt < def_certs.length; ++cnt){
|
|
51
51
|
try{
|
|
52
52
|
fs.statSync(def_certs[cnt]);
|
|
53
53
|
return fs.readFileSync(def_certs[cnt]);
|
|
54
54
|
}catch(err){
|
|
55
|
+
r3logger.dlog(JSON.stringify(err));
|
|
55
56
|
continue;
|
|
56
57
|
}
|
|
57
58
|
}
|
package/lib/dummyuserapi.js
CHANGED
|
@@ -716,7 +716,7 @@ exports.getUserUnscopedToken = function(uname, passwd, callback)
|
|
|
716
716
|
//
|
|
717
717
|
// update token : not implemented
|
|
718
718
|
//
|
|
719
|
-
exports.getUserUnscopedTokenByToken = function(token, callback)
|
|
719
|
+
exports.getUserUnscopedTokenByToken = function(token, callback)
|
|
720
720
|
{
|
|
721
721
|
var error = new Error('getUserUnscopedTokenByToken is not implemented');
|
|
722
722
|
r3logger.elog(error.message);
|
package/lib/ipwatch.js
CHANGED
|
@@ -267,7 +267,7 @@ function rawWatchAddressesAlive(oneshotCB)
|
|
|
267
267
|
return null;
|
|
268
268
|
}
|
|
269
269
|
}catch(error){
|
|
270
|
-
r3logger.elog('could not load module : ' + (rawIsBasicType() ? './basicipcheck' : localchkipconfig.funcmod));
|
|
270
|
+
r3logger.elog('could not load module : ' + (rawIsBasicType() ? './basicipcheck' : localchkipconfig.funcmod), JSON.stringify(error));
|
|
271
271
|
return null;
|
|
272
272
|
}
|
|
273
273
|
|
package/lib/k2hr3acrutil.js
CHANGED
|
@@ -73,20 +73,18 @@ function rawACRSendVerifyEx(scopedtoken, urlobj, callback)
|
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
};
|
|
89
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
76
|
+
var headers = {
|
|
77
|
+
'Content-Type': 'application/json',
|
|
78
|
+
'Content-Length': 0,
|
|
79
|
+
'X-Auth-Token': scopedtoken // [NOTE] this token string does not have 'U=' prefix.
|
|
80
|
+
};
|
|
81
|
+
var options = {
|
|
82
|
+
'host': apiutil.getSafeString(urlobj.host),
|
|
83
|
+
'port': urlobj.port,
|
|
84
|
+
'path': apiutil.getSafeString(urlobj.path),
|
|
85
|
+
'method': 'GET',
|
|
86
|
+
'headers': headers
|
|
87
|
+
};
|
|
90
88
|
|
|
91
89
|
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
92
90
|
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
package/lib/k2hr3apiutil.js
CHANGED
|
@@ -104,7 +104,7 @@ function rawCheckSimpleJSON(str)
|
|
|
104
104
|
}
|
|
105
105
|
try{
|
|
106
106
|
var tmp = JSON.parse(str); // eslint-disable-line no-unused-vars
|
|
107
|
-
}catch(exception){
|
|
107
|
+
}catch(exception){ // eslint-disable-line no-unused-vars
|
|
108
108
|
return false;
|
|
109
109
|
}
|
|
110
110
|
return true;
|
|
@@ -117,7 +117,7 @@ function rawParseJSON(str)
|
|
|
117
117
|
}
|
|
118
118
|
try{
|
|
119
119
|
return JSON.parse(str);
|
|
120
|
-
}catch(exception){
|
|
120
|
+
}catch(exception){ // eslint-disable-line no-unused-vars
|
|
121
121
|
return null;
|
|
122
122
|
}
|
|
123
123
|
}
|
|
@@ -1183,7 +1183,7 @@ function rawCheckFileExist(file)
|
|
|
1183
1183
|
}
|
|
1184
1184
|
try{
|
|
1185
1185
|
fs.statSync(file);
|
|
1186
|
-
}catch(err){
|
|
1186
|
+
}catch(err){ // eslint-disable-line no-unused-vars
|
|
1187
1187
|
return false;
|
|
1188
1188
|
}
|
|
1189
1189
|
return true;
|
|
@@ -1197,7 +1197,7 @@ function rawReadFileContents(file)
|
|
|
1197
1197
|
}
|
|
1198
1198
|
try{
|
|
1199
1199
|
contents = fs.readFileSync(file).toString();
|
|
1200
|
-
}catch(err){
|
|
1200
|
+
}catch(err){ // eslint-disable-line no-unused-vars
|
|
1201
1201
|
return contents;
|
|
1202
1202
|
}
|
|
1203
1203
|
return contents;
|
|
@@ -1221,7 +1221,7 @@ function rawCheckMakeDir(path)
|
|
|
1221
1221
|
}
|
|
1222
1222
|
try{
|
|
1223
1223
|
fs.mkdirSync(path);
|
|
1224
|
-
}catch(err){
|
|
1224
|
+
}catch(err){ // eslint-disable-line no-unused-vars
|
|
1225
1225
|
return false;
|
|
1226
1226
|
}
|
|
1227
1227
|
return true;
|
package/lib/k2hr3cryptutil.js
CHANGED
|
@@ -68,6 +68,7 @@ function rawR3Encrypt(str, passphrase, algorithm)
|
|
|
68
68
|
// convert '/', '?', ':' characters.
|
|
69
69
|
return encodeURIComponent(cryptedStr);
|
|
70
70
|
}catch(exception){
|
|
71
|
+
r3logger.dlog(JSON.stringify(exception));
|
|
71
72
|
return null;
|
|
72
73
|
}
|
|
73
74
|
}
|
|
@@ -122,6 +123,7 @@ function rawR3Decrypt(str, passphrase, algorithm)
|
|
|
122
123
|
}
|
|
123
124
|
return decryptedStr;
|
|
124
125
|
}catch(exception){
|
|
126
|
+
r3logger.dlog(JSON.stringify(exception));
|
|
125
127
|
return null;
|
|
126
128
|
}
|
|
127
129
|
}
|