Skip to content

Commit 4a60242

Browse files
committed
Sanitize the name and description in get results
Apply the same filters as list results, since the tag comes back from the same user-authored data.
1 parent 3766cd4 commit 4a60242

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

‎pkg/github/automation_tags.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ func GetAutomationTag(t translations.TranslationHelperFunc) inventory.ServerTool
176176
if resp.StatusCode != http.StatusOK {
177177
return ghErrors.NewGitHubAPIStatusErrorResponse(ctx, "failed to get automation tag", resp, nil), nil, nil
178178
}
179+
sanitizeAutomationTagNameAndDescription(&output)
179180
return MarshalledTextResult(&output), &output, nil
180181
},
181182
)

‎pkg/github/automation_tags_test.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,12 @@ func Test_GetAutomationTag(t *testing.T) {
320320
body: `{"id":"a/b c","name":"Release","description":"","version":"v","created_at":"2026-10-01T00:00:00Z","updated_at":"2026-10-02T00:00:00Z"}`,
321321
want: `{"id":"a/b c","name":"Release","description":"","version":"v","created_at":"2026-10-01T00:00:00Z","updated_at":"2026-10-02T00:00:00Z"}`,
322322
},
323+
{
324+
name: "sanitized name and description",
325+
status: http.StatusOK,
326+
body: `{"id":"tag-1","name":"<script>alert(1)</script>Hello\u200bWorld","description":"<script>alert(1)</script>Hello\u200bWorld","version":"v1","created_at":"","updated_at":""}`,
327+
want: `{"id":"tag-1","name":"HelloWorld","description":"<script>alert(1)</script>HelloWorld","version":"v1","created_at":"","updated_at":""}`,
328+
},
323329
{name: "non-disclosure", status: http.StatusNotFound, body: `{"message":"not found","documentation_url":"https://docs.github.com/rest"}`, wantError: "404"},
324330
{name: "empty denial", status: http.StatusNotFound, wantError: "404"},
325331
{name: "bad request", status: http.StatusBadRequest, body: `{"message":"Bad Request"}`, wantError: "400"},

0 commit comments

Comments
 (0)