Skip to content

Support for DNF modules#1660

Open
yagarea wants to merge 6 commits intopyinfra-dev:3.xfrom
yagarea:3.x
Open

Support for DNF modules#1660
yagarea wants to merge 6 commits intopyinfra-dev:3.xfrom
yagarea:3.x

Conversation

@yagarea
Copy link
Copy Markdown

@yagarea yagarea commented Apr 9, 2026

Solves #1659

  • Pull request is based on the default branch (3.x at this time)
  • Pull request includes tests for any new/updated operations/facts
  • Pull request includes documentation for any new/updated operations/facts
  • Tests pass (see scripts/dev-test.sh) (1552 passed, 15 deselected, 3 warnings in 7.93s)
  • Type checking & code style passes (see scripts/dev-lint.sh)

@yagarea
Copy link
Copy Markdown
Author

yagarea commented Apr 13, 2026

Warning: "nstalled" should be "installed".
error: `nstalled` should be `installed`
  --> ./tests/facts/dnf.DnfEnabledModules/multiple_modules.json:9:54
  |
9 |         "Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled"
  |                                                      ^^^^^^^^

What can I do about these spell checks failing? This is real dnf output

@wowi42
Copy link
Copy Markdown
Collaborator

wowi42 commented Apr 20, 2026

Drive-by review, hope it's useful.

Must-fix

Shell-injection in src/pyinfra/operations/dnf.py

yield f"dnf module enable -y {module}:{stream}"

module and stream are user-supplied and end up unquoted in a shell string. This regresses the recent bfb2fafe ("security: quote untrusted values in command construction"). Suggested:

from pyinfra.api import QuoteString, StringCommand
yield StringCommand("dnf module enable -y", QuoteString(f"{module}:{stream}"))

Should-address

Scope: op is named module but only enables. Either rename to module_enable, or add present: bool = True and handle dnf module disable/reset symmetrically. As-is, dnf.module(..., present=False)-style expectations will be surprising.

Stream switching: dnf module enable won't switch streams when packages from the old stream are installed, it will error. Worth a docstring note, or auto-issuing a reset first.

Docs checkbox unchecked: docstrings are present and scripts/generate_operations_docs.py picks them up, so probably just an oversight.

Nice-to-have

Parse robustness (DnfEnabledModules.process): the \"[e]\" not in line filter is fine, but the startswith(\"Hint:\") guard is unreachable since the hint line contains no [e]. Remove or replace with a real edge case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants