Skip to content

Commit 3c1f48a

Browse files
Copilotpelikhan
andauthored
feat: mark content-redaction as experimental
Add experimental warning for content-redaction feature to alert users that this feature is still experimental and subject to change. The warning is emitted during workflow compilation when content-redaction is configured. Changes: - Add content-redaction to experimental warnings in emitExperimentalFeatureWarnings - Add comprehensive integration tests for experimental warning The warning appears when any of these content-redaction forms are used: - Inline string: `content-redaction: "policy text"` - Array shorthand: `content-redaction: ["url", "policy"]` - Object form: `content-redaction: { policies: "..." }` Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent 1bc9983 commit 3c1f48a

2 files changed

Lines changed: 127 additions & 0 deletions

File tree

‎pkg/workflow/compiler_validators.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ func (c *Compiler) emitExperimentalFeatureWarnings(workflowData *WorkflowData) {
304304
{enabled: workflowData.SafeOutputs != nil && workflowData.SafeOutputs.DispatchRepository != nil, message: "Using experimental feature: dispatch-repository"},
305305
{enabled: workflowData.SafeOutputs != nil && workflowData.SafeOutputs.MergePullRequest != nil, message: "Using experimental feature: merge-pull-request"},
306306
{enabled: workflowData.SafeOutputs != nil && workflowData.SafeOutputs.ReplaceLabel != nil, message: "Using experimental feature: replace-label"},
307+
{enabled: workflowData.SafeOutputs != nil && workflowData.SafeOutputs.ContentRedaction != nil, message: "Using experimental feature: content-redaction"},
307308
{enabled: workflowData.EngineConfig != nil && workflowData.EngineConfig.CopilotSDK, message: "Using experimental feature: engine.copilot-sdk"},
308309
{enabled: isFeatureEnabled(constants.GHAWDetectionFeatureFlag, workflowData), message: "Using experimental feature: gh-aw-detection"},
309310
{enabled: len(workflowData.LSP) > 0, message: "Using experimental feature: lsp"},
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
//go:build integration
2+
3+
package workflow
4+
5+
import (
6+
"bytes"
7+
"io"
8+
"os"
9+
"path/filepath"
10+
"strings"
11+
"testing"
12+
13+
"github.com/github/gh-aw/pkg/testutil"
14+
)
15+
16+
func TestContentRedactionExperimentalWarning(t *testing.T) {
17+
tests := []struct {
18+
name string
19+
content string
20+
expectWarning bool
21+
}{
22+
{
23+
name: "content-redaction enabled produces experimental warning",
24+
content: `---
25+
on: workflow_dispatch
26+
engine: copilot
27+
safe-outputs:
28+
add-comment:
29+
content-redaction:
30+
policies: "Do not disclose security vulnerabilities"
31+
---
32+
33+
# Test Workflow
34+
`,
35+
expectWarning: true,
36+
},
37+
{
38+
name: "no content-redaction does not produce experimental warning",
39+
content: `---
40+
on: workflow_dispatch
41+
engine: copilot
42+
safe-outputs:
43+
add-comment:
44+
---
45+
46+
# Test Workflow
47+
`,
48+
expectWarning: false,
49+
},
50+
{
51+
name: "content-redaction with inline string produces experimental warning",
52+
content: `---
53+
on: workflow_dispatch
54+
engine: copilot
55+
safe-outputs:
56+
add-comment:
57+
content-redaction: "Never disclose internal credentials"
58+
---
59+
60+
# Test Workflow
61+
`,
62+
expectWarning: true,
63+
},
64+
{
65+
name: "content-redaction with array produces experimental warning",
66+
content: `---
67+
on: workflow_dispatch
68+
engine: copilot
69+
safe-outputs:
70+
add-comment:
71+
content-redaction:
72+
- "https://corp.example.com/policy.md"
73+
- "Never disclose CVE IDs before fix"
74+
---
75+
76+
# Test Workflow
77+
`,
78+
expectWarning: true,
79+
},
80+
}
81+
82+
for _, tt := range tests {
83+
t.Run(tt.name, func(t *testing.T) {
84+
tmpDir := testutil.TempDir(t, "content-redaction-experimental-warning-test")
85+
86+
testFile := filepath.Join(tmpDir, "test-workflow.md")
87+
if err := os.WriteFile(testFile, []byte(tt.content), 0644); err != nil {
88+
t.Fatal(err)
89+
}
90+
91+
oldStderr := os.Stderr
92+
r, w, _ := os.Pipe()
93+
os.Stderr = w
94+
95+
compiler := NewCompiler()
96+
compiler.SetStrictMode(false)
97+
err := compiler.CompileWorkflow(testFile)
98+
99+
w.Close()
100+
os.Stderr = oldStderr
101+
var buf bytes.Buffer
102+
io.Copy(&buf, r)
103+
stderrOutput := buf.String()
104+
105+
if err != nil {
106+
t.Errorf("expected compilation to succeed but it failed: %v", err)
107+
return
108+
}
109+
110+
expectedMessage := "Using experimental feature: content-redaction"
111+
if tt.expectWarning {
112+
if !strings.Contains(stderrOutput, expectedMessage) {
113+
t.Errorf("expected warning containing %q, got stderr:\n%s", expectedMessage, stderrOutput)
114+
}
115+
if compiler.GetWarningCount() == 0 {
116+
t.Error("expected warning count > 0 but got 0")
117+
}
118+
return
119+
}
120+
121+
if strings.Contains(stderrOutput, expectedMessage) {
122+
t.Errorf("did not expect warning %q, but got stderr:\n%s", expectedMessage, stderrOutput)
123+
}
124+
})
125+
}
126+
}

0 commit comments

Comments
 (0)