Files
claude-code-action/src/github/api/queries/github.ts
Ashwin Bhat a6888c03f2 feat: add time-based comment filtering to tag mode (#512)
Implement time-based filtering for GitHub comments and reviews to prevent
malicious actors from editing existing comments after Claude is triggered
to inject harmful content.

Changes:
- Add updatedAt and lastEditedAt fields to GraphQL queries
- Update GitHubComment and GitHubReview types with timestamp fields
- Implement filterCommentsToTriggerTime() and filterReviewsToTriggerTime()
- Add extractTriggerTimestamp() to extract trigger time from webhooks
- Update tag and review modes to pass trigger timestamp to data fetcher

Security benefits:
- Prevents comment injection attacks via post-trigger edits
- Maintains chronological integrity of conversation context
- Ensures only comments in their final state before trigger are processed
- Backward compatible with graceful degradation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-29 09:49:08 -07:00

126 lines
2.3 KiB
TypeScript

// GraphQL queries for GitHub data
export const PR_QUERY = `
query($owner: String!, $repo: String!, $number: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $number) {
title
body
author {
login
}
baseRefName
headRefName
headRefOid
createdAt
additions
deletions
state
commits(first: 100) {
totalCount
nodes {
commit {
oid
message
author {
name
email
}
}
}
}
files(first: 100) {
nodes {
path
additions
deletions
changeType
}
}
comments(first: 100) {
nodes {
id
databaseId
body
author {
login
}
createdAt
updatedAt
lastEditedAt
isMinimized
}
}
reviews(first: 100) {
nodes {
id
databaseId
author {
login
}
body
state
submittedAt
updatedAt
lastEditedAt
comments(first: 100) {
nodes {
id
databaseId
body
path
line
author {
login
}
createdAt
updatedAt
lastEditedAt
isMinimized
}
}
}
}
}
}
}
`;
export const ISSUE_QUERY = `
query($owner: String!, $repo: String!, $number: Int!) {
repository(owner: $owner, name: $repo) {
issue(number: $number) {
title
body
author {
login
}
createdAt
state
comments(first: 100) {
nodes {
id
databaseId
body
author {
login
}
createdAt
updatedAt
lastEditedAt
isMinimized
}
}
}
}
}
`;
export const USER_QUERY = `
query($login: String!) {
user(login: $login) {
name
}
}
`;