Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: webhook check on edit escalation policy step #3040

Merged
merged 3 commits into from
May 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions graphql2/graphqlapp/escalationpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func (m *Mutation) CreateEscalationPolicyStep(ctx context.Context, input graphql

for _, tgt := range input.Targets {
if tgt.Type == assignment.TargetTypeChanWebhook && !cfg.ValidWebhookURL(tgt.ID) {
// UI code expects targets to be un-indexed
return nil, validation.NewFieldError("targets", "URL not allowed by administrator")
}
}
Expand Down Expand Up @@ -227,6 +228,7 @@ func (m *Mutation) UpdateEscalationPolicy(ctx context.Context, input graphql2.Up

func (m *Mutation) UpdateEscalationPolicyStep(ctx context.Context, input graphql2.UpdateEscalationPolicyStepInput) (bool, error) {
err := withContextTx(ctx, m.DB, func(ctx context.Context, tx *sql.Tx) error {
cfg := config.FromContext(ctx)
step, err := m.PolicyStore.FindOneStepForUpdateTx(ctx, tx, input.ID) // get delay
if err != nil {
return err
Expand All @@ -246,6 +248,10 @@ func (m *Mutation) UpdateEscalationPolicyStep(ctx context.Context, input graphql
if input.Targets != nil {
step.Targets = make([]assignment.Target, len(input.Targets))
for i, tgt := range input.Targets {
if tgt.Type == assignment.TargetTypeChanWebhook && !cfg.ValidWebhookURL(tgt.ID) {
// UI code expects targets to be un-indexed
return validation.NewFieldError("targets", "URL not allowed by administrator")
andrewbenington marked this conversation as resolved.
Show resolved Hide resolved
}
step.Targets[i] = tgt
}

Expand Down