-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsearch.go
102 lines (97 loc) · 2.57 KB
/
search.go
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
91
92
93
94
95
96
97
98
99
100
101
102
package pulsedive
import (
"net/url"
)
// SearchIndicators implement api Search Indicators
func SearchIndicators(value string, attributes []string, threats []string, feeds []string) ([]byte, error) {
q := url.Values{}
q.Add("value", value)
for _, indicatorType := range indicatorTypes {
q.Add("type[]", indicatorType)
}
for _, risk := range risks {
q.Add("risk[]", risk)
}
for _, attribute := range attributes {
q.Add("attribute[]", attribute)
}
q.Add("property", "content-type:text/html")
for _, threat := range threats {
q.Add("threat[]", threat)
}
for _, feed := range feeds {
q.Add("feed[]", feed)
}
q.Add("limit", "hundred")
q.Add("pretty", pretty)
q.Add("key", apiKey)
return Get(q.Encode(), "/search.php")
}
// SearchToCSV implement api Search Exporting to CSV
func SearchToCSV(value string, attributes []string, threats []string, feeds []string) ([]byte, error) {
q := url.Values{}
q.Add("value", value)
q.Add("property", "content-type:text/html")
for _, indicatorType := range indicatorTypes {
q.Add("type[]", indicatorType)
}
for _, risk := range risks {
q.Add("risk[]", risk)
}
for _, attribute := range attributes {
q.Add("attribute[]", attribute)
}
q.Add("property", "content-type:text/html")
for _, threat := range threats {
q.Add("threat[]", threat)
}
for _, feed := range feeds {
q.Add("feed[]", feed)
}
q.Add("limit", "hundred")
q.Add("export", "1")
q.Add("pretty", pretty)
q.Add("key", apiKey)
return Get(q.Encode(), "/search.php")
}
// SearchThreat implement api Search Threats
func SearchThreat(value string, attributes []string, threats []string, feeds []string) ([]byte, error) {
q := url.Values{}
q.Add("search", "threat")
q.Add("value", value)
for _, category := range categories {
q.Add("category[]", category)
}
for _, risk := range risks {
q.Add("risk[]", risk)
}
for _, attribute := range attributes {
q.Add("attribute[]", attribute)
}
q.Add("property", "content-type:text/html")
for _, threat := range threats {
q.Add("threat[]", threat)
}
for _, feed := range feeds {
q.Add("feed[]", feed)
}
q.Add("property", "content-type:text/html")
q.Add("limit", "hundred")
q.Add("splitrisk", "1")
q.Add("pretty", pretty)
q.Add("key", apiKey)
return Get(q.Encode(), "/search.php")
}
// SearchFeed implement api Search Feeds
func SearchFeed(value string) ([]byte, error) {
q := url.Values{}
q.Add("search", "feed")
q.Add("value", value)
for _, category := range categories {
q.Add("category[]", category)
}
q.Add("splitrisk", "1")
q.Add("pretty", pretty)
q.Add("key", apiKey)
return Get(q.Encode(), "/search.php")
}