-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhar-scan-req-domains-report.jq
90 lines (67 loc) · 1.62 KB
/
har-scan-req-domains-report.jq
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# This script traverses a HAR file and scans it for a list of unique domains (distinct from unique urls) that were called. Each domain is followed by a list of numbers indicating the HAR file entry.
# save the original HAR file to a variable; we'll need that later.
. as $original
|
# get the original entries
.log.entries
|
# get all the index numbers for the entries
keys
|
#create an array
[
# for each entry, save the index number for later
.[] as $index
|
#by going through the log and getting each entry
$original.log.entries[$index]
#and pulling the URL from each one
.request.url
#now we've got a list of URLs
|
# hack off everything after the domain
capture("(?<domain>^http[s]?://.*?)[/?]")
|
#now we have a JSON object from which we can pull the domain
[$index, .domain]
]
|
# save where we are
. as $original
|
# make an array out of all the domains
[
.[].[1]
]
|
# get rid of the duplicates
unique
|
# iterate through each of the unique domains
.[] as $key
|
# enclose in an array so that we can get the TSV, later
[
# print the domain as the first column
$key,
# collect all the entry numbers into a text list
(
# enclose in an array...
[
# now start from the top...
$original[]
|
# ...and search for any entry with the current domain...
select(.[1] == $key)
|
# ...and grab that for our list.
.[0]
]
|
# turn the collected list into a comma-separated list
@csv
)
]
|
# turn the final array into a tab-separated list
@tsv