viberadar 0.3.187 → 0.3.189

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAO7B,OAAO,EAAE,UAAU,EAA4H,MAAM,YAAY,CAAC;AAOlK,UAAU,aAAa;IACrB,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;CACrB;AAuhED,wBAAgB,WAAW,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CA22F1G"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAO7B,OAAO,EAAE,UAAU,EAA4H,MAAM,YAAY,CAAC;AAOlK,UAAU,aAAa;IACrB,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;CACrB;AAuhED,wBAAgB,WAAW,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAo7F1G"}
@@ -4975,7 +4975,8 @@ a{color:var(--blue)}
4975
4975
  return;
4976
4976
  }
4977
4977
  if (url.startsWith('/api/probe/screenshot/') && req.method === 'GET') {
4978
- const filename = path.basename(url.replace('/api/probe/screenshot/', ''));
4978
+ const rawName = url.replace('/api/probe/screenshot/', '').split('?')[0];
4979
+ const filename = path.basename(decodeURIComponent(rawName));
4979
4980
  const screenshotsDir = path.join(process.cwd(), '.viberadar', 'probe-screenshots');
4980
4981
  const filePath = path.join(screenshotsDir, filename);
4981
4982
  // Security: only serve .png files from the designated screenshots directory
@@ -5099,6 +5100,99 @@ a{color:var(--blue)}
5099
5100
  });
5100
5101
  return;
5101
5102
  }
5103
+ if (url === '/api/probe/rename-check' && req.method === 'POST') {
5104
+ let body = '';
5105
+ req.on('data', (d) => { body += d; });
5106
+ req.on('end', () => {
5107
+ try {
5108
+ const { oldName, newName } = JSON.parse(body);
5109
+ if (!oldName || !newName || !newName.trim()) {
5110
+ res.writeHead(400, jsonH);
5111
+ res.end(JSON.stringify({ error: 'oldName and newName required' }));
5112
+ return;
5113
+ }
5114
+ const configPath = path.join(projectRoot, 'probe.config.yml');
5115
+ if (!fs.existsSync(configPath)) {
5116
+ res.writeHead(404, jsonH);
5117
+ res.end(JSON.stringify({ error: 'probe.config.yml not found' }));
5118
+ return;
5119
+ }
5120
+ let yaml = fs.readFileSync(configPath, 'utf-8');
5121
+ // Replace `name: <oldName>` with `name: <newName>` (only exact match on a line)
5122
+ const escaped = oldName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
5123
+ const re = new RegExp(`(^|\\n)(\\s*- name:\\s*)${escaped}(\\s*$)`, 'm');
5124
+ if (!re.test(yaml)) {
5125
+ res.writeHead(404, jsonH);
5126
+ res.end(JSON.stringify({ error: `Check "${oldName}" not found in config` }));
5127
+ return;
5128
+ }
5129
+ yaml = yaml.replace(re, `$1$2${newName.trim()}$3`);
5130
+ fs.writeFileSync(configPath, yaml, 'utf-8');
5131
+ res.writeHead(200, jsonH);
5132
+ res.end(JSON.stringify({ ok: true, newName: newName.trim() }));
5133
+ }
5134
+ catch (err) {
5135
+ res.writeHead(500, jsonH);
5136
+ res.end(JSON.stringify({ error: err.message }));
5137
+ }
5138
+ });
5139
+ return;
5140
+ }
5141
+ if (url === '/api/probe/delete-check' && req.method === 'POST') {
5142
+ let body = '';
5143
+ req.on('data', (d) => { body += d; });
5144
+ req.on('end', () => {
5145
+ try {
5146
+ const { checkName, deleteFile } = JSON.parse(body);
5147
+ if (!checkName) {
5148
+ res.writeHead(400, jsonH);
5149
+ res.end(JSON.stringify({ error: 'checkName required' }));
5150
+ return;
5151
+ }
5152
+ const configPath = path.join(projectRoot, 'probe.config.yml');
5153
+ if (!fs.existsSync(configPath)) {
5154
+ res.writeHead(404, jsonH);
5155
+ res.end(JSON.stringify({ error: 'probe.config.yml not found' }));
5156
+ return;
5157
+ }
5158
+ const config = (0, config_1.loadProbeConfig)(configPath);
5159
+ if (!config) {
5160
+ res.writeHead(500, jsonH);
5161
+ res.end(JSON.stringify({ error: 'Failed to parse probe.config.yml' }));
5162
+ return;
5163
+ }
5164
+ const check = config.checks.find(c => c.name === checkName);
5165
+ if (!check) {
5166
+ res.writeHead(404, jsonH);
5167
+ res.end(JSON.stringify({ error: `Check "${checkName}" not found` }));
5168
+ return;
5169
+ }
5170
+ // Remove the check block from YAML (from `- name: <checkName>` until next `- name:` or end)
5171
+ let yaml = fs.readFileSync(configPath, 'utf-8');
5172
+ const escaped = checkName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
5173
+ // Match a list item starting with `- name: <checkName>` and all its indented lines
5174
+ const re = new RegExp(`\\n?[ \\t]*- name: ${escaped}[\\s\\S]*?(?=\\n[ \\t]*- name:|$)`, 'm');
5175
+ yaml = yaml.replace(re, '');
5176
+ fs.writeFileSync(configPath, yaml, 'utf-8');
5177
+ // Optionally delete the test file
5178
+ let fileDeleted = false;
5179
+ if (deleteFile && check.file) {
5180
+ const filePath = path.resolve(projectRoot, check.file);
5181
+ if (fs.existsSync(filePath)) {
5182
+ fs.unlinkSync(filePath);
5183
+ fileDeleted = true;
5184
+ }
5185
+ }
5186
+ res.writeHead(200, jsonH);
5187
+ res.end(JSON.stringify({ ok: true, fileDeleted }));
5188
+ }
5189
+ catch (err) {
5190
+ res.writeHead(500, jsonH);
5191
+ res.end(JSON.stringify({ error: err.message }));
5192
+ }
5193
+ });
5194
+ return;
5195
+ }
5102
5196
  res.writeHead(404);
5103
5197
  res.end('Not found');
5104
5198
  });