35 lines
1.3 KiB
JavaScript
35 lines
1.3 KiB
JavaScript
|
|
#!/usr/bin/env node
|
||
|
|
// Temporary diagnostic script — fetch a specific finding and dump host fields
|
||
|
|
require('dotenv').config();
|
||
|
|
const { ivantiPost } = require('../helpers/ivantiApi');
|
||
|
|
|
||
|
|
const apiKey = process.env.IVANTI_API_KEY;
|
||
|
|
const clientId = process.env.IVANTI_CLIENT_ID || '1550';
|
||
|
|
const skipTls = process.env.IVANTI_SKIP_TLS === 'true';
|
||
|
|
|
||
|
|
const findingId = process.argv[2] || '2814870699';
|
||
|
|
|
||
|
|
const urlPath = `/client/${encodeURIComponent(clientId)}/hostFinding/search`;
|
||
|
|
const body = {
|
||
|
|
filters: [
|
||
|
|
{ field: 'id', exclusive: false, operator: 'EXACT', orWithPrevious: false, implicitFilters: [], value: findingId, caseSensitive: false }
|
||
|
|
],
|
||
|
|
projection: 'internal',
|
||
|
|
sort: [{ field: 'severity', direction: 'ASC' }],
|
||
|
|
page: 0,
|
||
|
|
size: 1
|
||
|
|
};
|
||
|
|
|
||
|
|
ivantiPost(urlPath, body, apiKey, skipTls).then(r => {
|
||
|
|
const data = JSON.parse(r.body);
|
||
|
|
const finding = (data._embedded && data._embedded.hostFindings || [])[0];
|
||
|
|
if (!finding) { console.log('Finding not found'); process.exit(0); }
|
||
|
|
|
||
|
|
console.log('=== host object ===');
|
||
|
|
console.log(JSON.stringify(finding.host, null, 2));
|
||
|
|
console.log('');
|
||
|
|
console.log('=== hostAdditionalDetails ===');
|
||
|
|
console.log(JSON.stringify(finding.hostAdditionalDetails, null, 2));
|
||
|
|
process.exit(0);
|
||
|
|
}).catch(e => { console.error(e.message); process.exit(1); });
|