Skip to content

Commit a343bc8

Browse files
authored
SecurityTrails: New action components (#13808)
1 parent 2709077 commit a343bc8

File tree

7 files changed

+200
-8
lines changed

7 files changed

+200
-8
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import app from "../../securitytrails.app.mjs";
2+
3+
export default {
4+
key: "securitytrails-get-domain-details",
5+
name: "Get Domain Details",
6+
description: "Returns the current data about the given hostname. [See the documentation](https://docs.securitytrails.com/reference/domain-details)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
hostname: {
12+
propDefinition: [
13+
app,
14+
"hostname",
15+
],
16+
},
17+
},
18+
methods: {
19+
getDomainDetails({
20+
hostname, ...args
21+
} = {}) {
22+
return this.app._makeRequest({
23+
path: `/domain/${hostname}`,
24+
...args,
25+
});
26+
},
27+
},
28+
async run({ $ }) {
29+
const {
30+
getDomainDetails,
31+
hostname,
32+
} = this;
33+
34+
const response = await getDomainDetails({
35+
$,
36+
hostname,
37+
});
38+
$.export("$summary", `Successfully retrieved details for hostname \`${response.hostname}\`.`);
39+
return response;
40+
},
41+
};
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import app from "../../securitytrails.app.mjs";
2+
3+
export default {
4+
key: "securitytrails-get-history-dns",
5+
name: "Get Historical DNS",
6+
description: "Lists out specific historical information about the given hostname parameter. [See the documentation](https://docs.securitytrails.com/reference/history-dns)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
hostname: {
12+
propDefinition: [
13+
app,
14+
"hostname",
15+
],
16+
},
17+
type: {
18+
type: "string",
19+
label: "Record Type",
20+
description: "Select the DNS record type to query historical data for.",
21+
options: [
22+
{
23+
label: "A",
24+
value: "a",
25+
},
26+
{
27+
label: "AAAA",
28+
value: "aaaa",
29+
},
30+
{
31+
label: "MX",
32+
value: "mx",
33+
},
34+
{
35+
label: "NS",
36+
value: "ns",
37+
},
38+
{
39+
label: "SOA",
40+
value: "soa",
41+
},
42+
{
43+
label: "TXT",
44+
value: "txt",
45+
},
46+
],
47+
},
48+
},
49+
methods: {
50+
getHistoryDns({
51+
hostname, type, ...args
52+
} = {}) {
53+
return this.app._makeRequest({
54+
path: `/history/${hostname}/dns/${type}`,
55+
...args,
56+
});
57+
},
58+
},
59+
async run({ $ }) {
60+
const {
61+
getHistoryDns,
62+
hostname,
63+
type,
64+
} = this;
65+
66+
const response = await getHistoryDns({
67+
$,
68+
hostname,
69+
type,
70+
});
71+
$.export("$summary", `Successfully retrieved historical DNS data for type \`${response.type}\`.`);
72+
return response;
73+
},
74+
};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import app from "../../securitytrails.app.mjs";
2+
3+
export default {
4+
key: "securitytrails-get-ips-neighbors",
5+
name: "Get IPs Neighbors",
6+
description: "Returns the neighbors in any given IP level range and essentially allows you to explore closeby IP addresses.",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
ipaddress: {
12+
type: "string",
13+
label: "IP Address",
14+
description: "Enter the IP address to find neighbors for. Eg. `8.8.8.8`.",
15+
},
16+
},
17+
methods: {
18+
getIpNeighbors({
19+
ipaddress, ...args
20+
}) {
21+
return this.app._makeRequest({
22+
path: `/ips/nearby/${ipaddress}`,
23+
...args,
24+
});
25+
},
26+
},
27+
async run({ $ }) {
28+
const {
29+
getIpNeighbors,
30+
ipaddress,
31+
} = this;
32+
33+
const response = await getIpNeighbors({
34+
$,
35+
ipaddress,
36+
});
37+
38+
$.export("$summary", `Successfully retrieved \`${response?.blocks.length}\` neighbor(s).`);
39+
return response;
40+
},
41+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const BASE_URL = "https://api.securitytrails.com";
2+
const VERSION_PATH = "/v1";
3+
4+
export default {
5+
BASE_URL,
6+
VERSION_PATH,
7+
};

components/securitytrails/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/securitytrails",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream SecurityTrails Components",
55
"main": "securitytrails.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "3.0.1"
1417
}
15-
}
18+
}
Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,34 @@
1+
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
3+
14
export default {
25
type: "app",
36
app: "securitytrails",
4-
propDefinitions: {},
7+
propDefinitions: {
8+
hostname: {
9+
type: "string",
10+
label: "Hostname",
11+
description: "Enter the hostname to query information for. Eg. `oracle.com`",
12+
},
13+
},
514
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
15+
getUrl(path) {
16+
return `${constants.BASE_URL}${constants.VERSION_PATH}${path}`;
17+
},
18+
getHeaders(headers = {}) {
19+
return {
20+
...headers,
21+
APIKEY: this.$auth.api_key,
22+
};
23+
},
24+
_makeRequest({
25+
$ = this, path, headers, ...args
26+
} = {}) {
27+
return axios($, {
28+
...args,
29+
url: this.getUrl(path),
30+
headers: this.getHeaders(headers),
31+
});
932
},
1033
},
11-
};
34+
};

pnpm-lock.yaml

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)