mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 22:54:05 -08:00
683d2dfc98
* ✨ Add injection to notion, Add test to notion in cred * 🔥 Remove unuse method * 🎨 Move testing from node file to cred file * ✨ Add injection and testing in facebook graph * Add cred injec with testing * Add Cred injection and cred test * Add cred injection, and cred testing for typeform, fix issue in clickup * Add cred injection, move testing inside creds * Add cred injection and cred testing to SendGrid * Add cred injection and cred testing to woocommerce * Add cred injection, add cred test to gitlab * 🔥 Fix duplicated imports in Mautic cred * 🔥 removed unused credentials testing in node * Add cred injection, cred testing, handles slash trailing for Grafana node * Add cred injection, cred testing to shopify * Add cred injection , add cred testing to stripe * changed cred injection, add testing to cred for mattermost * add cred injection and testing for dropbox * Add cred injection, cred testing to webflow * ✨ Add cred injection and cred test to nocodb * ✨ Add cred injection, cred testing to mailchimp * 🐛 fix a bug In credentials testing * ✨ Add cred injection, cred testing to sms77 * ✨ Add cred injection, cred testing to ActiveCampaign * Add cred injection, cred testing to TheHive * ✨ Add cred injection, add cred testing to ApiTemplateio * ✨ Add cred injection, add cred testing for zoom * ✨ Add cred injection, cred testing to rocketchat * ✨ Add cred injection, add cred test to getResponse * 🔥 Remove useless authentcate creds and testing from facebookGraphApp * 🔥 Remove useless imports in FacebookGrappApp credentials file * 🔥 Removed useless imports and if statement * 🐛 Add version to header when testing cred Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: Jan Oberhauser <janober@users.noreply.github.com>
175 lines
3.9 KiB
TypeScript
175 lines
3.9 KiB
TypeScript
import {
|
|
IExecuteFunctions,
|
|
} from 'n8n-core';
|
|
|
|
import {
|
|
IDataObject,
|
|
INodeExecutionData,
|
|
INodeType,
|
|
INodeTypeDescription,
|
|
NodeOperationError,
|
|
} from 'n8n-workflow';
|
|
|
|
import {
|
|
OptionsWithUri,
|
|
} from 'request';
|
|
|
|
import {
|
|
scanFields,
|
|
scanOperations,
|
|
} from './descriptions';
|
|
|
|
import {
|
|
handleListing,
|
|
normalizeId,
|
|
urlScanIoApiRequest,
|
|
} from './GenericFunctions';
|
|
|
|
export class UrlScanIo implements INodeType {
|
|
description: INodeTypeDescription = {
|
|
displayName: 'urlscan.io',
|
|
name: 'urlScanIo',
|
|
icon: 'file:urlScanIo.svg',
|
|
group: ['transform'],
|
|
version: 1,
|
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
description: 'Provides various utilities for monitoring websites like health checks or screenshots',
|
|
defaults: {
|
|
name: 'urlscan.io',
|
|
},
|
|
inputs: ['main'],
|
|
outputs: ['main'],
|
|
credentials: [
|
|
{
|
|
name: 'urlScanIoApi',
|
|
required: true,
|
|
},
|
|
],
|
|
properties: [
|
|
{
|
|
displayName: 'Resource',
|
|
name: 'resource',
|
|
noDataExpression: true,
|
|
type: 'options',
|
|
options: [
|
|
{
|
|
name: 'Scan',
|
|
value: 'scan',
|
|
},
|
|
],
|
|
default: 'scan',
|
|
},
|
|
...scanOperations,
|
|
...scanFields,
|
|
],
|
|
};
|
|
|
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
const items = this.getInputData();
|
|
const returnData: IDataObject[] = [];
|
|
|
|
const resource = this.getNodeParameter('resource', 0) as 'scan';
|
|
const operation = this.getNodeParameter('operation', 0) as 'perform' | 'get' | 'getAll';
|
|
|
|
let responseData;
|
|
|
|
for (let i = 0; i < items.length; i++) {
|
|
|
|
try {
|
|
|
|
if (resource === 'scan') {
|
|
|
|
// **********************************************************************
|
|
// scan
|
|
// **********************************************************************
|
|
|
|
if (operation === 'get') {
|
|
|
|
// ----------------------------------------
|
|
// scan: get
|
|
// ----------------------------------------
|
|
|
|
const scanId = this.getNodeParameter('scanId', i) as string;
|
|
responseData = await urlScanIoApiRequest.call(this, 'GET', `/result/${scanId}`);
|
|
|
|
} else if (operation === 'getAll') {
|
|
|
|
// ----------------------------------------
|
|
// scan: getAll
|
|
// ----------------------------------------
|
|
|
|
// https://urlscan.io/docs/search
|
|
|
|
const filters = this.getNodeParameter('filters', i) as { query?: string };
|
|
|
|
const qs: IDataObject = {};
|
|
|
|
if (filters?.query) {
|
|
qs.q = filters.query;
|
|
}
|
|
|
|
responseData = await handleListing.call(this, '/search', qs);
|
|
responseData = responseData.map(normalizeId);
|
|
|
|
} else if (operation === 'perform') {
|
|
|
|
// ----------------------------------------
|
|
// scan: perform
|
|
// ----------------------------------------
|
|
|
|
// https://urlscan.io/docs/search
|
|
|
|
const {
|
|
tags: rawTags,
|
|
...rest
|
|
} = this.getNodeParameter('additionalFields', i) as {
|
|
customAgent?: string;
|
|
visibility?: 'public' | 'private' | 'unlisted';
|
|
tags?: string;
|
|
referer?: string;
|
|
overrideSafety: string;
|
|
};
|
|
|
|
const body: IDataObject = {
|
|
url: this.getNodeParameter('url', i) as string,
|
|
...rest,
|
|
};
|
|
|
|
if (rawTags) {
|
|
const tags = rawTags.split(',').map(tag => tag.trim());
|
|
|
|
if (tags.length > 10) {
|
|
throw new NodeOperationError(
|
|
this.getNode(),
|
|
'Please enter at most 10 tags', { itemIndex: i },
|
|
);
|
|
}
|
|
|
|
body.tags = tags;
|
|
}
|
|
|
|
responseData = await urlScanIoApiRequest.call(this, 'POST', '/scan', body);
|
|
responseData = normalizeId(responseData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Array.isArray(responseData)
|
|
? returnData.push(...responseData)
|
|
: returnData.push(responseData);
|
|
|
|
} catch (error) {
|
|
if (this.continueOnFail()) {
|
|
returnData.push({ error: error.message });
|
|
continue;
|
|
}
|
|
throw error;
|
|
}
|
|
|
|
}
|
|
|
|
return [this.helpers.returnJsonArray(returnData)];
|
|
}
|
|
}
|