diff --git a/.fullsend/harness/verify-pr.yaml b/.fullsend/harness/verify-pr.yaml index 125f5a735..27d0de591 100644 --- a/.fullsend/harness/verify-pr.yaml +++ b/.fullsend/harness/verify-pr.yaml @@ -48,7 +48,7 @@ # (base URLs are validated against that allowlist, not inherited). # Re-pin after any base edit: push harness/verify-pr.yaml, set the SHA to the new # commit + the sha256 to `shasum -a 256 harness/verify-pr.yaml`, `fullsend lock`. -base: https://raw.githubusercontent.com/RHEcosystemAppEng/sdlc-plugins/0bcdff92d772db4132af79e72fcdbfdb8be57bde/harness/verify-pr.yaml#sha256=81ed85130c3d42493aab890a349b8c7ce76839d3903132f084f575f72c2d8186 +base: https://raw.githubusercontent.com/RHEcosystemAppEng/sdlc-plugins/02ba46de77353bd767ef7e2a0f4046ad92f5e1eb/harness/verify-pr.yaml#sha256=8b3d1f1663e73a8f053fffc7162a1724d78bcd864ff2130eb7d1a3d77283daa0 # CEL trigger (ADR 0061) — MUST be declared here, on the composing child, not # only on the base. `fullsend dispatch` registers this child (config.base.yaml diff --git a/.fullsend/lock.yaml b/.fullsend/lock.yaml index 927983a11..6f54c9bd5 100644 --- a/.fullsend/lock.yaml +++ b/.fullsend/lock.yaml @@ -336,59 +336,59 @@ harnesses: fetched_at: 2026-10-27T17:49:56.922062Z verify-pr: source: harness/verify-pr.yaml - sha256: 1c8f6946b1e3155ae74afb261186d5bc6f9d0d4dda63553141b0b50af630e977 - resolved_at: 2026-10-27T17:49:58.822942Z + sha256: 943ef2ede099dde296e08e1a238ec9fb831373d49f2cb16682af0e36ca9b7d45 + resolved_at: 2026-10-29T15:42:42.710683Z dependencies: - field: base - url: https://raw.githubusercontent.com/RHEcosystemAppEng/sdlc-plugins/0bcdff92d772db4132af79e72fcdbfdb8be57bde/harness/verify-pr.yaml - sha256: 81ed85130c3d42493aab890a349b8c7ce76839d3903132f084f575f72c2d8186 + url: https://raw.githubusercontent.com/RHEcosystemAppEng/sdlc-plugins/02ba46de77353bd767ef7e2a0f4046ad92f5e1eb/harness/verify-pr.yaml + sha256: 8b3d1f1663e73a8f053fffc7162a1724d78bcd864ff2130eb7d1a3d77283daa0 type: file - fetched_at: 2026-10-27T17:49:57.070607Z + fetched_at: 2026-10-29T15:42:34.873528Z - field: pre_script - url: https://raw.githubusercontent.com/RHEcosystemAppEng/sdlc-plugins/0bcdff92d772db4132af79e72fcdbfdb8be57bde/plugins/sdlc-workflow/scripts/pre-verify-pr.sh - sha256: 23781310b5d4dd4d8fe99dbb55e47434badc5dc3008685148796e6f60a4bb8ce + url: https://raw.githubusercontent.com/RHEcosystemAppEng/sdlc-plugins/02ba46de77353bd767ef7e2a0f4046ad92f5e1eb/plugins/sdlc-workflow/scripts/pre-verify-pr.sh + sha256: 34a1aaf4c53c40ad28e9f16b32defe58a2e751f3bc6769c50bc1489e5a1e6ba1 type: directory files: - path: execute-actions.py - sha256: 595220e3cac4426acaecfda17e9c7b73532cd9bf59a453c4093dc8e9a57a0936 + sha256: b1943700abe42de187a0958682b45ae43ffed244c5e3f161a5f212d95074ecfe - path: execute-triage-security-actions.py - sha256: 3c2fba88a6f65d349f522e5e0840bd680c0fd7f5f270c38bb1aac528e1f4e3cb + sha256: ce36c5a201be23152a49d116b0a90e6b1fa07530d0527c2958a60976536a3c06 - path: jira-client.py - sha256: d2ed3d8188f3f0ceda5f8ed13deadaba19e0f4a3ec9a4041d7f9bef4c101e5e7 + sha256: 6ee706af29a919bd78b5d5d0578c7d266ff65b0ff025ea46bb48bc74b6ecb5e2 - path: post-triage-security.sh sha256: 370e67d61a21609eae7503ae4b0fb5e79ce114352a3d36480dfbc1f392eae81a - path: post-verify-pr.sh - sha256: 0cdd85d68e1c94546964747badcb1837602aae0e47a168903f39e3760d1be687 + sha256: f08c12c152843b00dd84abb2b0eae90494668aceb0b1cba8ea2f3085b888ae2d - path: pre-triage-security.sh - sha256: ea31567399191ad17f318d46649d68de64559c6332131112a29259d1328d4673 + sha256: 3435ce1a664a41096121a0d3cb26f14e643cd205cc9e60e0c59097afa3c016b9 - path: pre-verify-pr.sh - sha256: 4f80f09e8a0f43609e088eeadf2cc539854df776bcd7c34f4fa13f20817de639 + sha256: 2fc2c0e12834ee3dd3d18cc6f8f9d3581e908f88a0e73548d777deecc689f3f4 - path: pre_triage_security.py - sha256: fea2ebbb49c8bcd01371ee44fe35047c41d8e464df40d71d155b816f2892e618 + sha256: 3fc8f9730e6d6ca33d4be37a75b20c57413b23b61236fccefe4dd7a5df0f44f5 - path: pre_verify_pr.py sha256: 95b4c146231bc109f45e7613dadb8a9ecbb872cbe987a5d56dd98214089e27da - path: strip_extra_properties.py sha256: 9099200014a0a4a9da8795a3346f963efc34c53f4603d340551c46b8d135d122 - path: test_execute_actions.py - sha256: 4170eea78768a516097d212a48b4b459ffb47370c0cc224bc157113d581ab0d4 + sha256: 936626fd12f184d66ce5f21a503f152154c97bd157cc3332d561d5ee886b10be - path: test_execute_triage_security_actions.py - sha256: fe43e9307dfed275d3408113c54f4e146ca2a93fa35974f1d1b6306fd5a29843 + sha256: d1589b3e8816f80a5bf1d801ef38dafc5f5d69a42cd48d93de5a15946fc0f976 - path: test_fullsend_gate_eval.py sha256: ccc67d006e872d1a6e31c8a01c49fb5eb57ea7a25f9380e2d29865ec19b98fea - path: test_jira_client.py - sha256: 1b9a6cc3aa36942e373df3ed847c550b2e396bc6df6cff5f03361253f7bbc8f1 + sha256: 8b417d72c84d7ec6823495185cabaddfdf7d663fd1f3e2c6c8fd173752942115 - path: test_jira_client_cli.py - sha256: d36b790c1a310111a0d2f3e81415f9576e80acc5f0bc7d0ff8084ffad001285f + sha256: bbf71c1e2ec4214459cb2f769f95f654de03f5818b2912be01dd88dae83a7cc2 - path: test_native_fullsend_eval_ci.py - sha256: a7df5cc8269c6129bf009f517343db91029dd9ed669d43d698fadde318f93363 + sha256: 9709a68679738767dd5421adfc7d90627461da4ca69faac86f403acb345f6faf - path: test_native_fullsend_execution.py sha256: 3b923e1e53fc410d648c9be56ef6c09c5b4cdc47ce4030541f5030b1fb757049 - path: test_pre_triage_security.py - sha256: cddebab3bebba2df545f58bc24045ef929193536f6c328d307f74f8754c0922e + sha256: 4a25ce05baf4a921849b7170a8e1cd7439818d4e66e8eee396205e2b669ca7fa - path: test_pre_verify_pr.py - sha256: e23e7292d73162feb1b39105a6abdc41181c26aa8d14685163066c45d62173d6 + sha256: 6563a15187877b388673edcc1e520626b337231b09af5adb563717367f7fb8d6 - path: test_triage_security_fullsend.py - sha256: 8837d5d6f4763c8bd7388b7f98d15c1f962c4280e83446fd9046f13dce4c4c0f + sha256: fb825e85ac713832c67234e04244764e3234a19d96feafca1defec20f73cfd7f - path: test_triage_security_staleness_evals.py sha256: 94bbc65f0c6b7d10dcae0af91dab3728f659722d4058aa5bc1ac4e8eadbc5547 - path: test_verify_pr_eval_observability.py @@ -397,52 +397,52 @@ harnesses: sha256: 7ce1b74a91c6a7fbef5b6070dcc65ebaba018ecf9e8595e645cce503fb775e78 - path: validate-output-schema.sh sha256: 56b964145da0b62f438dbc1885780d86e2d589c5340adb93c00e3c8777979cbe - fetched_at: 2026-10-27T17:49:21.277021Z + fetched_at: 2026-10-29T15:42:38.277478Z - field: post_script - url: https://raw.githubusercontent.com/RHEcosystemAppEng/sdlc-plugins/0bcdff92d772db4132af79e72fcdbfdb8be57bde/plugins/sdlc-workflow/scripts/post-verify-pr.sh - sha256: 23781310b5d4dd4d8fe99dbb55e47434badc5dc3008685148796e6f60a4bb8ce + url: https://raw.githubusercontent.com/RHEcosystemAppEng/sdlc-plugins/02ba46de77353bd767ef7e2a0f4046ad92f5e1eb/plugins/sdlc-workflow/scripts/post-verify-pr.sh + sha256: 34a1aaf4c53c40ad28e9f16b32defe58a2e751f3bc6769c50bc1489e5a1e6ba1 type: directory files: - path: execute-actions.py - sha256: 595220e3cac4426acaecfda17e9c7b73532cd9bf59a453c4093dc8e9a57a0936 + sha256: b1943700abe42de187a0958682b45ae43ffed244c5e3f161a5f212d95074ecfe - path: execute-triage-security-actions.py - sha256: 3c2fba88a6f65d349f522e5e0840bd680c0fd7f5f270c38bb1aac528e1f4e3cb + sha256: ce36c5a201be23152a49d116b0a90e6b1fa07530d0527c2958a60976536a3c06 - path: jira-client.py - sha256: d2ed3d8188f3f0ceda5f8ed13deadaba19e0f4a3ec9a4041d7f9bef4c101e5e7 + sha256: 6ee706af29a919bd78b5d5d0578c7d266ff65b0ff025ea46bb48bc74b6ecb5e2 - path: post-triage-security.sh sha256: 370e67d61a21609eae7503ae4b0fb5e79ce114352a3d36480dfbc1f392eae81a - path: post-verify-pr.sh - sha256: 0cdd85d68e1c94546964747badcb1837602aae0e47a168903f39e3760d1be687 + sha256: f08c12c152843b00dd84abb2b0eae90494668aceb0b1cba8ea2f3085b888ae2d - path: pre-triage-security.sh - sha256: ea31567399191ad17f318d46649d68de64559c6332131112a29259d1328d4673 + sha256: 3435ce1a664a41096121a0d3cb26f14e643cd205cc9e60e0c59097afa3c016b9 - path: pre-verify-pr.sh - sha256: 4f80f09e8a0f43609e088eeadf2cc539854df776bcd7c34f4fa13f20817de639 + sha256: 2fc2c0e12834ee3dd3d18cc6f8f9d3581e908f88a0e73548d777deecc689f3f4 - path: pre_triage_security.py - sha256: fea2ebbb49c8bcd01371ee44fe35047c41d8e464df40d71d155b816f2892e618 + sha256: 3fc8f9730e6d6ca33d4be37a75b20c57413b23b61236fccefe4dd7a5df0f44f5 - path: pre_verify_pr.py sha256: 95b4c146231bc109f45e7613dadb8a9ecbb872cbe987a5d56dd98214089e27da - path: strip_extra_properties.py sha256: 9099200014a0a4a9da8795a3346f963efc34c53f4603d340551c46b8d135d122 - path: test_execute_actions.py - sha256: 4170eea78768a516097d212a48b4b459ffb47370c0cc224bc157113d581ab0d4 + sha256: 936626fd12f184d66ce5f21a503f152154c97bd157cc3332d561d5ee886b10be - path: test_execute_triage_security_actions.py - sha256: fe43e9307dfed275d3408113c54f4e146ca2a93fa35974f1d1b6306fd5a29843 + sha256: d1589b3e8816f80a5bf1d801ef38dafc5f5d69a42cd48d93de5a15946fc0f976 - path: test_fullsend_gate_eval.py sha256: ccc67d006e872d1a6e31c8a01c49fb5eb57ea7a25f9380e2d29865ec19b98fea - path: test_jira_client.py - sha256: 1b9a6cc3aa36942e373df3ed847c550b2e396bc6df6cff5f03361253f7bbc8f1 + sha256: 8b417d72c84d7ec6823495185cabaddfdf7d663fd1f3e2c6c8fd173752942115 - path: test_jira_client_cli.py - sha256: d36b790c1a310111a0d2f3e81415f9576e80acc5f0bc7d0ff8084ffad001285f + sha256: bbf71c1e2ec4214459cb2f769f95f654de03f5818b2912be01dd88dae83a7cc2 - path: test_native_fullsend_eval_ci.py - sha256: a7df5cc8269c6129bf009f517343db91029dd9ed669d43d698fadde318f93363 + sha256: 9709a68679738767dd5421adfc7d90627461da4ca69faac86f403acb345f6faf - path: test_native_fullsend_execution.py sha256: 3b923e1e53fc410d648c9be56ef6c09c5b4cdc47ce4030541f5030b1fb757049 - path: test_pre_triage_security.py - sha256: cddebab3bebba2df545f58bc24045ef929193536f6c328d307f74f8754c0922e + sha256: 4a25ce05baf4a921849b7170a8e1cd7439818d4e66e8eee396205e2b669ca7fa - path: test_pre_verify_pr.py - sha256: e23e7292d73162feb1b39105a6abdc41181c26aa8d14685163066c45d62173d6 + sha256: 6563a15187877b388673edcc1e520626b337231b09af5adb563717367f7fb8d6 - path: test_triage_security_fullsend.py - sha256: 8837d5d6f4763c8bd7388b7f98d15c1f962c4280e83446fd9046f13dce4c4c0f + sha256: fb825e85ac713832c67234e04244764e3234a19d96feafca1defec20f73cfd7f - path: test_triage_security_staleness_evals.py sha256: 94bbc65f0c6b7d10dcae0af91dab3728f659722d4058aa5bc1ac4e8eadbc5547 - path: test_verify_pr_eval_observability.py @@ -451,52 +451,52 @@ harnesses: sha256: 7ce1b74a91c6a7fbef5b6070dcc65ebaba018ecf9e8595e645cce503fb775e78 - path: validate-output-schema.sh sha256: 56b964145da0b62f438dbc1885780d86e2d589c5340adb93c00e3c8777979cbe - fetched_at: 2026-10-27T17:49:21.277021Z + fetched_at: 2026-10-29T15:42:38.268136Z - field: validation_loop.script - url: https://raw.githubusercontent.com/RHEcosystemAppEng/sdlc-plugins/0bcdff92d772db4132af79e72fcdbfdb8be57bde/plugins/sdlc-workflow/scripts/validate-output-schema.sh - sha256: 23781310b5d4dd4d8fe99dbb55e47434badc5dc3008685148796e6f60a4bb8ce + url: https://raw.githubusercontent.com/RHEcosystemAppEng/sdlc-plugins/02ba46de77353bd767ef7e2a0f4046ad92f5e1eb/plugins/sdlc-workflow/scripts/validate-output-schema.sh + sha256: 34a1aaf4c53c40ad28e9f16b32defe58a2e751f3bc6769c50bc1489e5a1e6ba1 type: directory files: - path: execute-actions.py - sha256: 595220e3cac4426acaecfda17e9c7b73532cd9bf59a453c4093dc8e9a57a0936 + sha256: b1943700abe42de187a0958682b45ae43ffed244c5e3f161a5f212d95074ecfe - path: execute-triage-security-actions.py - sha256: 3c2fba88a6f65d349f522e5e0840bd680c0fd7f5f270c38bb1aac528e1f4e3cb + sha256: ce36c5a201be23152a49d116b0a90e6b1fa07530d0527c2958a60976536a3c06 - path: jira-client.py - sha256: d2ed3d8188f3f0ceda5f8ed13deadaba19e0f4a3ec9a4041d7f9bef4c101e5e7 + sha256: 6ee706af29a919bd78b5d5d0578c7d266ff65b0ff025ea46bb48bc74b6ecb5e2 - path: post-triage-security.sh sha256: 370e67d61a21609eae7503ae4b0fb5e79ce114352a3d36480dfbc1f392eae81a - path: post-verify-pr.sh - sha256: 0cdd85d68e1c94546964747badcb1837602aae0e47a168903f39e3760d1be687 + sha256: f08c12c152843b00dd84abb2b0eae90494668aceb0b1cba8ea2f3085b888ae2d - path: pre-triage-security.sh - sha256: ea31567399191ad17f318d46649d68de64559c6332131112a29259d1328d4673 + sha256: 3435ce1a664a41096121a0d3cb26f14e643cd205cc9e60e0c59097afa3c016b9 - path: pre-verify-pr.sh - sha256: 4f80f09e8a0f43609e088eeadf2cc539854df776bcd7c34f4fa13f20817de639 + sha256: 2fc2c0e12834ee3dd3d18cc6f8f9d3581e908f88a0e73548d777deecc689f3f4 - path: pre_triage_security.py - sha256: fea2ebbb49c8bcd01371ee44fe35047c41d8e464df40d71d155b816f2892e618 + sha256: 3fc8f9730e6d6ca33d4be37a75b20c57413b23b61236fccefe4dd7a5df0f44f5 - path: pre_verify_pr.py sha256: 95b4c146231bc109f45e7613dadb8a9ecbb872cbe987a5d56dd98214089e27da - path: strip_extra_properties.py sha256: 9099200014a0a4a9da8795a3346f963efc34c53f4603d340551c46b8d135d122 - path: test_execute_actions.py - sha256: 4170eea78768a516097d212a48b4b459ffb47370c0cc224bc157113d581ab0d4 + sha256: 936626fd12f184d66ce5f21a503f152154c97bd157cc3332d561d5ee886b10be - path: test_execute_triage_security_actions.py - sha256: fe43e9307dfed275d3408113c54f4e146ca2a93fa35974f1d1b6306fd5a29843 + sha256: d1589b3e8816f80a5bf1d801ef38dafc5f5d69a42cd48d93de5a15946fc0f976 - path: test_fullsend_gate_eval.py sha256: ccc67d006e872d1a6e31c8a01c49fb5eb57ea7a25f9380e2d29865ec19b98fea - path: test_jira_client.py - sha256: 1b9a6cc3aa36942e373df3ed847c550b2e396bc6df6cff5f03361253f7bbc8f1 + sha256: 8b417d72c84d7ec6823495185cabaddfdf7d663fd1f3e2c6c8fd173752942115 - path: test_jira_client_cli.py - sha256: d36b790c1a310111a0d2f3e81415f9576e80acc5f0bc7d0ff8084ffad001285f + sha256: bbf71c1e2ec4214459cb2f769f95f654de03f5818b2912be01dd88dae83a7cc2 - path: test_native_fullsend_eval_ci.py - sha256: a7df5cc8269c6129bf009f517343db91029dd9ed669d43d698fadde318f93363 + sha256: 9709a68679738767dd5421adfc7d90627461da4ca69faac86f403acb345f6faf - path: test_native_fullsend_execution.py sha256: 3b923e1e53fc410d648c9be56ef6c09c5b4cdc47ce4030541f5030b1fb757049 - path: test_pre_triage_security.py - sha256: cddebab3bebba2df545f58bc24045ef929193536f6c328d307f74f8754c0922e + sha256: 4a25ce05baf4a921849b7170a8e1cd7439818d4e66e8eee396205e2b669ca7fa - path: test_pre_verify_pr.py - sha256: e23e7292d73162feb1b39105a6abdc41181c26aa8d14685163066c45d62173d6 + sha256: 6563a15187877b388673edcc1e520626b337231b09af5adb563717367f7fb8d6 - path: test_triage_security_fullsend.py - sha256: 8837d5d6f4763c8bd7388b7f98d15c1f962c4280e83446fd9046f13dce4c4c0f + sha256: fb825e85ac713832c67234e04244764e3234a19d96feafca1defec20f73cfd7f - path: test_triage_security_staleness_evals.py sha256: 94bbc65f0c6b7d10dcae0af91dab3728f659722d4058aa5bc1ac4e8eadbc5547 - path: test_verify_pr_eval_observability.py @@ -505,30 +505,30 @@ harnesses: sha256: 7ce1b74a91c6a7fbef5b6070dcc65ebaba018ecf9e8595e645cce503fb775e78 - path: validate-output-schema.sh sha256: 56b964145da0b62f438dbc1885780d86e2d589c5340adb93c00e3c8777979cbe - fetched_at: 2026-10-27T17:49:21.277021Z + fetched_at: 2026-10-29T15:42:38.268136Z - field: validation_loop.schema - url: https://raw.githubusercontent.com/RHEcosystemAppEng/sdlc-plugins/0bcdff92d772db4132af79e72fcdbfdb8be57bde/plugins/sdlc-workflow/schemas/verify-pr-result.schema.json + url: https://raw.githubusercontent.com/RHEcosystemAppEng/sdlc-plugins/02ba46de77353bd767ef7e2a0f4046ad92f5e1eb/plugins/sdlc-workflow/schemas/verify-pr-result.schema.json sha256: 62c3e5ce0c47e73823b5cab9a577be7b721d8fb31389bc8602dc82ee05526ad6 type: resource - fetched_at: 2026-10-27T17:49:57.935461Z + fetched_at: 2026-10-29T15:42:38.600059Z - field: agent - url: https://raw.githubusercontent.com/RHEcosystemAppEng/sdlc-plugins/0bcdff92d772db4132af79e72fcdbfdb8be57bde/plugins/sdlc-workflow/agents/verify-pr.md + url: https://raw.githubusercontent.com/RHEcosystemAppEng/sdlc-plugins/02ba46de77353bd767ef7e2a0f4046ad92f5e1eb/plugins/sdlc-workflow/agents/verify-pr.md sha256: 229fef270b4b195f91cc46ef3ba50cbf7701f49ee546291882cff893d53844b3 type: resource - fetched_at: 2026-10-27T17:49:58.392385Z + fetched_at: 2026-10-29T15:42:38.879531Z - field: policy - url: https://raw.githubusercontent.com/RHEcosystemAppEng/sdlc-plugins/0bcdff92d772db4132af79e72fcdbfdb8be57bde/plugins/sdlc-workflow/policies/verify-pr.yaml + url: https://raw.githubusercontent.com/RHEcosystemAppEng/sdlc-plugins/02ba46de77353bd767ef7e2a0f4046ad92f5e1eb/plugins/sdlc-workflow/policies/verify-pr.yaml sha256: 62d1374be253b0b225921bd8e22e679781076ecdb3a9ea22d5e6a4805753c5a7 type: resource - fetched_at: 2026-10-27T17:49:58.798838Z + fetched_at: 2026-10-29T15:42:39.174272Z - field: host_files[0].src - url: https://raw.githubusercontent.com/RHEcosystemAppEng/sdlc-plugins/0bcdff92d772db4132af79e72fcdbfdb8be57bde/plugins/sdlc-workflow/env/gcp-vertex.env + url: https://raw.githubusercontent.com/RHEcosystemAppEng/sdlc-plugins/02ba46de77353bd767ef7e2a0f4046ad92f5e1eb/plugins/sdlc-workflow/env/gcp-vertex.env sha256: 10b2ba695b1d4e65e0964a233b75d6a06853f1eaefc260c56b9eedd989ae7d41 type: resource - fetched_at: 2026-10-27T17:49:52.960372Z + fetched_at: 2026-10-29T15:42:39.473087Z - field: plugins[0] - url: https://raw.githubusercontent.com/RHEcosystemAppEng/sdlc-plugins/0bcdff92d772db4132af79e72fcdbfdb8be57bde/plugins/sdlc-workflow/ - sha256: ba7a12fe8a9e4222e8e28128bba62b21c62c0438c9d9847aeafc1320e7d459ec + url: https://raw.githubusercontent.com/RHEcosystemAppEng/sdlc-plugins/02ba46de77353bd767ef7e2a0f4046ad92f5e1eb/plugins/sdlc-workflow/ + sha256: 0d32724e37ff7dd70b3b6ea4268691b5d66128ebedb8eb67180962f3e2e268af type: directory files: - path: .claude-plugin/plugin.json @@ -552,45 +552,45 @@ harnesses: - path: schemas/verify-pr-result.schema.json sha256: 62c3e5ce0c47e73823b5cab9a577be7b721d8fb31389bc8602dc82ee05526ad6 - path: scripts/execute-actions.py - sha256: 595220e3cac4426acaecfda17e9c7b73532cd9bf59a453c4093dc8e9a57a0936 + sha256: b1943700abe42de187a0958682b45ae43ffed244c5e3f161a5f212d95074ecfe - path: scripts/execute-triage-security-actions.py - sha256: 3c2fba88a6f65d349f522e5e0840bd680c0fd7f5f270c38bb1aac528e1f4e3cb + sha256: ce36c5a201be23152a49d116b0a90e6b1fa07530d0527c2958a60976536a3c06 - path: scripts/jira-client.py - sha256: d2ed3d8188f3f0ceda5f8ed13deadaba19e0f4a3ec9a4041d7f9bef4c101e5e7 + sha256: 6ee706af29a919bd78b5d5d0578c7d266ff65b0ff025ea46bb48bc74b6ecb5e2 - path: scripts/post-triage-security.sh sha256: 370e67d61a21609eae7503ae4b0fb5e79ce114352a3d36480dfbc1f392eae81a - path: scripts/post-verify-pr.sh - sha256: 0cdd85d68e1c94546964747badcb1837602aae0e47a168903f39e3760d1be687 + sha256: f08c12c152843b00dd84abb2b0eae90494668aceb0b1cba8ea2f3085b888ae2d - path: scripts/pre-triage-security.sh - sha256: ea31567399191ad17f318d46649d68de64559c6332131112a29259d1328d4673 + sha256: 3435ce1a664a41096121a0d3cb26f14e643cd205cc9e60e0c59097afa3c016b9 - path: scripts/pre-verify-pr.sh - sha256: 4f80f09e8a0f43609e088eeadf2cc539854df776bcd7c34f4fa13f20817de639 + sha256: 2fc2c0e12834ee3dd3d18cc6f8f9d3581e908f88a0e73548d777deecc689f3f4 - path: scripts/pre_triage_security.py - sha256: fea2ebbb49c8bcd01371ee44fe35047c41d8e464df40d71d155b816f2892e618 + sha256: 3fc8f9730e6d6ca33d4be37a75b20c57413b23b61236fccefe4dd7a5df0f44f5 - path: scripts/pre_verify_pr.py sha256: 95b4c146231bc109f45e7613dadb8a9ecbb872cbe987a5d56dd98214089e27da - path: scripts/strip_extra_properties.py sha256: 9099200014a0a4a9da8795a3346f963efc34c53f4603d340551c46b8d135d122 - path: scripts/test_execute_actions.py - sha256: 4170eea78768a516097d212a48b4b459ffb47370c0cc224bc157113d581ab0d4 + sha256: 936626fd12f184d66ce5f21a503f152154c97bd157cc3332d561d5ee886b10be - path: scripts/test_execute_triage_security_actions.py - sha256: fe43e9307dfed275d3408113c54f4e146ca2a93fa35974f1d1b6306fd5a29843 + sha256: d1589b3e8816f80a5bf1d801ef38dafc5f5d69a42cd48d93de5a15946fc0f976 - path: scripts/test_fullsend_gate_eval.py sha256: ccc67d006e872d1a6e31c8a01c49fb5eb57ea7a25f9380e2d29865ec19b98fea - path: scripts/test_jira_client.py - sha256: 1b9a6cc3aa36942e373df3ed847c550b2e396bc6df6cff5f03361253f7bbc8f1 + sha256: 8b417d72c84d7ec6823495185cabaddfdf7d663fd1f3e2c6c8fd173752942115 - path: scripts/test_jira_client_cli.py - sha256: d36b790c1a310111a0d2f3e81415f9576e80acc5f0bc7d0ff8084ffad001285f + sha256: bbf71c1e2ec4214459cb2f769f95f654de03f5818b2912be01dd88dae83a7cc2 - path: scripts/test_native_fullsend_eval_ci.py - sha256: a7df5cc8269c6129bf009f517343db91029dd9ed669d43d698fadde318f93363 + sha256: 9709a68679738767dd5421adfc7d90627461da4ca69faac86f403acb345f6faf - path: scripts/test_native_fullsend_execution.py sha256: 3b923e1e53fc410d648c9be56ef6c09c5b4cdc47ce4030541f5030b1fb757049 - path: scripts/test_pre_triage_security.py - sha256: cddebab3bebba2df545f58bc24045ef929193536f6c328d307f74f8754c0922e + sha256: 4a25ce05baf4a921849b7170a8e1cd7439818d4e66e8eee396205e2b669ca7fa - path: scripts/test_pre_verify_pr.py - sha256: e23e7292d73162feb1b39105a6abdc41181c26aa8d14685163066c45d62173d6 + sha256: 6563a15187877b388673edcc1e520626b337231b09af5adb563717367f7fb8d6 - path: scripts/test_triage_security_fullsend.py - sha256: 8837d5d6f4763c8bd7388b7f98d15c1f962c4280e83446fd9046f13dce4c4c0f + sha256: fb825e85ac713832c67234e04244764e3234a19d96feafca1defec20f73cfd7f - path: scripts/test_triage_security_staleness_evals.py sha256: 94bbc65f0c6b7d10dcae0af91dab3728f659722d4058aa5bc1ac4e8eadbc5547 - path: scripts/test_verify_pr_eval_observability.py @@ -618,9 +618,9 @@ harnesses: - path: skills/define-feature/SKILL.md sha256: c314f3f549c3ef835e03c38ed8ce2212422c77a876d9b786dd4e08806f5d5e4e - path: skills/implement-task/SKILL.md - sha256: bd4ea474c2504cbdc0500bdfb33949af53584b05dc2696bcf9f12dc5d898a16a + sha256: 263fc83a8c487ed0bc7e3522b3b005391b03eb897f5075d12a1ab19d9c2058c2 - path: skills/plan-feature/SKILL.md - sha256: a8603de28ac9ff7d163b3ef5e11c44ab3f190d735e7ec6fd57604b6b9766a9ce + sha256: e0e51e4a30e46fb76e024e0ec27fb5b0216c48496a61fb013f197f38879f9785 - path: skills/report-bug/SKILL.md sha256: cc841f523aa9b2620f01426c32a84ee29710c732157356743a87e8ff60823cc4 - path: skills/run-evals/SKILL.md @@ -665,4 +665,4 @@ harnesses: sha256: 128877cf7e156666dbb403805a0112059cc8cc3255e148c6794da29d48b8f5cf - path: skills/verify-pr/style-conventions.md sha256: 5ab920c596615c0d23354cb0e90fe5ebf5f08635ffa3602e8e2d2abd74028a19 - fetched_at: 2026-10-27T17:49:56.901958Z + fetched_at: 2026-10-29T15:42:42.702161Z diff --git a/fullsend.md b/fullsend.md index d4ab8109b..a4ad923b2 100644 --- a/fullsend.md +++ b/fullsend.md @@ -56,8 +56,8 @@ serve interactive Claude Code users and fullsend runs with zero duplication. The Jira and GitHub tokens live **only on the runner**. The pre_script prefetches everything the agent needs (the Jira issue and a GitHub read bundle) and the post_script performs every write after the sandbox is destroyed. The sandbox -itself receives read-only context only — `JIRA_BASE_URL` (display links) — plus -the prefetched read bundle mounted read-only. The Jira key is not passed as an +itself receives no Jira configuration — only the prefetched read bundle, mounted +read-only. The Jira key is not passed as an env var: the pre_script derives it from the triggering PR URL and records it as `task_id` inside `verify-pr-input.json`, which the agent reads. The **only** credential that ever enters the sandbox is the Vertex AI service-account key, @@ -70,10 +70,98 @@ never place a credential in the sandbox at all. | Service | Tier | Credential in sandbox? | How it is delivered | |---|---|---|---| -| **Jira** | 1 | No | The pre_script prefetches the issue on the runner; the post_script posts comments with `fullsend issues post-comment --tracker jira`. The token stays in runner env only. | +| **Jira** | 1 | No | The pre_script prefetches the issue on the runner; the post_script posts comments with `fullsend issues post-comment --tracker jira`. The token stays in runner env only. REST calls go through the Atlassian API gateway (see **Jira through the API gateway** below). | | **GitHub** | 1 | No | The pre_script prefetches the read bundle (`gh pr diff` / `gh pr view` → diff, diffstat, reviews, comments, commits), the head-SHA **CI check-run outcomes** (`github.check_runs` — name/status/conclusion/details_url), and the **concatenated `--log-failed` output of every failed check-run** (written to `check-run-logs.txt`, mounted separately; only its path rides in the bundle so the large log text stays off the agent's context until Correctness Check 1b reads it on a FAIL), and records the PR head ref name and head commit SHA in it; the post_script writes via `fullsend issues post-comment --tracker github` and `gh` (PR reviews/replies via `gh api`). The token stays in runner env only. The PR-head working tree is the `--target-repo` clone, checked out at the head SHA before the run (see below) — the pre_script does not check out. | | **Vertex AI** | 4 (fullsend-mandated) | **Yes** | The in-sandbox runtime does the model inference and reads `GOOGLE_APPLICATION_CREDENTIALS` from a file (`/tmp/.gcp-credentials.json`). Vertex auth requires local JWT signing, so tier 4 (file on the sandbox filesystem) is unavoidable. This is the one credential set in the sandbox. | +### Jira through the API gateway + +The Jira credential is a dedicated Atlassian **Service Account** +(`tpa-fullsend-jira-sa`, issued through JIRACONFSD-10163). Its scoped API token +authenticates **only through the Atlassian API gateway**, so every runner-side +Jira REST call uses the gateway as its base: + +```text +JIRA_BASE_URL=https://api.atlassian.com/ex/jira/ +``` + +On the site URL (`https://redhat.atlassian.net`) the Service Account token gets +401/403, and an unauthenticated JQL search **silently returns `[]`** — so a green +job is not proof the credential works; check that the report comment is authored +by the Service Account. + +| Token | Site, Basic | Site, Bearer | Gateway, Basic | Gateway, Bearer | +|---|---|---|---|---| +| Service Account (`ATSTT`) | 401 / empty `[]` | 403 | 200 | 200 | +| Personal (`ATATT`) | 200 | 403 | 200 | 401 | + +- **`jira-client.py` picks the auth scheme from `JIRA_EMAIL`.** Unset or empty + (the runner): the token is sent as `Bearer`. Set (interactive users with + personal tokens, which are Basic-only): `Basic email:token`, unchanged. Neither + harness sets `JIRA_EMAIL`. fullsend layers `env.runner` over the inherited host + environment, so **do not export `JIRA_EMAIL` in the shell of a local + `fullsend run`** (the interactive `/setup` flow may have): it would reach + `jira-client.py` and switch the runner to Basic, which pairs your email with + the Service Account token and gets a 401. +- **The email reaches only the fullsend CLI.** `fullsend issues post-comment` + (called from `execute-actions.py`, including triage-security `comment` actions + through `post_jira_comment_native`) authenticates with Basic and requires + `JIRA_USER_EMAIL`. Both harnesses declare it in `env.runner` because fullsend + drops it from script environments otherwise; no other script reads it. +- **The pre_script fails closed before trusting an empty search.** Because both + a broken credential and an account without project access get `200 []` from + JQL, `pre-verify-pr.sh` first requires `GET /myself` to resolve an `accountId` + (`jira-client.py verify_identity`) and `BROWSE_PROJECTS` on + `JIRA_PROJECT_KEY` (`verify_project_access`, via `GET /mypermissions`); only + then is an empty search an ADR-0072 skip. The Service Account therefore needs + Browse Projects on TC and a token allowed to read `/myself`. +- **The email must be the one on record, with its random suffix** + (`tpa-fullsend-jira-sa-@serviceaccount.atlassian.com`); the display + address without the suffix gets 401. Read it with + `GET /rest/api/3/myself` → `emailAddress`. +- **`/browse/` links come from `GET /rest/api/3/serverInfo` → `baseUrl`**, which + returns the site address through either base. It is fetched once per process, + only when a link is needed, and a failure aborts the run — there is no fallback + to `JIRA_SERVER_URL` (the gateway URL has no browsable hostname). The three link + builders are `execute-actions.py` (sub-task links in PR replies), + `execute-triage-security-actions.py` (generated references) and + `pre_triage_security.py discover`. + +> **Unsupported fullsend setup.** fullsend documents gateway URLs and managed +> Service Accounts as unsupported (fullsend-ai/fullsend#8678; native support is +> tracked in #4885). It works today because the CLI builds +> `{JIRA_BASE_URL}/rest/api/3/...`. **Re-check it on every fullsend bump.** +> Fallback if a bump breaks it: replace `post_jira_comment_native` with +> `jira-client.py` (Bearer on the gateway), adding a find-and-update-by-marker +> helper so re-runs don't duplicate the report comment; then drop +> `JIRA_USER_EMAIL` and the `JIRA_EMAIL` secret. Switch back once #4885 delivers +> native support. + +**Exit condition.** The interim personal API token used before TC-6191 is +replaced by the Service Account: CI's `JIRA_API_TOKEN` / `JIRA_EMAIL` secrets +hold the Service Account token and suffixed email, and `JIRA_BASE_URL` is the +gateway. Because the runner sends Bearer and personal tokens fail Bearer, the +secrets must be switched **before** merging code that drops `JIRA_EMAIL` from the +runner. + +**Emergency fallback to a personal token (CI).** If the Service Account token is +unavailable, CI can run on a personal API token, but not by swapping secrets +alone: personal tokens are Basic-only, and the dispatch forwards only +`JIRA_TOKEN`, `JIRA_USER_EMAIL` and `JIRA_BASE_URL` to the runner, so +`jira-client.py` has no email and sends Bearer (personal token → 401). The +procedure is a code change: + +1. Set the repo secrets `JIRA_API_TOKEN` (personal token) and `JIRA_EMAIL` + (that account's email). `JIRA_BASE_URL` can stay on the gateway (personal + Basic → 200 there). +2. In `harness/verify-pr.yaml` (and `harness/triage-security.yaml` if needed), + add `JIRA_EMAIL: "${JIRA_USER_EMAIL}"` under `env.runner`, so `jira-client.py` + uses Basic. +3. Commit, push, re-pin and re-lock (**The pin-and-bump process**), and merge + with a merge commit. +4. To return to the Service Account, restore its secrets and revert step 2 with + another re-pin. + Because Vertex is the only in-sandbox credential, the sandbox's only network egress is the inference egress of fullsend's **built-in `fullsend-vertex-ai` profile**: `*.googleapis.com:443` and `api.anthropic.com:443`, for the @@ -156,11 +244,11 @@ ANTHROPIC_VERTEX_PROJECT_ID=my-project GOOGLE_CLOUD_PROJECT=my-project CLOUD_ML_REGION=global GOOGLE_APPLICATION_CREDENTIALS=/path/to/sa-key.json -# Jira (tier 1 — runner only) -JIRA_SERVER_URL=https://myorg.atlassian.net -JIRA_EMAIL=me@example.com -JIRA_API_TOKEN=my-jira-token -JIRA_PROJECT_KEY=TC +# Jira (tier 1 — runner only). The harness maps these host vars in env.runner. +JIRA_BASE_URL=https://api.atlassian.com/ex/jira/ +JIRA_TOKEN=my-service-account-token +# Email on record (with its suffix); read only by `fullsend issues post-comment` +JIRA_USER_EMAIL=my-sa-@serviceaccount.atlassian.com # GitHub (tier 1 — runner only) GH_TOKEN=my-github-token ``` @@ -313,9 +401,9 @@ repo's **Settings → Secrets and variables → Actions** (or with `gh variable | Name | Kind | Purpose | Update when | |---|---|---|---| -| `JIRA_EMAIL` | secret | Jira Service Account email for the tier-1 Basic-auth credential (mapped to vendor input `JIRA_USER_EMAIL`); authors the report comment. | Changing the Jira Service Account. | -| `JIRA_API_TOKEN` | secret | Jira scoped API token for the same account (mapped to `JIRA_TOKEN`). | Rotating the SA token (tokens expire / are revoked). | -| `JIRA_BASE_URL` | variable | Jira site URL for display links inside the sandbox. | Jira site moves. | +| `JIRA_EMAIL` | secret | Jira Service Account email **on record, with its random suffix** (mapped to vendor input `JIRA_USER_EMAIL`); read only by the fullsend CLI, which authors the report comment with Basic auth. | Changing the Jira Service Account. | +| `JIRA_API_TOKEN` | secret | Jira scoped API token for the same account (mapped to `JIRA_TOKEN`); `jira-client.py` sends it as Bearer. | Rotating the SA token (tokens expire / are revoked). | +| `JIRA_BASE_URL` | variable | Atlassian API gateway REST base, `https://api.atlassian.com/ex/jira/`, for every runner Jira call. Not used for links (those come from `serverInfo`). | Jira site / cloud ID changes. | | `FULLSEND_GCP_WIF_PROVIDER` | secret | Vertex Workload Identity Federation provider resource. | Re-provisioning inference (`fullsend inference provision`). | | `FULLSEND_GCP_PROJECT_ID` | secret | GCP project hosting Vertex inference. | GCP project changes. | | `FULLSEND_MINT_URL` | variable | OIDC mint endpoint for the review-role App token. | App / mint endpoint changes. | @@ -323,8 +411,9 @@ repo's **Settings → Secrets and variables → Actions** (or with `gh variable | `FULLSEND_PROJECT_NUMBER` | variable | GCP project number for OIDC. | GCP project changes. | | `OTEL_EXPORTER_OTLP_HEADERS`, `OTEL_EXPORTER_OTLP_TRACES_HEADERS` | secret | OpenTelemetry export auth headers (optional observability). | Rotating the OTLP endpoint credential. | -The Jira credential is a dedicated **Service Account** — email + scoped token, -Basic auth (fullsend's Jira tracker is Basic-auth only). It is a **tier-1** +The Jira credential is a dedicated **Service Account** — scoped token used through +the API gateway (Bearer from `jira-client.py`, Basic with the suffixed email from +the fullsend CLI; see **Jira through the API gateway**). It is a **tier-1** credential: it stays in runner env and never enters the sandbox (see **Credential delivery and tiers**). To rotate it, issue a new scoped token for the SA and update `JIRA_API_TOKEN` (and `JIRA_EMAIL` if the account itself changes); the next @@ -429,10 +518,10 @@ that affect this repo: - **Jira secrets no longer inherited by host scripts** (#8154, v0.46.0). `JIRA_TOKEN`, `JIRA_USER_EMAIL` and the OTLP header variables are dropped from the pre/post/validation script environment unless the harness declares them in - `env.runner`. Both harnesses already map them explicitly - (`JIRA_API_TOKEN: "${JIRA_TOKEN}"`, `JIRA_EMAIL: "${JIRA_USER_EMAIL}"`), so no - change is needed — but a script must never read the dispatch-provided names - ambiently. + `env.runner`. Both harnesses map the token explicitly + (`JIRA_API_TOKEN: "${JIRA_TOKEN}"`) and declare + `JIRA_USER_EMAIL: "${JIRA_USER_EMAIL}"` for the fullsend CLI, so no change is + needed — but a script must never read the dispatch-provided names ambiently. - **`issues post-comment` verifies the comment author** (v0.44.0). The sticky Jira/GitHub comment that `execute-actions.py` posts is edited only when its author is the identity posting now; otherwise a new comment is posted. After a @@ -691,8 +780,9 @@ against the pinned `validation_loop.schema`. The caller supplies the rest. history (matrix refs are read with `git show`); `git clone --filter=blob:none` is enough, a shallow clone is not. - The runner needs `jsonschema[format]` for the pre-script's bundle validation. -- Jira credentials stay runner-only (`JIRA_BASE_URL`, `JIRA_USER_EMAIL`, - `JIRA_TOKEN`, mapped in `env.runner`). +- Jira credentials stay runner-only (`JIRA_BASE_URL` — the API gateway — + `JIRA_TOKEN`, and `JIRA_USER_EMAIL` for `comment` actions, mapped in + `env.runner`; see **Jira through the API gateway**). **Adopter child.** Fullsend rejects an absolute `host_files` source inherited from a URL-sourced base, so the adopter's local child re-declares the runner diff --git a/harness/triage-security.yaml b/harness/triage-security.yaml index 36af567ec..94f6392b4 100644 --- a/harness/triage-security.yaml +++ b/harness/triage-security.yaml @@ -63,14 +63,17 @@ validation_loop: env: runner: PYTHONDONTWRITEBYTECODE: "1" + # JIRA_BASE_URL is the Atlassian API gateway; with no JIRA_EMAIL set, + # jira-client.py sends the token as Bearer. Browse links come from serverInfo. JIRA_SERVER_URL: "${JIRA_BASE_URL}" - JIRA_EMAIL: "${JIRA_USER_EMAIL}" JIRA_API_TOKEN: "${JIRA_TOKEN}" + # The email on record for the token, consumed ONLY by the fullsend CLI: + # `comment` actions post through execute-actions.py post_jira_comment_native + # (`fullsend issues post-comment`, Basic auth). fullsend drops JIRA_USER_EMAIL + # from script environments unless env.runner declares it. + JIRA_USER_EMAIL: "${JIRA_USER_EMAIL}" JIRA_PROJECT_KEY: "TC" FULLSEND_OUTPUT_FILE: "agent-result.json" - sandbox: - # Display-only context; the sandbox has no Jira egress or credential. - JIRA_BASE_URL: "${JIRA_BASE_URL}" timeout_minutes: 30 version: 1 diff --git a/harness/verify-pr.yaml b/harness/verify-pr.yaml index 3d62de197..c7e56149b 100644 --- a/harness/verify-pr.yaml +++ b/harness/verify-pr.yaml @@ -14,8 +14,10 @@ # # Split-trust I/O: the Jira and GitHub tokens live ONLY on the runner (pre_script # prefetch + post_script writes) and are NEVER exposed to the sandbox. The -# sandbox receives read-only context only (JIRA_BASE_URL for display links) and -# reads the Jira task + PR URL from the pre_script's verify-pr-input.json. +# sandbox gets no Jira configuration at all: it reads the Jira task + PR URL from +# the pre_script's verify-pr-input.json. Runner Jira REST calls go through the +# Atlassian API gateway (JIRA_BASE_URL); human-facing /browse/ links come from +# Jira's serverInfo.baseUrl, not from that URL (fullsend.md "Credential delivery"). # # The Vertex provider and its egress profile are fullsend's built-ins, declared by # bare name below (TC-7141); the repo copies (providers/vertex-ai.yaml, @@ -110,8 +112,7 @@ validation_loop: env: # Tokens (JIRA_API_TOKEN, GH_TOKEN) live on the runner ONLY — the pre_script - # prefetch and post_script writes need them; they are never placed in - # env.sandbox. + # prefetch and post_script writes need them; nothing is placed in env.sandbox. runner: # Disable Python bytecode writes for every runner-side Python invocation. # The pre/post scripts execute in place inside fullsend's content-addressed @@ -120,14 +121,21 @@ env: # execute-actions.py's own sys.dont_write_bytecode (TC-6112). PYTHONDONTWRITEBYTECODE: "1" # Map fullsend's dispatch-provided Jira host vars (JIRA_BASE_URL / - # JIRA_USER_EMAIL / JIRA_TOKEN — set by reusable-dispatch harness-run) onto - # the canonical names jira-client.py reads. A local run must export the same - # JIRA_BASE_URL / JIRA_USER_EMAIL / JIRA_TOKEN host vars. JIRA_ISSUE_ID is no - # longer an input: the pre_script derives the Jira key from the triggering PR - # URL (FULLSEND_WORK_ITEM_URL, read ambiently) by JQL on customfield_10875. + # JIRA_TOKEN — set by reusable-dispatch harness-run) onto the canonical + # names jira-client.py reads. JIRA_BASE_URL is the Atlassian API gateway + # (https://api.atlassian.com/ex/jira/); with no JIRA_EMAIL set, + # jira-client.py sends the Service Account token as Bearer. A local run must + # export the same JIRA_BASE_URL / JIRA_USER_EMAIL / JIRA_TOKEN host vars. + # JIRA_ISSUE_ID is no longer an input: the pre_script derives the Jira key + # from the triggering PR URL (FULLSEND_WORK_ITEM_URL, read ambiently) by JQL + # on customfield_10875. JIRA_SERVER_URL: "${JIRA_BASE_URL}" - JIRA_EMAIL: "${JIRA_USER_EMAIL}" JIRA_API_TOKEN: "${JIRA_TOKEN}" + # The email on record for the token, consumed ONLY by the fullsend CLI + # (`fullsend issues post-comment` in execute-actions.py requires Basic auth). + # Declared explicitly because fullsend drops JIRA_USER_EMAIL from script + # environments unless env.runner declares it (inheritedScriptDenyKeys). + JIRA_USER_EMAIL: "${JIRA_USER_EMAIL}" # Project key for post_script root-cause task creation. The CI dispatch path # exports no project-key host var, so pin this repo's constant (CLAUDE.md # Jira Configuration: Project key TC) as a literal rather than a ${ref} that @@ -136,13 +144,9 @@ env: GH_TOKEN: "${GH_TOKEN}" FULLSEND_OUTPUT_SCHEMA: "${FULLSEND_DIR}/plugins/sdlc-workflow/schemas/verify-pr-result.schema.json" FULLSEND_OUTPUT_FILE: "agent-result.json" - # Read-only context only — no tokens, and no atlassian/github egress from the - # sandbox (network policy enforced in TC-5809). JIRA_BASE_URL is the base for - # display links only (no token), sourced from the dispatch-provided host var. - # The Jira key and PR URL reach the sandbox via verify-pr-input.json (the - # pre_script writes the JQL-derived key as task_id), so no JIRA_ISSUE_ID env - # var is needed here. - sandbox: - JIRA_BASE_URL: "${JIRA_BASE_URL}" + # No env.sandbox: the sandbox has no tokens and no atlassian/github egress + # (network policy enforced in TC-5809), and needs no Jira URL — the Jira key + # and PR URL reach it via verify-pr-input.json (the pre_script writes the + # JQL-derived key as task_id). timeout_minutes: 30 diff --git a/plugins/sdlc-workflow/scripts/execute-actions.py b/plugins/sdlc-workflow/scripts/execute-actions.py index d963416d9..8d03c813c 100755 --- a/plugins/sdlc-workflow/scripts/execute-actions.py +++ b/plugins/sdlc-workflow/scripts/execute-actions.py @@ -26,7 +26,10 @@ execute-actions.py Required env vars: - JIRA_SERVER_URL, JIRA_EMAIL, JIRA_API_TOKEN — Jira credentials + JIRA_SERVER_URL, JIRA_API_TOKEN — Jira REST base (the API gateway) and token; + jira-client.py sends the token as Bearer (no JIRA_EMAIL is set) + JIRA_USER_EMAIL — email on record for the token; read only by the fullsend + CLI (`fullsend issues post-comment`), which requires Basic auth GH_TOKEN — GitHub token JIRA_PROJECT_KEY — Jira project key (for root-cause task creation) """ @@ -467,26 +470,28 @@ def adf_to_markdown(doc: dict) -> str: def build_issue_url(key: str) -> str: - """Build Jira issue browse URL from key.""" - server = os.environ.get("JIRA_SERVER_URL", "").rstrip("/") - if not server: - print("JIRA_SERVER_URL is required for issue URL construction", file=sys.stderr) - sys.exit(1) - return f"{server}/browse/{key}" + """Build the Jira issue browse URL from serverInfo.baseUrl (the site address). + + JIRA_SERVER_URL may be the API gateway, which has no browsable /browse/ + path, so the link base comes from the cached serverInfo, never the REST base. + Exits if serverInfo cannot be fetched. + """ + return _jira_mod.browse_url(key) def _jira_native_env() -> dict[str, str]: """Build the environment for the native fullsend Jira CLI. - Maps this script's JIRA_SERVER_URL / JIRA_EMAIL / JIRA_API_TOKEN onto the - JIRA_BASE_URL / JIRA_USER_EMAIL / JIRA_TOKEN names the fullsend CLI expects. + Maps this script's JIRA_SERVER_URL / JIRA_API_TOKEN onto the JIRA_BASE_URL / + JIRA_TOKEN names the fullsend CLI expects, and passes JIRA_USER_EMAIL through + unchanged: the CLI is the only consumer of the email (it requires Basic auth). Exits with a clear message if any credential is missing. """ try: return { **os.environ, "JIRA_BASE_URL": os.environ["JIRA_SERVER_URL"], - "JIRA_USER_EMAIL": os.environ["JIRA_EMAIL"], + "JIRA_USER_EMAIL": os.environ["JIRA_USER_EMAIL"], "JIRA_TOKEN": os.environ["JIRA_API_TOKEN"], } except KeyError as e: @@ -555,6 +560,10 @@ def _create_and_register(action: dict, registry: dict, *, labels = action["labels"] description_adf = resolve_refs_in_obj(action["description_adf"], registry) + # Fetch (and cache) serverInfo before the write: if the browse-link base is + # unavailable, abort now rather than after creating an issue whose key would + # never be registered (a retry would then create a duplicate). + _jira_mod.get_server_info() try: result = _jira_mod.create_issue( project_key=project_key, diff --git a/plugins/sdlc-workflow/scripts/execute-triage-security-actions.py b/plugins/sdlc-workflow/scripts/execute-triage-security-actions.py index 7a7fdfc0d..011572102 100644 --- a/plugins/sdlc-workflow/scripts/execute-triage-security-actions.py +++ b/plugins/sdlc-workflow/scripts/execute-triage-security-actions.py @@ -76,9 +76,8 @@ def _plugin_version() -> str: def _browse_url(issue_key: str) -> str: - """Build a Jira browse URL for a generated issue reference.""" - base_url = os.environ.get("JIRA_SERVER_URL", "https://jira.invalid").rstrip("/") - return "{}/browse/{}".format(base_url, issue_key) + """Build a Jira browse URL for a generated issue reference from serverInfo.baseUrl.""" + return _jira_mod.browse_url(issue_key) def _validate_action(action: Any) -> None: @@ -331,7 +330,12 @@ def _trusted_targets(trusted_input: dict[str, Any]) -> set[str]: def _preflight_plan(result: dict[str, Any], trusted_input: dict[str, Any]) -> None: - """Authorize every target and reference before Jira reads, writes, or retry repair.""" + """Authorize every target and reference before Jira reads, writes, or retry repair. + + The only Jira request made here is the cached serverInfo read behind + ``_browse_url`` (for reference-producing actions), so a missing browse-link + base aborts before any write. + """ targets = _trusted_targets(trusted_input) if result["report"]["issue"] != trusted_input["issue"]["key"]: raise ActionError("report issue does not match the trusted issue") diff --git a/plugins/sdlc-workflow/scripts/jira-client.py b/plugins/sdlc-workflow/scripts/jira-client.py index 1d7d8ccdc..a401dfc50 100755 --- a/plugins/sdlc-workflow/scripts/jira-client.py +++ b/plugins/sdlc-workflow/scripts/jira-client.py @@ -11,31 +11,34 @@ import os import re import sys +from urllib.parse import urlencode from urllib.request import Request, urlopen from urllib.error import HTTPError, URLError from base64 import b64encode from typing import Dict, List, Optional, Any -def get_credentials() -> tuple[str, str, str]: +def get_credentials() -> tuple[str, Optional[str], str]: """Read credentials from environment variables. + ``JIRA_EMAIL`` is optional: when set, requests use Basic auth (personal API + tokens, which are Basic-only); when unset, requests send the token as a + Bearer header (Atlassian Service Account tokens on the API gateway). + Returns: - Tuple of (server_url, email, api_token) + Tuple of (server_url, email or None, api_token) Raises: - SystemExit: If any credentials are missing + SystemExit: If JIRA_SERVER_URL or JIRA_API_TOKEN is missing """ server_url = os.getenv('JIRA_SERVER_URL') - email = os.getenv('JIRA_EMAIL') + email = os.getenv('JIRA_EMAIL') or None api_token = os.getenv('JIRA_API_TOKEN') - if not all([server_url, email, api_token]): + if not all([server_url, api_token]): missing = [] if not server_url: missing.append('JIRA_SERVER_URL') - if not email: - missing.append('JIRA_EMAIL') if not api_token: missing.append('JIRA_API_TOKEN') @@ -46,6 +49,22 @@ def get_credentials() -> tuple[str, str, str]: return server_url.rstrip('/'), email, api_token +def build_auth_header(email: Optional[str], api_token: str) -> str: + """Build the Authorization header value: Basic when an email is set, else Bearer. + + Args: + email: Account email for Basic auth, or None to send a Bearer token + api_token: The Jira API token + + Returns: + The ``Authorization`` header value + """ + if email: + auth_b64 = b64encode(f"{email}:{api_token}".encode('utf-8')).decode('ascii') + return f"Basic {auth_b64}" + return f"Bearer {api_token}" + + def mask_token(token: str) -> str: """Mask API token for safe logging. @@ -78,12 +97,9 @@ def make_request(method: str, endpoint: str, data: Optional[Dict] = None) -> Dic # Build request url = f"{server_url}/rest/api/3/{endpoint}" - auth_string = f"{email}:{api_token}" - auth_bytes = auth_string.encode('utf-8') - auth_b64 = b64encode(auth_bytes).decode('ascii') headers = { - 'Authorization': f"Basic {auth_b64}", + 'Authorization': build_auth_header(email, api_token), 'Accept': 'application/json', 'Content-Type': 'application/json' } @@ -118,7 +134,7 @@ def handle_http_error(error: HTTPError) -> None: if status == 401: print("❌ Authentication failed (401 Unauthorized)", file=sys.stderr) - print("Check your email and API token. Run /setup to update credentials.", file=sys.stderr) + print("Check your API token (and JIRA_EMAIL, if set). Run /setup to update credentials.", file=sys.stderr) elif status == 403: print("❌ Permission denied (403 Forbidden)", file=sys.stderr) print("Contact your JIRA admin to grant project access.", file=sys.stderr) @@ -700,6 +716,98 @@ def get_user_info() -> Dict[str, Any]: return make_request('GET', 'myself') +def verify_identity() -> Dict[str, Any]: + """Confirm the configured credential resolves to a real Jira principal. + + Some invalid credentials (e.g. a Service Account token used outside the API + gateway) make JQL searches return an empty result instead of an HTTP error, + which is indistinguishable from a genuine no-match. Callers that treat an + empty search as meaningful must call this first. + + Returns: + The ``myself`` user object (contains a non-empty ``accountId``) + + Raises: + SystemExit: On HTTP errors (401/403 via make_request), or if the + response carries no ``accountId`` (anonymous / unresolved principal) + """ + user = get_user_info() + account_id = user.get('accountId') if isinstance(user, dict) else None + if not isinstance(account_id, str) or not account_id: + print("❌ Jira identity could not be verified: /myself returned no accountId " + "(unauthenticated or unresolved principal)", file=sys.stderr) + sys.exit(1) + return user + + +def verify_project_access(project_key: str) -> Dict[str, Any]: + """Confirm the credential can browse ``project_key``. + + Jira silently drops issues the caller cannot see, so a search by an account + without Browse Projects returns an empty result instead of an error. Callers + that treat an empty search as meaningful must call this first. + + Args: + project_key: Project key (e.g., TC) + + Returns: + The ``mypermissions`` response + + Raises: + SystemExit: On HTTP errors, or unless BROWSE_PROJECTS.havePermission is true + """ + query = urlencode({'projectKey': project_key, 'permissions': 'BROWSE_PROJECTS'}) + result = make_request('GET', f"mypermissions?{query}") + permissions = result.get('permissions') if isinstance(result, dict) else None + browse = permissions.get('BROWSE_PROJECTS') if isinstance(permissions, dict) else None + if not isinstance(browse, dict) or browse.get('havePermission') is not True: + print(f"❌ The Jira credential cannot browse project {project_key} " + "(BROWSE_PROJECTS not granted); searches would silently return no issues", + file=sys.stderr) + sys.exit(1) + return result + + +# Process-wide cache for get_server_info(); serverInfo does not change mid-run. +_SERVER_INFO_CACHE: Optional[Dict[str, Any]] = None + + +def get_server_info() -> Dict[str, Any]: + """Get Jira server info, fetched once per process and cached. + + ``baseUrl`` is the site address (e.g. ``https://redhat.atlassian.net``) + whether JIRA_SERVER_URL is the site or the API gateway, so it is the base + for human-facing ``/browse/`` links. + + Returns: + serverInfo object with baseUrl, version, deploymentType + + Raises: + SystemExit: On HTTP errors, or if the response has no ``baseUrl`` + """ + global _SERVER_INFO_CACHE + if _SERVER_INFO_CACHE is None: + info = make_request('GET', 'serverInfo') + base_url = info.get('baseUrl') if isinstance(info, dict) else None + if not isinstance(base_url, str) or not base_url: + print("❌ serverInfo response has no baseUrl; cannot build Jira browse links", file=sys.stderr) + sys.exit(1) + _SERVER_INFO_CACHE = info + return _SERVER_INFO_CACHE + + +def browse_url(issue_key: str) -> str: + """Build the human-facing ``/browse/`` URL for an issue from serverInfo.baseUrl. + + Args: + issue_key: Issue key (e.g., TC-123) + + Returns: + ``/browse/`` + """ + return f"{get_server_info()['baseUrl'].rstrip('/')}/browse/{issue_key}" + + def get_remote_links(issue_key: str) -> List[Dict[str, Any]]: """Get remote links for a JIRA issue. @@ -774,7 +882,9 @@ def main(argv=None): parser = argparse.ArgumentParser( description='JIRA REST API v3 client for sdlc-workflow skills', - epilog='Set JIRA_SERVER_URL, JIRA_EMAIL, JIRA_API_TOKEN environment variables before use.' + epilog=('Set JIRA_SERVER_URL and JIRA_API_TOKEN environment variables before use. ' + 'Set JIRA_EMAIL to use Basic auth (personal API tokens); leave it unset to ' + 'send the token as Bearer (Service Account tokens on the API gateway).') ) subparsers = parser.add_subparsers(dest='command', required=True, help='Available commands') @@ -831,6 +941,17 @@ def main(argv=None): # get_user_info subparsers.add_parser('get_user_info', help='Get current user info') + # verify_identity + subparsers.add_parser('verify_identity', help='Fail unless the credential resolves to a Jira accountId') + + # verify_project_access + verify_access_parser = subparsers.add_parser( + 'verify_project_access', help='Fail unless the credential has BROWSE_PROJECTS on the project') + verify_access_parser.add_argument('project_key', help='Project key (e.g., TC)') + + # get_server_info + subparsers.add_parser('get_server_info', help='Get server info (baseUrl is the site URL for browse links)') + # get_remote_links get_remote_links_parser = subparsers.add_parser('get_remote_links', help='Get remote links for issue') get_remote_links_parser.add_argument('issue_key', help='Issue key (e.g., TC-123)') @@ -904,6 +1025,17 @@ def main(argv=None): elif args.command == 'get_user_info': result = get_user_info() + elif args.command == 'verify_identity': + user = verify_identity() + result = {"accountId": user["accountId"], "displayName": user.get("displayName")} + + elif args.command == 'verify_project_access': + verify_project_access(args.project_key) + result = {"projectKey": args.project_key, "BROWSE_PROJECTS": True} + + elif args.command == 'get_server_info': + result = get_server_info() + elif args.command == 'get_remote_links': result = get_remote_links(args.issue_key) diff --git a/plugins/sdlc-workflow/scripts/post-verify-pr.sh b/plugins/sdlc-workflow/scripts/post-verify-pr.sh index c6ae68abd..ba3f1e9e0 100755 --- a/plugins/sdlc-workflow/scripts/post-verify-pr.sh +++ b/plugins/sdlc-workflow/scripts/post-verify-pr.sh @@ -5,9 +5,10 @@ # Working directory is the fullsend run output directory. # # Required env vars: -# JIRA_SERVER_URL — Jira instance URL -# JIRA_EMAIL — Jira user email -# JIRA_API_TOKEN — Jira API token +# JIRA_SERVER_URL — Jira REST base (the Atlassian API gateway) +# JIRA_API_TOKEN — Jira API token (jira-client.py sends it as Bearer) +# JIRA_USER_EMAIL — email on record for the token; read ONLY by the fullsend +# CLI (`fullsend issues post-comment`), which needs Basic auth # JIRA_PROJECT_KEY — Jira project key (for root-cause task creation) # GH_TOKEN — GitHub token # diff --git a/plugins/sdlc-workflow/scripts/pre-triage-security.sh b/plugins/sdlc-workflow/scripts/pre-triage-security.sh index 0f93939d8..b1b23a368 100755 --- a/plugins/sdlc-workflow/scripts/pre-triage-security.sh +++ b/plugins/sdlc-workflow/scripts/pre-triage-security.sh @@ -9,7 +9,6 @@ set -euo pipefail # the complete evidence bundle for that one issue. : "${FULLSEND_WORK_ITEM_URL:?FULLSEND_WORK_ITEM_URL (Jira work-item URL) is required}" : "${JIRA_SERVER_URL:?JIRA_SERVER_URL is required}" -: "${JIRA_EMAIL:?JIRA_EMAIL is required}" : "${JIRA_API_TOKEN:?JIRA_API_TOKEN is required}" if [[ ! "${FULLSEND_WORK_ITEM_URL}" =~ ^https?://[^/]+/browse/([A-Z][A-Z0-9]+-[0-9]+)/?$ ]]; then diff --git a/plugins/sdlc-workflow/scripts/pre-verify-pr.sh b/plugins/sdlc-workflow/scripts/pre-verify-pr.sh index 220a7cb21..9cb62faf4 100755 --- a/plugins/sdlc-workflow/scripts/pre-verify-pr.sh +++ b/plugins/sdlc-workflow/scripts/pre-verify-pr.sh @@ -14,7 +14,10 @@ # so a stale or unqualified PR is never reviewed. # # 1. Validates required env vars and the PR URL shape -# 2. Resolves + gates the Jira key by JQL on customfield_10875 == PR URL +# 2. Verifies the Jira identity (/myself → accountId) and fails the run if it +# cannot be confirmed, and checks Browse Projects on JIRA_PROJECT_KEY, so an +# unauthenticated or permission-filtered empty search is never a skip; then +# resolves + gates the Jira key by JQL on customfield_10875 == PR URL # 3. If the gate fails (no/ambiguous match, status != Review, label absent): # emits an ADR-0072 skip signal and exits 0 (nothing to verify) # 4. Fetches the full Jira issue and prefetches the GitHub tier-1 read bundle @@ -25,9 +28,9 @@ # # Required env vars: # FULLSEND_WORK_ITEM_URL — the triggering PR URL (harness-run / local export) -# JIRA_SERVER_URL — Jira instance URL -# JIRA_EMAIL — Jira user email -# JIRA_API_TOKEN — Jira API token +# JIRA_SERVER_URL — Jira REST base (the Atlassian API gateway) +# JIRA_API_TOKEN — Jira API token (sent as Bearer; no email needed) +# JIRA_PROJECT_KEY — Jira project whose Browse permission the gate checks # GH_TOKEN — GitHub token (PR prefetch) # # Optional env vars: @@ -42,8 +45,8 @@ set -euo pipefail # 1. Validate required env vars are set : "${FULLSEND_WORK_ITEM_URL:?FULLSEND_WORK_ITEM_URL (triggering PR URL) is required}" : "${JIRA_SERVER_URL:?JIRA_SERVER_URL is required}" -: "${JIRA_EMAIL:?JIRA_EMAIL is required}" : "${JIRA_API_TOKEN:?JIRA_API_TOKEN is required}" +: "${JIRA_PROJECT_KEY:?JIRA_PROJECT_KEY is required}" PR_URL="${FULLSEND_WORK_ITEM_URL}" @@ -51,6 +54,12 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PRE_OUTPUT_DIR="${PRE_DIR:-/tmp/fullsend-pre-output}" mkdir -p "${PRE_OUTPUT_DIR}" +# Per-run scratch file for jira-client stderr. mktemp (not a fixed /tmp path) so +# concurrent runs on one host — or parallel test runs — never read each other's +# errors; kept out of PRE_OUTPUT_DIR, which is mounted into the sandbox. +JIRA_STDERR_FILE="$(mktemp)" +trap 'rm -f "${JIRA_STDERR_FILE}"' EXIT + # request_skip REASON — emit an ADR-0072 skip signal and exit cleanly. # The pre-script output protocol (v1) is line-based key=value; the guard on # FULLSEND_PRESCRIPT_OUTPUT matches the scaffold's GITHUB_OUTPUT guard, so a @@ -79,6 +88,42 @@ PR_REPO="${BASH_REMATCH[1]}" PR_NUM="${BASH_REMATCH[2]}" echo "PR: ${PR_REPO}#${PR_NUM} (${PR_URL})" +# 2b. Verify the Jira identity BEFORE trusting any search result. Some invalid +# credentials (e.g. a Service Account token off the API gateway) make JQL +# return an empty result with exit 0 instead of a 401, which step 3 would +# otherwise turn into a green ADR-0072 skip without verifying the PR. +# verify_identity exits non-zero unless /myself resolves to an accountId. +IDENTITY_JSON=$(python3 "${SCRIPT_DIR}/jira-client.py" verify_identity \ + 2>"${JIRA_STDERR_FILE}") || { + JIRA_STDERR=$(cat "${JIRA_STDERR_FILE}" 2>/dev/null || echo "") + if echo "${JIRA_STDERR}" | grep -qi "401\|unauthorized"; then + echo "ERROR: Jira authentication failed — check JIRA_API_TOKEN and JIRA_SERVER_URL" + elif echo "${JIRA_STDERR}" | grep -qi "403\|forbidden"; then + echo "ERROR: Jira permission denied — check that the API token can read its own user" + else + echo "ERROR: Jira identity could not be verified — refusing to treat an empty search as a skip" + echo "${JIRA_STDERR}" + fi + rm -f "${JIRA_STDERR_FILE}" + exit 1 +} +rm -f "${JIRA_STDERR_FILE}" +IDENTITY_NAME=$(printf '%s' "${IDENTITY_JSON}" | python3 -c 'import json,sys; u=json.load(sys.stdin); print(u.get("displayName") or u["accountId"])') +echo "Jira identity verified: ${IDENTITY_NAME}" + +# 2c. Verify the identity can browse the project. Jira silently drops issues the +# caller cannot see, so a search by an account without Browse Projects also +# returns [] with exit 0 — indistinguishable from a genuine no-match. +python3 "${SCRIPT_DIR}/jira-client.py" verify_project_access "${JIRA_PROJECT_KEY}" \ + >/dev/null 2>"${JIRA_STDERR_FILE}" || { + echo "ERROR: Jira credential cannot browse project ${JIRA_PROJECT_KEY} — refusing to treat an empty search as a skip" + cat "${JIRA_STDERR_FILE}" 2>/dev/null || true + rm -f "${JIRA_STDERR_FILE}" + exit 1 +} +rm -f "${JIRA_STDERR_FILE}" +echo "Jira project access verified: ${JIRA_PROJECT_KEY} (BROWSE_PROJECTS)" + # 3. Resolve + gate the Jira key by JQL on the Git Pull Request custom field. # The JQL `~` recall is broad; resolve-gated-issue re-confirms the exact PR # URL and enforces status=Review + the ai-generated-jira label in Python. @@ -88,20 +133,20 @@ echo "PR: ${PR_REPO}#${PR_NUM} (${PR_URL})" PR_JQL=$(python3 "${SCRIPT_DIR}/pre_verify_pr.py" build-pr-jql "${PR_URL}") SEARCH_JSON=$(python3 "${SCRIPT_DIR}/jira-client.py" search_jql \ --jql "${PR_JQL}" --fields "status,labels,customfield_10875" --all \ - 2>"/tmp/fullsend-pre-jira-stderr.txt") || { - JIRA_STDERR=$(cat /tmp/fullsend-pre-jira-stderr.txt 2>/dev/null || echo "") + 2>"${JIRA_STDERR_FILE}") || { + JIRA_STDERR=$(cat "${JIRA_STDERR_FILE}" 2>/dev/null || echo "") if echo "${JIRA_STDERR}" | grep -qi "401\|unauthorized"; then - echo "ERROR: Jira authentication failed — check JIRA_EMAIL and JIRA_API_TOKEN" + echo "ERROR: Jira authentication failed — check JIRA_API_TOKEN and JIRA_SERVER_URL" elif echo "${JIRA_STDERR}" | grep -qi "403\|forbidden"; then echo "ERROR: Jira permission denied — check that the API token can search issues" else echo "ERROR: Failed to search Jira for PR ${PR_URL}" echo "${JIRA_STDERR}" fi - rm -f /tmp/fullsend-pre-jira-stderr.txt + rm -f "${JIRA_STDERR_FILE}" exit 1 } -rm -f /tmp/fullsend-pre-jira-stderr.txt +rm -f "${JIRA_STDERR_FILE}" # resolve-gated-issue exits 3 when a gate fails (→ ADR-0072 skip), 0 with the # resolved key on success, and 1 on an unexpected error. Capture without letting @@ -121,10 +166,10 @@ JIRA_ISSUE_ID="${GATE_OUT}" echo "Jira issue resolved + gated: ${JIRA_ISSUE_ID} (status=Review, label=ai-generated-jira)" # 4. Fetch full issue details (pre-fetches the task context for the sandbox) -ISSUE_JSON=$(python3 "${SCRIPT_DIR}/jira-client.py" get_issue "${JIRA_ISSUE_ID}" --fields "*all" 2>"/tmp/fullsend-pre-jira-stderr.txt") || { - JIRA_STDERR=$(cat /tmp/fullsend-pre-jira-stderr.txt 2>/dev/null || echo "") +ISSUE_JSON=$(python3 "${SCRIPT_DIR}/jira-client.py" get_issue "${JIRA_ISSUE_ID}" --fields "*all" 2>"${JIRA_STDERR_FILE}") || { + JIRA_STDERR=$(cat "${JIRA_STDERR_FILE}" 2>/dev/null || echo "") if echo "${JIRA_STDERR}" | grep -qi "401\|unauthorized"; then - echo "ERROR: Jira authentication failed — check JIRA_EMAIL and JIRA_API_TOKEN" + echo "ERROR: Jira authentication failed — check JIRA_API_TOKEN and JIRA_SERVER_URL" elif echo "${JIRA_STDERR}" | grep -qi "403\|forbidden"; then echo "ERROR: Jira permission denied — check that the API token has access to ${JIRA_ISSUE_ID}" elif echo "${JIRA_STDERR}" | grep -qi "404\|not found"; then @@ -133,10 +178,10 @@ ISSUE_JSON=$(python3 "${SCRIPT_DIR}/jira-client.py" get_issue "${JIRA_ISSUE_ID}" echo "ERROR: Failed to fetch Jira issue ${JIRA_ISSUE_ID}" echo "${JIRA_STDERR}" fi - rm -f /tmp/fullsend-pre-jira-stderr.txt + rm -f "${JIRA_STDERR_FILE}" exit 1 } -rm -f /tmp/fullsend-pre-jira-stderr.txt +rm -f "${JIRA_STDERR_FILE}" echo "Jira issue verified: ${JIRA_ISSUE_ID}" diff --git a/plugins/sdlc-workflow/scripts/pre_triage_security.py b/plugins/sdlc-workflow/scripts/pre_triage_security.py index c2cba2961..6720c37e4 100644 --- a/plugins/sdlc-workflow/scripts/pre_triage_security.py +++ b/plugins/sdlc-workflow/scripts/pre_triage_security.py @@ -881,13 +881,30 @@ def untriaged_jql(configuration): ) +# Process-wide cache for _browse_base_url(); serverInfo does not change mid-run. +_SERVER_INFO_BASE_URL = None + + +def _browse_base_url(): + """Return the Jira site URL for /browse/ links from serverInfo.baseUrl, fetched once. + + JIRA_SERVER_URL may be the API gateway, which carries no browsable hostname, + so links never derive from it. A failed or malformed serverInfo aborts. + """ + global _SERVER_INFO_BASE_URL + if _SERVER_INFO_BASE_URL is None: + info = _require_mapping(_jira_client("get_server_info"), "serverInfo") + base_url = info.get("baseUrl") + if not isinstance(base_url, str) or not base_url: + raise EvidenceError("serverInfo has no baseUrl") + _SERVER_INFO_BASE_URL = base_url.rstrip("/") + return _SERVER_INFO_BASE_URL + + def discover_untriaged(project_root, max_results=20): """List untriaged Vulnerability issues for an unattended poller, in JQL order.""" if not isinstance(max_results, int) or max_results < 1: raise EvidenceError("max_results must be a positive integer") - server_url = os.environ.get("JIRA_SERVER_URL", "").rstrip("/") - if not server_url: - raise EvidenceError("JIRA_SERVER_URL is required") claude_path = Path(project_root) / "CLAUDE.md" if not claude_path.is_file(): raise EvidenceError("target project CLAUDE.md is required") @@ -899,13 +916,15 @@ def discover_untriaged(project_root, max_results=20): search = _require_mapping( _jira_client("search_jql", "--jql", untriaged_jql(configuration), "--fields", "key", *paging), "untriaged search") - issues = [] + keys = [] for item in _require_list(search.get("issues"), "untriaged search issues", allow_empty=True)[:max_results]: key = _require_mapping(item, "untriaged issue").get("key") if not isinstance(key, str) or not _ISSUE_KEY_RE.fullmatch(key) or not key.startswith(project + "-"): raise EvidenceError("untriaged issue is outside the configured project") - issues.append({"key": key, "url": "{}/browse/{}".format(server_url, key)}) - return {"issues": issues} + keys.append(key) + # Fetch serverInfo only when there is a link to build, after every key is valid. + base_url = _browse_base_url() if keys else None + return {"issues": [{"key": key, "url": "{}/browse/{}".format(base_url, key)} for key in keys]} def parse_mutation_authorization(value): diff --git a/plugins/sdlc-workflow/scripts/test_execute_actions.py b/plugins/sdlc-workflow/scripts/test_execute_actions.py index ba8480965..e7d98e665 100644 --- a/plugins/sdlc-workflow/scripts/test_execute_actions.py +++ b/plugins/sdlc-workflow/scripts/test_execute_actions.py @@ -7,6 +7,7 @@ import tempfile import importlib.util +import pytest from jsonschema import validate, ValidationError script_dir = os.path.dirname(os.path.abspath(__file__)) @@ -133,7 +134,7 @@ def __call__(self, cmd, input=None, text=None, capture_output=None, env=None): _JIRA_ENV = { "JIRA_SERVER_URL": "https://jira.example.com", - "JIRA_EMAIL": "bot@example.com", + "JIRA_USER_EMAIL": "bot@example.com", "JIRA_API_TOKEN": "s3cr3t", } @@ -176,7 +177,7 @@ def test_post_jira_comment_native_builds_argv(): def test_post_jira_comment_native_maps_env(): - """The native CLI receives JIRA_BASE_URL/JIRA_USER_EMAIL/JIRA_TOKEN mapped from this script's vars.""" + """The native CLI receives JIRA_BASE_URL/JIRA_TOKEN mapped from this script's vars and JIRA_USER_EMAIL passed through.""" recorder = _RunRecorder() restore = _with_jira_env_and_recorder(recorder) try: @@ -189,6 +190,81 @@ def test_post_jira_comment_native_maps_env(): assert recorder.env["JIRA_TOKEN"] == "s3cr3t" +def test_jira_native_env_never_reads_jira_email(monkeypatch): + """JIRA_USER_EMAIL is passed through as-is; a conflicting JIRA_EMAIL is never read.""" + # Given both JIRA_USER_EMAIL and a different JIRA_EMAIL in the runner env + for key, value in _JIRA_ENV.items(): + monkeypatch.setenv(key, value) + monkeypatch.setenv("JIRA_EMAIL", "interactive-user@example.com") + + # When building the native CLI environment + env = execute_actions._jira_native_env() + + # Then the CLI email is JIRA_USER_EMAIL, not JIRA_EMAIL + assert env["JIRA_USER_EMAIL"] == "bot@example.com" + + +def test_jira_native_env_missing_user_email_exits(monkeypatch, capsys): + """Without JIRA_USER_EMAIL the native CLI env aborts, even when JIRA_EMAIL is set.""" + # Given the REST credentials and JIRA_EMAIL, but no JIRA_USER_EMAIL + for key, value in _JIRA_ENV.items(): + monkeypatch.setenv(key, value) + monkeypatch.delenv("JIRA_USER_EMAIL") + monkeypatch.setenv("JIRA_EMAIL", "bot@example.com") + + # When building the native CLI environment + with pytest.raises(SystemExit) as excinfo: + execute_actions._jira_native_env() + + # Then it exits 1 naming the missing variable + assert excinfo.value.code == 1 + assert "JIRA_USER_EMAIL" in capsys.readouterr().err + + +_SITE_URL = "https://redhat.atlassian.net" +_GATEWAY_URL = "https://api.atlassian.com/ex/jira/2b9e35e3-6bd3-4cec-b838-f4249ee02432" + + +@pytest.mark.parametrize("server_url", [_SITE_URL, _GATEWAY_URL]) +def test_build_issue_url_uses_server_info_base_url(monkeypatch, server_url): + """Sub-task links use serverInfo.baseUrl (the site) whether the REST base is the site or the gateway.""" + # Given a REST base and a Jira that reports the site as its baseUrl + monkeypatch.setenv("JIRA_SERVER_URL", server_url) + monkeypatch.setattr(execute_actions._jira_mod, "_SERVER_INFO_CACHE", None) + requests = [] + + def fake_make_request(method, endpoint, data=None): + requests.append((method, endpoint)) + return {"baseUrl": _SITE_URL} + + monkeypatch.setattr(execute_actions._jira_mod, "make_request", fake_make_request) + + # When building two issue URLs + urls = [execute_actions.build_issue_url("TC-100"), execute_actions.build_issue_url("TC-101")] + + # Then both are site browse links and serverInfo was fetched once + assert urls == [_SITE_URL + "/browse/TC-100", _SITE_URL + "/browse/TC-101"] + assert requests == [("GET", "serverInfo")] + + +def test_build_issue_url_server_info_failure_exits(monkeypatch): + """A failed serverInfo request aborts link construction instead of guessing a base.""" + # Given a Jira whose serverInfo request fails + monkeypatch.setattr(execute_actions._jira_mod, "_SERVER_INFO_CACHE", None) + + def failing_make_request(method, endpoint, data=None): + raise SystemExit(1) + + monkeypatch.setattr(execute_actions._jira_mod, "make_request", failing_make_request) + + # When building an issue URL + with pytest.raises(SystemExit) as excinfo: + execute_actions.build_issue_url("TC-100") + + # Then it exits 1 + assert excinfo.value.code == 1 + + def test_post_jira_comment_native_nonzero_exits(): """A non-zero CLI exit aborts with sys.exit(1).""" recorder = _RunRecorder(returncode=1, stderr="boom") @@ -991,10 +1067,12 @@ def fake_create_issue(**kwargs): saved_run = execute_actions.subprocess.run saved_create = execute_actions._jira_mod.create_issue + saved_server_info = execute_actions._jira_mod.get_server_info saved_argv = sys.argv saved_env = {k: os.environ.get(k) for k in _JIRA_ENV} execute_actions.subprocess.run = fake_run execute_actions._jira_mod.create_issue = fake_create_issue + execute_actions._jira_mod.get_server_info = lambda: {"baseUrl": "https://jira.example.com"} os.environ.update(_JIRA_ENV) fd, path = tempfile.mkstemp(suffix=".json") try: @@ -1005,6 +1083,7 @@ def fake_create_issue(**kwargs): finally: execute_actions.subprocess.run = saved_run execute_actions._jira_mod.create_issue = saved_create + execute_actions._jira_mod.get_server_info = saved_server_info sys.argv = saved_argv os.remove(path) for k, v in saved_env.items(): diff --git a/plugins/sdlc-workflow/scripts/test_execute_triage_security_actions.py b/plugins/sdlc-workflow/scripts/test_execute_triage_security_actions.py index 3caa0c1d3..f14771b06 100644 --- a/plugins/sdlc-workflow/scripts/test_execute_triage_security_actions.py +++ b/plugins/sdlc-workflow/scripts/test_execute_triage_security_actions.py @@ -109,6 +109,8 @@ def recorder(monkeypatch): monkeypatch.setattr(executor._jira_mod, "get_issue", value.get_issue) monkeypatch.setattr(executor._jira_mod, "create_link", value.create_link) monkeypatch.setattr(executor._jira_mod, "make_request", value.make_request) + monkeypatch.setattr(executor._jira_mod, "get_server_info", + lambda: {"baseUrl": "https://jira.example.com"}) monkeypatch.setattr(executor._action_helpers, "post_jira_comment_native", value.post_native) return value @@ -1182,3 +1184,47 @@ def test_duplicate_planned_release_identity_fails_before_calls(kind, recorder): with pytest.raises(executor.ActionError): executor.execute_plan(_plan(actions), _release_trusted()) assert recorder.calls == [] + + +_SITE_URL = "https://redhat.atlassian.net" +_GATEWAY_URL = "https://api.atlassian.com/ex/jira/2b9e35e3-6bd3-4cec-b838-f4249ee02432" + + +@pytest.mark.parametrize("server_url", [_SITE_URL, _GATEWAY_URL]) +def test_browse_url_uses_server_info_base_url(monkeypatch, server_url): + """Generated-reference links use serverInfo.baseUrl whether the REST base is the site or the gateway.""" + # Given a REST base and a Jira that reports the site as its baseUrl + monkeypatch.setenv("JIRA_SERVER_URL", server_url) + monkeypatch.setattr(executor._jira_mod, "_SERVER_INFO_CACHE", None) + requests = [] + + def fake_make_request(method, endpoint, data=None): + requests.append((method, endpoint)) + return {"baseUrl": _SITE_URL} + + monkeypatch.setattr(executor._jira_mod, "make_request", fake_make_request) + + # When building links for two generated references + urls = [executor._browse_url("TC-42"), executor._browse_url("TC-43")] + + # Then both are site browse links and serverInfo was fetched once + assert urls == [_SITE_URL + "/browse/TC-42", _SITE_URL + "/browse/TC-43"] + assert requests == [("GET", "serverInfo")] + + +def test_browse_url_server_info_failure_aborts(monkeypatch): + """A failed serverInfo aborts instead of falling back to a placeholder host.""" + # Given a Jira whose serverInfo request fails + monkeypatch.setattr(executor._jira_mod, "_SERVER_INFO_CACHE", None) + + def failing_make_request(method, endpoint, data=None): + raise SystemExit(1) + + monkeypatch.setattr(executor._jira_mod, "make_request", failing_make_request) + + # When building a generated-reference link + with pytest.raises(SystemExit) as excinfo: + executor._browse_url("TC-42") + + # Then it exits 1 + assert excinfo.value.code == 1 diff --git a/plugins/sdlc-workflow/scripts/test_jira_client.py b/plugins/sdlc-workflow/scripts/test_jira_client.py index 0056634a3..b939472ce 100644 --- a/plugins/sdlc-workflow/scripts/test_jira_client.py +++ b/plugins/sdlc-workflow/scripts/test_jira_client.py @@ -12,6 +12,8 @@ import os import importlib.util +import pytest + # Import jira-client.py dynamically (has hyphen in name) script_dir = os.path.dirname(os.path.abspath(__file__)) jira_client_path = os.path.join(script_dir, 'jira-client.py') @@ -710,6 +712,232 @@ def fake_make_request(method, endpoint, data=None): print("✓ create_issue fails fast on empty issue_type test passed") +_SITE_URL = "https://redhat.atlassian.net" +_GATEWAY_URL = "https://api.atlassian.com/ex/jira/2b9e35e3-6bd3-4cec-b838-f4249ee02432" + + +class _FakeResponse: + """Minimal urlopen() context-manager response returning a JSON body.""" + + def __init__(self, body): + self._body = json.dumps(body).encode("utf-8") + + def __enter__(self): + return self + + def __exit__(self, *_exc): + return False + + def read(self): + return self._body + + +@pytest.mark.parametrize("email, expected_auth", [ + (None, "Bearer s3cr3t-token"), + ("", "Bearer s3cr3t-token"), + ("me@example.com", "Basic bWVAZXhhbXBsZS5jb206czNjcjN0LXRva2Vu"), +]) +def test_make_request_auth_scheme_follows_jira_email(monkeypatch, email, expected_auth): + """make_request sends Bearer when JIRA_EMAIL is unset or empty, and Basic email:token when set.""" + # Given a gateway REST base, a token, and JIRA_EMAIL unset, empty, or set + monkeypatch.setenv("JIRA_SERVER_URL", _GATEWAY_URL + "/") + monkeypatch.setenv("JIRA_API_TOKEN", "s3cr3t-token") + if email is None: + monkeypatch.delenv("JIRA_EMAIL", raising=False) + else: + monkeypatch.setenv("JIRA_EMAIL", email) + captured = [] + + def fake_urlopen(request): + captured.append(request) + return _FakeResponse({"accountId": "abc"}) + + monkeypatch.setattr(jira_client, "urlopen", fake_urlopen) + + # When a command issues a request + result = jira_client.get_user_info() + + # Then the request targets the gateway with the expected Authorization scheme + assert result == {"accountId": "abc"} + assert captured[0].full_url == _GATEWAY_URL + "/rest/api/3/myself" + assert captured[0].get_header("Authorization") == expected_auth + + +def test_get_credentials_requires_server_url_and_token_only(monkeypatch, capsys): + """Missing JIRA_SERVER_URL/JIRA_API_TOKEN abort; a missing JIRA_EMAIL is not reported.""" + # Given no Jira variables at all + for key in ("JIRA_SERVER_URL", "JIRA_EMAIL", "JIRA_API_TOKEN"): + monkeypatch.delenv(key, raising=False) + + # When reading credentials + with pytest.raises(SystemExit) as excinfo: + jira_client.get_credentials() + + # Then it exits 1 naming only the two required variables + err = capsys.readouterr().err + assert excinfo.value.code == 1 + assert "Missing credentials: JIRA_SERVER_URL, JIRA_API_TOKEN" in err + assert "JIRA_EMAIL" not in err + + +def test_get_server_info_is_cached_per_process(monkeypatch): + """serverInfo is requested once; later calls and browse links reuse the cached response.""" + # Given an empty cache and a Jira that reports the site baseUrl + monkeypatch.setattr(jira_client, "_SERVER_INFO_CACHE", None) + requests = [] + + def fake_make_request(method, endpoint, data=None): + requests.append((method, endpoint)) + return {"baseUrl": _SITE_URL, "deploymentType": "Cloud"} + + monkeypatch.setattr(jira_client, "make_request", fake_make_request) + + # When fetching serverInfo twice and building a browse link + first = jira_client.get_server_info() + second = jira_client.get_server_info() + link = jira_client.browse_url("TC-1") + + # Then exactly one GET serverInfo was issued and every caller saw the same data + assert requests == [("GET", "serverInfo")] + assert first == second == {"baseUrl": _SITE_URL, "deploymentType": "Cloud"} + assert link == _SITE_URL + "/browse/TC-1" + + +@pytest.mark.parametrize("response", [{}, {"baseUrl": ""}, {"baseUrl": None}, []]) +def test_get_server_info_without_base_url_exits(monkeypatch, capsys, response): + """A serverInfo response without a usable baseUrl aborts and is not cached.""" + # Given a Jira whose serverInfo lacks baseUrl + monkeypatch.setattr(jira_client, "_SERVER_INFO_CACHE", None) + monkeypatch.setattr(jira_client, "make_request", lambda *_args, **_kwargs: response) + + # When fetching serverInfo + with pytest.raises(SystemExit) as excinfo: + jira_client.get_server_info() + + # Then it exits 1 with a clear error and leaves the cache empty + assert excinfo.value.code == 1 + assert "serverInfo response has no baseUrl" in capsys.readouterr().err + assert jira_client._SERVER_INFO_CACHE is None + + +def test_get_server_info_request_failure_raises(monkeypatch): + """A failed serverInfo request propagates SystemExit rather than falling back to JIRA_SERVER_URL.""" + # Given a reachable REST base but a failing serverInfo request + monkeypatch.setenv("JIRA_SERVER_URL", _SITE_URL) + monkeypatch.setattr(jira_client, "_SERVER_INFO_CACHE", None) + + def failing_make_request(method, endpoint, data=None): + raise SystemExit(1) + + monkeypatch.setattr(jira_client, "make_request", failing_make_request) + + # When building a browse link + with pytest.raises(SystemExit) as excinfo: + jira_client.browse_url("TC-1") + + # Then the failure propagates + assert excinfo.value.code == 1 + + +@pytest.mark.parametrize("server_url", [_SITE_URL, _GATEWAY_URL]) +def test_browse_url_uses_site_base_for_site_and_gateway(monkeypatch, server_url): + """browse_url emits a site link whether JIRA_SERVER_URL is the site or the gateway.""" + # Given a REST base (site or gateway) whose serverInfo reports the site with a trailing slash + monkeypatch.setenv("JIRA_SERVER_URL", server_url) + monkeypatch.setenv("JIRA_API_TOKEN", "t") + monkeypatch.delenv("JIRA_EMAIL", raising=False) + monkeypatch.setattr(jira_client, "_SERVER_INFO_CACHE", None) + captured = [] + + def fake_urlopen(request): + captured.append(request.full_url) + return _FakeResponse({"baseUrl": _SITE_URL + "/"}) + + monkeypatch.setattr(jira_client, "urlopen", fake_urlopen) + + # When building a browse link + link = jira_client.browse_url("TC-6191") + + # Then serverInfo was read through the REST base and the link is on the site + assert captured == [server_url + "/rest/api/3/serverInfo"] + assert link == _SITE_URL + "/browse/TC-6191" + + +@pytest.mark.parametrize("user", [{}, {"accountId": ""}, {"accountId": None}, []]) +def test_verify_identity_without_account_id_exits(monkeypatch, capsys, user): + """verify_identity aborts when /myself resolves no accountId (anonymous or unresolved principal).""" + # Given a /myself response with no usable accountId + monkeypatch.setattr(jira_client, "make_request", lambda *_args, **_kwargs: user) + + # When verifying identity + with pytest.raises(SystemExit) as excinfo: + jira_client.verify_identity() + + # Then it exits 1 with a clear error + assert excinfo.value.code == 1 + assert "Jira identity could not be verified" in capsys.readouterr().err + + +def test_verify_identity_returns_resolved_user(monkeypatch): + """verify_identity returns the /myself user when it carries an accountId.""" + # Given a /myself response for a real principal + requests = [] + + def fake_make_request(method, endpoint, data=None): + requests.append((method, endpoint)) + return {"accountId": "sa-123", "displayName": "tpa-fullsend-jira-sa"} + + monkeypatch.setattr(jira_client, "make_request", fake_make_request) + + # When verifying identity + user = jira_client.verify_identity() + + # Then the user is returned after one GET myself + assert user == {"accountId": "sa-123", "displayName": "tpa-fullsend-jira-sa"} + assert requests == [("GET", "myself")] + + +@pytest.mark.parametrize("response", [ + {"permissions": {"BROWSE_PROJECTS": {"havePermission": False}}}, + {"permissions": {"BROWSE_PROJECTS": {}}}, + {"permissions": {}}, + {}, + [], +]) +def test_verify_project_access_without_browse_permission_exits(monkeypatch, capsys, response): + """verify_project_access aborts unless BROWSE_PROJECTS.havePermission is exactly true.""" + # Given a mypermissions response that does not grant Browse Projects + monkeypatch.setattr(jira_client, "make_request", lambda *_args, **_kwargs: response) + + # When verifying project access + with pytest.raises(SystemExit) as excinfo: + jira_client.verify_project_access("TC") + + # Then it exits 1 naming the project + assert excinfo.value.code == 1 + assert "cannot browse project TC" in capsys.readouterr().err + + +def test_verify_project_access_queries_browse_permission(monkeypatch): + """verify_project_access requests BROWSE_PROJECTS for the URL-encoded project key and returns the grant.""" + # Given a mypermissions response granting Browse Projects + granted = {"permissions": {"BROWSE_PROJECTS": {"havePermission": True}}} + requests = [] + + def fake_make_request(method, endpoint, data=None): + requests.append((method, endpoint)) + return granted + + monkeypatch.setattr(jira_client, "make_request", fake_make_request) + + # When verifying access to a project key needing encoding + result = jira_client.verify_project_access("T C") + + # Then the query names the project and permission, and the grant is returned + assert result == granted + assert requests == [("GET", "mypermissions?projectKey=T+C&permissions=BROWSE_PROJECTS")] + + def run_all_tests(): """Run all tests and report results.""" tests = [ diff --git a/plugins/sdlc-workflow/scripts/test_jira_client_cli.py b/plugins/sdlc-workflow/scripts/test_jira_client_cli.py index 766452f17..709602dd9 100644 --- a/plugins/sdlc-workflow/scripts/test_jira_client_cli.py +++ b/plugins/sdlc-workflow/scripts/test_jira_client_cli.py @@ -9,6 +9,7 @@ import importlib.util import io +import json import sys import os @@ -198,6 +199,47 @@ def test_create_issue_help_shows_fix_versions_flag(): print("✓ create_issue --help shows --fix-versions flag test passed") +def test_get_server_info_help(): + """Verifies that the get_server_info subcommand is registered and shows help.""" + exit_code, stdout, stderr = run_cli_command(['get_server_info', '--help']) + + assert exit_code == 0, f"Expected exit code 0, got {exit_code}" + assert "get_server_info" in stdout, f"Expected 'get_server_info' in help output, got: {stdout}" + + print("✓ get_server_info --help test passed") + + +def test_help_epilog_documents_optional_email(): + """Verifies that --help lists the required variables and documents JIRA_EMAIL as the Basic-auth switch.""" + exit_code, stdout, stderr = run_cli_command(['--help']) + + assert exit_code == 0, f"Expected exit code 0, got {exit_code}" + flat = " ".join(stdout.split()) + assert "Set JIRA_SERVER_URL and JIRA_API_TOKEN" in flat, f"Got: {stdout}" + assert "Set JIRA_EMAIL to use Basic auth" in flat, f"Got: {stdout}" + assert "Bearer" in flat, f"Got: {stdout}" + + print("✓ --help epilog documents optional JIRA_EMAIL test passed") + + +def test_get_server_info_dispatch_prints_json(): + """Verifies that get_server_info dispatches to get_server_info() and prints its JSON.""" + # Given a stubbed get_server_info + original = jira_client.get_server_info + jira_client.get_server_info = lambda: {"baseUrl": "https://redhat.atlassian.net"} + try: + # When running the subcommand + exit_code, stdout, stderr = run_cli_command(['get_server_info']) + finally: + jira_client.get_server_info = original + + # Then it prints the serverInfo JSON + assert exit_code == 0, f"Expected exit code 0, got {exit_code}: {stderr}" + assert json.loads(stdout) == {"baseUrl": "https://redhat.atlassian.net"} + + print("✓ get_server_info dispatch test passed") + + def test_create_issue_fix_versions_comma_parsing(): """Verifies that --fix-versions splits comma-separated values into a list.""" # Given comma-separated version names @@ -227,6 +269,9 @@ def run_all_tests(): test_create_issue_help_shows_priority_flag, test_create_issue_help_shows_fix_versions_flag, test_create_issue_fix_versions_comma_parsing, + test_get_server_info_help, + test_help_epilog_documents_optional_email, + test_get_server_info_dispatch_prints_json, ] failed = [] diff --git a/plugins/sdlc-workflow/scripts/test_pre_triage_security.py b/plugins/sdlc-workflow/scripts/test_pre_triage_security.py index 1be8cf533..5e3768dcd 100644 --- a/plugins/sdlc-workflow/scripts/test_pre_triage_security.py +++ b/plugins/sdlc-workflow/scripts/test_pre_triage_security.py @@ -157,7 +157,6 @@ def test_pre_triage_script_rejects_missing_poller_work_item_url(): environment = { "PATH": os.environ["PATH"], "JIRA_SERVER_URL": "https://jira.example.com", - "JIRA_EMAIL": "runner@example.com", "JIRA_API_TOKEN": "token", } @@ -177,7 +176,6 @@ def test_pre_triage_script_rejects_missing_runner_credentials(): "PATH": os.environ["PATH"], "FULLSEND_WORK_ITEM_URL": "https://jira.example.com/browse/TC-42", "JIRA_SERVER_URL": "https://jira.example.com", - "JIRA_EMAIL": "runner@example.com", } # When the trusted pre-script starts @@ -204,7 +202,6 @@ def _run_dir_guard_environment(tmp_path, run_directory): "FULLSEND_PROJECT_ROOT": str(project_root), "FULLSEND_RUN_DIR": str(run_directory), "JIRA_SERVER_URL": "https://jira.example.com", - "JIRA_EMAIL": "runner@example.com", "JIRA_API_TOKEN": "token", } @@ -284,8 +281,7 @@ def environment_for(issue_key, run_directory): "COLLECTOR_READY_DIR": str(ready_directory), "COLLECTOR_RELEASE": str(release_file), "JIRA_SERVER_URL": "https://jira.example.com", - "JIRA_EMAIL": "runner@example.com", - "JIRA_API_TOKEN": "token", + "JIRA_API_TOKEN": "token", } first_run = tmp_path / "run-one" @@ -1263,11 +1259,17 @@ def test_validate_bundle_checks_release_decision_family_bindings(decisions): """ -def _discovery_project(tmp_path, monkeypatch, project_key="TC", issue_type_id="10016"): - """Write a synthetic target CLAUDE.md and set the runner's Jira server URL.""" +_SITE_URL = "https://redhat.atlassian.net" +_GATEWAY_URL = "https://api.atlassian.com/ex/jira/2b9e35e3-6bd3-4cec-b838-f4249ee02432" + + +def _discovery_project(tmp_path, monkeypatch, project_key="TC", issue_type_id="10016", + server_url="https://jira.example.com/"): + """Write a synthetic target CLAUDE.md, set the runner's Jira REST base, and reset the serverInfo cache.""" (tmp_path / "CLAUDE.md").write_text( _DISCOVERY_CLAUDE_MD.format(project_key=project_key, issue_type_id=issue_type_id)) - monkeypatch.setenv("JIRA_SERVER_URL", "https://jira.example.com/") + monkeypatch.setenv("JIRA_SERVER_URL", server_url) + monkeypatch.setattr(pre_triage_security, "_SERVER_INFO_BASE_URL", None) return tmp_path @@ -1315,8 +1317,10 @@ def test_discover_returns_ordered_keys_and_urls_within_cap( root = _discovery_project(tmp_path, monkeypatch) calls = [] - def jira_client(_command, *arguments): - """Return three issues in the order the JQL sorts them.""" + def jira_client(command, *arguments): + """Return three issues in the order the JQL sorts them, and the site serverInfo.""" + if command == "get_server_info": + return {"baseUrl": "https://jira.example.com"} calls.append(arguments) return {"issues": [{"key": "TC-3"}, {"key": "TC-1"}, {"key": "TC-2"}]} @@ -1374,6 +1378,86 @@ def failing_client(*_args): assert captured.err.startswith("ERROR:") +@pytest.mark.parametrize("server_url", [_SITE_URL, _GATEWAY_URL]) +def test_discover_links_use_server_info_base_url(tmp_path, monkeypatch, capsys, server_url): + """Discover links come from serverInfo.baseUrl whether the REST base is the site or the gateway.""" + # Given a REST base (site or gateway) and serverInfo reporting the site address + root = _discovery_project(tmp_path, monkeypatch, server_url=server_url) + commands = [] + + def jira_client(command, *_arguments): + """Return one issue and the site serverInfo, recording each command.""" + commands.append(command) + if command == "get_server_info": + return {"baseUrl": _SITE_URL + "/"} + return {"issues": [{"key": "TC-7"}, {"key": "TC-8"}]} + + monkeypatch.setattr(pre_triage_security, "_jira_client", jira_client) + + # When the poller runs the discover command + status = pre_triage_security.main(["discover", str(root)]) + + # Then every link is on the site, and serverInfo is fetched once for both links + assert status == 0 + assert json.loads(capsys.readouterr().out) == {"issues": [ + {"key": "TC-7", "url": _SITE_URL + "/browse/TC-7"}, + {"key": "TC-8", "url": _SITE_URL + "/browse/TC-8"}, + ]} + assert commands == ["search_jql", "get_server_info"] + + +def test_discover_skips_server_info_when_no_issues(tmp_path, monkeypatch, capsys): + """An empty untriaged search builds no links, so serverInfo is never fetched.""" + # Given a search with no untriaged issues + root = _discovery_project(tmp_path, monkeypatch) + commands = [] + + def jira_client(command, *_arguments): + """Record each command and return no issues.""" + commands.append(command) + return {"issues": []} + + monkeypatch.setattr(pre_triage_security, "_jira_client", jira_client) + + # When the poller runs the discover command + status = pre_triage_security.main(["discover", str(root)]) + + # Then it reports an empty list after a single search + assert status == 0 + assert json.loads(capsys.readouterr().out) == {"issues": []} + assert commands == ["search_jql"] + + +@pytest.mark.parametrize("server_info", [ + subprocess.CalledProcessError(1, ["jira-client"]), + {"version": "1001.0.0"}, + {"baseUrl": ""}, +]) +def test_discover_fails_when_server_info_is_unusable(tmp_path, monkeypatch, capsys, server_info): + """A failed or baseUrl-less serverInfo aborts discover instead of emitting guessed links.""" + # Given a valid search and a serverInfo call that fails or lacks baseUrl + root = _discovery_project(tmp_path, monkeypatch) + + def jira_client(command, *_arguments): + """Return one issue; fail or return a malformed serverInfo.""" + if command != "get_server_info": + return {"issues": [{"key": "TC-7"}]} + if isinstance(server_info, Exception): + raise server_info + return server_info + + monkeypatch.setattr(pre_triage_security, "_jira_client", jira_client) + + # When the poller runs the discover command + status = pre_triage_security.main(["discover", str(root)]) + + # Then it exits 1 with an error and prints no issue list + captured = capsys.readouterr() + assert status == 1 + assert captured.out == "" + assert captured.err.startswith("ERROR:") + + @pytest.mark.parametrize("setup, message", [ (lambda root, mp: (root / "CLAUDE.md").unlink(), "target project CLAUDE.md is required"), (lambda root, mp: (root / "CLAUDE.md").write_text("# Project Configuration\n"), @@ -1381,7 +1465,6 @@ def failing_client(*_args): (lambda root, mp: (root / "CLAUDE.md").write_text( _DISCOVERY_CLAUDE_MD.format(project_key="TC", issue_type_id="10016 OR x")), "Vulnerability issue type ID must be numeric"), - (lambda root, mp: mp.delenv("JIRA_SERVER_URL"), "JIRA_SERVER_URL is required"), ]) def test_discover_rejects_invalid_configuration(tmp_path, monkeypatch, capsys, setup, message): """Missing or invalid runner configuration fails before any Jira search.""" diff --git a/plugins/sdlc-workflow/scripts/test_pre_verify_pr.py b/plugins/sdlc-workflow/scripts/test_pre_verify_pr.py index fb88cf697..bba458529 100644 --- a/plugins/sdlc-workflow/scripts/test_pre_verify_pr.py +++ b/plugins/sdlc-workflow/scripts/test_pre_verify_pr.py @@ -7,6 +7,8 @@ import subprocess import sys import tempfile +import threading +from http.server import BaseHTTPRequestHandler, HTTPServer script_dir = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, script_dir) @@ -1833,6 +1835,149 @@ def test_pre_verify_sh_revalidates_gate_before_writing_input(): "a failed re-validation must map to request_skip" +# --- Jira identity + project-access gate (pre-verify-pr.sh, TC-7265 / TC-6191) --- + +_BROWSE_GRANTED = {"permissions": {"BROWSE_PROJECTS": {"havePermission": True}}} +_MYSELF_PATH = "/rest/api/3/myself" +_PERMISSIONS_PATH = "/rest/api/3/mypermissions?projectKey=TC&permissions=BROWSE_PROJECTS" +_SEARCH_PATH = "/rest/api/3/search/jql" + + +class _StubJira: + """Local HTTP stand-in for Jira: configurable /myself and /mypermissions, empty JQL search, request log.""" + + def __init__(self, myself_status, myself_body, permissions_status=200, permissions_body=None): + self.paths = [] + stub = self + + class Handler(BaseHTTPRequestHandler): + def _reply(self, status, body): + payload = json.dumps(body).encode() + self.send_response(status) + self.send_header("Content-Type", "application/json") + self.send_header("Content-Length", str(len(payload))) + self.end_headers() + self.wfile.write(payload) + + def do_GET(self): + stub.paths.append(self.path) + if self.path == _MYSELF_PATH: + self._reply(myself_status, myself_body) + elif self.path.startswith("/rest/api/3/mypermissions"): + self._reply(permissions_status, + _BROWSE_GRANTED if permissions_body is None else permissions_body) + else: + self._reply(404, {"errorMessages": ["unexpected"]}) + + def do_POST(self): + stub.paths.append(self.path) + self.rfile.read(int(self.headers.get("Content-Length", 0))) + # An unauthenticated gateway search answers 200 with no issues, + # exactly like a legitimate no-match. + self._reply(200, {"issues": [], "isLast": True}) + + def log_message(self, *_args): + pass + + self.server = HTTPServer(("127.0.0.1", 0), Handler) + self.url = "http://127.0.0.1:{}".format(self.server.server_port) + threading.Thread(target=self.server.serve_forever, daemon=True).start() + + def close(self): + self.server.shutdown() + self.server.server_close() + + +def _run_pre_verify_gate(myself_status, myself_body, permissions_status=200, permissions_body=None): + """Run the real pre-verify-pr.sh against a stub Jira. + + Returns (result, prescript-output text, request paths seen by the stub). + """ + stub = _StubJira(myself_status, myself_body, permissions_status, permissions_body) + try: + with tempfile.TemporaryDirectory() as d: + signal_file = os.path.join(d, "prescript-output") + open(signal_file, "w").close() + env = { + "PATH": os.environ["PATH"], + "FULLSEND_WORK_ITEM_URL": "https://github.com/acme/widget/pull/42", + "JIRA_SERVER_URL": stub.url, + "JIRA_API_TOKEN": "token", + "JIRA_PROJECT_KEY": "TC", + "PRE_DIR": os.path.join(d, "pre"), + "FULLSEND_PRESCRIPT_OUTPUT": signal_file, + "TMPDIR": d, + "PYTHONDONTWRITEBYTECODE": "1", + } + result = subprocess.run(["bash", pre_verify_sh], env=env, capture_output=True, + text=True, timeout=60) + with open(signal_file) as f: + signal = f.read() + finally: + stub.close() + return result, signal, stub.paths + + +def test_unverified_identity_with_empty_search_fails_instead_of_skipping(): + """An unauthenticated or accountId-less /myself fails the run before an empty search can become a skip.""" + cases = [ + (401, {"errorMessages": ["Client must be authenticated to access this resource."]}), + (200, {}), + (200, {"accountId": ""}), + ] + for myself_status, myself_body in cases: + # Given a Jira whose search returns [] but whose /myself does not resolve a principal + # When the verify-pr pre-script gates the PR + result, signal, paths = _run_pre_verify_gate(myself_status, myself_body) + + # Then it exits non-zero, emits no skip signal, and never runs the search + case = f"/myself {myself_status} {myself_body!r}: " + assert result.returncode != 0, case + result.stdout + result.stderr + assert "SKIP:" not in result.stdout, case + result.stdout + assert "skipped=true" not in signal, case + signal + assert paths == [_MYSELF_PATH], case + repr(paths) + + +def test_verified_identity_with_empty_search_is_a_normal_skip(): + """An authenticated no-match search still yields the ADR-0072 skip, after the identity and access checks.""" + # Given a Jira that resolves the principal and finds no issue for the PR + # When the verify-pr pre-script gates the PR + result, signal, paths = _run_pre_verify_gate( + 200, {"accountId": "sa-123", "displayName": "tpa-fullsend-jira-sa"}) + + # Then it skips cleanly, and identity and project access were verified before the search + assert result.returncode == 0, result.stdout + result.stderr + assert "Jira identity verified: tpa-fullsend-jira-sa" in result.stdout + assert "Jira project access verified: TC (BROWSE_PROJECTS)" in result.stdout + assert "SKIP:" in result.stdout + assert "skipped=true" in signal + assert paths == [_MYSELF_PATH, _PERMISSIONS_PATH, _SEARCH_PATH] + + +def test_missing_browse_permission_with_empty_search_fails_instead_of_skipping(): + """A real account without Browse Projects on the project fails the run instead of skipping on a filtered empty search.""" + cases = [ + (200, {"permissions": {"BROWSE_PROJECTS": {"havePermission": False}}}), + (200, {"permissions": {}}), + (200, {}), + (403, {"errorMessages": ["Forbidden"]}), + ] + for permissions_status, permissions_body in cases: + # Given a resolved principal whose project permission is missing or denied + # When the verify-pr pre-script gates the PR + result, signal, paths = _run_pre_verify_gate( + 200, {"accountId": "sa-123", "displayName": "tpa-fullsend-jira-sa"}, + permissions_status, permissions_body) + + # Then it exits non-zero naming the project, emits no skip, and never runs the search + case = f"/mypermissions {permissions_status} {permissions_body!r}: " + assert result.returncode != 0, case + result.stdout + result.stderr + assert "cannot browse project TC" in result.stdout, case + result.stdout + assert "SKIP:" not in result.stdout, case + result.stdout + assert "skipped=true" not in signal, case + signal + assert paths == [_MYSELF_PATH, _PERMISSIONS_PATH], case + repr(paths) + + # --- runner --- if __name__ == "__main__": diff --git a/plugins/sdlc-workflow/scripts/test_triage_security_fullsend.py b/plugins/sdlc-workflow/scripts/test_triage_security_fullsend.py index e654aee6c..21e091a6d 100644 --- a/plugins/sdlc-workflow/scripts/test_triage_security_fullsend.py +++ b/plugins/sdlc-workflow/scripts/test_triage_security_fullsend.py @@ -118,6 +118,8 @@ def recorder(monkeypatch): monkeypatch.setattr(executor._jira_mod, "get_issue", value.get_issue) monkeypatch.setattr(executor._jira_mod, "create_link", value.create_link) monkeypatch.setattr(executor._jira_mod, "make_request", value.make_request) + monkeypatch.setattr(executor._jira_mod, "get_server_info", + lambda: {"baseUrl": "https://jira.example.com"}) monkeypatch.setattr(executor._action_helpers, "post_jira_comment_native", value.post_native) return value