-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautomation-IsIPInRanges.yml
66 lines (60 loc) · 1.7 KB
/
automation-IsIPInRanges.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
commonfields:
id: IsIPInRanges
version: -1
name: IsIPInRanges
script: |
var private_subnets = [
'172.16.0.0/12',
'10.0.0.0/8',
'198.18.0.0/15',
'192.168.0.0/16',
'100.64.0.0/10',
'192.0.0.0/24'
];
var ip = args.ip;
var ipranges = argToList(args.ipRanges);
if (!ipranges || ipranges.length === 0) {
ipranges = private_subnets;
}
var isInRange = ipranges.some(function(iprange) {
return isIPInSubnet(ip, iprange.replace(/[\s]/g, ''));
});
var ipObj = {};
ipObj.Address = ip;
ipObj.InRange = isInRange ? 'yes' : 'no';
var ec = {'IP(val.Address == obj.Address)' : ipObj};
return {
Type: entryTypes.note,
Contents: isInRange ? 'yes' : 'no',
ContentsFormat: formats.text,
EntryContext: ec
};
type: javascript
tags:
- ip
comment: Returns yes if the IP is in one of the ranges provided, returns no otherwise.
enabled: true
system: true
args:
- name: ip
required: true
default: true
description: IP to check in ranges
- name: ipRanges
description: 'A list of IP ranges to check the IP in. The list should be provided
in CIDR notation, separated by commas. An example of a list of ranges would be:
"172.16.0.0/12,10.0.0.0/8,192.168.0.0/16" (without quotes). If a list is not provided,
will use default list provided in the IsIPInRanges script (the known IPv4 private
address ranges).'
outputs:
- contextPath: "yes"
description: if given value is an IP range
- contextPath: "no"
description: if given value is not a IP range
- contextPath: IP.Address
description: The IP Address
- contextPath: IP.InRange
description: Is the IP is in the input ranges? (could be 'yes' or 'no)
scripttarget: 0
runonce: false
runas: DBotWeakRole