aboutsummaryrefslogtreecommitdiff
path: root/fprox.go
blob: 214ef9a7a67414cbe7e21e7a4f46b4ac7afc0cbb (plain)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
package app

import (
	"encoding/json"
	"fmt"
	"io"
	"net/http"
)

// CveHasExploits fetches the fprox report for the given CVE and reports
// whether it contains any proof-of-concept or exploitation artifacts.
func CveHasExploits(cve string) (bool, error) {
	url := fmt.Sprintf("https://fprox.hrbrmstr.app/cve/%s", cve)
	resp, err := http.Get(url)
	if err != nil {
		return false, err
	}
	defer resp.Body.Close()

	body, err := io.ReadAll(resp.Body)
	if err != nil {
		return false, err
	}

	r, err := UnmarshalFproxResponse(body)
	if err != nil {
		return false, err
	}

	if len(r.Props.PageProps.CveInfo.ProofOfConcepts) > 0 {
		return true, nil
	}

	if len(r.Props.PageProps.CveInfo.ExploitedAt) > 0 {
		return true, nil
	}

	return false, nil
}

func UnmarshalFproxResponse(data []byte) (FproxResponse, error) {
	var r FproxResponse
	err := json.Unmarshal(data, &r)
	return r, err
}

func (r *FproxResponse) Marshal() ([]byte, error) {
	return json.Marshal(r)
}

type FproxResponse struct {
	Props                 Props         `json:"props"`
	Page                  string        `json:"page"`
	Query                 Query         `json:"query"`
	BuildID               string        `json:"buildId"`
	AssetPrefix           string        `json:"assetPrefix"`
	IsFallback            bool          `json:"isFallback"`
	IsExperimentalCompile bool          `json:"isExperimentalCompile"`
	Gsp                   bool          `json:"gsp"`
	ScriptLoader          []interface{} `json:"scriptLoader"`
}

type Props struct {
	PageProps PageProps `json:"pageProps"`
	NSsg      bool      `json:"__N_SSG"`
}

type PageProps struct {
	AdvisoryEntry         Entry         `json:"advisoryEntry"`
	Categories            []Category    `json:"categories"`
	ChatterEntries        []Entry       `json:"chatterEntries"`
	CveInfo               CveInfo       `json:"cveInfo"`
	Events                []Event       `json:"events"`
	GraphMarkup           string        `json:"graphMarkup"`
	ReferenceEntries      []interface{} `json:"referenceEntries"`
	TotalChatterEntries   int64         `json:"totalChatterEntries"`
	TotalReferenceEntries int64         `json:"totalReferenceEntries"`
}

type Entry struct {
	Crawled     int64   `json:"crawled"`
	ID          string  `json:"id"`
	Origin      Origin  `json:"origin"`
	Title       string  `json:"title"`
	Description string  `json:"description"`
	SourceLink  string  `json:"sourceLink"`
	Visual      *Visual `json:"visual,omitempty"`
}

type Origin struct {
	StreamID string `json:"streamId"`
	Title    string `json:"title"`
	HTMLURL  string `json:"htmlUrl"`
}

type Visual struct {
	URL         string  `json:"url"`
	ContentType *string `json:"contentType,omitempty"`
	Height      *int64  `json:"height,omitempty"`
	Processor   *string `json:"processor,omitempty"`
	Width       *int64  `json:"width,omitempty"`
}

type Category struct {
	NumSimilarVulnerabilities int64  `json:"numSimilarVulnerabilities"`
	Label                     string `json:"label"`
	URI                       string `json:"uri"`
}

type CveInfo struct {
	Cveid                    string                     `json:"cveid"`
	ID                       string                     `json:"id"`
	Type                     string                     `json:"type"`
	Label                    string                     `json:"label"`
	HasSalience              bool                       `json:"hasSalience"`
	AdvisoryURL              string                     `json:"advisoryUrl"`
	CveStatus                string                     `json:"cveStatus"`
	Description              string                     `json:"description"`
	CvssCategoryEstimate     string                     `json:"cvssCategoryEstimate"`
	CvssV3                   CvssV3                     `json:"cvssV3"`
	CweIDS                   []CweID                    `json:"cweIds"`
	SmallGraphURL            string                     `json:"smallGraphUrl"`
	GraphURL                 string                     `json:"graphUrl"`
	EpssScore                string                     `json:"epssScore"`
	PatchDetails             []PatchDetail              `json:"patchDetails"`
	Patched                  bool                       `json:"patched"`
	DetectedBy               []DetectedBy               `json:"detectedBy"`
	FeedlyInsertedDate       string                     `json:"feedlyInsertedDate"`
	FeedlyUpdatedDate        string                     `json:"feedlyUpdatedDate"`
	PublishedDate            string                     `json:"publishedDate"`
	PublicationDateInfo      []PublicationDateInfo      `json:"publicationDateInfo"`
	AffectedProductsEstimate []AffectedProductsEstimate `json:"affectedProductsEstimate"`
	IDMapping                []interface{}              `json:"idMapping"`
	Timeline                 []Timeline                 `json:"timeline"`
	ExecutiveSummary         ExecutiveSummary           `json:"executiveSummary"`
	Stats                    Stats                      `json:"stats"`
	ExploitedAt              []interface{}              `json:"exploitedAt"`
	ProofOfConcepts          []interface{}              `json:"proofOfConcepts"`
	Products                 []VendorElement            `json:"products"`
	Vendors                  []VendorElement            `json:"vendors"`
}

