From eef075e899178ea18a59b6c8cd4d411d168c108a Mon Sep 17 00:00:00 2001 From: ChaoticByte Date: Fri, 13 Oct 2023 19:58:24 +0200 Subject: [PATCH] Added an api endpoint filter and updated the README --- README.md | 15 ++++++++++++++- filter.go | 4 ++++ notice.go | 1 + widapi.go | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ca05210..de5176e 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,13 @@ A tool that sends configurable email notifications for This Software only supports Linux. +## Supported API Endpoints + +| ID | Portal URL | +|--------|-------------------------------------------------------| +| `bund` | https://wid.cert-bund.de/portal/wid/kurzinformationen | +| `bay` | https://wid.lsi.bayern.de/portal/wid/warnmeldungen | + # Config Example: @@ -57,7 +64,8 @@ You must filter the notices to be sent per user. Multiple filters can be set per "min_basescore": 0, "status": "", "products_contain": "", - "no_patch": "" + "no_patch": "", + "api_endpoint": "" }, ... ] @@ -135,6 +143,10 @@ If set to `"false"`, notices where no patch is available will be included. If set to `""`, this criteria will be ignored. +### api_endpoint + +Includes notices from the given [API Endpoint](#supported-api-endpoints). + ## Templates The syntax for the mail templates is described [here](https://pkg.go.dev/text/template). @@ -155,6 +167,7 @@ type WidNotice struct { Cves []string // empty = unknown NoPatch string // "" = unknown // metadata + ApiEndpointId string PortalUrl string } ``` diff --git a/filter.go b/filter.go index 8c32671..2fa7398 100644 --- a/filter.go +++ b/filter.go @@ -12,6 +12,7 @@ type Filter struct { Status string `json:"status"` ProductsContain string `json:"products_contain"` NoPatch string `json:"no_patch"` + ApiEndpointId string `json:"api_endpoint"` } func (f Filter) filter(notices []WidNotice) []WidNotice { @@ -40,6 +41,9 @@ func (f Filter) filter(notices []WidNotice) []WidNotice { if f.NoPatch != "" { matches = append(matches, f.NoPatch == n.NoPatch) } + if f.ApiEndpointId != "" { + matches = append(matches, f.ApiEndpointId == n.ApiEndpointId) + } } allMatch := len(matches) > 0 for _, m := range matches { diff --git a/notice.go b/notice.go index 6c01087..e07c6b8 100644 --- a/notice.go +++ b/notice.go @@ -19,6 +19,7 @@ type WidNotice struct { Cves []string `json:"cves"` // empty = unknown NoPatch string `json:"noPatch"` // "" = unknown // metadata + ApiEndpointId string PortalUrl string } diff --git a/widapi.go b/widapi.go index fa85110..f4c9830 100644 --- a/widapi.go +++ b/widapi.go @@ -98,6 +98,7 @@ func parseApiResponse(data map[string]interface{}, apiEndpoint ApiEndpoint) []Wi Name: d["name"].(string), Title: d["title"].(string), Classification: d["classification"].(string), + ApiEndpointId: apiEndpoint.Id, } published, err := time.Parse(PUBLISHED_TIME_FORMAT, d["published"].(string)) if err != nil {