in src/github/api/graphql-data-fetcher.ts [73:132]
async fetchPullRequestData(owner: string, repo: string, pullNumber: number, triggerTime?: string) {
const response = await this.executeGraphQLWithRetry<PullRequestQueryResponse>(
PULL_REQUEST_QUERY,
{
owner,
repo,
number: pullNumber
}
);
const pr = response.repository.pullRequest;
// Filter timeline comments to trigger time
const filteredTimelineNodes = filterCommentsToTriggerTime(
pr.timelineItems.nodes,
triggerTime
);
// Filter reviews to trigger time
const filteredReviews = filterReviewsToTriggerTime(
pr.reviews.nodes,
triggerTime
);
// Filter review comments within each review
const reviewsWithFilteredComments = filteredReviews.map(review => ({
...review,
comments: {
nodes: filterCommentsToTriggerTime(
review.comments.nodes,
triggerTime
)
}
}));
// Check if body is safe to use
const bodyIsSafe = isBodySafeToUse(pr, triggerTime);
if (!bodyIsSafe) {
console.warn(
`Security: PR #${pullNumber} body was edited after the trigger event. ` +
`Excluding body content to prevent potential injection attacks.`
);
}
// Create filtered PR object
const filteredPR: GraphQLPullRequest = {
...pr,
body: bodyIsSafe ? pr.body : "",
timelineItems: {
nodes: filteredTimelineNodes
},
reviews: {
nodes: reviewsWithFilteredComments
}
};
return {
pullRequest: filteredPR
};
}