type AffectedProductsEstimate struct {
	Products []AffectedProductsEstimateProduct `json:"products"`
	Vendor   string                            `json:"vendor"`
}

type AffectedProductsEstimateProduct struct {
	Name string `json:"name"`
}

type CvssV3 struct {
	PrivilegesRequired    string  `json:"privilegesRequired"`
	VectorString          string  `json:"vectorString"`
	BaseScore             float64 `json:"baseScore"`
	Scope                 string  `json:"scope"`
	UserInteraction       string  `json:"userInteraction"`
	ConfidentialityImpact string  `json:"confidentialityImpact"`
	AvailabilityImpact    string  `json:"availabilityImpact"`
	AttackComplexity      string  `json:"attackComplexity"`
	AttackVector          string  `json:"attackVector"`
	Version               string  `json:"version"`
	IntegrityImpact       string  `json:"integrityImpact"`
}

type CweID struct {
	CweID string `json:"cweID"`
	Name  string `json:"name"`
}

type DetectedBy struct {
	ScannerName string `json:"scannerName"`
	DetectionID string `json:"detectionId"`
}

type ExecutiveSummary struct {
	Description  string `json:"description"`
	Patch        string `json:"patch"`
	Mitigation   string `json:"mitigation"`
	Exploitation string `json:"exploitation"`
	Impact       string `json:"impact"`
}

type PatchDetail struct {
	Title                string `json:"title"`
	Source               string `json:"source"`
	PatchAddedDate       string `json:"patchAddedDate"`
	URL                  string `json:"url"`
	FeedlyPatchAddedDate string `json:"feedlyPatchAddedDate"`
}

type VendorElement struct {
	ID     string `json:"id"`
	Label  string `json:"label"`
	Origin string `json:"origin"`
}

type PublicationDateInfo struct {
	FeedlyUpdatedDate  *string `json:"feedlyUpdatedDate,omitempty"`
	Source             string  `json:"source"`
	PublishedDate      string  `json:"publishedDate"`
	FeedlyInsertedDate *string `json:"feedlyInsertedDate,omitempty"`
	LastModifiedDate   string  `json:"lastModifiedDate"`
}

type Stats struct {
	FirstEntryID    string                `json:"firstEntryId"`
	TimeSeries      map[string][]TimeSery `json:"timeSeries"`
	AdvisoryEntryID string                `json:"advisoryEntryId"`
	FirstTimestamp  int64                 `json:"firstTimestamp"`
}

type TimeSery struct {
	URL          string   `json:"url"`
	FirstEntryID string   `json:"firstEntryId"`
	Age          int64    `json:"age"`
	Timestamp    int64    `json:"timestamp"`
	SourceType   []string `json:"sourceType,omitempty"`
}

type Timeline struct {
	Event  string `json:"event"`
	Date   string `json:"date"`
	Source string `json:"source"`
}

type Event struct {
	ID                   string         `json:"id"`
	Type                 string         `json:"type"`
	Ts                   int64          `json:"ts"`
	Updated              int64          `json:"updated"`
	EntryID              *string        `json:"entryId,omitempty"`
	SourceName           *string        `json:"sourceName,omitempty"`
	CvssCategoryEstimate *string        `json:"cvssCategoryEstimate,omitempty"`
	Score                *float64       `json:"score,omitempty"`
	Update               *bool          `json:"update,omitempty"`
	Percentile           *float64       `json:"percentile,omitempty"`
	URL                  *string        `json:"url,omitempty"`
	VendorName           *string        `json:"vendorName,omitempty"`
	ModuleID             *string        `json:"moduleId,omitempty"`
	ScannerName          *string        `json:"scannerName,omitempty"`
	GroupedEvents        []GroupedEvent `json:"groupedEvents,omitempty"`
	AdvisoryID           *string        `json:"advisoryId,omitempty"`
}

type GroupedEvent struct {
	ID          string `json:"id"`
	Type        string `json:"type"`
	Ts          int64  `json:"ts"`
	Updated     int64  `json:"updated"`
	ModuleID    string `json:"moduleId"`
	ScannerName string `json:"scannerName"`
}

type Query struct {
	CveID string `json:"cveId"`
}