Align enqueue/dequeue events with trigger events

EnqueueEvents and DequeueEvents are duck-typed as TriggerEvents
when they are passed to source.getChange.  TriggerEvents are always
created in the context of a connection, so they have a hostname
field and a name field, and name should never have the hostname.

However, our current EnqueueEvents are created directly from
client-side user input and accept any form of project name.  This
means when we get a change from them, we may end up with a Project
that has a canonical name for it's "name" field.  This could not
only cause the enqueue event to be rejected, it could leak project
objects.

To correct this, perform some pre-processing on the input data to
get separate host/name data for the project, and then use that to
construct an Enqueue/DequeueEvent with the same field usage as
a TriggerEvent.

Change-Id: Ib596c282eba3a01c10d28593545e5d238d09de0c
This commit is contained in:
James E. Blair
2021-03-27 08:11:55 -07:00
parent 3095910660
commit abad438e53
5 changed files with 85 additions and 9 deletions

View File

@@ -597,6 +597,7 @@ class GithubEventProcessor(object):
event = DequeueEvent(
dequeue_attrs["tenant"],
dequeue_attrs["pipeline"],
self.connection.canonical_hostname,
project,
change,
ref=None