Finding the flaws
A vulnerability is a weakness a threat could use: a bug in software, a bad setting, a missing step. Each publicly known one gets an ID called a CVE. This mail server runs software with one.
Vulnerability management is a loop: find flaws, rank them, fix them, check the fix, repeat. It starts with an inventory of every system and the software on it, with versions. You cannot fix what you do not know you have.
A vulnerability scanner compares each system's software and versions with public lists of known flaws. Every match is a finding. Here it reports one finding on each server: the web server, the mail server and the database.
The Common Vulnerability Scoring System (CVSS) rates how severe a flaw is, from 0 to 10. NIST's National Vulnerability Database publishes scores. Ours: web 9.1 (critical), mail 7.5 (high), database 5.3 (medium).
Severity is not urgency. CISA's Known Exploited Vulnerabilities (KEV) catalog lists flaws attackers are really using, and CISA urges everyone to fix these first. The mail server's flaw is on the list; the other two are not.
Ranking them in Python
A short Python script ranks the work. Each finding is a tuple, a fixed group of values: the host, its CVSS score, and True or False for 'on the KEV list'. The three findings make one list.
rank() turns a finding into a sort key: (not kev, -cvss). Python compares tuples item by item, and False sorts before True, so KEV flaws come first. The minus sign then puts higher scores first.
sorted() orders the findings by that key, and the loop prints each host: mail, web, db. The exploited high-severity flaw goes ahead of the critical one that is not known to be exploited. That order is the fix queue.
Fixing and checking
Remediating removes the flaw, usually by installing the vendor's patch: a fixed version of the software. If no patch exists yet, mitigate: switch off the risky feature or isolate the system until one arrives.
Then check. A fresh scan of the mail server confirms the flaw is gone, and only then is the finding closed. The queue moves on to web, then db. Tracking how long each fix takes shows if you keep up.
New flaws are published every day, and the KEV list keeps growing. So the loop never stops: keep the inventory current, scan regularly, re-rank when the lists change and patch on a schedule. NIST calls patching preventive maintenance.
What happens
;; step 1/11 · weakness
vulnerability a weakness that a threat could use
(NIST CSRC glossary)
CVE one public ID per known flaw
CVE-YEAR-NUMBER, for example
CVE-2021-44228 (Log4Shell, in Apache Log4j)
here the flaws are made-up examples
The three findings, their scores and the KEV mark are made up to show the method. Real CVE records list their own scores, and an NVD score can change as more is learned. FIRST, which maintains CVSS, says it is designed to measure severity and should not be used alone to assess risk. Real programs also weigh how exposed a system is and how important it is: CISA's SSVC decision trees and FIRST's EPSS (the chance of exploitation) help with that.