Skip to content

Commit 05fede2

Browse files
refactor(safe-outputs): rename upload-attachment to upload-workitem-attachment (#372)
Agent-Logs-Url: https://github.com/githubnext/ado-aw/sessions/b64aa169-a63c-4ed7-8d1a-7e1b6e53c26c Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com>
1 parent 3fa067f commit 05fede2

10 files changed

Lines changed: 63 additions & 63 deletions

File tree

.github/workflows/red-team-security.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ grep -n 'replace\|replace_with_indent' src/compile/standalone.rs src/compile/one
6868

6969
### Category B: Path Traversal & File System
7070

71-
Audit `src/execute.rs`, `src/tools/create_pr.rs`, `src/tools/memory.rs`, `src/tools/upload_attachment.rs` for:
71+
Audit `src/execute.rs`, `src/tools/create_pr.rs`, `src/tools/memory.rs`, `src/tools/upload_workitem_attachment.rs` for:
7272

7373
- **Directory traversal**: Are `..` sequences fully blocked in all path inputs? Check safe output file paths, memory file paths, wiki page paths, attachment paths.
7474
- **Bounding directory escape**: Can the MCP server's bounding directory check be bypassed via symlinks, null bytes, or Unicode normalization?
@@ -79,7 +79,7 @@ Focus files:
7979
```bash
8080
cat src/tools/memory.rs
8181
cat src/tools/create_pr.rs
82-
cat src/tools/upload_attachment.rs
82+
cat src/tools/upload_workitem_attachment.rs
8383
grep -rn 'Path\|PathBuf\|canonicalize\|starts_with' src/tools/
8484
grep -rn '\.\./' src/
8585
```

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Every compiled pipeline runs as three sequential jobs:
9393
│ │ ├── update_pr.rs
9494
│ │ ├── update_wiki_page.rs
9595
│ │ ├── update_work_item.rs
96-
│ │ └── upload_attachment.rs
96+
│ │ └── upload_workitem_attachment.rs
9797
│ ├── runtimes/ # Runtime environment implementations (one dir per runtime)
9898
│ │ ├── mod.rs # Module entry point
9999
│ │ └── lean/ # Lean 4 theorem prover runtime

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ actions, and the executor processes them after threat analysis.
389389
| `create-git-tag` | Creates a git tag on a repository ref |
390390
| `create-branch` | Creates a new branch from an existing ref |
391391
| `add-build-tag` | Adds a tag to an ADO build |
392-
| `upload-attachment` | Uploads a workspace file as an attachment to a work item |
392+
| `upload-workitem-attachment` | Uploads a workspace file as an attachment to a work item |
393393
| `report-incomplete` | Reports that a task could not be completed |
394394
| `noop` | Reports no action was needed |
395395
| `missing-data` | Reports required data was unavailable |

docs/safe-outputs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ safe-outputs:
400400
max: 1 # Maximum per run (default: 1)
401401
```
402402

403-
### upload-attachment
403+
### upload-workitem-attachment
404404
Uploads a workspace file as an attachment to an Azure DevOps work item.
405405

406406
**Agent parameters:**
@@ -411,7 +411,7 @@ Uploads a workspace file as an attachment to an Azure DevOps work item.
411411
**Configuration options (front matter):**
412412
```yaml
413413
safe-outputs:
414-
upload-attachment:
414+
upload-workitem-attachment:
415415
max-file-size: 5242880 # Maximum file size in bytes (default: 5 MB)
416416
allowed-extensions: [] # Optional — restrict file types (e.g., [".png", ".pdf"])
417417
comment-prefix: "[Agent] " # Optional — prefix prepended to the comment

prompts/create-ado-agentic-workflow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ tools:
277277
| `update-work-item` | Update fields on existing work items (each field requires opt-in) | ✅ |
278278
| `comment-on-work-item` | Add comments to work items (requires `target` scoping) | ✅ |
279279
| `link-work-items` | Link two work items (parent/child, related, etc.) | ✅ |
280-
| `upload-attachment` | Upload a workspace file to a work item | ✅ |
280+
| `upload-workitem-attachment` | Upload a workspace file to a work item | ✅ |
281281
| **Pull Requests** | | |
282282
| `create-pull-request` | Create PRs from agent code changes | ✅ |
283283
| `add-pr-comment` | Add a comment thread to a PR | ✅ |

prompts/update-ado-agentic-workflow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ permissions:
193193
| Both | Agent reads; safe-outputs write |
194194
| Neither | No ADO tokens anywhere |
195195

196-
If adding write-requiring safe outputs (`create-pull-request`, `create-work-item`, `comment-on-work-item`, `update-work-item`, `create-wiki-page`, `update-wiki-page`, `link-work-items`, `upload-attachment`, `create-branch`, `create-git-tag`, `add-build-tag`, `add-pr-comment`, `reply-to-pr-comment`, `resolve-pr-thread`, `submit-pr-review`, `update-pr`, `queue-build`), you **must** also add `permissions.write`. The compiler will error otherwise.
196+
If adding write-requiring safe outputs (`create-pull-request`, `create-work-item`, `comment-on-work-item`, `update-work-item`, `create-wiki-page`, `update-wiki-page`, `link-work-items`, `upload-workitem-attachment`, `create-branch`, `create-git-tag`, `add-build-tag`, `add-pr-comment`, `reply-to-pr-comment`, `resolve-pr-thread`, `submit-pr-review`, `update-pr`, `queue-build`), you **must** also add `permissions.write`. The compiler will error otherwise.
197197

198198
### Adding Pre/Post Steps
199199

src/execute.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::safeoutputs::{
1717
ExecutionContext, ExecutionResult, Executor, LinkWorkItemsResult, MissingDataResult,
1818
MissingToolResult, NoopResult, QueueBuildResult, ReplyToPrCommentResult,
1919
ReportIncompleteResult, ResolvePrThreadResult, SubmitPrReviewResult, ToolResult,
20-
UpdatePrResult, UpdateWikiPageResult, UpdateWorkItemResult, UploadAttachmentResult,
20+
UpdatePrResult, UpdateWikiPageResult, UpdateWorkItemResult, UploadWorkitemAttachmentResult,
2121
};
2222

2323
// Re-export memory types for use by main.rs
@@ -91,7 +91,7 @@ pub async fn execute_safe_outputs(
9191
AddBuildTagResult,
9292
CreateBranchResult,
9393
UpdatePrResult,
94-
UploadAttachmentResult,
94+
UploadWorkitemAttachmentResult,
9595
SubmitPrReviewResult,
9696
ReplyToPrCommentResult,
9797
ResolvePrThreadResult,
@@ -262,7 +262,7 @@ pub async fn execute_safe_output(
262262
"add-build-tag" => AddBuildTagResult,
263263
"create-branch" => CreateBranchResult,
264264
"update-pr" => UpdatePrResult,
265-
"upload-attachment" => UploadAttachmentResult,
265+
"upload-workitem-attachment" => UploadWorkitemAttachmentResult,
266266
"submit-pr-review" => SubmitPrReviewResult,
267267
"reply-to-pr-review-comment" => ReplyToPrCommentResult,
268268
"resolve-pr-thread" => ResolvePrThreadResult,

src/mcp.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::safeoutputs::{
2727
QueueBuildResult, SubmitPrReviewParams, SubmitPrReviewResult, ToolResult,
2828
UpdatePrParams, UpdatePrResult,
2929
UpdateWorkItemParams, UpdateWorkItemResult,
30-
UploadAttachmentParams, UploadAttachmentResult,
30+
UploadWorkitemAttachmentParams, UploadWorkitemAttachmentResult,
3131
anyhow_to_mcp_error,
3232
};
3333

@@ -960,21 +960,21 @@ Changes will be applied during safe output processing."
960960
}
961961

962962
#[tool(
963-
name = "upload-attachment",
963+
name = "upload-workitem-attachment",
964964
description = "Upload a file attachment to an Azure DevOps work item. The file will be \
965965
uploaded and linked during safe output processing. File size and type restrictions may apply."
966966
)]
967-
async fn upload_attachment(
967+
async fn upload_workitem_attachment(
968968
&self,
969-
params: Parameters<UploadAttachmentParams>,
969+
params: Parameters<UploadWorkitemAttachmentParams>,
970970
) -> Result<CallToolResult, McpError> {
971971
info!(
972-
"Tool called: upload-attachment - work item #{} file '{}'",
972+
"Tool called: upload-workitem-attachment - work item #{} file '{}'",
973973
params.0.work_item_id, params.0.file_path
974974
);
975975
let mut sanitized = params.0;
976976
sanitized.comment = sanitized.comment.map(|c| sanitize_text(&c));
977-
let result: UploadAttachmentResult = sanitized.try_into()?;
977+
let result: UploadWorkitemAttachmentResult = sanitized.try_into()?;
978978
self.write_safe_output_file(&result).await
979979
.map_err(|e| anyhow_to_mcp_error(anyhow::anyhow!("Failed to write safe output: {}", e)))?;
980980
Ok(CallToolResult::success(vec![Content::text(format!(

src/safeoutputs/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub const WRITE_REQUIRING_SAFE_OUTPUTS: &[&str] = tool_names![
4242
AddBuildTagResult,
4343
CreateBranchResult,
4444
UpdatePrResult,
45-
UploadAttachmentResult,
45+
UploadWorkitemAttachmentResult,
4646
SubmitPrReviewResult,
4747
ReplyToPrCommentResult,
4848
ResolvePrThreadResult,
@@ -75,7 +75,7 @@ pub const ALL_KNOWN_SAFE_OUTPUTS: &[&str] = all_safe_output_names![
7575
AddBuildTagResult,
7676
CreateBranchResult,
7777
UpdatePrResult,
78-
UploadAttachmentResult,
78+
UploadWorkitemAttachmentResult,
7979
SubmitPrReviewResult,
8080
ReplyToPrCommentResult,
8181
ResolvePrThreadResult,
@@ -262,7 +262,7 @@ mod submit_pr_review;
262262
mod update_pr;
263263
mod update_wiki_page;
264264
mod update_work_item;
265-
mod upload_attachment;
265+
mod upload_workitem_attachment;
266266

267267
pub use add_build_tag::*;
268268
pub use add_pr_comment::*;
@@ -287,7 +287,7 @@ pub use submit_pr_review::*;
287287
pub use update_pr::*;
288288
pub use update_wiki_page::*;
289289
pub use update_work_item::*;
290-
pub use upload_attachment::*;
290+
pub use upload_workitem_attachment::*;
291291

292292
#[cfg(test)]
293293
mod tests {
@@ -344,7 +344,7 @@ mod tests {
344344
assert!(AddBuildTagResult::REQUIRES_WRITE);
345345
assert!(CreateBranchResult::REQUIRES_WRITE);
346346
assert!(UpdatePrResult::REQUIRES_WRITE);
347-
assert!(UploadAttachmentResult::REQUIRES_WRITE);
347+
assert!(UploadWorkitemAttachmentResult::REQUIRES_WRITE);
348348
assert!(SubmitPrReviewResult::REQUIRES_WRITE);
349349
assert!(ReplyToPrCommentResult::REQUIRES_WRITE);
350350
assert!(ResolvePrThreadResult::REQUIRES_WRITE);

0 commit comments

Comments
 (0)