MCPcopy
hub / github.com/ossf/scorecard / IsStepWindows

Function IsStepWindows

checks/fileparser/github_workflow.go:277–301  ·  view source on GitHub ↗

IsStepWindows returns true if the step will be run on Windows.

(step *actionlint.Step)

Source from the content-addressed store, hash-verified

275
276// IsStepWindows returns true if the step will be run on Windows.
277func IsStepWindows(step *actionlint.Step) (bool, error) {
278 if step.If == nil {
279 return false, nil
280 }
281 windowsRegexes := []string{
282 // Looking for "if: runner.os == 'Windows'" (and variants)
283 `(?i)runner\.os\s*==\s*['"]windows['"]`,
284 // Looking for "if: ${{ startsWith(runner.os, 'Windows') }}" (and variants)
285 `(?i)\$\{\{\s*startsWith\(runner\.os,\s*['"]windows['"]\)`,
286 // Looking for "if: matrix.os == 'windows-2019'" (and variants)
287 `(?i)matrix\.os\s*==\s*['"]windows-`,
288 }
289
290 for _, windowsRegex := range windowsRegexes {
291 matches, err := regexp.MatchString(windowsRegex, step.If.Value)
292 if err != nil {
293 return false, sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf("error matching Windows regex: %v", err))
294 }
295 if matches {
296 return true, nil
297 }
298 }
299
300 return false, nil
301}
302
303// IsWorkflowFile returns true if this is a GitHub workflow file.
304func IsWorkflowFile(pathfn string) bool {

Callers 1

GetShellForStepFunction · 0.85

Calls 1

WithMessageMethod · 0.80

Tested by

no test coverage detected