Skip to content

Commit a5bc898

Browse files
committed
Attach IFC label to list_code_quality_findings results
Label successful results with ifc.LabelSecurityAlert() (private, untrusted) when the ifc_labels feature flag is enabled, the same label the code scanning, Dependabot and secret scanning tools use. Findings embed file paths and messages derived from repository code, and without a label, clients that enforce IFC have no classification for this data. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 314335a commit a5bc898

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎pkg/github/code_quality.go‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/modelcontextprotocol/go-sdk/mcp"
1414

1515
ghErrors "github.com/github/github-mcp-server/v2/pkg/errors"
16+
"github.com/github/github-mcp-server/v2/pkg/ifc"
1617
"github.com/github/github-mcp-server/v2/pkg/inventory"
1718
"github.com/github/github-mcp-server/v2/pkg/scopes"
1819
"github.com/github/github-mcp-server/v2/pkg/translations"
@@ -222,7 +223,12 @@ func ListCodeQualityFindings(t translations.TranslationHelperFunc) inventory.Ser
222223
return utils.NewToolResultErrorFromErr("failed to marshal findings", err), CodeQualityFindingsOutput{}, nil
223224
}
224225

225-
return utils.NewToolResultText(string(r)), output, nil
226+
result := utils.NewToolResultText(string(r))
227+
// Like code scanning alerts, findings embed text derived from
228+
// repository code (file paths and messages), so they share the
229+
// private-untrusted security alert label.
230+
result = attachStaticIFCLabel(ctx, deps, result, ifc.LabelSecurityAlert())
231+
return result, output, nil
226232
},
227233
normalizeTypedReadArguments(nil, false),
228234
)

‎pkg/github/code_quality_test.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/stretchr/testify/assert"
1212
"github.com/stretchr/testify/require"
1313

14+
"github.com/github/github-mcp-server/v2/pkg/ifc"
1415
"github.com/github/github-mcp-server/v2/pkg/translations"
1516
)
1617

@@ -339,7 +340,7 @@ func Test_ListCodeQualityFindings(t *testing.T) {
339340
for _, tc := range tests {
340341
t.Run(tc.name, func(t *testing.T) {
341342
client := mustNewGHClient(t, tc.mockedClient)
342-
deps := BaseDeps{Client: client}
343+
deps := BaseDeps{Client: client, featureChecker: featureCheckerFor(FeatureFlagIFCLabels)}
343344
handler := toolDef.Handler(deps)
344345

345346
request := createMCPRequest(tc.requestArgs)
@@ -356,6 +357,7 @@ func Test_ListCodeQualityFindings(t *testing.T) {
356357

357358
require.NoError(t, err)
358359
require.False(t, result.IsError)
360+
assert.JSONEq(t, mustMarshalJSON(t, ifc.LabelSecurityAlert()), mustMarshalJSON(t, result.Meta["ifc"]))
359361

360362
textContent := getTextResult(t, result)
361363

‎pkg/github/typed_security_outputs_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ func TestTypedSecurityToolOutputs(t *testing.T) {
261261

262262
require.NotNil(t, result.StructuredContent, "%s must return structured content", call.Name)
263263
assert.Equal(t, legacyIFC[call.Name], mustMarshalJSON(t, result.Meta["ifc"]), "IFC labels must protect text and structured content identically")
264-
if call.Name != "get_code_quality_finding" && call.Name != "list_code_quality_findings" {
264+
if call.Name != "get_code_quality_finding" {
265265
assert.NotNil(t, result.Meta["ifc"], "%s must retain its IFC label", call.Name)
266266
}
267267
schemaJSON, err := json.Marshal(toolsByName[call.Name].OutputSchema)

0 commit comments

Comments
 (0)