Server.Monitoring.RSSFeeds
Type: Server event (monitoring)
Polls RSS feeds at a configurable interval and alerts users about new items.
By default this artifact follows the Atlantiraptor security advisories feed, so every console user is told once about each new advisory.
The server runs its server monitoring artifacts in every org, but console notices belong to the user, not the org. So only the root org polls the feeds, and it notifies each matching user of every org once. In other orgs this artifact does nothing.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
FeedURLs |
csv | (see the artifact source) | |
Period |
int | 600 |
How often to check for changes. |
UserRegex |
string | . |
Send message to all users matching this regex |
AgeDays |
int | 7 |
The age in days we report a change |
Source
Defined in artifacts/definitions/Server/Monitoring/RSSFeeds.yaml.
name: Server.Monitoring.RSSFeeds
description: |
Polls RSS feeds at a configurable interval and alerts users about
new items.
By default this artifact follows the Atlantiraptor security
advisories feed, so every console user is told once about each new
advisory.
The server runs its server monitoring artifacts in every org, but
console notices belong to the user, not the org. So only the root org
polls the feeds, and it notifies each matching user of every org
once. In other orgs this artifact does nothing.
type: SERVER_EVENT
parameters:
- name: FeedURLs
type: csv
default: |
URL
https://atlantsecurity.github.io/atlantiraptor/security/advisories/index.xml
- name: Period
type: int
default: "600"
description: How often to check for changes.
- name: UserRegex
default: .
description: Send message to all users matching this regex
- name: AgeDays
description: The age in days we report a change
type: int
default: 7
export: |
// Each user once, even when they belong to several orgs.
LET _Users = SELECT name FROM gui_users(all_orgs=TRUE)
WHERE name =~ UserRegex
GROUP BY name
LET _Send(Message) =
SELECT user_message(user=name, message=Message) AS User
FROM _Users
LET Send(Message) = _Send(Message=Message).User
// URLs - an array of URLs
LET RSS(URLs) = SELECT * FROM foreach(row=URLs,
query={
SELECT parse_xml(accessor="data", file=Content) AS XML
FROM http_client(url=_value)
WHERE Response = 200
})
LET AgeSeconds <= AgeDays * 24 * 60 * 60
LET GetRSS(URLs) = SELECT *
FROM foreach(row={
SELECT * FROM RSS(URLs=URLs)
},
query={
SELECT guid,
title,
link,
timestamp(string=pubDate) AS pubDate
FROM foreach(row=XML.rss.channel.item, column="_value")
WHERE now() - AgeSeconds < pubDate.Unix
})
sources:
- query: |
// Only the root org polls the feeds; see the description.
LET IsRootOrg <= org().id = "root"
LET URLs <= FeedURLs.URL
// Create the initial cache and watch for changes.
LET m <= if(condition=IsRootOrg,
then=to_dict(item={
SELECT guid AS _key,
dict(title=title, link=link, pubDate=pubDate) AS _value
FROM GetRSS(URLs=URLs)
}),
else=dict())
LET Watch = SELECT *
FROM foreach(row={
SELECT *
FROM clock(period=Period)
},
query={
SELECT *,
Send(Message=dict(title=title, link=link, date=pubDate)) AS Users
FROM GetRSS(URLs=URLs)
WHERE NOT get(item=m, field=guid)
AND set(item=m,
field=guid,
value=dict(title=title, link=link, pubDate=pubDate))
AND log(message="Sending message to %v", args=[Users,])
})
SELECT *
FROM if(condition=IsRootOrg,
then=Watch,
else={
SELECT *
FROM scope()
WHERE log(message="RSS feeds are polled by the root org only")
AND FALSE
})
column_types:
- name: link
type: url