Visitar URL original
pkg/aflow: allow the patch generator to create source files by rsd-darshan · Pull Request #8084 · google/syzkaller · GitHub
Skip to content

pkg/aflow: allow the patch generator to create source files - #8084

Open
rsd-darshan wants to merge 1 commit into
google:masterfrom
rsd-darshan:fix/aflow-create-files
Open

rsd-darshan wants to merge 1 commit into
google:masterfrom
rsd-darshan:fix/aflow-create-files

Conversation

@rsd-darshan

@rsd-darshan rsd-darshan commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

The patch generator can edit existing source files but cannot add new ones. Give it a separate creation tool so the patch formatter retains only the shared edit tool.

The new tool validates source paths and uses SandboxRoot for exclusive creation and sandbox ownership. The file is closed before sandboxed Git registers it with intent-to-add, making it visible in generated diffs without staging its contents. Git receives the filename as a literal pathspec after --.

Tests cover the new-file diff and patch application, sandbox ownership, existing-file rejection, and invalid paths and symlinks.

Fixes #8047.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the ability to create new source files in the codeeditor tool when CurrentCode is empty. It adds a createFile helper that handles exclusive file creation, writes the new content, changes file ownership to the sandbox user via a new SandboxChownFile utility, and registers the file with git using --intent-to-add. Comprehensive tests are added for these new features. The reviewer recommends closing the file descriptor in createFile before executing the external git command to prevent potential race conditions or locked files.

Comment thread pkg/aflow/tool/codeeditor/codeeditor.go Resolved
@rsd-darshan

Copy link
Copy Markdown
Contributor Author

@pimyn-girgis Friendly ping on this when you have a chance. Would appreciate your review of the source-file creation support for #8047. Thanks!

@github-actions github-actions Bot added well-shaped PR has no conflicts and all checks pass and removed well-shaped PR has no conflicts and all checks pass labels Nov 12, 2026
@pimyn-girgis

Copy link
Copy Markdown
Collaborator

I'm sorry for the dealay. It's been a busy couple of weeks. I'll look into this today.

@github-actions github-actions Bot removed the well-shaped PR has no conflicts and all checks pass label Nov 18, 2026
@pimyn-girgis

Copy link
Copy Markdown
Collaborator

Could you please check if the code could benefit from any of the new sandboxing and protections introduced in the last week?

@pimyn-girgis pimyn-girgis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't necessarily like that we're giving codeeditor the ability to also create files. Patch formatter uses it, and it shouldn't be able to create new files.

Comment thread pkg/aflow/tool/codeeditor/codeeditor.go Resolved
Comment thread pkg/aflow/tool/codeeditor/codeeditor.go Resolved
Comment thread pkg/aflow/tool/codeeditor/codeeditor.go Resolved
Give the patch generator a separate tool for creating a source file.
Keep the shared editor and patch formatter limited to editing files.

Validate paths, create files exclusively through SandboxRoot, and set
sandbox ownership before closing the file. Register each creation as
intent-to-add using sandboxed Git and a literal pathspec so it appears
in generated patches.

Fixes google#8047.
@rsd-darshan
rsd-darshan force-pushed the fix/aflow-create-files branch from b39c7e0 to d21eae1 Compare November 18, 2026 16:09
@rsd-darshan rsd-darshan changed the title pkg/aflow/tool/codeeditor: support creating source files pkg/aflow: allow the patch generator to create source files Nov 18, 2026
@rsd-darshan

Copy link
Copy Markdown
Contributor Author

@pimyn-girgis Thanks for the review. I updated the branch to use the new SandboxRoot helper and the current network-isolated Git wrapper. File creation is now available only to the patch generator; the formatter still uses the edit-only tool. The file is closed before Git runs. Targeted Go tests and the Linux sandbox ownership tests passed. Could you take another look when you have a chance?

@github-actions github-actions Bot added the well-shaped PR has no conflicts and all checks pass label Nov 18, 2026
@pimyn-girgis

Copy link
Copy Markdown
Collaborator

LGTM, cc+ @a-nogikh.

@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 43.33333% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.9%. Comparing base (2006bdc) to head (d21eae1).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
pkg/osutil/sandbox_root.go 0.0% 11 Missing ⚠️
pkg/aflow/tool/codeeditor/create.go 66.7% 3 Missing and 3 partials ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
pkg/aflow/flow/patching/patching.go 87.5% <100.0%> (ø)
pkg/aflow/tool/codeeditor/create.go 66.7% <66.7%> (ø)
pkg/osutil/sandbox_root.go 62.7% <0.0%> (-17.3%) ⬇️

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

well-shaped PR has no conflicts and all checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pkg/aflow: support creating new files in the patch generation workflow

2 participants