Skip to content

Commit bd547cd

Browse files
committed
Sanitize automation tag names and descriptions
Tag names and descriptions are user-authored, so list results apply the same PlainText and Content filters used for release names and bodies.
1 parent e7ec39d commit bd547cd

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

‎pkg/github/automation_tags.go‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
ghErrors "github.com/github/github-mcp-server/v2/pkg/errors"
1010
"github.com/github/github-mcp-server/v2/pkg/inventory"
11+
"github.com/github/github-mcp-server/v2/pkg/sanitize"
1112
"github.com/github/github-mcp-server/v2/pkg/scopes"
1213
"github.com/github/github-mcp-server/v2/pkg/translations"
1314
"github.com/github/github-mcp-server/v2/pkg/utils"
@@ -97,8 +98,16 @@ func ListAutomationTags(t translations.TranslationHelperFunc) inventory.ServerTo
9798
if resp.StatusCode != http.StatusOK {
9899
return ghErrors.NewGitHubAPIStatusErrorResponse(ctx, "failed to list automation tags", resp, nil), nil, nil
99100
}
101+
for i := range output.Tags {
102+
sanitizeAutomationTagNameAndDescription(&output.Tags[i])
103+
}
100104
output.NextPage = resp.NextPage
101105
return MarshalledTextResult(&output), &output, nil
102106
},
103107
)
104108
}
109+
110+
func sanitizeAutomationTagNameAndDescription(tag *AutomationTag) {
111+
tag.Name = sanitize.PlainText(tag.Name)
112+
tag.Description = sanitize.Content(tag.Description)
113+
}

‎pkg/github/automation_tags_test.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ func Test_ListAutomationTags(t *testing.T) {
128128
escapedPath: "/agents/repos/own%20er%2Fteam/re%2Fpo/automation-tags",
129129
want: `{"tags":[],"total_count":0,"nextPage":0}`,
130130
},
131+
{
132+
name: "sanitized name and description",
133+
status: http.StatusOK,
134+
body: `{"tags":[{"id":"tag-1","name":"<script>alert(1)</script>Hello\u200bWorld","description":"<script>alert(1)</script>Hello\u200bWorld","version":"v1","created_at":"","updated_at":""}],"total_count":1}`,
135+
want: `{"tags":[{"id":"tag-1","name":"HelloWorld","description":"<script>alert(1)</script>HelloWorld","version":"v1","created_at":"","updated_at":""}],"total_count":1,"nextPage":0}`,
136+
},
131137
{name: "non-disclosure", status: http.StatusNotFound, body: `{"message":"Not Found"}`, wantError: "404"},
132138
{name: "empty denial", status: http.StatusNotFound, wantError: "404"},
133139
{name: "bad request", status: http.StatusBadRequest, body: `{"message":"Bad Request"}`, wantError: "400"},

0 commit comments

Comments
 (0)