Skip to content

Commit c532eed

Browse files
committed
Fix parsing of github action name.
Signed-off-by: Jeff Mendoza <[email protected]>
1 parent 609be43 commit c532eed

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

pkg/policies/action/action.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package action
1818
import (
1919
"context"
2020
"fmt"
21-
"regexp"
2221
"sort"
2322
"strings"
2423

@@ -34,8 +33,6 @@ import (
3433
const configFile = "actions.yaml"
3534
const polName = "GitHub Actions"
3635

37-
var actionNameVersionRegex = regexp.MustCompile(`^([a-zA-Z0-9_\-.]+\/[a-zA-Z0-9_\-.]+)@([a-zA-Z0-9\-.]+)$`)
38-
3936
const failText = "This policy, specified at the organization level, sets requirements for Action use by repos within the organization. This repo is failing to fully comply with organization policies, as explained below.\n\n```\n%s```\n\nSee the org-level %s policy configuration for details."
4037

4138
const maxWorkflows = 50
@@ -270,8 +267,8 @@ func (a Action) Check(ctx context.Context, c *github.Client, owner,
270267
// Missing uses in step
271268
continue
272269
}
273-
sm := actionNameVersionRegex.FindStringSubmatch(actionStep.Uses.Value)
274-
if sm == nil {
270+
sm := strings.SplitN(actionStep.Uses.Value, "@", 2)
271+
if len(sm) != 2 {
275272
// Ignore invalid Action
276273
log.Warn().
277274
Str("org", owner).
@@ -281,8 +278,8 @@ func (a Action) Check(ctx context.Context, c *github.Client, owner,
281278
Msg("Ignoring invalid action")
282279
continue
283280
}
284-
name := sm[1]
285-
version := sm[2]
281+
name := sm[0]
282+
version := sm[1]
286283
actions = append(actions, &actionMetadata{
287284
name: name,
288285
version: version,

0 commit comments

Comments
 (0)