Define the catalog publication identity
Some checks failed
Dependency Audit / dependency-audit (push) Failing after 15s
Security Audit / security-audit (push) Failing after 13s

This commit is contained in:
2026-07-22 22:23:01 +02:00
parent b6e9a9bd81
commit 76e4baa76e
2 changed files with 37 additions and 0 deletions

View File

@@ -26,11 +26,42 @@ from govoplan_release.publisher import ( # noqa: E402
verify_committed_publication,
verify_remote_branch_head,
verify_remote_publication,
_sanitized_git_environment,
_trusted_npm_command,
)
class ReleaseCatalogPublicationTests(unittest.TestCase):
def test_publication_git_identity_is_fixed_and_non_personal(self) -> None:
with patch.dict(
os.environ,
{
"GIT_AUTHOR_NAME": "Attacker",
"GIT_AUTHOR_EMAIL": "attacker@example.test",
"GIT_COMMITTER_NAME": "Attacker",
"GIT_COMMITTER_EMAIL": "attacker@example.test",
},
clear=False,
):
environment = _sanitized_git_environment()
self.assertEqual(
"GovOPlaN Release Automation",
environment["GIT_AUTHOR_NAME"],
)
self.assertEqual(
"release@govoplan.invalid",
environment["GIT_AUTHOR_EMAIL"],
)
self.assertEqual(
environment["GIT_AUTHOR_NAME"],
environment["GIT_COMMITTER_NAME"],
)
self.assertEqual(
environment["GIT_AUTHOR_EMAIL"],
environment["GIT_COMMITTER_EMAIL"],
)
def test_build_command_uses_its_pinned_node_directory(self) -> None:
completed = subprocess.CompletedProcess(
["/trusted/node/bin/npm"],

View File

@@ -45,6 +45,8 @@ _MAX_GIT_OUTPUT_BYTES = 16 * 1024 * 1024
_MAX_REMOTE_METADATA_BYTES = 16 * 1024
_MAX_REMOVED_TREE_ENTRIES = 100_000
_MAX_REMOVED_TREE_DEPTH = 64
_RELEASE_GIT_NAME = "GovOPlaN Release Automation"
_RELEASE_GIT_EMAIL = "release@govoplan.invalid"
class CatalogPublicationAmbiguousError(RuntimeError):
@@ -1898,6 +1900,10 @@ def _sanitized_git_environment(
"GIT_CONFIG_COUNT": "0",
"GIT_CONFIG_GLOBAL": os.devnull,
"GIT_CONFIG_NOSYSTEM": "1",
"GIT_AUTHOR_EMAIL": _RELEASE_GIT_EMAIL,
"GIT_AUTHOR_NAME": _RELEASE_GIT_NAME,
"GIT_COMMITTER_EMAIL": _RELEASE_GIT_EMAIL,
"GIT_COMMITTER_NAME": _RELEASE_GIT_NAME,
"GIT_NO_REPLACE_OBJECTS": "1",
"GIT_PAGER": "cat",
"GIT_SSH_COMMAND": "/usr/bin/ssh -o BatchMode=yes -o ConnectTimeout=8",