diff --git a/.github/scripts/check-workflow-policy.py b/.github/scripts/check-workflow-policy.py index a7f94b10df..9480c9c201 100644 --- a/.github/scripts/check-workflow-policy.py +++ b/.github/scripts/check-workflow-policy.py @@ -17,7 +17,6 @@ DEFAULT_WORKFLOW_GLOB = ".github/workflows/*" DEFAULT_ACTION_GLOB = ".github/actions/**/action.y*ml" ALLOWED_RUNNERS = {"ubuntu-24.04", "ubuntu-slim"} CHECKOUT_WRITE_WORKFLOWS = { - ".github/workflows/released-dependency-audit.yml", ".github/workflows/security-baseline-refresh.yml", ".github/workflows/update-contributors.yml", } diff --git a/tests/tools/check_all_pages.sh b/tests/tools/check_all_pages.sh index 83229fbbd8..e813fadb5e 100755 --- a/tests/tools/check_all_pages.sh +++ b/tests/tools/check_all_pages.sh @@ -758,6 +758,7 @@ FILTERED_LOG="$(grep -v \ -e "DSDEBUG Bad Data" \ -e "PUSHOUT Child Started" \ -e "MAINTENANCE INFO: Another maintenance session is already running" \ + -e "POLLER: Poller\[[0-9]*\] PID\[[0-9]*\] NOTE: Purged [0-9]* Audit Log Records from Cacti" \ -e "io_uring_queue_init() failed" \ "$CACTI_LOG")" || true diff --git a/tests/tools/test_workflow_policy.py b/tests/tools/test_workflow_policy.py index a798490e4f..409020c179 100644 --- a/tests/tools/test_workflow_policy.py +++ b/tests/tools/test_workflow_policy.py @@ -13,6 +13,7 @@ from unittest import mock ROOT = Path(__file__).resolve().parents[2] SCRIPT = ROOT / ".github/scripts/check-workflow-policy.py" PUBLISHER = ".github/workflows/released-dependency-audit.yml" +CONTRIBUTORS = ".github/workflows/update-contributors.yml" sys.dont_write_bytecode = True SPEC = importlib.util.spec_from_file_location("check_workflow_policy", SCRIPT) @@ -31,23 +32,29 @@ def run_policy(*workflows: str) -> tuple[int, str]: class WorkflowPolicyTest(unittest.TestCase): - def test_publisher_checkout_may_keep_credentials_for_its_push(self) -> None: + def test_publisher_passes_without_a_credentialed_checkout_allowance(self) -> None: + # The publisher scopes its git credentials to the push step, so its + # checkouts no longer need an entry in CHECKOUT_WRITE_WORKFLOWS. + self.assertNotIn(PUBLISHER, POLICY.CHECKOUT_WRITE_WORKFLOWS) + status, output = run_policy(PUBLISHER) self.assertEqual(0, status, output) def test_unlisted_workflow_with_a_credentialed_checkout_is_rejected(self) -> None: - allowed = POLICY.CHECKOUT_WRITE_WORKFLOWS - {PUBLISHER} + allowed = POLICY.CHECKOUT_WRITE_WORKFLOWS - {CONTRIBUTORS} with mock.patch.object(POLICY, "CHECKOUT_WRITE_WORKFLOWS", allowed): - status, output = run_policy(PUBLISHER) + status, output = run_policy(CONTRIBUTORS) self.assertEqual(1, status) - self.assertIn( - f"{PUBLISHER}:Checkout released branch for publication: " - "read-only checkout must set persist-credentials: false", - output, - ) + self.assertIn("read-only checkout must set persist-credentials: false", output) + self.assertIn(f"{CONTRIBUTORS}:", output) + + def test_listed_workflow_may_keep_checkout_credentials(self) -> None: + status, output = run_policy(CONTRIBUTORS) + + self.assertEqual(0, status, output) if __name__ == "__main__":