mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
validator: Disable WildValue equality comparison.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
2747127e6c
commit
10705e0db3
@@ -62,7 +62,7 @@ def get_body(payload: WildValue) -> str:
|
||||
}
|
||||
)
|
||||
|
||||
if payload["status"] == "successful":
|
||||
if payload["status"].tame(check_string) == "successful":
|
||||
status = "was successful"
|
||||
else:
|
||||
status = "failed"
|
||||
|
||||
@@ -78,7 +78,10 @@ def api_circleci_webhook(
|
||||
# We currently don't support projects using VCS providers other than GitHub,
|
||||
# BitBucket and GitLab.
|
||||
pipeline = payload["pipeline"]
|
||||
if "trigger_parameters" in pipeline and pipeline["trigger"]["type"] != "gitlab":
|
||||
if (
|
||||
"trigger_parameters" in pipeline
|
||||
and pipeline["trigger"]["type"].tame(check_string) != "gitlab"
|
||||
):
|
||||
raise JsonableError(
|
||||
_("Projects using this version control system provider aren't supported")
|
||||
) # nocoverage
|
||||
@@ -102,7 +105,7 @@ def get_commit_details(payload: WildValue) -> str:
|
||||
revision = payload["pipeline"]["vcs"]["revision"].tame(check_string)
|
||||
commit_id = get_short_sha(revision)
|
||||
|
||||
if payload["pipeline"]["vcs"]["provider_name"] == "github":
|
||||
if payload["pipeline"]["vcs"]["provider_name"].tame(check_string) == "github":
|
||||
commit_link = GITHUB_COMMIT_LINK.format(
|
||||
target_repository_url=payload["pipeline"]["vcs"]["target_repository_url"].tame(
|
||||
check_url
|
||||
|
||||
@@ -77,7 +77,7 @@ STORY_UPDATE_BATCH_ADD_REMOVE_TEMPLATE = "{operation} with {entity}"
|
||||
|
||||
def get_action_with_primary_id(payload: WildValue) -> WildValue:
|
||||
for action in payload["actions"]:
|
||||
if payload["primary_id"] == action["id"]:
|
||||
if payload["primary_id"].tame(check_int) == action["id"].tame(check_int):
|
||||
action_with_primary_id = action
|
||||
|
||||
return action_with_primary_id
|
||||
@@ -176,9 +176,9 @@ def get_comment_added_body(entity: str, payload: WildValue, ignored_action: Wild
|
||||
actions = payload["actions"]
|
||||
kwargs = {"entity": entity}
|
||||
for action in actions:
|
||||
if action["id"] == payload["primary_id"]:
|
||||
if action["id"].tame(check_int) == payload["primary_id"].tame(check_int):
|
||||
kwargs["text"] = action["text"].tame(check_string)
|
||||
elif action["entity_type"] == entity:
|
||||
elif action["entity_type"].tame(check_string) == entity:
|
||||
name_template = get_name_template(entity).format(
|
||||
name=action["name"].tame(check_string),
|
||||
app_url=action.get("app_url").tame(check_none_or(check_string)),
|
||||
@@ -663,7 +663,7 @@ def get_story_update_batch_body(payload: WildValue, action: WildValue) -> str |
|
||||
def get_entity_name(entity: str, payload: WildValue, action: WildValue) -> str | None:
|
||||
name = action["name"].tame(check_string) if "name" in action else None
|
||||
|
||||
if name is None or action["entity_type"] == "branch":
|
||||
if name is None or action["entity_type"].tame(check_string) == "branch":
|
||||
for other_action in payload["actions"]:
|
||||
if other_action["entity_type"].tame(check_string) == entity:
|
||||
name = other_action["name"].tame(check_string)
|
||||
|
||||
@@ -25,7 +25,7 @@ def api_crashlytics_webhook(
|
||||
*,
|
||||
payload: JsonBodyPayload[WildValue],
|
||||
) -> HttpResponse:
|
||||
event = payload["event"]
|
||||
event = payload["event"].tame(check_string)
|
||||
if event == VERIFICATION_EVENT:
|
||||
topic_name = CRASHLYTICS_SETUP_TOPIC_TEMPLATE
|
||||
body = CRASHLYTICS_SETUP_MESSAGE_TEMPLATE
|
||||
|
||||
@@ -225,7 +225,7 @@ def handle_updated_issue_event(payload: WildValue, user_profile: UserProfile) ->
|
||||
else:
|
||||
verb = "deleted a comment from"
|
||||
|
||||
if payload.get("webhookEvent") == "comment_created":
|
||||
if payload.get("webhookEvent").tame(check_none_or(check_string)) == "comment_created":
|
||||
author = payload["comment"]["author"]["displayName"].tame(check_string)
|
||||
else:
|
||||
author = get_issue_author(payload)
|
||||
|
||||
@@ -271,7 +271,7 @@ def api_slack_webhook(
|
||||
# for how to add support for this type of payload.
|
||||
raise UnsupportedWebhookEventTypeError(
|
||||
"integration bot message"
|
||||
if event_dict["subtype"] == "bot_message"
|
||||
if event_dict["subtype"].tame(check_string) == "bot_message"
|
||||
else "unknown Slack event"
|
||||
)
|
||||
sender = get_slack_sender_name(user_id, slack_app_token)
|
||||
|
||||
Reference in New Issue
Block a user