Skip to content

Commit a8bc5b9

Browse files
chore: remove dead functions — 3 functions removed (#32411)
1 parent 46f04b1 commit a8bc5b9

4 files changed

Lines changed: 0 additions & 185 deletions

File tree

pkg/cli/compile_compiler_setup_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,3 @@ func TestSetupRepositoryContext_ScheduleSeedTakesPrecedenceOverPerFileRemote(t *
8282
t.Fatalf("--schedule-seed should take precedence over per-file remote; expected upstream/repo, got %q", got)
8383
}
8484
}
85-
86-
func TestCreateAndConfigureCompiler_ForceStaged(t *testing.T) {
87-
compiler := createAndConfigureCompiler(CompileConfig{Staged: true})
88-
89-
if !compiler.IsForceStaged() {
90-
t.Fatal("expected --staged compiler configuration to force staged mode")
91-
}
92-
}

pkg/workflow/compiler_types.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ func WithVersion(version string) CompilerOption {
4949
return func(c *Compiler) { c.version = version }
5050
}
5151

52-
// WithContext sets the context used for network operations such as SHA resolution.
53-
// Defaults to context.Background() if not specified.
54-
func WithContext(ctx context.Context) CompilerOption {
55-
return func(c *Compiler) { c.ctx = ctx }
56-
}
57-
5852
// FileCreationTracker interface for tracking files created during compilation
5953
type FileCreationTracker interface {
6054
TrackCreated(filePath string)
@@ -194,11 +188,6 @@ func (c *Compiler) SetForceStaged(force bool) {
194188
c.forceStaged = force
195189
}
196190

197-
// IsForceStaged reports whether the compiler forces safe-outputs into staged mode.
198-
func (c *Compiler) IsForceStaged() bool {
199-
return c.forceStaged
200-
}
201-
202191
// SetFileTracker sets the file tracker for tracking created files
203192
func (c *Compiler) SetFileTracker(tracker FileCreationTracker) {
204193
c.fileTracker = tracker

pkg/workflow/template_injection_validation.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,6 @@ func hasAnyExpressionInRunContent(yamlContent string) bool {
7676
return hasExpressionInRunContent(yamlContent, inlineExpressionRegex)
7777
}
7878

79-
// hasUnsafeExpressionInRunContent performs a fast line-by-line text scan to determine
80-
// whether any unsafe context expression (${{ github.event.* }},
81-
// ${{ steps.*.outputs.* }}, or ${{ inputs.* }}) appears inside the content of a
82-
// YAML run: block.
83-
//
84-
// This is used as an efficient pre-flight check in generateAndValidateYAML.
85-
// Most compiler-generated workflows place unsafe expressions only in env: values
86-
// (the compiler's normal output pattern), so the expensive full YAML parse for
87-
// template-injection validation can be skipped in the common case.
88-
//
89-
// The scanner is intentionally lightweight rather than fully conservative: when it
90-
// encounters `run:` with no inline content (rest == ""), it enters run-block scanning
91-
// mode and only returns true if a subsequent indented line matches unsafeContextRegex.
92-
func hasUnsafeExpressionInRunContent(yamlContent string) bool {
93-
return hasExpressionInRunContent(yamlContent, unsafeContextRegex)
94-
}
95-
9679
func hasExpressionInRunContent(yamlContent string, expressionRegex *regexp.Regexp) bool {
9780
// Fast-path: no matching expressions anywhere → definitely no violation.
9881
if !expressionRegex.MatchString(yamlContent) {

pkg/workflow/template_injection_validation_test.go

Lines changed: 0 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,152 +1298,3 @@ func TestTemplateInjectionYAMLParsingEdgeCases(t *testing.T) {
12981298
})
12991299
}
13001300
}
1301-
1302-
// TestHasUnsafeExpressionInRunContent tests the fast text-based pre-flight check
1303-
// that gates full YAML parsing in generateAndValidateYAML.
1304-
func TestHasUnsafeExpressionInRunContent(t *testing.T) {
1305-
tests := []struct {
1306-
name string
1307-
yaml string
1308-
expected bool
1309-
desc string
1310-
}{
1311-
{
1312-
name: "empty yaml",
1313-
yaml: "",
1314-
expected: false,
1315-
desc: "empty input has no violations",
1316-
},
1317-
{
1318-
name: "no unsafe expressions",
1319-
yaml: `jobs:
1320-
test:
1321-
steps:
1322-
- run: echo "hello"`,
1323-
expected: false,
1324-
desc: "no unsafe expressions anywhere",
1325-
},
1326-
{
1327-
name: "unsafe expression only in env block - common compiler pattern",
1328-
yaml: `jobs:
1329-
test:
1330-
steps:
1331-
- name: Step
1332-
env:
1333-
VALUE: ${{ github.event.issue.title }}
1334-
run: |
1335-
echo "$VALUE"`,
1336-
expected: false,
1337-
desc: "compiler puts expressions in env: blocks, not run: – no violation",
1338-
},
1339-
{
1340-
name: "unsafe expression in concurrency group - not in run block",
1341-
yaml: `concurrency:
1342-
group: "ci-${{ github.event.pull_request.number }}"
1343-
jobs:
1344-
test:
1345-
steps:
1346-
- name: Step
1347-
env:
1348-
PR: ${{ github.event.pull_request.number }}
1349-
run: |
1350-
echo "$PR"`,
1351-
expected: false,
1352-
desc: "expressions in concurrency.group are not in run: blocks",
1353-
},
1354-
{
1355-
name: "unsafe expression directly in inline run value",
1356-
yaml: `jobs:
1357-
test:
1358-
steps:
1359-
- run: echo "${{ github.event.issue.title }}"`,
1360-
expected: true,
1361-
desc: "direct expression use in inline run: is unsafe",
1362-
},
1363-
{
1364-
name: "unsafe expression in block scalar run content",
1365-
yaml: `jobs:
1366-
test:
1367-
steps:
1368-
- run: |
1369-
echo "${{ github.event.issue.title }}"`,
1370-
expected: true,
1371-
desc: "direct expression use in run: block scalar is unsafe",
1372-
},
1373-
{
1374-
name: "unsafe expression in folded block run content",
1375-
yaml: `jobs:
1376-
test:
1377-
steps:
1378-
- run: >
1379-
echo "${{ github.event.issue.title }}"`,
1380-
expected: true,
1381-
desc: "direct expression use in run: folded block is unsafe",
1382-
},
1383-
{
1384-
name: "unsafe expression in steps outputs context",
1385-
yaml: `jobs:
1386-
test:
1387-
steps:
1388-
- run: |
1389-
echo "${{ steps.prior.outputs.data }}"`,
1390-
expected: true,
1391-
desc: "steps.outputs expression in run: is unsafe",
1392-
},
1393-
{
1394-
name: "unsafe expression in inputs context",
1395-
yaml: `jobs:
1396-
test:
1397-
steps:
1398-
- run: |
1399-
echo "${{ inputs.user_data }}"`,
1400-
expected: true,
1401-
desc: "inputs expression in run: is unsafe",
1402-
},
1403-
{
1404-
name: "expression in env block above run block - not in run content",
1405-
yaml: `jobs:
1406-
test:
1407-
steps:
1408-
- name: Multi-step with env
1409-
env:
1410-
A: ${{ github.event.issue.title }}
1411-
B: ${{ steps.prior.outputs.val }}
1412-
run: |
1413-
echo "$A $B"
1414-
- run: echo "done"`,
1415-
expected: false,
1416-
desc: "expressions in env: before run: are not inside run: content",
1417-
},
1418-
{
1419-
name: "multiple steps - only one has unsafe run content",
1420-
yaml: `jobs:
1421-
test:
1422-
steps:
1423-
- env:
1424-
V: ${{ github.event.issue.title }}
1425-
run: echo "$V"
1426-
- run: |
1427-
echo "${{ github.event.issue.title }}"`,
1428-
expected: true,
1429-
desc: "second step has unsafe expression directly in run: block",
1430-
},
1431-
{
1432-
name: "chomping indicator |- still detected",
1433-
yaml: `jobs:
1434-
test:
1435-
steps:
1436-
- run: |-
1437-
echo "${{ github.event.issue.title }}"`,
1438-
expected: true,
1439-
desc: "chomping indicators don't prevent detection",
1440-
},
1441-
}
1442-
1443-
for _, tt := range tests {
1444-
t.Run(tt.name, func(t *testing.T) {
1445-
got := hasUnsafeExpressionInRunContent(tt.yaml)
1446-
assert.Equal(t, tt.expected, got, tt.desc)
1447-
})
1448-
}
1449-
}

0 commit comments

Comments
 (0)