Added an api endpoint filter and updated the README
This commit is contained in:
parent
1fe6bacbc2
commit
eef075e899
4 changed files with 20 additions and 1 deletions
15
README.md
15
README.md
|
@ -9,6 +9,13 @@ A tool that sends configurable email notifications for
|
||||||
|
|
||||||
This Software only supports Linux.
|
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
|
# Config
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
@ -57,7 +64,8 @@ You must filter the notices to be sent per user. Multiple filters can be set per
|
||||||
"min_basescore": 0,
|
"min_basescore": 0,
|
||||||
"status": "",
|
"status": "",
|
||||||
"products_contain": "",
|
"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.
|
If set to `""`, this criteria will be ignored.
|
||||||
|
|
||||||
|
### api_endpoint
|
||||||
|
|
||||||
|
Includes notices from the given [API Endpoint](#supported-api-endpoints).
|
||||||
|
|
||||||
## Templates
|
## Templates
|
||||||
|
|
||||||
The syntax for the mail templates is described [here](https://pkg.go.dev/text/template).
|
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
|
Cves []string // empty = unknown
|
||||||
NoPatch string // "" = unknown
|
NoPatch string // "" = unknown
|
||||||
// metadata
|
// metadata
|
||||||
|
ApiEndpointId string
|
||||||
PortalUrl string
|
PortalUrl string
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -12,6 +12,7 @@ type Filter struct {
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
ProductsContain string `json:"products_contain"`
|
ProductsContain string `json:"products_contain"`
|
||||||
NoPatch string `json:"no_patch"`
|
NoPatch string `json:"no_patch"`
|
||||||
|
ApiEndpointId string `json:"api_endpoint"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f Filter) filter(notices []WidNotice) []WidNotice {
|
func (f Filter) filter(notices []WidNotice) []WidNotice {
|
||||||
|
@ -40,6 +41,9 @@ func (f Filter) filter(notices []WidNotice) []WidNotice {
|
||||||
if f.NoPatch != "" {
|
if f.NoPatch != "" {
|
||||||
matches = append(matches, f.NoPatch == n.NoPatch)
|
matches = append(matches, f.NoPatch == n.NoPatch)
|
||||||
}
|
}
|
||||||
|
if f.ApiEndpointId != "" {
|
||||||
|
matches = append(matches, f.ApiEndpointId == n.ApiEndpointId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
allMatch := len(matches) > 0
|
allMatch := len(matches) > 0
|
||||||
for _, m := range matches {
|
for _, m := range matches {
|
||||||
|
|
|
@ -19,6 +19,7 @@ type WidNotice struct {
|
||||||
Cves []string `json:"cves"` // empty = unknown
|
Cves []string `json:"cves"` // empty = unknown
|
||||||
NoPatch string `json:"noPatch"` // "" = unknown
|
NoPatch string `json:"noPatch"` // "" = unknown
|
||||||
// metadata
|
// metadata
|
||||||
|
ApiEndpointId string
|
||||||
PortalUrl string
|
PortalUrl string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,7 @@ func parseApiResponse(data map[string]interface{}, apiEndpoint ApiEndpoint) []Wi
|
||||||
Name: d["name"].(string),
|
Name: d["name"].(string),
|
||||||
Title: d["title"].(string),
|
Title: d["title"].(string),
|
||||||
Classification: d["classification"].(string),
|
Classification: d["classification"].(string),
|
||||||
|
ApiEndpointId: apiEndpoint.Id,
|
||||||
}
|
}
|
||||||
published, err := time.Parse(PUBLISHED_TIME_FORMAT, d["published"].(string))
|
published, err := time.Parse(PUBLISHED_TIME_FORMAT, d["published"].(string))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue