Skip to content

Cyber Watch

The functions of cyber_watch.core, taken from their docstrings.

cyber_watch.core

severity_of(score, version=3)

The label of a score: LOW, MEDIUM, HIGH or CRITICAL (a CVSS 2.0 score is never critical); '' for 0.

v3_score(vector)

The base score of a CVSS 3.0 / 3.1 vector ("CVSS:3.1/AV:N/AC:L/..."), None when it is not a valid one.

best_cvss(item)

(score, severity) of an advisory: the CVSS 3.x score if there is one, else 4.0, else 2.0; the highest of those of the same version. When only a vector is given, the score is computed from it. (None, '') when it is not scored yet.

record_values(item)

What a full CVE record gives besides the score: its publication date (naive) and its description, when it has them.

record_details(item)

What a full CVE record (CVE 5.x) gives that the list of the latest ones does not: title, CVSS scores with their vectors, CWEs, vendors and products, CISA's SSVC reading, remediation, references with their tags, last update.

start_scheduler()

Launch multiple planning tasks in background:

- Fetch latest CVEs every 30 minutes.
- Fetch ransomware data every 30 minutes.
- Fetch RansomLook data every 30 minutes.

fetch_latest_cves()

Fetch latest CVEs from cve.circl.lu API and store new ones in database. Automatically matches against active WatchRules and records hits.

Returns:

Type Description

None

cve_id_of(item)

The identifier an advisory is kept under. The CVE it is about when there is one: its own id, an alias, or one written in its id (Debian's "DEBIAN-CVE-2026-1234" is the CVE 2026-1234, seen by Debian, which must not be counted twice). Otherwise its own id (OSV-, PYSEC-, GHSA-…): an advisory that is not a CVE.

cve_lookup_url(cve_id)

The address of one CVE on the source of the latest ones (.../api/last -> .../api/vulnerability/<id>), else None.

record_changes(cve, item)

What a full record of the source gives a CVE: its score, the facts of the sheet (record_details), and the date and description it lacks.

enrich_batch(limit=ENRICH_PER_CYCLE)

A CVE is often published before it is scored. Ask the source again for a few unscored ones, the longest unasked first, and keep the score, severity, date and description it now gives. On a 429 the pass stops and gives back the wait it asks.

Returns:

Type Description

(CVEs scored, seconds the source asked to wait before the next request, 0 when it did not)

enrich_details(limit=ENRICH_PER_CYCLE)

Complete the scored CVEs with the full record of the source: the High and Critical first, then the others; the never-read before the ones to read again (a week for the High, a month for the others). The unscored ones are enrich_batch's. On a 429 the pass stops. Returns the number of CVEs completed.

enrich_unscored(limit=ENRICH_PER_CYCLE)

One pass of enrich_batch: the number of CVEs that got a score (a limit of the source only ends the pass early).

epss_text(epss)

0.00175 -> "0.18 %", 0.25 -> "25 %".

hit_facts(cve)

What the notification of a rule hit tells besides the CVE: the score, KEV, EPSS and the product, for the VOC to qualify it.

exploited_content(cve)

What the notification "CVE exploited in the wild" says: the figures the CVE has, 'N/A' for the ones it has not.

fetch_kev()

CISA's catalogue of the vulnerabilities exploited in the wild: flag the CVEs of Watcher that are in it, with the date they were added, the date they must be fixed by and whether ransomware groups use them. A CVE that left the catalogue is unflagged. A CVE seen in the feeds later is flagged at the next pass (once a day).

fetch_epss()

The EPSS score of FIRST.org of every CVE (not the other advisories): the probability that it is exploited in the next 30 days, and its percentile. One request per EPSS_BATCH CVEs. The service limits its requests: on an answer of "too many" the pass stops, the next day's pass goes on.

fetch_ransomware_data()

Fetch ransomware groups and recent victims from ransomware.live API. Automatically matches against active WatchRules and records hits.

Returns:

Type Description

None

fetch_ransomlook_data()

Fetch ransomware data from RansomLook API. Includes groups, recent victims, and threat actors. Automatically matches against active WatchRules and records hits.

Returns:

Type Description

None

send_cyber_watch_notifications(content)

Send CyberWatch notifications via Slack, Citadel, TheHive and/or Email. Slack, Citadel and TheHive follow the instance settings (Connectors > Notifications); the email goes to the subscribers who ticked E-mail and asked for this kind of notification.

victim_key(victim)

WatchRuleHit.object_id of a victim, as written by _check_watch_rules_for_victim.

match_rule(keywords, exceptions, scope)

What a rule would match in the active CVEs and victims: counts and the latest few of each.

record_rule_hits(rule)

Record the hits of rule on the active CVEs and victims already collected (the fetch jobs only check new ones). No notification is sent: these are not new events. Returns the number of new hits.

hit_targets(hits)

{hit id: the CVE or victim it points at}, in two queries for a page of hits.

old_cves()

The CVEs older than CYBER_WATCH_CVE_RETENTION_DAYS (their publication date, or the day they were fetched when they have none). Never the ones flagged as exploited in the wild (the CISA catalogue is short and stays useful), nor the ones a watch rule matched (the hit points to them).

old_victims()

The ransomware victims older than CYBER_WATCH_VICTIM_RETENTION_DAYS (the day of the attack, or the day they were fetched), but the ones a watch rule matched (a hit points to "group::name").

purge_old_data(dry_run=False)

Take out the old CVEs and victims, PURGE_BATCH at a time (a long delete would hold the table). With dry_run nothing is deleted: it only counts. Returns {'cves': n, 'victims': n}.

cleanup_old_data()

Scheduled job (every night): the retention of the CVEs and of the ransomware victims.