fix(host-status): keep models.py at its recorded size, one literal for the dnf query
driver / standard (pull_request) Successful in 14s
driver / lint (pull_request) Successful in 13s
driver / types (pull_request) Successful in 58s
driver / test (3.12) (pull_request) Successful in 1m11s
driver / test (3.13) (pull_request) Successful in 1m5s
driver / lowest (pull_request) Successful in 40s
driver / build (pull_request) Successful in 36s
driver / security (pull_request) Successful in 1m6s
CI / driver (pull_request) Successful in 2m38s
driver / publish (pull_request) Skipped
driver / standard (pull_request) Successful in 14s
driver / lint (pull_request) Successful in 13s
driver / types (pull_request) Successful in 58s
driver / test (3.12) (pull_request) Successful in 1m11s
driver / test (3.13) (pull_request) Successful in 1m5s
driver / lowest (pull_request) Successful in 40s
driver / build (pull_request) Successful in 36s
driver / security (pull_request) Successful in 1m6s
CI / driver (pull_request) Successful in 2m38s
driver / publish (pull_request) Skipped
The quality ratchet records models.py at 1454 lines and the new comments had made it 1460. bandit read the dnf history query, built with an f-string for its path, as SQL put together from strings (B608); it is a fixed query, now one literal with the path spelt out, and a test holds it to DNF_HISTORY. Refs NetOrk/netork#851
This commit is contained in:
1 parent
658f1c8ab2
commit
92891473be
3 files changed
+8
-12
No files matched your search
@@ -85,11 +85,8 @@ class InterruptedPackageDict(TypedDict):
|
||||
"""A package an interrupted package manager run left halfway."""
|
||||
|
||||
name: str
|
||||
#: dpkg's word for it: "half-installed", "unpacked", "half-configured",
|
||||
#: "triggers-awaited", "triggers-pending", or "reinstall-required"; opkg's
|
||||
#: "unpacked", "half-configured", "half-installed" or "reinstall-required";
|
||||
#: rpm's "duplicate" (two versions installed); apk's "broken-files" or
|
||||
#: "broken-script".
|
||||
#: The manager's word for it: dpkg's and opkg's ("unpacked", "half-configured", ...),
|
||||
#: rpm's "duplicate", apk's "broken-files" and "broken-script" (``package_managers``).
|
||||
state: str
|
||||
|
||||
|
||||
@@ -114,12 +111,9 @@ class HostStatusDict(TypedDict):
|
||||
reboot_reason: str | None
|
||||
#: True when the host installs updates on its own (unattended-upgrades, dnf-automatic).
|
||||
auto_updates: bool | None
|
||||
#: The package manager the next two fields are about: "dpkg", "dnf", "yum",
|
||||
#: "apk" or "opkg"; None when none could be read.
|
||||
#: The package manager read (dpkg, dnf, yum, apk, opkg; None: none) and whether a run
|
||||
#: of it was cut off, left halfway (None: cannot tell, or one is running right now).
|
||||
package_manager: NotRequired[str | None]
|
||||
#: True when a package manager run was cut off and left the system halfway
|
||||
#: (dpkg: until ``dpkg --configure -a``, opkg: ``opkg configure``); None when
|
||||
#: it cannot tell, or a package manager is running right now.
|
||||
package_manager_interrupted: NotRequired[bool | None]
|
||||
#: The packages that run left halfway; empty when only its journal says so.
|
||||
interrupted_packages: NotRequired[list[InterruptedPackageDict]]
|
||||
|
||||
@@ -74,8 +74,10 @@ _OPKG_HALFWAY = frozenset({"unpacked", "half-configured", "half-installed"})
|
||||
_OPKG_REINSTALL = "reinstreq"
|
||||
|
||||
#: The newest transaction in dnf's history as ``<id> <state>``; nothing when unreadable.
|
||||
#: One literal, with :data:`DNF_HISTORY` spelt out: a fixed query, nothing put into it.
|
||||
_DNF_HISTORY_PY = (
|
||||
f"import sqlite3; c = sqlite3.connect('file:{DNF_HISTORY}?mode=ro', uri=True); "
|
||||
"import sqlite3; "
|
||||
"c = sqlite3.connect('file:/var/lib/dnf/history.sqlite?mode=ro', uri=True); "
|
||||
"r = c.execute('SELECT id, state FROM trans ORDER BY id DESC LIMIT 1').fetchone(); "
|
||||
"r and print(*r)"
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user