Skip to content

Commit

Permalink
SecurityTrails: New action components (#13808)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcortes authored Sep 5, 2024
1 parent 2709077 commit a343bc8
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import app from "../../securitytrails.app.mjs";

export default {
key: "securitytrails-get-domain-details",
name: "Get Domain Details",
description: "Returns the current data about the given hostname. [See the documentation](https://docs.securitytrails.com/reference/domain-details)",
version: "0.0.1",
type: "action",
props: {
app,
hostname: {
propDefinition: [
app,
"hostname",
],
},
},
methods: {
getDomainDetails({
hostname, ...args
} = {}) {
return this.app._makeRequest({
path: `/domain/${hostname}`,
...args,
});
},
},
async run({ $ }) {
const {
getDomainDetails,
hostname,
} = this;

const response = await getDomainDetails({
$,
hostname,
});
$.export("$summary", `Successfully retrieved details for hostname \`${response.hostname}\`.`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import app from "../../securitytrails.app.mjs";

export default {
key: "securitytrails-get-history-dns",
name: "Get Historical DNS",
description: "Lists out specific historical information about the given hostname parameter. [See the documentation](https://docs.securitytrails.com/reference/history-dns)",
version: "0.0.1",
type: "action",
props: {
app,
hostname: {
propDefinition: [
app,
"hostname",
],
},
type: {
type: "string",
label: "Record Type",
description: "Select the DNS record type to query historical data for.",
options: [
{
label: "A",
value: "a",
},
{
label: "AAAA",
value: "aaaa",
},
{
label: "MX",
value: "mx",
},
{
label: "NS",
value: "ns",
},
{
label: "SOA",
value: "soa",
},
{
label: "TXT",
value: "txt",
},
],
},
},
methods: {
getHistoryDns({
hostname, type, ...args
} = {}) {
return this.app._makeRequest({
path: `/history/${hostname}/dns/${type}`,
...args,
});
},
},
async run({ $ }) {
const {
getHistoryDns,
hostname,
type,
} = this;

const response = await getHistoryDns({
$,
hostname,
type,
});
$.export("$summary", `Successfully retrieved historical DNS data for type \`${response.type}\`.`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import app from "../../securitytrails.app.mjs";

export default {
key: "securitytrails-get-ips-neighbors",
name: "Get IPs Neighbors",
description: "Returns the neighbors in any given IP level range and essentially allows you to explore closeby IP addresses.",
version: "0.0.1",
type: "action",
props: {
app,
ipaddress: {
type: "string",
label: "IP Address",
description: "Enter the IP address to find neighbors for. Eg. `8.8.8.8`.",
},
},
methods: {
getIpNeighbors({
ipaddress, ...args
}) {
return this.app._makeRequest({
path: `/ips/nearby/${ipaddress}`,
...args,
});
},
},
async run({ $ }) {
const {
getIpNeighbors,
ipaddress,
} = this;

const response = await getIpNeighbors({
$,
ipaddress,
});

$.export("$summary", `Successfully retrieved \`${response?.blocks.length}\` neighbor(s).`);
return response;
},
};
7 changes: 7 additions & 0 deletions components/securitytrails/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const BASE_URL = "https://api.securitytrails.com";
const VERSION_PATH = "/v1";

export default {
BASE_URL,
VERSION_PATH,
};
7 changes: 5 additions & 2 deletions components/securitytrails/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/securitytrails",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream SecurityTrails Components",
"main": "securitytrails.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "3.0.1"
}
}
}
33 changes: 28 additions & 5 deletions components/securitytrails/securitytrails.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "securitytrails",
propDefinitions: {},
propDefinitions: {
hostname: {
type: "string",
label: "Hostname",
description: "Enter the hostname to query information for. Eg. `oracle.com`",
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
getUrl(path) {
return `${constants.BASE_URL}${constants.VERSION_PATH}${path}`;
},
getHeaders(headers = {}) {
return {
...headers,
APIKEY: this.$auth.api_key,
};
},
_makeRequest({
$ = this, path, headers, ...args
} = {}) {
return axios($, {
...args,
url: this.getUrl(path),
headers: this.getHeaders(headers),
});
},
},
};
};
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a343bc8

Please sign in to comment.