Repository navigation
Conversation
${from_file:...} now only reads a file that resolves, after following
symlinks, below the working directory or the inventory path. Any other
path fails the inventory render with an error naming the path. A custom
from_file in resolvers.py still replaces the built-in one for projects
that read outside on purpose.
Fixes #1639
Signed-off-by: Moep90 <3042152+Moep90@users.noreply.github.com>
This was referenced Nov 7, 2026
kadet-hub-kapitan-next Bot
pushed a commit
to kadet-hub/kapitan
that referenced
this pull request
Nov 7, 2026
Signed-off-by: Moep90 <3042152+Moep90@users.noreply.github.com> # Conflicts: # kapitan/inventory/backends/omegaconf/resolvers.py
kadet-hub-kapitan-next Bot
pushed a commit
to kadet-hub/kapitan
that referenced
this pull request
Nov 7, 2026
Merged: kapicorp#1388 kapicorp#1440 kapicorp#1446 kapicorp#1449 kapicorp#1459 kapicorp#1465 kapicorp#1484 kapicorp#1486 kapicorp#1488 kapicorp#1497 kapicorp#1501 kapicorp#1516 kapicorp#1518 kapicorp#1527 kapicorp#1528 kapicorp#1529 kapicorp#1530 kapicorp#1531 kapicorp#1539 kapicorp#1540 kapicorp#1541 kapicorp#1542 kapicorp#1543 kapicorp#1544 kapicorp#1545 kapicorp#1546 kapicorp#1547 kapicorp#1554 kapicorp#1555 kapicorp#1559 kapicorp#1565 kapicorp#1566 kapicorp#1598 kapicorp#1600 kapicorp#1606 kapicorp#1609 kapicorp#1612 kapicorp#1614 kapicorp#1615 kapicorp#1623 kapicorp#1624 kapicorp#1625 kapicorp#1627 kapicorp#1629 kapicorp#1631 kapicorp#1633 kapicorp#1634 kapicorp#1635 kapicorp#1636 kapicorp#1637 kapicorp#1640 kapicorp#1642 kapicorp#1643 kapicorp#1646 kapicorp#1648 kapicorp#1650 kapicorp#1652 kapicorp#1654 kapicorp#1656 kapicorp#1659 kapicorp#1660 kapicorp#1668 kapicorp#1669 kapicorp#1670 kapicorp#1671 kapicorp#1674 kapicorp#1678 Conflicting: kapicorp#1658 kapicorp#1662 kapicorp#1664 kapicorp#1666 kapicorp#1676 kapicorp#1677 Next-Fingerprint: f03513f 169c870 1388 e047547 1440 624bbb4 1446 8600881 1449 916c63d 1459 519a90b 1465 7f6b85b 1484 2543d11 1486 6a7be30 1488 9991a7c 1497 96cdde6 1501 2706f7e 1516 2485def 1518 24bb6ad 1527 2f4e188 1528 02e2e25 1529 bb4fa93 1530 d499bb7 1531 6e6afff 1539 ee8bb7b 1540 84c0929 1541 46d0f7a 1542 4a4d562 1543 5cd2a5c 1544 d27945f 1545 ee6e895 1546 0902bbc 1547 094c999 1554 ccb0486 1555 f5cbd07 1559 79d42fa 1565 07d2b6d 1566 7ec811a 1598 570ab14 1600 5cf9875 1606 942fdeb 1609 1dccc5e 1612 9cd6b5c 1614 782afcb 1615 0beed2b 1623 9e88063 1624 872197a 1625 9267812 1627 531002f 1629 75ae30a 1631 5ef2dca 1633 4af5f87 1634 822a175 1635 7327e46 1636 b6fb808 1637 1c2d6dc 1640 b909052 1642 ea824d8 1643 67c0727 1646 5a60b7f 1648 a126868 1650 c970796 1652 8314139 1654 7f1adca 1656 a174d8e 1658 a9ec63f 1659 a59f187 1660 28869c7 1662 235ae8b 1664 929dec3 1666 4a23d70 1668 2f07d58 1669 991f82e 1670 9eb680b 1671 d761ef1 1674 2d40202 1676 f835258 1677 3bbaedf 1678 a14e904
kadet-hub-kapitan-next Bot
pushed a commit
to kadet-hub/kapitan
that referenced
this pull request
Nov 7, 2026
Merged: kapicorp#1388 kapicorp#1440 kapicorp#1446 kapicorp#1449 kapicorp#1459 kapicorp#1465 kapicorp#1484 kapicorp#1486 kapicorp#1488 kapicorp#1497 kapicorp#1501 kapicorp#1516 kapicorp#1518 kapicorp#1527 kapicorp#1528 kapicorp#1529 kapicorp#1530 kapicorp#1531 kapicorp#1539 kapicorp#1540 kapicorp#1541 kapicorp#1542 kapicorp#1543 kapicorp#1544 kapicorp#1545 kapicorp#1546 kapicorp#1547 kapicorp#1554 kapicorp#1555 kapicorp#1559 kapicorp#1565 kapicorp#1566 kapicorp#1598 kapicorp#1600 kapicorp#1606 kapicorp#1609 kapicorp#1612 kapicorp#1614 kapicorp#1615 kapicorp#1623 kapicorp#1624 kapicorp#1625 kapicorp#1627 kapicorp#1629 kapicorp#1631 kapicorp#1633 kapicorp#1634 kapicorp#1635 kapicorp#1636 kapicorp#1637 kapicorp#1640 kapicorp#1642 kapicorp#1643 kapicorp#1646 kapicorp#1648 kapicorp#1650 kapicorp#1652 kapicorp#1654 kapicorp#1656 kapicorp#1659 kapicorp#1660 kapicorp#1668 kapicorp#1669 kapicorp#1670 kapicorp#1671 kapicorp#1674 kapicorp#1678 Conflicting: kapicorp#1658 kapicorp#1662 kapicorp#1664 kapicorp#1666 kapicorp#1676 kapicorp#1677 Next-Fingerprint: f03513f 169c870 1388 e047547 1440 624bbb4 1446 8600881 1449 916c63d 1459 519a90b 1465 7f6b85b 1484 2543d11 1486 6a7be30 1488 9991a7c 1497 96cdde6 1501 2706f7e 1516 2485def 1518 24bb6ad 1527 2f4e188 1528 02e2e25 1529 bb4fa93 1530 d499bb7 1531 6e6afff 1539 ee8bb7b 1540 84c0929 1541 46d0f7a 1542 4a4d562 1543 5cd2a5c 1544 d27945f 1545 ee6e895 1546 0902bbc 1547 094c999 1554 ccb0486 1555 f5cbd07 1559 79d42fa 1565 07d2b6d 1566 7ec811a 1598 570ab14 1600 5cf9875 1606 942fdeb 1609 1dccc5e 1612 9cd6b5c 1614 782afcb 1615 0beed2b 1623 9e88063 1624 872197a 1625 9267812 1627 531002f 1629 75ae30a 1631 5ef2dca 1633 4af5f87 1634 822a175 1635 7327e46 1636 b6fb808 1637 1c2d6dc 1640 b909052 1642 ea824d8 1643 67c0727 1646 5a60b7f 1648 a126868 1650 c970796 1652 8314139 1654 7f1adca 1656 a174d8e 1658 a9ec63f 1659 a59f187 1660 28869c7 1662 235ae8b 1664 929dec3 1666 4a23d70 1668 2f07d58 1669 991f82e 1670 9eb680b 1671 d761ef1 1674 2d40202 1676 f835258 1677 3bbaedf 1678 a14e904
kadet-hub-kapitan-next Bot
pushed a commit
to kadet-hub/kapitan
that referenced
this pull request
Nov 7, 2026
Merged: kapicorp#1388 kapicorp#1440 kapicorp#1446 kapicorp#1449 kapicorp#1459 kapicorp#1465 kapicorp#1484 kapicorp#1486 kapicorp#1488 kapicorp#1497 kapicorp#1501 kapicorp#1516 kapicorp#1518 kapicorp#1527 kapicorp#1528 kapicorp#1529 kapicorp#1530 kapicorp#1531 kapicorp#1539 kapicorp#1540 kapicorp#1541 kapicorp#1542 kapicorp#1543 kapicorp#1544 kapicorp#1545 kapicorp#1546 kapicorp#1547 kapicorp#1554 kapicorp#1555 kapicorp#1559 kapicorp#1565 kapicorp#1566 kapicorp#1598 kapicorp#1600 kapicorp#1606 kapicorp#1609 kapicorp#1612 kapicorp#1614 kapicorp#1615 kapicorp#1623 kapicorp#1624 kapicorp#1625 kapicorp#1627 kapicorp#1629 kapicorp#1631 kapicorp#1633 kapicorp#1634 kapicorp#1635 kapicorp#1636 kapicorp#1637 kapicorp#1640 kapicorp#1642 kapicorp#1643 kapicorp#1646 kapicorp#1648 kapicorp#1650 kapicorp#1652 kapicorp#1654 kapicorp#1656 kapicorp#1659 kapicorp#1660 kapicorp#1668 kapicorp#1669 kapicorp#1670 kapicorp#1671 kapicorp#1674 kapicorp#1678 Conflicting: kapicorp#1658 kapicorp#1662 kapicorp#1664 kapicorp#1666 kapicorp#1676 kapicorp#1677 Next-Fingerprint: f03513f 169c870 1388 e047547 1440 624bbb4 1446 8600881 1449 916c63d 1459 519a90b 1465 7f6b85b 1484 2543d11 1486 6a7be30 1488 9991a7c 1497 96cdde6 1501 2706f7e 1516 2485def 1518 24bb6ad 1527 2f4e188 1528 02e2e25 1529 bb4fa93 1530 d499bb7 1531 6e6afff 1539 ee8bb7b 1540 84c0929 1541 46d0f7a 1542 4a4d562 1543 5cd2a5c 1544 d27945f 1545 ee6e895 1546 0902bbc 1547 094c999 1554 ccb0486 1555 f5cbd07 1559 79d42fa 1565 07d2b6d 1566 7ec811a 1598 570ab14 1600 5cf9875 1606 942fdeb 1609 1dccc5e 1612 9cd6b5c 1614 782afcb 1615 0beed2b 1623 9e88063 1624 872197a 1625 9267812 1627 531002f 1629 75ae30a 1631 5ef2dca 1633 4af5f87 1634 822a175 1635 7327e46 1636 b6fb808 1637 1c2d6dc 1640 b909052 1642 ea824d8 1643 67c0727 1646 5a60b7f 1648 a126868 1650 c970796 1652 8314139 1654 7f1adca 1656 a174d8e 1658 a9ec63f 1659 a59f187 1660 28869c7 1662 235ae8b 1664 929dec3 1666 4a23d70 1668 2f07d58 1669 991f82e 1670 9eb680b 1671 d761ef1 1674 2d40202 1676 f835258 1677 3bbaedf 1678 a14e904
kadet-hub-kapitan-next Bot
pushed a commit
to kadet-hub/kapitan
that referenced
this pull request
Nov 7, 2026
Merged: kapicorp#1388 kapicorp#1440 kapicorp#1446 kapicorp#1449 kapicorp#1459 kapicorp#1465 kapicorp#1484 kapicorp#1486 kapicorp#1488 kapicorp#1497 kapicorp#1501 kapicorp#1516 kapicorp#1518 kapicorp#1527 kapicorp#1528 kapicorp#1529 kapicorp#1530 kapicorp#1531 kapicorp#1539 kapicorp#1540 kapicorp#1541 kapicorp#1542 kapicorp#1543 kapicorp#1544 kapicorp#1545 kapicorp#1546 kapicorp#1547 kapicorp#1554 kapicorp#1555 kapicorp#1559 kapicorp#1565 kapicorp#1566 kapicorp#1598 kapicorp#1600 kapicorp#1606 kapicorp#1609 kapicorp#1612 kapicorp#1614 kapicorp#1615 kapicorp#1623 kapicorp#1624 kapicorp#1625 kapicorp#1627 kapicorp#1629 kapicorp#1631 kapicorp#1633 kapicorp#1634 kapicorp#1635 kapicorp#1636 kapicorp#1637 kapicorp#1640 kapicorp#1642 kapicorp#1643 kapicorp#1646 kapicorp#1648 kapicorp#1650 kapicorp#1652 kapicorp#1654 kapicorp#1656 kapicorp#1659 kapicorp#1660 kapicorp#1668 kapicorp#1669 kapicorp#1670 kapicorp#1671 kapicorp#1674 kapicorp#1678 Conflicting: kapicorp#1658 kapicorp#1662 kapicorp#1664 kapicorp#1666 kapicorp#1676 kapicorp#1677 Next-Fingerprint: f03513f 169c870 1388 e047547 1440 624bbb4 1446 8600881 1449 916c63d 1459 519a90b 1465 7f6b85b 1484 2543d11 1486 6a7be30 1488 9991a7c 1497 96cdde6 1501 2706f7e 1516 2485def 1518 24bb6ad 1527 2f4e188 1528 02e2e25 1529 bb4fa93 1530 d499bb7 1531 6e6afff 1539 ee8bb7b 1540 84c0929 1541 46d0f7a 1542 4a4d562 1543 5cd2a5c 1544 d27945f 1545 ee6e895 1546 0902bbc 1547 094c999 1554 ccb0486 1555 f5cbd07 1559 79d42fa 1565 07d2b6d 1566 7ec811a 1598 570ab14 1600 5cf9875 1606 942fdeb 1609 1dccc5e 1612 9cd6b5c 1614 782afcb 1615 0beed2b 1623 9e88063 1624 872197a 1625 9267812 1627 531002f 1629 75ae30a 1631 5ef2dca 1633 4af5f87 1634 822a175 1635 7327e46 1636 b6fb808 1637 1c2d6dc 1640 b909052 1642 ea824d8 1643 67c0727 1646 5a60b7f 1648 a126868 1650 c970796 1652 8314139 1654 7f1adca 1656 a174d8e 1658 a9ec63f 1659 a59f187 1660 28869c7 1662 235ae8b 1664 929dec3 1666 4a23d70 1668 2f07d58 1669 991f82e 1670 9eb680b 1671 d761ef1 1674 2d40202 1676 f835258 1677 3bbaedf 1678 a14e904
kadet-hub-kapitan-next Bot
pushed a commit
to kadet-hub/kapitan
that referenced
this pull request
Nov 7, 2026
Merged: kapicorp#1388 kapicorp#1440 kapicorp#1446 kapicorp#1449 kapicorp#1459 kapicorp#1465 kapicorp#1484 kapicorp#1486 kapicorp#1488 kapicorp#1497 kapicorp#1501 kapicorp#1516 kapicorp#1518 kapicorp#1527 kapicorp#1528 kapicorp#1529 kapicorp#1530 kapicorp#1531 kapicorp#1539 kapicorp#1540 kapicorp#1541 kapicorp#1542 kapicorp#1543 kapicorp#1544 kapicorp#1545 kapicorp#1546 kapicorp#1547 kapicorp#1554 kapicorp#1555 kapicorp#1559 kapicorp#1565 kapicorp#1566 kapicorp#1598 kapicorp#1600 kapicorp#1606 kapicorp#1609 kapicorp#1612 kapicorp#1614 kapicorp#1615 kapicorp#1623 kapicorp#1624 kapicorp#1625 kapicorp#1627 kapicorp#1629 kapicorp#1631 kapicorp#1633 kapicorp#1634 kapicorp#1635 kapicorp#1636 kapicorp#1637 kapicorp#1640 kapicorp#1642 kapicorp#1643 kapicorp#1646 kapicorp#1648 kapicorp#1650 kapicorp#1652 kapicorp#1654 kapicorp#1656 kapicorp#1659 kapicorp#1660 kapicorp#1668 kapicorp#1669 kapicorp#1670 kapicorp#1671 kapicorp#1674 kapicorp#1678 Conflicting: kapicorp#1658 kapicorp#1662 kapicorp#1664 kapicorp#1666 kapicorp#1676 kapicorp#1677 Next-Fingerprint: f03513f 169c870 1388 e047547 1440 624bbb4 1446 8600881 1449 916c63d 1459 519a90b 1465 7f6b85b 1484 2543d11 1486 6a7be30 1488 9991a7c 1497 96cdde6 1501 2706f7e 1516 2485def 1518 24bb6ad 1527 2f4e188 1528 02e2e25 1529 bb4fa93 1530 d499bb7 1531 6e6afff 1539 ee8bb7b 1540 84c0929 1541 46d0f7a 1542 4a4d562 1543 5cd2a5c 1544 d27945f 1545 ee6e895 1546 0902bbc 1547 094c999 1554 ccb0486 1555 f5cbd07 1559 79d42fa 1565 07d2b6d 1566 7ec811a 1598 570ab14 1600 5cf9875 1606 942fdeb 1609 1dccc5e 1612 9cd6b5c 1614 782afcb 1615 0beed2b 1623 9e88063 1624 872197a 1625 9267812 1627 531002f 1629 75ae30a 1631 5ef2dca 1633 4af5f87 1634 822a175 1635 7327e46 1636 b6fb808 1637 1c2d6dc 1640 b909052 1642 ea824d8 1643 67c0727 1646 5a60b7f 1648 a126868 1650 c970796 1652 8314139 1654 7f1adca 1656 a174d8e 1658 a9ec63f 1659 a59f187 1660 28869c7 1662 235ae8b 1664 929dec3 1666 4a23d70 1668 2f07d58 1669 991f82e 1670 9eb680b 1671 d761ef1 1674 2d40202 1676 f835258 1677 3bbaedf 1678 a14e904
kadet-hub-kapitan-next Bot
pushed a commit
to kadet-hub/kapitan
that referenced
this pull request
Nov 8, 2026
Merged: kapicorp#1388 kapicorp#1440 kapicorp#1446 kapicorp#1449 kapicorp#1459 kapicorp#1465 kapicorp#1484 kapicorp#1486 kapicorp#1488 kapicorp#1497 kapicorp#1501 kapicorp#1516 kapicorp#1518 kapicorp#1527 kapicorp#1528 kapicorp#1529 kapicorp#1530 kapicorp#1531 kapicorp#1539 kapicorp#1540 kapicorp#1541 kapicorp#1542 kapicorp#1543 kapicorp#1544 kapicorp#1545 kapicorp#1546 kapicorp#1547 kapicorp#1554 kapicorp#1555 kapicorp#1559 kapicorp#1565 kapicorp#1566 kapicorp#1598 kapicorp#1600 kapicorp#1606 kapicorp#1609 kapicorp#1612 kapicorp#1614 kapicorp#1615 kapicorp#1623 kapicorp#1624 kapicorp#1625 kapicorp#1627 kapicorp#1629 kapicorp#1631 kapicorp#1633 kapicorp#1634 kapicorp#1635 kapicorp#1636 kapicorp#1637 kapicorp#1640 kapicorp#1642 kapicorp#1643 kapicorp#1646 kapicorp#1648 kapicorp#1650 kapicorp#1652 kapicorp#1654 kapicorp#1656 kapicorp#1659 kapicorp#1660 kapicorp#1668 kapicorp#1669 kapicorp#1670 kapicorp#1671 kapicorp#1674 kapicorp#1678 Conflicting: kapicorp#1658 kapicorp#1662 kapicorp#1664 kapicorp#1666 kapicorp#1676 kapicorp#1677 Next-Fingerprint: f03513f 169c870 1388 e047547 1440 624bbb4 1446 8600881 1449 916c63d 1459 519a90b 1465 7f6b85b 1484 2543d11 1486 6a7be30 1488 9991a7c 1497 96cdde6 1501 2706f7e 1516 2485def 1518 24bb6ad 1527 2f4e188 1528 02e2e25 1529 bb4fa93 1530 d499bb7 1531 6e6afff 1539 ee8bb7b 1540 84c0929 1541 46d0f7a 1542 4a4d562 1543 5cd2a5c 1544 d27945f 1545 ee6e895 1546 0902bbc 1547 094c999 1554 ccb0486 1555 f5cbd07 1559 79d42fa 1565 07d2b6d 1566 7ec811a 1598 570ab14 1600 5cf9875 1606 942fdeb 1609 1dccc5e 1612 9cd6b5c 1614 782afcb 1615 0beed2b 1623 9e88063 1624 872197a 1625 9267812 1627 531002f 1629 75ae30a 1631 5ef2dca 1633 4af5f87 1634 822a175 1635 7327e46 1636 b6fb808 1637 1c2d6dc 1640 b909052 1642 ea824d8 1643 67c0727 1646 5a60b7f 1648 a126868 1650 c970796 1652 8314139 1654 7f1adca 1656 a174d8e 1658 a9ec63f 1659 a59f187 1660 28869c7 1662 235ae8b 1664 929dec3 1666 4a23d70 1668 2f07d58 1669 991f82e 1670 9eb680b 1671 d761ef1 1674 2d40202 1676 f835258 1677 3bbaedf 1678 a14e904
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
${from_file:...}now only reads a file that resolves, after following symlinks, below the directory Kapitan runs in or below the inventory path. Any other path fails the inventory render.Fixes #1639
This should land together with #1676 (reload the inventory after
--fetch) or before it. #1676 lets classes fetched from someone else take effect in the same run, and without this change such a class can read any file the user running Kapitan can read.Motivation
On master, a class with
${from_file:${oc.env:HOME}/.kube/config}or${from_file:../outside/secret.txt}compiles with exit code 0, and both files end up in the compiled output. Same on 0.36.3.How it works:
register_resolversbinds the real paths of the working directory and of the inventory path tofrom_filewhen it registers it. Each inventory worker calls it, so the roots come from the process that renders.from_filecompares the real path of its argument with those roots viaos.path.commonpathand raisesInventoryErrorwhen neither contains it. The check runs before the file is opened, so it also doesn't tell whether an outside file exists.from_fileinresolvers.py. User resolvers are registered after the built-ins and replace them. I checked that by hand and wrote it into the docs.I didn't tie this to
--path-traversal-modefrom #1566. That PR isn't merged, its defaultwarnwouldn't confine anything, and it sets the mode in the compile workers, whilefrom_fileruns during the inventory render. If you'd rather have one switch for all file accessors, I can makefrom_filefollow that flag once #1566 is in.Affected files or URLs
kapitan/inventory/backends/omegaconf/resolvers.py:from_file,register_resolverstests/test_omegaconf_from_file.py(new)docs/pages/inventory/omegaconf.md: Utility ResolversTest plan
../path and symlink pointing out. Two of the tests run a realkapitan compile. The four refusal tests fail on master, the allowed ones pass on both.make docs_build(mkdocs--strict) andmake docs_checkpassmake lintpassesmake formatpasses (ruff format --checkand pre-commit on the changed files)uv run pytest tests/ --no-cov, 764 passed, 4 skipped)from_fileresolver to the project #1639 now fails with the new error and writes no compiled output.Risk assessment
Projects that use
from_fileon files outside the working directory and the inventory path break with this change, for example a monorepo reading../shared/ca.crt. The error names the path and says how to override the resolver. Revert is a single commit.Follow-up work intentionally left out
FILE NOT EXISTS, so the compile carries on. [feat]: confine the omegaconffrom_fileresolver to the project #1639 suggests failing there too. That changes behaviour for a different reason, so I'd do it separately.external,jinja2andkadetinputs in a fetched class can still run code by design, as [feat]: confine the omegaconffrom_fileresolver to the project #1639 says.