-
Notifications
You must be signed in to change notification settings - Fork 42
fix(#1625): exclude agent working directories from git tracking #1627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -818,6 +818,26 @@ func TestResolveLinuxBinary_Download(t *testing.T) { | |
| assert.NoError(t, validateLinuxBinary(binPath), "downloaded binary should be a valid Linux/amd64 ELF") | ||
| } | ||
|
|
||
| func TestAgentWorkingDirExcludes_ContainsKnownPatterns(t *testing.T) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [low] correctness Go tests verify the agentWorkingDirExcludes slice contents but do not test the excludeAgentWorkingDirs function itself. Shell command generation, error handling, and sandbox interaction are untested. Suggested fix: Add a unit test that exercises excludeAgentWorkingDirs with a mock sandbox, verifying the generated command and error paths. |
||
| // Verify the exclusion list contains the known agent working directories. | ||
| expected := []string{".agentready/", ".fullsend-workspace/"} | ||
| for _, pattern := range expected { | ||
| found := false | ||
| for _, exclude := range agentWorkingDirExcludes { | ||
| if exclude == pattern { | ||
| found = true | ||
| break | ||
| } | ||
| } | ||
| assert.True(t, found, "agentWorkingDirExcludes should contain %q", pattern) | ||
| } | ||
| } | ||
|
|
||
| func TestAgentWorkingDirExcludes_NotEmpty(t *testing.T) { | ||
| assert.NotEmpty(t, agentWorkingDirExcludes, | ||
| "agentWorkingDirExcludes must not be empty — agents create working dirs that need exclusion") | ||
| } | ||
|
|
||
| func TestReadOIDCAuthFile_Success(t *testing.T) { | ||
| f := filepath.Join(t.TempDir(), "auth") | ||
| require.NoError(t, os.WriteFile(f, []byte("bearer test-token"), 0o600)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -126,6 +126,34 @@ fi | |
| echo "Changed files:" | ||
| echo "${CHANGED_FILES}" | sed 's/^/ /' | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [high] correctness Section 2b ("Strip agent working directories") detects agent artifacts and logs warnings, but never actually removes them from the commit. STRIPPED_FILES is set but never consumed — no git rm, git reset HEAD, or filtering of CHANGED_FILES follows. The defense-in-depth layer is inert. Suggested fix: After the detection loop, use git rm --cached on each file in STRIPPED_FILES and amend the commit, or filter CHANGED_FILES to exclude them before the push step. |
||
| # 2b. Strip agent working directories (defense-in-depth) | ||
| # | ||
| # Agent working dirs (.agentready/, .fullsend-workspace/) should never | ||
| # appear in commits. The harness excludes them via .git/info/exclude, but | ||
| # if an agent manages to stage them anyway, strip them here before push. | ||
| # --------------------------------------------------------------------------- | ||
| AGENT_ARTIFACT_PATTERNS=".agentready/ .fullsend-workspace/" | ||
| STRIPPED_FILES="" | ||
| for file in ${CHANGED_FILES}; do | ||
| is_artifact=false | ||
| for pattern in ${AGENT_ARTIFACT_PATTERNS}; do | ||
| dir="${pattern%/}" # strip trailing slash for prefix matching | ||
| case "${file}" in | ||
| "${dir}"/*|"${dir}") is_artifact=true; break ;; | ||
| */"${dir}"/*|*/"${dir}") is_artifact=true; break ;; | ||
| esac | ||
| done | ||
| if [ "${is_artifact}" = "true" ]; then | ||
| echo "::warning::Stripping agent artifact from commit: ${file}" | ||
| STRIPPED_FILES="${STRIPPED_FILES} ${file}" | ||
| fi | ||
| done | ||
|
|
||
| if [ -n "${STRIPPED_FILES}" ]; then | ||
| echo "::warning::Agent committed working directory artifacts — stripping before push" | ||
| fi | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # 3. Authoritative secret scan | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[low] security
excludeAgentWorkingDirs constructs a shell command via fmt.Sprintf with payload and repoDir interpolated into a single-quoted string. Safe with current hardcoded values and consistent with existing patterns, but fragile if a future agentWorkingDirExcludes entry contains a single quote.
Suggested fix: Consider writing patterns to a temp file and appending via cat, or escaping the payload.