Skip to content

fix(blueprint): keep the scheduled plan unmasked after PATCH /blueprints - #9247

Open
Thanatos9404 wants to merge 1 commit into
apache:mainfrom
Thanatos9404:fix/blueprint-patch-keeps-scheduled-plan
Open

Thanatos9404 wants to merge 1 commit into
apache:mainfrom
Thanatos9404:fix/blueprint-patch-keeps-scheduled-plan

Conversation

@Thanatos9404

Copy link
Copy Markdown

Summary

After PATCH /blueprints/:id, PatchBlueprint sanitized the same blueprint object the cron job had just been given, and the gitextractor sanitizer rewrote options["url"] in place. Scheduled runs then cloned with a masked URL until the server restarted. Normal-mode blueprints with credentials in beforePlan or afterPlan were affected too, since those tasks are shared with the generated plan.

Sanitizing now works on copies: the options map is cloned before masking, SanitizeTask returns a new task, and SanitizeBlueprint and SanitizePipeline build a new plan. PatchBlueprint sanitizes a copy for its response, so the returned plan is still masked. Its beforePlan and afterPlan now come back unmasked, as GET already returns them; before, they were masked only through this aliasing.

Two new unit tests in blueprint_test.go fail on main and pass here, and go test, go vet and golangci-lint are clean for server/services.

Does this close any open issues?

Closes #9243

PatchBlueprint sanitized the blueprint it had just handed to the cron
job, and the gitextractor sanitizer rewrote the options map in place.
The next scheduled pipeline then cloned with a masked URL until the
server restarted. Normal-mode blueprints with credentials in beforePlan
or afterPlan were hit too, since those tasks are shared with the
generated plan.

Sanitizing now works on copies: SanitizePluginOption masks a clone of
the options, SanitizeTask returns a new task, and SanitizeBlueprint and
SanitizePipeline build a new plan. PatchBlueprint sanitizes a copy of
the saved blueprint for its response, so the plan it returns is still
masked.

Closes apache#9243

Signed-off-by: Yashvardhan Thanvi <yashvt9404@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][Blueprint] Cron-triggered pipelines use a sanitized plan after PATCH /blueprints, gitextractor fails with masked credentials

1 participant