Skip to content

Commit c1e9a1b

Browse files
mbuechsegarloffdepressiveRobot
authored
Relax scs-0210-v2: extend update time for patch versions (#1153)
* Relax scs-0210-v2: extend update time for patch versions Signed-off-by: Matthias Büchse <matthias.buechse@alasca.cloud> * Fix testcase... Signed-off-by: Matthias Büchse <matthias.buechse@alasca.cloud> * Suggest 3 time periods as discussed in #1153. - 1 month MUST for any patch version - 2 weeks MUST for patch w/ CVE w/ CVSS >= 8. - 2 days RECOMMENDED for patch w/ CVE w/ CVSS >= 8. I moved the recommendation from behind the "critical CVE" definition next to the requirement, so it becomes a tad easier to parse. Signed-off-by: Kurt Garloff <kurt@garloff.de> * fix spelling Signed-off-by: Marvin Frommhold <depressiveRobot@users.noreply.github.com> * Update tests for k8s version policy to reflect new language in standard Signed-off-by: Matthias Büchse <matthias.buechse@alasca.cloud> --------- Signed-off-by: Matthias Büchse <matthias.buechse@alasca.cloud> Signed-off-by: Kurt Garloff <kurt@garloff.de> Signed-off-by: Marvin Frommhold <depressiveRobot@users.noreply.github.com> Co-authored-by: Kurt Garloff <kurt@garloff.de> Co-authored-by: Marvin Frommhold <depressiveRobot@users.noreply.github.com>
1 parent 19d5638 commit c1e9a1b

3 files changed

Lines changed: 19 additions & 14 deletions

File tree

Standards/scs-0210-v2-k8s-version-policy.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ In order to keep up-to-date with the latest Kubernetes features, bug fixes and s
5757
the provided Kubernetes versions should be kept up-to-date with new upstream releases:
5858

5959
- The latest minor version MUST be provided no later than 4 months after release.
60-
- The latest patch version MUST be provided no later than 2 weeks after release.
61-
- This time period MUST be even shorter for patches that fix critical CVEs.
60+
- The latest patch version MUST be provided no later than 1 month after release.
61+
- This time period (for providing the latest patch version) MUST not be longer than
62+
2 weeks if the patch addresses critical CVEs and it is RECOMMENDED to be provided
63+
within 2 days of the release.
6264
In this context, a critical CVE is a CVE with a CVSS base score >= 8 according
6365
to the CVSS version used in the original CVE record (e.g., CVSSv3.1).
64-
It is RECOMMENDED to provide a new patch version in a 2-day time period after their release.
6566
- New versions MUST be tested before being rolled out on productive infrastructure;
6667
at least the [CNCF E2E tests][cncf-conformance] should be passed beforehand.
6768

Tests/kaas/k8s-version-policy/k8s_version_policy.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@
4545

4646

4747
MINOR_VERSION_CADENCE = timedelta(days=120)
48-
PATCH_VERSION_CADENCE = timedelta(weeks=2)
49-
CVE_VERSION_CADENCE = timedelta(days=2)
48+
PATCH_VERSION_CADENCE = timedelta(days=31)
49+
CVE_VERSION_CADENCE = timedelta(weeks=2)
50+
CVE_VERSION_CADENCE_WARN = timedelta(days=2)
5051
CVE_SEVERITY = 8 # CRITICAL
5152

5253
HERE = Path(__file__).parent
@@ -420,19 +421,19 @@ def check_k8s_version_recency(
420421
# whoops, the cluster should have been updated to this (or a higher version) already!
421422
return False
422423
ranges = [_range for _range in cve_affected_ranges if my_version in _range]
423-
if ranges and release.age > CVE_VERSION_CADENCE:
424-
# -- two FIXMEs:
425-
# (a) if the release still has the CVE, then there is no use if we updated to it?
426-
# (b) the standard says "time period MUST be even shorter ... it is RECOMMENDED that ...",
427-
# so what is it now, a requirement or a recommendation?
424+
if ranges and release.age > CVE_VERSION_CADENCE_WARN:
425+
# -- FIXME:
426+
# if the release still has the CVE, then there is no use if we updated to it?
428427
# shouldn't we check for CVEs of my_version and then check whether the new one still has them?
429428
# -- so, this has to be reworked in a major way, but for the time being, just emit an INFO
430429
# (unfortunately, the cluster name is not available here)
431-
logger.info(
430+
logger.warning(
432431
"Consider updating from %s to %s to avoid a CVE",
433432
my_version,
434433
release.version,
435434
)
435+
if release.age > CVE_VERSION_CADENCE:
436+
return False
436437
return True
437438

438439

Tests/kaas/k8s-version-policy/k8s_version_policy_test.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def release_data():
4545
EXPECTED_RECENCIES = {
4646
datetime(2024, 1, 17): True,
4747
datetime(2024, 1, 31): True,
48-
datetime(2024, 2, 1): False,
48+
datetime(2024, 2, 18): False,
4949
}
5050

5151

@@ -65,8 +65,11 @@ def test_check_version_recency_with_cve(caplog, release_data):
6565
# 2 days after release of patch for affected_version
6666
dt.now.return_value = datetime(2024, 1, 20)
6767
assert check_k8s_version_recency(affected_version, release_data, fake_ranges)
68-
assert len(caplog.records) == 1, "expected a log message"
69-
assert caplog.records[0].levelname == "INFO"
68+
# 2 weeks after the release
69+
dt.now.return_value = datetime(2024, 2, 1)
70+
assert not check_k8s_version_recency(affected_version, release_data, fake_ranges)
71+
assert len(caplog.records) >= 1, "expected a log message"
72+
assert caplog.records[0].levelname == "WARNING"
7073
assert "Consider updating from 1.28.5" in caplog.records[0].message
7174

7275

0 commit comments

Comments
 (0)