mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-28 22:06:31 +00:00
CodeQL py/cyclic-import alerts #1023-#1029 and #1112-#1113 map to three cycles: utils.inventory.tools <-> libretranslate, utils.env.builder <-> its handlers, and utils.roles.applications.variants <-> the inventory legacy resolver. Each cycle loaded only because one side deferred an import into a function body. The shared piece now lives in a leaf module both sides import: utils/inventory/tools_vars.py, utils/env/context.py (BuildContext, EnvBuilder), and _resolve_round_include inside variants.py. The stricter lint found four more cycles, each broken the same way: compose <-> down (cli/administration/deploy/development/docker_root.py), the utils.cache package web (utils/cache/reset.py), utils.cache.carrier <-> users (utils/cache/tokens.py replaces users/store.py) and credentials -> provision (cli/administration/inventory/ruamel_io.py).
tests/lint/repository/python/test_import_cycles.py fails on any runtime import cycle between the repository's own modules. It counts TYPE_CHECKING imports and implied parent-package edges, and skips only __main__ blocks and submodule-to-parent reads. Negative control: 3 of the 11 self-tests fail on the old logic. Whole repository: 12 passed. Targeted tests of every touched module: 4275 passed.
Accepted security findings: 78 medusa findings, all on lines that exist verbatim in base 28d05e0183. They come from code moved unchanged into docker_root.py, tools_vars.py and tokens.py, or from untouched lines of touched files (compose.py, credentials_generator.py, credentials/reset/cli.py, users/__init__.py, yaml.py). Reviewed as by design or false positive: argv-list subprocess calls, dev docker-root teardown, NotASecret test-lane keys, SafeLoader yaml.load, md5 memo key, Jinja expression strings.
🎯 Fix: 90 %
💥 Break: 5 %
💸 Cost: –
⏱️ Time: –
🛡️ Security: 100 %
🏆 Score: 86
🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 %
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
from utils.cache.files import read_text
|
|
from utils.inventory import tools_vars
|
|
|
|
MARKUP = "/models/<a & 'b'>\""
|
|
TEMPLATE = (
|
|
'models: "[[ models_dir ]]"\n'
|
|
"languages: [[ load_only | join(',') ]]\n"
|
|
"key: [[ s1_api_key ]]\n"
|
|
"[% raw %]{{ ansible_expression }}[% endraw %]\n"
|
|
)
|
|
|
|
|
|
class TestRender(unittest.TestCase):
|
|
def test_the_yaml_lane_renders_without_html_escaping(self) -> None:
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
root = Path(tmp)
|
|
template = root / tools_vars.TEMPLATE
|
|
template.parent.mkdir(parents=True)
|
|
template.write_text(TEMPLATE, encoding="utf-8")
|
|
with patch.object(tools_vars, "models_dir", return_value=MARKUP):
|
|
rendered = read_text(str(tools_vars.render(root, ["en", "de"])))
|
|
self.assertIn(f'models: "{MARKUP}"', rendered)
|
|
self.assertIn("languages: de,en", rendered)
|
|
self.assertIn(f"key: {tools_vars.API_KEY}", rendered)
|
|
self.assertIn("{{ ansible_expression }}", rendered)
|
|
self.assertNotIn("<", rendered)
|
|
self.assertNotIn("&", rendered)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|