Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .github/PROJECT_SYNC.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ or deletes source Issues/PRs.
not count. Populate PR links and actual release tag/URL, never guess a version.
- Issue/PR lifecycle events read only their subject and bounded linked issues/PRs,
including old/new body references and previously stored implementation links.
Fork-origin PR events are skipped to avoid spending an Actions run per fork event;
the scheduled reconciliation still observes their final repository-visible state.
They do not scan repository Issues, PRs, Project items, or releases. Six-hour
scheduled and manual runs do full reconciliation; changes discovered only by
broad push/release scans wait until the next scheduled or manual run.
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/project-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ concurrency:

jobs:
sync:
if: github.repository == 'AstrBotDevs/AstrBot' && vars.ASTRBOT_PROJECT_ID != ''
if: >-
github.repository == 'AstrBotDevs/AstrBot' &&
vars.ASTRBOT_PROJECT_ID != '' &&
(github.event_name != 'pull_request_target' ||
github.event.pull_request.head.repo.full_name == github.repository)
# Configure this environment to allow only the default branch before adding secrets.
environment: project-sync
runs-on: ubuntu-latest
Expand Down
13 changes: 13 additions & 0 deletions tests/test_sync_github_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,19 @@ def test_schedule_uses_configured_default_branch(self):


class WorkflowSecurityTests(unittest.TestCase):
def test_fork_pull_request_events_are_filtered_at_job_boundary(self):
workflow = (
SCRIPT.parents[1] / ".github/workflows/project-sync.yml"
).read_text()
job_condition = workflow.split(" sync:\n", 1)[1].split(
" environment:", 1
)[0]
self.assertIn("github.event_name != 'pull_request_target'", job_condition)
self.assertIn(
"github.event.pull_request.head.repo.full_name == github.repository",
job_condition,
)

def test_sync_job_requires_environment_before_any_steps(self):
workflow = (
SCRIPT.parents[1] / ".github/workflows/project-sync.yml"
Expand Down
Loading